/* ==========================================================================
   WardDesk — Reusable components
   ========================================================================== */

/* Buttons ------------------------------------------------------------------- */
.btn {
  --btn-h: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-h);
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 2px rgba(17, 24, 39, 0.12);
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-active); }

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn--secondary:hover { background: var(--surface-hover); }
.btn--secondary:active { background: var(--surface-active); }

.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); }
.btn--danger:focus-visible { box-shadow: var(--ring-danger); }

.btn--danger-ghost { background: transparent; color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-soft); }

.btn--success { background: var(--success-strong); color: #fff; }
.btn--success:hover { filter: brightness(0.95); }

.btn--sm { --btn-h: 30px; padding: 0 10px; font-size: var(--text-sm); }
.btn--lg { --btn-h: 42px; padding: 0 18px; font-size: var(--text-md); }
.btn--block { width: 100%; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.9) transparent transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn--secondary.is-loading::after,
.btn--ghost.is-loading::after { border-color: var(--text-2) var(--text-2) transparent transparent; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn .lucide { width: 18px; height: 18px; }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm .lucide { width: 16px; height: 16px; }

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Form controls ------------------------------------------------------------- */
.input,
.select,
.textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-3); }
.input:hover,
.select:hover,
.textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}
.input:disabled,
.select:disabled,
.textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus { box-shadow: var(--ring-danger); }

.textarea {
  height: auto;
  min-height: 88px;
  padding: 9px var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b909a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.select--sm,
.input--sm { height: 30px; font-size: var(--text-sm); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .lucide {
  position: absolute;
  left: 11px;
  color: var(--text-3);
  pointer-events: none;
}
.input-group > .input { padding-left: 34px; }
.input-group > .input.has-trailing { padding-right: 38px; }
.input-group__trailing {
  position: absolute;
  right: 4px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: var(--space-4); }
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.field-row + .field,
.field + .field-row,
.field-row + .field-row { margin-top: var(--space-4); }
.field-row .field + .field { margin-top: 0; }

.label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.label__req { color: var(--danger); }
.label__opt { color: var(--text-3); font-weight: var(--weight-regular); }
.help { color: var(--text-3); font-size: var(--text-xs); }
.field-error {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.field-error .lucide { width: 13px; height: 13px; }

.checkbox {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  flex-shrink: 0;
}
.checkbox:checked,
.checkbox:indeterminate { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.checkbox:indeterminate::after {
  content: "";
  width: 8px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}
.checkbox:focus-visible { outline: none; box-shadow: var(--ring); }

.check-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

/* Choice cards (verification status picker) */
.choice-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  border: 0;
  margin: 0;
  padding: 0;
}
.choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
}
.choice:hover { background: var(--surface-hover); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice__dot {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.choice__title { font-weight: var(--weight-medium); font-size: var(--text-sm); }
.choice__desc { color: var(--text-3); font-size: var(--text-xs); margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:checked) .choice__dot { border-color: var(--accent); }
.choice:has(input:checked) .choice__dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.choice:has(input:focus-visible) { box-shadow: var(--ring); }

/* Switch */
.switch {
  position: relative;
  appearance: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  cursor: pointer;
  transition: background var(--dur);
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur) var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.switch:focus-visible { outline: none; box-shadow: var(--ring); }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Cards --------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.card__header--plain { border-bottom: 0; padding-bottom: 0; min-height: 0; padding-top: var(--space-5); }
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card__subtitle { color: var(--text-3); font-size: var(--text-xs); margin-top: 2px; }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }
.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}
.card__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* Stat card */
.stat {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.stat:hover { border-color: var(--border-strong); }
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.stat__icon .lucide { width: 17px; height: 17px; }
.stat__icon--success { background: var(--success-soft); color: var(--success); }
.stat__icon--warning { background: var(--warning-soft); color: var(--warning); }
.stat__icon--danger { background: var(--danger-soft); color: var(--danger); }
.stat__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat__label { color: var(--text-2); font-size: var(--text-sm); margin-top: 6px; }
.stat__share { color: var(--text-3); font-size: var(--text-xs); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.trend .lucide { width: 12px; height: 12px; }
.trend--up { background: var(--success-soft); color: var(--success); }
.trend--down { background: var(--danger-soft); color: var(--danger); }
.trend--flat { background: var(--bg-subtle); color: var(--text-2); }

/* Badges -------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--verified { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge--pending { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge--correction { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge--neutral { background: var(--bg-subtle); color: var(--text-2); }

/* Avatar -------------------------------------------------------------------- */
.avatar {
  --size: 32px;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: calc(var(--size) * 0.38);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { --size: 24px; }
.avatar--sm { --size: 28px; }
.avatar--md { --size: 36px; }
.avatar--lg { --size: 56px; }
.avatar--xl { --size: 96px; }
.avatar--square { border-radius: var(--radius-md); }
.avatar--xl.avatar--square { border-radius: var(--radius-lg); }

/* Tables -------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.table th {
  position: sticky;
  top: 0;
  height: 38px;
  padding: 0 var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-align: left;
  white-space: nowrap;
}
.table td {
  height: 52px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table td.cell-primary { color: var(--text); font-weight: var(--weight-medium); }
.table .col-check { width: 44px; padding-right: 0; }
.table .col-actions { width: 56px; text-align: right; }
.table--compact td { height: 44px; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 -6px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: inherit;
  font: inherit;
}
.th-sort:hover { color: var(--text); background: var(--surface-hover); }
.th-sort .lucide { width: 13px; height: 13px; opacity: 0.5; }
th[aria-sort="ascending"] .th-sort,
th[aria-sort="descending"] .th-sort { color: var(--text); }
th[aria-sort="ascending"] .th-sort .lucide,
th[aria-sort="descending"] .th-sort .lucide { opacity: 1; color: var(--accent); }

.person-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.person-cell__name {
  color: var(--text);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.person-cell__name:hover { color: var(--accent-text); }
.person-cell__sub { color: var(--text-3); font-size: var(--text-xs); }
a.person-cell:hover { text-decoration: none; }

/* Toolbar (filters above tables) ------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar__search { flex: 1 1 260px; max-width: 360px; }
.toolbar__spacer { flex: 1; }
.toolbar .select { width: auto; min-width: 150px; }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--accent-text);
  font-weight: var(--weight-medium);
  flex-wrap: wrap;
}

/* Pagination ---------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-2);
  flex-wrap: wrap;
}
.pagination__info { font-variant-numeric: tabular-nums; }
.pagination__controls { display: flex; align-items: center; gap: var(--space-1); }
.pagination__size { display: flex; align-items: center; gap: var(--space-2); }
.pagination__size .select { width: auto; }
.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  display: inline-grid;
  place-items: center;
}
.page-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.page-btn[aria-current="page"] {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-xs);
}
.page-btn:disabled { opacity: 0.4; }
.page-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.page-gap { padding: 0 4px; color: var(--text-3); }

/* Skeletons ----------------------------------------------------------------- */
.skeleton {
  display: block;
  height: 12px;
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--surface-active) 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--circle { border-radius: 50%; }
.skeleton--title { height: 28px; width: 40%; }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Empty / error / access states -------------------------------------------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.state--compact { padding: var(--space-8) var(--space-4); }
.state__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-3);
}
.state__icon .lucide { width: 20px; height: 20px; }
.state__icon--danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.state__icon--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.state__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.state__desc { color: var(--text-2); max-width: 44ch; font-size: var(--text-sm); }
.state__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; justify-content: center; }

/* Alerts -------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--text-sm);
  color: var(--text-2);
}
.alert .lucide { margin-top: 2px; }
.alert__title { color: var(--text); font-weight: var(--weight-medium); }
.alert--danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.alert--danger .alert__title { color: var(--danger); }
.alert--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.alert--warning .alert__title { color: var(--warning); }
.alert--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert--info { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

/* Dropdown menu ------------------------------------------------------------- */
.menu-anchor { position: relative; display: inline-flex; }
.menu {
  position: fixed;
  z-index: var(--z-dropdown);
  min-width: 200px;
  padding: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: pop-in var(--dur) var(--ease);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 32px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  text-align: left;
  white-space: nowrap;
}
.menu__item .lucide { color: var(--text-3); }
.menu__item:hover,
.menu__item:focus-visible { background: var(--surface-hover); outline: none; text-decoration: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger .lucide { color: var(--danger); }
.menu__sep { height: 1px; margin: var(--space-1) calc(-1 * var(--space-1)); background: var(--border); }
.menu__header { padding: var(--space-2) var(--space-2) var(--space-1); color: var(--text-3); font-size: var(--text-xs); }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* Notification panel */
.notif-panel { width: 360px; max-width: calc(100vw - 24px); padding: 0; }
.notif-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-weight: var(--weight-semibold);
}
.notif-panel__list { max-height: 380px; overflow-y: auto; }
.notif {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.notif:last-child { border-bottom: 0; }
.notif.is-unread { background: var(--accent-soft); }
.notif__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-2);
  flex-shrink: 0;
}
.notif__icon .lucide { width: 14px; height: 14px; }
.notif__text { color: var(--text); }
.notif__time { color: var(--text-3); font-size: var(--text-xs); margin-top: 2px; }

/* Modal --------------------------------------------------------------------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: var(--overlay);
  animation: fade-in var(--dur) var(--ease);
}
.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-slow) var(--ease);
}
.modal--lg { max-width: 640px; }
.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6) 0;
}
.modal__title { font-size: var(--text-lg); }
.modal__desc { margin-top: 6px; color: var(--text-2); font-size: var(--text-sm); }
.modal__body { padding: var(--space-5) var(--space-6); overflow-y: auto; }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.modal__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--space-3);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.modal__icon--danger { background: var(--danger-soft); color: var(--danger); }
.modal__icon--success { background: var(--success-soft); color: var(--success); }
.modal__icon--warning { background: var(--warning-soft); color: var(--warning); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* Toasts -------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast__icon { margin-top: 1px; }
.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--danger); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info .toast__icon { color: var(--accent); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: var(--weight-medium); color: var(--text); }
.toast__msg { color: var(--text-2); margin-top: 2px; }
.toast__close { margin: -4px -6px -4px 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(16px); }
}

/* Charts -------------------------------------------------------------------- */
.legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-2);
}
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 8px; height: 8px; border-radius: 2px; }

.swatch--verified { background: var(--chart-verified); }
.swatch--pending { background: var(--chart-pending); }
.swatch--correction { background: var(--chart-correction); }

.hbar-chart { display: flex; flex-direction: column; gap: 10px; }
.hbar {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 56px;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
}
.hbar__label {
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar__label:hover { color: var(--text); text-decoration: none; }
.hbar__track {
  position: relative;
  display: flex;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--chart-track);
  overflow: hidden;
}
.hbar__seg { height: 100%; transition: width var(--dur-slow) var(--ease); }
.hbar__seg + .hbar__seg { box-shadow: inset 1px 0 0 var(--surface); }
.hbar__value { color: var(--text); font-weight: var(--weight-medium); text-align: right; font-variant-numeric: tabular-nums; }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
  justify-content: center;
}
.donut { position: relative; width: 168px; height: 168px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 16; }
.donut__track { stroke: var(--chart-track); }
.donut__seg { transition: stroke-dasharray var(--dur-slow) var(--ease); }
.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.donut__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.donut__label { color: var(--text-3); font-size: var(--text-xs); }
.donut-legend { display: flex; flex-direction: column; gap: var(--space-3); min-width: 180px; flex: 1; }
.donut-legend__row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.donut-legend__row .legend__swatch { width: 10px; height: 10px; }
.donut-legend__label { color: var(--text-2); }
.donut-legend__value { font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.donut-legend__pct { color: var(--text-3); font-weight: var(--weight-regular); margin-left: 6px; }

/* Progress (thin) */
.progress {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--chart-track);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}
.progress--stack { display: flex; }
.progress--stack .progress__bar { border-radius: 0; }

/* Description list ---------------------------------------------------------- */
.dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5) var(--space-6);
  margin: 0;
}
.dl__item { min-width: 0; }
.dl dt { color: var(--text-3); font-size: var(--text-xs); font-weight: var(--weight-medium); margin-bottom: 4px; }
.dl dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.dl__item--full { grid-column: 1 / -1; }

/* Timeline (activity) ------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item {
  position: relative;
  display: flex;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
}
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 30px;
  bottom: 4px;
  width: 1px;
  background: var(--border);
}
.timeline__icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-3);
  flex-shrink: 0;
}
.timeline__icon .lucide { width: 13px; height: 13px; }
.timeline__icon--success { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.timeline__icon--danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.timeline__icon--accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.timeline__body { min-width: 0; padding-top: 3px; font-size: var(--text-sm); }
.timeline__text { color: var(--text-2); }
.timeline__text strong { color: var(--text); font-weight: var(--weight-medium); }
.timeline__meta { color: var(--text-3); font-size: var(--text-xs); margin-top: 2px; }
.timeline__note {
  margin-top: 6px;
  padding: var(--space-2) var(--space-3);
  border-left: 2px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-2);
  font-size: var(--text-xs);
}

/* Dropzone (photo upload) --------------------------------------------------- */
.dropzone {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: border-color var(--dur), background var(--dur);
}
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-invalid { border-color: var(--danger); }
.dropzone__preview {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text-3);
}
.dropzone__preview img { width: 100%; height: 100%; object-fit: cover; }
.dropzone__preview .lucide { width: 28px; height: 28px; stroke-width: 1.5; }
.dropzone__body { flex: 1; min-width: 0; }
.dropzone__title { font-weight: var(--weight-medium); }
.dropzone__hint { color: var(--text-3); font-size: var(--text-xs); margin-top: 2px; }
.dropzone__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }
.dropzone__progress { margin-top: var(--space-3); }
.dropzone__progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-2);
  margin-bottom: 4px;
}

/* Form sections ------------------------------------------------------------- */
.form-section {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: var(--space-8);
  padding: var(--space-6);
}
.form-section + .form-section { border-top: 1px solid var(--border); }
.form-section__title { font-size: var(--text-md); }
.form-section__desc { color: var(--text-2); font-size: var(--text-sm); margin-top: 6px; }

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.form-actions__status { color: var(--text-3); font-size: var(--text-sm); }
.form-actions__buttons { display: flex; gap: var(--space-2); margin-left: auto; }

/* Chips (assigned wards etc.) ---------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-2);
  max-height: 220px;
  overflow-y: auto;
  padding: var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

/* Key shortcut hint / misc -------------------------------------------------- */
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.kv-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--text-sm); }
.kv-inline .lucide { color: var(--text-3); width: 14px; height: 14px; }
.masked { letter-spacing: 0.08em; color: var(--text-3); }

/* File picker button: keep keyboard focus visible on the wrapping label */
.file-btn { position: relative; }
.file-btn:has(input:focus-visible) { box-shadow: var(--ring); }

/* Possible-duplicate list (profile form) */
.dup-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); }
.dup-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.dup-item + .dup-item { border-top: 1px solid var(--border); }
