/* The shared component layer: cards, tiles, buttons, forms, tables, toasts,
   modals, drawers, chips, empty states. Single source — reused everywhere. */

/* ---------- card ---------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--ring), var(--shadow-1);
  padding: var(--s-5);
}
.card__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.card__head h2, .card__head h3 { margin: 0; }
.card__head .spacer { flex: 1 1 auto; }
.card__sub { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- icon chip ----------------------------------------------------- */
.chip-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-050); color: var(--brand);
}
.chip-icon svg { width: 19px; height: 19px; }
.chip-icon--ok       { background: var(--ok-wash);       color: var(--ok-ink); }
.chip-icon--warn     { background: var(--warn-wash);     color: var(--warn-ink); }
.chip-icon--serious  { background: var(--serious-wash);  color: var(--serious-ink); }
.chip-icon--critical { background: var(--critical-wash); color: var(--critical-ink); }
.chip-icon--blue     { background: var(--blue-100);      color: var(--blue-600); }

/* ---------- hero figure --------------------------------------------------- */
.hero {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s-6); align-items: center;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--ring), var(--shadow-2);
  padding: var(--s-6); position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset-inline-start: -80px; top: -120px;
  width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-050) 0%, transparent 70%);
  pointer-events: none;
}
.hero__body { position: relative; }
.hero__label { color: var(--ink-2); font-weight: 600; }
.hero__value { font-size: var(--fs-hero); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.hero__note { color: var(--muted); font-size: var(--fs-sm); }
.hero__stats { display: flex; gap: var(--s-6); flex-wrap: wrap; margin-top: var(--s-4); }
.hero__stat-label { font-size: var(--fs-xs); color: var(--muted); }
.hero__stat-value { font-size: var(--fs-xl); font-weight: 650; }

@media (max-width: 700px) {
  .hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
}

/* ---------- square stat tiles -------------------------------------------- */
/* The dashboard renders exactly six tiles, so the column count is pinned rather
   than left to auto-fill — auto-fill lands on 5 at common widths and orphans the
   sixth tile on a row of its own.
   The grid is also width-capped at the lower counts: the tiles are square, so a
   column wider than ~230px produces a tile that is 300px+ TALL, with a canyon of
   empty space between the icon and the value. 6 / 3 / 2 all divide six evenly. */
.tiles {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
/* The tile count varies with the signed-in user's role, so the column count is
   pinned per count — always a divisor, so no row is ever orphaned. */
.tiles--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 440px; }
.tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 660px; }
.tiles--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 880px; }
.tiles--7 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 880px; }

@media (max-width: 1040px) {
  .tiles, .tiles--4, .tiles--7 {
    grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 660px;
  }
}
@media (max-width: 700px) {
  .tiles, .tiles--3, .tiles--4, .tiles--7 {
    grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 440px;
  }
}
.tile {
  aspect-ratio: 1 / 1;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--ring), var(--shadow-1);
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2);
  color: inherit;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--ring), var(--shadow-2); color: inherit; }
.tile__top { display: flex; align-items: flex-start; gap: var(--s-2); }
.tile__ring { margin-inline-start: auto; }
.tile__value {
  font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.03em;
  line-height: 1.05; margin-top: auto;
}
.tile__value--sm { font-size: var(--fs-2xl); }
.tile__label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 550; }
.tile__flag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 650;
}
.tile__flag svg { width: 14px; height: 14px; }
.tile--ok       .tile__flag { color: var(--ok-ink); }
.tile--warn     .tile__flag { color: var(--warn-ink); }
.tile--critical .tile__flag { color: var(--critical-ink); }
.tile--ok       { box-shadow: var(--ring), var(--shadow-1), inset 0 -3px 0 var(--ok); }
.tile--warn     { box-shadow: var(--ring), var(--shadow-1), inset 0 -3px 0 var(--warn); }
.tile--critical { box-shadow: var(--ring), var(--shadow-1), inset 0 -3px 0 var(--critical); }

@media (max-width: 520px) { .tile__value { font-size: var(--fs-2xl); } }

/* ---------- buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 9px var(--s-4); border-radius: var(--r);
  border: 1px solid transparent; background: var(--surface);
  font-size: var(--fs-md); font-weight: 600; cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-600); color: #fff; }
.btn--ghost { border-color: var(--hairline); color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger { border-color: var(--critical-wash); background: var(--critical-wash); color: var(--critical-ink); }
.btn--danger:hover { background: #f6dede; }
.btn--sm { padding: 6px 11px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

/* ---------- forms --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--critical); margin-inline-start: 2px; }
.input, .select, .textarea {
  width: 100%; padding: 9px var(--s-3);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r); font-size: var(--fs-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-300); box-shadow: var(--focus);
}
.textarea { min-height: 78px; resize: vertical; }
.select { appearance: none; background-image: none; padding-inline-end: var(--s-4); }
.field__error {
  font-size: var(--fs-sm); color: var(--critical-ink); font-weight: 600;
  display: none; align-items: center; gap: 5px;
}
.field__error svg { width: 14px; height: 14px; flex: none; }
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--critical); background: #fffafa; }
.field.has-error .field__error { display: flex; }
.field__hint { font-size: var(--fs-xs); color: var(--muted); }

.form-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }

/* ---------- filter bar (one row above every table) ------------------------ */
.filters {
  display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--ring); padding: var(--s-4); margin-bottom: var(--s-4);
}
.filters .field { flex: 1 1 168px; }
.filters .field--sm { flex: 0 1 132px; }
.filters .spacer { flex: 1 1 auto; }
.filters__actions { display: flex; gap: var(--s-2); align-items: center; }

.switch { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); cursor: pointer; padding-bottom: 9px; }
.switch input { width: 17px; height: 17px; accent-color: var(--brand); }

/* ---------- table --------------------------------------------------------- */
.table-wrap {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--ring), var(--shadow-1); overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td {
  padding: 11px var(--s-3); text-align: start;
  border-bottom: 1px solid var(--gridline); vertical-align: middle;
  white-space: nowrap;
}
table.data thead th {
  background: var(--surface-2); color: var(--ink-2);
  font-weight: 650; font-size: var(--fs-xs);
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--hairline);
}
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--brand-050); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; min-width: 160px; }
table.data td.num-cell, table.data th.num-cell { text-align: end; font-variant-numeric: tabular-nums; }
table.data tfoot td {
  background: var(--surface-2); font-weight: 700;
  border-top: 2px solid var(--baseline); border-bottom: 0;
}
.row-actions { display: flex; gap: 4px; opacity: .35; transition: opacity var(--t-fast); }
tr:hover .row-actions { opacity: 1; }
.icon-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm); border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn--danger:hover { background: var(--critical-wash); color: var(--critical-ink); }

/* A defaulted client's row is marked by a left rule plus a wash — the متعثر badge
   in the row carries the meaning in text, so this is emphasis, not the signal. */
tr.row-defaulted td { background: #fdf6f6; }
tr.row-defaulted td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
tr.row-defaulted:hover td { background: #fbeded; }
.callout-danger { border-inline-start: 4px solid var(--critical); }

.group-row td {
  background: var(--brand-050); font-weight: 700; color: var(--brand-700);
  border-bottom: 1px solid var(--brand-100);
}

/* ---------- badges (status: colour + icon + label, never colour alone) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px;
  font-size: var(--fs-xs); font-weight: 650;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--hairline);
}
.badge svg { width: 13px; height: 13px; flex: none; }
.badge--ok       { background: var(--ok-wash);       color: var(--ok-ink);       border-color: #cbe8cb; }
.badge--warn     { background: var(--warn-wash);     color: var(--warn-ink);     border-color: #f3e0b4; }
.badge--serious  { background: var(--serious-wash);  color: var(--serious-ink);  border-color: #f6d5c6; }
.badge--critical { background: var(--critical-wash); color: var(--critical-ink); border-color: #f1c9c9; }
.badge--brand    { background: var(--brand-050);     color: var(--brand-700);    border-color: var(--brand-100); }
.badge--blue     { background: var(--blue-100);      color: var(--blue-600);     border-color: #b9d7f8; }

/* ---------- toast --------------------------------------------------------- */
#toasts {
  position: fixed; inset-block-start: var(--s-4); inset-inline-start: var(--s-4);
  z-index: 90; display: flex; flex-direction: column; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--ring), var(--shadow-3);
  padding: var(--s-3) var(--s-4); min-width: 268px; max-width: 400px;
  font-weight: 600; font-size: var(--fs-sm);
  border-inline-start: 4px solid var(--ok);
  animation: toast-in var(--t-med) both; pointer-events: auto;
}
.toast svg { width: 19px; height: 19px; flex: none; color: var(--ok-ink); }
.toast--error { border-inline-start-color: var(--critical); }
.toast--error svg { color: var(--critical-ink); }
.toast.is-out { animation: toast-out var(--t-fast) both; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- modal & drawer ------------------------------------------------ */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(26,25,23,.42); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: var(--s-4);
  animation: fade-in var(--t-fast) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); width: min(760px, 100%);
  max-height: 90vh; display: flex; flex-direction: column;
  animation: modal-in var(--t-med) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.modal--sm { width: min(440px, 100%); }
.modal__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-3); border-bottom: 1px solid var(--hairline);
}
.modal__head .spacer { flex: 1 1 auto; }
.modal__body { padding: var(--s-5); overflow-y: auto; }
.modal__foot {
  display: flex; gap: var(--s-2); justify-content: flex-start;
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--hairline);
  background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.modal__foot .spacer { flex: 1 1 auto; }

.drawer-overlay { justify-items: end; align-items: stretch; padding: 0; }
.drawer {
  background: var(--surface); width: min(560px, 100%); height: 100%;
  display: flex; flex-direction: column; box-shadow: var(--shadow-3);
  animation: drawer-in var(--t-med) both;
}
@keyframes drawer-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .overlay, .modal, .drawer, .toast { animation: none; }
}

/* ---------- empty state --------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-8) var(--s-4); text-align: center; color: var(--ink-2);
}
.empty img, .empty svg { width: 168px; height: auto; opacity: .95; }
.empty h3 { color: var(--ink); }
.empty p { max-width: 46ch; color: var(--muted); }

/* ---------- misc ---------------------------------------------------------- */
.section { margin-top: var(--s-6); }
.grid-2 { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.rowline { display: flex; align-items: center; gap: var(--s-3); }
.rowline .spacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.ink2 { color: var(--ink-2); }
.crit { color: var(--critical-ink); }
.okc  { color: var(--ok-ink); }

.summary-strip {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  margin-bottom: var(--s-4);
}
.summary-cell {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--ring); padding: var(--s-3) var(--s-4);
}
.summary-cell__label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.summary-cell__value { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }

.list-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px 0; border-bottom: 1px solid var(--gridline);
}
.list-row:last-child { border-bottom: 0; }
.list-row .spacer { flex: 1 1 auto; }

.loading { padding: var(--s-8); text-align: center; color: var(--muted); }

/* ---------- auth (login / first-run setup) -------------------------------- */
.auth {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--s-4);
  padding: var(--s-5); position: relative; overflow: hidden;
}
.auth::before {
  content: ""; position: absolute; inset-block-start: -220px; inset-inline-start: -160px;
  width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-050) 0%, transparent 68%);
  pointer-events: none;
}
.auth__panel {
  position: relative; width: min(430px, 100%);
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--ring), var(--shadow-3); padding: var(--s-6);
}
.auth__brand { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-5); }
.auth__mark { flex: none; line-height: 0; }
/* The office logo, whatever shape it is. object-fit keeps a wide wordmark or a
   square emblem both looking deliberate in the same slot. */
.brand-logo {
  width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 9px; display: block;
}
.auth__mark .brand-logo { width: 52px; height: 52px; }
.brand__mark { display: block; }
.logo-preview {
  width: 92px; height: 92px; border-radius: var(--r); background: var(--surface-2);
  display: grid; place-items: center; padding: var(--s-2); flex: none;
  box-shadow: var(--ring);
}
.auth__office { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.02em; }
.auth__system { font-size: var(--fs-xs); color: var(--muted); }
.auth__title { font-size: var(--fs-2xl); }
.auth__sub { color: var(--ink-2); font-size: var(--fs-sm); margin: var(--s-1) 0 var(--s-5); }
.auth__foot { position: relative; font-size: var(--fs-xs); color: var(--muted); margin: 0; }
.btn--block { width: 100%; margin-top: var(--s-2); padding: 11px var(--s-4); }
.auth__link {
  background: none; border: 0; padding: var(--s-2) 0; cursor: pointer;
  color: var(--brand); font-size: var(--fs-sm); font-weight: 600; text-align: center;
}
.auth__link:hover { color: var(--brand-600); text-decoration: underline; }
.auth__note {
  font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface-2);
  border-radius: var(--r); padding: var(--s-3); margin: 0 0 var(--s-4);
}
.input--code {
  text-align: center; font-size: var(--fs-2xl); font-weight: 700;
  letter-spacing: 0.3em; padding: var(--s-3); font-variant-numeric: tabular-nums;
}

/* ---------- account block in the sidebar ---------------------------------- */
#account { margin-bottom: var(--s-3); }
.account { display: flex; align-items: center; gap: var(--s-2); }
.account__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--brand-050); color: var(--brand-700);
  font-weight: 700; font-size: var(--fs-sm);
}
.account__id { min-width: 0; }
.account__name {
  font-size: var(--fs-sm); font-weight: 650; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account__role { font-size: var(--fs-xs); color: var(--muted); }
.sidebar__version { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-2); }

@media (max-width: 860px) {
  #account { margin: 0; margin-inline-start: auto; }
  .account__id { display: none; }
  #account .btn-row { margin-top: 0 !important; }
  .sidebar__version { display: none; }
}

/* ---------- permission matrix --------------------------------------------- */
.perm-table th, .perm-table td { vertical-align: middle; }
.perm-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.perm-head .chip-icon { width: 30px; height: 30px; }
.perm-box { width: 19px; height: 19px; accent-color: var(--brand); cursor: pointer; }
.perm-box[disabled] { cursor: not-allowed; opacity: .55; }
.perm-table tbody tr:hover { background: var(--brand-050); }

/* ---------- charts -------------------------------------------------------- */
.chart-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--ring), var(--shadow-1); padding: var(--s-5); }
.chart-scroll { overflow-x: auto; }
.ring { display: block; }

/* Bar chart. Mark specs: bar <= 24px thick, 4px rounded data-end, square at the
   baseline, recessive hairline gridlines, value labelled at the tip only. */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bars__row {
  display: grid; align-items: center; gap: var(--s-3);
  grid-template-columns: 150px minmax(0, 1fr) 92px;
}
.bars__label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 550; line-height: 1.3; }
.bars__track {
  position: relative; height: 22px;                 /* <= 24px cap */
  display: flex; justify-content: flex-start;       /* RTL: starts at the right */
  /* four recessive gridlines, hairline and solid, one step off the surface */
  background-image: repeating-linear-gradient(
    to left, var(--gridline) 0 1px, transparent 1px 25%);
  border-inline-start: 1px solid var(--baseline);   /* the single baseline */
}
.bars__bar {
  height: 100%;
  /* rounded at the data-end, square where it meets the baseline */
  border-start-end-radius: 4px; border-end-end-radius: 4px;
  transition: width var(--t-slow), opacity var(--t-fast);
}
.bars__row:hover .bars__bar { opacity: .84; }
.bars__value {
  font-size: var(--fs-sm); font-weight: 650; color: var(--ink);
  text-align: end; font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) {
  .bars__row { grid-template-columns: 108px minmax(0, 1fr) 74px; gap: var(--s-2); }
  .bars__label { font-size: var(--fs-xs); }
}

/* Chart legend — present whenever there are two or more series. The aging chart
   is a single series, so it deliberately has none: the card title names it. */
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-2); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* ===================================================================== v1.2
   Documents (§1.1/§1.7), hearing notes (§1.2), audit (§4.1), notifications.
   Built on the existing tokens only — no new colours are introduced here, so
   these panels inherit the print stylesheet and any future theme work.
   ===================================================================== */

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.panel-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.panel-head__actions { display: flex; gap: 8px; }

/* --- §1.7 essentials ---------------------------------------------------- */
.doc-essentials {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.doc-essential {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface);
}
.doc-essential.is-present { border-color: var(--ok); color: var(--ok); }
/* Missing is the state that matters, so it is the one that draws the eye. */
.doc-essential.is-missing { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.doc-essential__count {
  background: var(--surface-2); border-radius: 999px; padding: 0 6px; font-size: 11px;
}
.doc-essential__missing { font-size: 11px; opacity: .85; }

/* --- §1.1 document list ------------------------------------------------- */
.doc-list { display: grid; gap: 8px; }
.doc-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.doc-row__main { flex: 1; min-width: 0; }
.doc-row__title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--text); text-decoration: none;
}
.doc-row__title:hover { color: var(--brand); text-decoration: underline; }
.doc-row__meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 6px; font-size: 12px; color: var(--muted);
}
.doc-row__notes { margin-top: 6px; font-size: 13px; color: var(--muted); }
.doc-row__actions { display: flex; gap: 4px; flex-shrink: 0; }
.doc-usage { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: left; }

.doc-versions { margin-top: 8px; font-size: 12px; }
.doc-versions summary { cursor: pointer; color: var(--muted); }
.doc-versions ul { list-style: none; margin: 8px 0 0; padding: 0 12px 0 0; display: grid; gap: 6px; }
.doc-versions li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.doc-versions__no { font-weight: 600; color: var(--text); }
.doc-versions__meta { color: var(--muted); }

/* --- §1.2 hearing notes ------------------------------------------------- */
.note-list { display: grid; gap: 12px; }
.note {
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.note__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.note__date { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.note__actions { display: flex; gap: 4px; }
.note-section { margin-bottom: 10px; }
.note-section__label {
  font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px;
  display: flex; align-items: center; gap: 5px;
}
.note-section__body { font-size: 14px; line-height: 1.7; }
/* Action items are what someone returns for, so they are visually separated. */
.note-section--actions {
  background: var(--warn-wash, var(--surface-2));
  border-inline-start: 3px solid var(--warn, var(--brand));
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.note__foot {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}

/* --- notifications ------------------------------------------------------ */
.notif-bell { position: relative; }
.notif-bell__dot {
  position: absolute; top: 2px; inset-inline-end: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 10px; line-height: 16px; text-align: center; font-weight: 700;
}
.notif-list { display: grid; gap: 8px; }
.notif {
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
}
.notif.is-unread { border-inline-start: 3px solid var(--brand); background: var(--brand-wash, var(--surface)); }
.notif__title { font-weight: 600; font-size: 14px; }
.notif__body { font-size: 13px; color: var(--muted); margin-top: 3px; }
.notif__meta { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* --- §3.4 today's hearings: un-updated rows are red --------------------- */
.hearing-today__row.needs-update {
  border-inline-start: 3px solid var(--danger);
  background: var(--danger-wash, var(--surface));
}
.hearing-today__row.needs-update .hearing-today__case { color: var(--danger); font-weight: 700; }

/* --- §4.1 audit --------------------------------------------------------- */
.audit-row { display: grid; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.audit-row__head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.audit-row__who { font-weight: 600; }
.audit-row__when { font-size: 12px; color: var(--muted); margin-inline-start: auto; }
.audit-row__summary { font-size: 13px; }
.audit-diff { margin-top: 4px; font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.audit-diff__from { text-decoration: line-through; opacity: .75; }

/* --- §5 AI -------------------------------------------------------------- */
.ai-answer { white-space: pre-wrap; line-height: 1.8; font-size: 14px; }
.ai-disclaimer {
  margin-top: 12px; padding: 10px 12px; font-size: 12px;
  border: 1px solid var(--warn, var(--line)); border-radius: var(--radius-sm);
  background: var(--warn-wash, var(--surface-2)); color: var(--text);
}

.modal-form { display: grid; gap: 12px; }
.modal__hint { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.empty--inline { padding: 24px 12px; text-align: center; color: var(--muted); }
.notice {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 13px; margin-bottom: 12px;
}
.notice--warn {
  background: var(--warn-wash, var(--surface-2));
  border: 1px solid var(--warn, var(--line));
}

/* --- drawer tabs (case screen) ----------------------------------------- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 16px; overflow-x: auto;
}
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab-panel[hidden] { display: none; }

.notif-slot { display: flex; justify-content: flex-start; margin-bottom: 8px; }

/* ---------------------------------------------------- global search (v1.6) */
/* One box reachable from any screen with `/`. Uses the existing tokens only —
   no new colours, no change to any existing component. */
.gs {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 18, 28, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
}
.gs__panel {
  width: min(680px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-2); overflow: hidden;
  display: flex; flex-direction: column; max-height: 70vh;
}
.gs__bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.gs__bar svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.gs__input {
  flex: 1; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink);
}
.gs__results { overflow-y: auto; padding: 6px; }
.gs__group { display: flex; flex-direction: column; gap: 2px; }
.gs__group + .gs__group { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 4px; }
.gs__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: inherit; text-decoration: none;
}
.gs__item:hover, .gs__item.is-active { background: var(--brand-050); }
.gs__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gs__title { font-weight: 600; overflow-wrap: anywhere; }
.gs__sub, .gs__detail { font-size: 12px; color: var(--muted); }
.gs__detail { flex: none; max-width: 40%; text-align: end; }
.gs__amount { font-variant-numeric: tabular-nums; font-weight: 700; flex: none; }
.gs__hint { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 14px; }
.gs__foot {
  display: flex; gap: 14px; justify-content: center;
  padding: 8px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted);
}
@media (max-width: 560px) {
  .gs { padding: 0; }
  .gs__panel { max-height: 100vh; height: 100%; border-radius: 0; }
  .gs__detail { display: none; }
}

/* ------------------------------------------------------- اليوم screen (v1.6) */
.today__section--critical { border-inline-start: 3px solid var(--critical); }
.today__section--warn     { border-inline-start: 3px solid var(--warn); }
.today__section--info     { border-inline-start: 3px solid var(--brand-300); }
.today__list { display: flex; flex-direction: column; gap: 2px; }
.today__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: inherit; text-decoration: none;
}
.today__item:hover { background: var(--brand-050); }
.today__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.today__title { font-weight: 700; }
.today__sub { font-size: 13px; }
.today__detail, .today__note { font-size: 12px; color: var(--muted); }
.today__note { flex: none; text-align: end; }
.today__amount { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .today__detail { display: none; }
}

/* ------------------------------------------- دليل القوانين العُمانية (v1.7) */
.lawref-list { display: flex; flex-direction: column; }
.lawref {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.lawref:last-child { border-bottom: 0; }
.lawref__pick { flex: none; padding-top: 2px; }
.lawref__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lawref__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lawref__topic { font-weight: 700; }
.lawref__cite { font-size: 13.5px; color: var(--ink-2, var(--ink)); overflow-wrap: anywhere; }
