/* ==========================================================================
   Natiq — design system
   Written with CSS logical properties throughout (margin-inline-start, inset-inline…)
   so the same stylesheet serves LTR English and RTL Arabic without overrides.
   ========================================================================== */

:root {
  --ink:        #15201e;
  --ink-soft:   #3d4b48;
  --muted:      #6b7a76;
  --bg:         #f6f5f1;
  --surface:    #ffffff;
  --surface-2:  #fbfaf7;
  --line:       #e4e1d8;
  --line-soft:  #efece5;

  --accent:     #0f766e;
  --accent-ink: #0b5a54;
  --accent-bg:  #e7f4f1;
  --accent-ring:rgba(15, 118, 110, .22);

  --ok:         #067647;
  --ok-bg:      #e7f6ee;
  --warn:       #b54708;
  --warn-bg:    #fdf1e3;
  --danger:     #b42318;
  --danger-bg:  #fdecea;
  --info:       #175cd3;
  --info-bg:    #eaf1fd;
  --gold:       #b98900;

  --radius:     14px;
  --radius-sm:  9px;
  --radius-lg:  20px;

  --shadow-sm: 0 1px 2px rgba(21, 32, 30, .06);
  --shadow:    0 2px 8px rgba(21, 32, 30, .07), 0 12px 28px -18px rgba(21, 32, 30, .35);
  --shadow-lg: 0 24px 60px -24px rgba(21, 32, 30, .45);

  --sidebar-w: 252px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #eef2f0;
    --ink-soft:   #c3cecb;
    --muted:      #92a19d;
    --bg:         #101615;
    --surface:    #18201f;
    --surface-2:  #1d2624;
    --line:       #2a3432;
    --line-soft:  #232c2a;
    --accent:     #34b8a8;
    --accent-ink: #7dd3c8;
    --accent-bg:  #14302e;
    --accent-ring:rgba(52, 184, 168, .28);
    --ok:         #4ade80;
    --ok-bg:      #0f2a1d;
    --warn:       #fbbf24;
    --warn-bg:    #2c2110;
    --danger:     #f87171;
    --danger-bg:  #2d1514;
    --info:       #7aa8f8;
    --info-bg:    #131f36;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 2px 8px rgba(0, 0, 0, .35), 0 12px 28px -18px rgba(0, 0, 0, .8);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p  { margin: 0; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── boot & noscript ─────────────────────────────────────────────────── */
.boot { display: grid; place-items: center; min-height: 100dvh; }
.boot__inner { display: grid; place-items: center; gap: 18px; }
.boot__mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 1.7rem; font-weight: 700;
}
.boot__spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.noscript { padding: 2rem; text-align: center; }

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

/* ── app shell ───────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 14px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
}
.brand__mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.1rem;
  flex: 0 0 auto;
}
.brand__text { display: grid; line-height: 1.15; }
.brand__name { font-weight: 700; letter-spacing: -.02em; }
.brand__sub { font-size: .72rem; color: var(--muted); }

.nav-section {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 520;
  font-size: .92rem;
  cursor: pointer;
  border: 0; background: none; width: 100%; text-align: start;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.is-active { background: var(--accent-bg); color: var(--accent-ink); font-weight: 640; }
.nav-item__icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav-item__badge {
  margin-inline-start: auto;
  background: var(--accent); color: #fff;
  border-radius: 999px; font-size: .68rem; font-weight: 700;
  padding: 1px 7px; min-width: 20px; text-align: center;
}

.sidebar__foot { margin-top: auto; padding-top: 14px; display: grid; gap: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 26px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 660; font-size: 1rem; }
.topbar__spacer { margin-inline-start: auto; }
.topbar__org { font-size: .8rem; color: var(--muted); }
.topbar__avatar {
  display: none; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent-ink);
  font-size: .78rem; font-weight: 700; letter-spacing: .02em;
  flex: 0 0 auto;
}

/* provider branding — top of every screen and in the footer */
.brand-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 0 0 auto;
}

.brand-footer {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 16px 26px 22px;
  font-size: .78rem; color: var(--muted);
}
.brand-footer--block { padding: 0; }
.brand-footer__name { font-weight: 700; color: var(--ink-soft); }
.brand-footer__sep { opacity: .5; }
.brand-footer__link { color: inherit; text-decoration: none; }
.brand-footer__link:hover { text-decoration: underline; color: var(--accent-ink); }
.brand-footer--light { color: rgba(234, 246, 244, .72); }
.brand-footer--light .brand-footer__name { color: #eaf6f4; }

.content { padding: 26px; max-width: 1320px; width: 100%; }

/* ── primitives ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: 20px; }
.card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-block-end: 1px solid var(--line-soft);
}
.card__head h2 { font-size: 1rem; }
.card__head .spacer { margin-inline-start: auto; }
.card__body { padding: 18px 20px; }

.stack  { display: grid; gap: 16px; }
.stack--sm { gap: 9px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { margin-inline-start: auto; }

.grid-cards {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
}
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid; gap: 3px;
}
.stat__label { font-size: .76rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.stat__value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat__hint { font-size: .76rem; color: var(--muted); }
.stat--accent { background: linear-gradient(160deg, var(--accent-bg), var(--surface)); border-color: var(--accent-ring); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 580; font-size: .9rem;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--ghost { border-color: transparent; background: none; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 6px 11px; font-size: .82rem; }
.btn--lg { padding: 12px 22px; font-size: 1rem; }
.btn--block { width: 100%; }

/* forms */
.field { display: grid; gap: 6px; }
.field > label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.field__hint { font-size: .76rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input--lg { padding: 12px 14px; font-size: 1rem; }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { inline-size: 16px; block-size: 16px; accent-color: var(--accent); }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem; font-weight: 640;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge--ok     { background: var(--ok-bg);     color: var(--ok);     border-color: transparent; }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge--warn   { background: var(--warn-bg);   color: var(--warn);   border-color: transparent; }
.badge--info   { background: var(--info-bg);   color: var(--info);   border-color: transparent; }
.badge--accent { background: var(--accent-bg); color: var(--accent-ink); border-color: transparent; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td {
  text-align: start;
  padding: 10px 14px;
  border-block-end: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700;
  background: var(--surface-2);
  position: sticky; top: 0;
  white-space: nowrap;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-block-end: 0; }
.table .num { font-variant-numeric: tabular-nums; }
.table .truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table--compact th, .table--compact td { padding: 7px 11px; }

.mono { font-family: var(--mono); font-size: .82em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.empty {
  padding: 34px 20px; text-align: center; color: var(--muted);
  display: grid; gap: 8px; justify-items: center;
}

/* progress */
.progress { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .35s ease; }
.progress__bar--ok { background: var(--ok); }

/* toasts */
.toasts {
  position: fixed; inset-block-end: 20px; inset-inline-end: 20px;
  display: grid; gap: 8px; z-index: 200; max-width: min(380px, calc(100vw - 40px));
}
.toast {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: .88rem;
  animation: toast-in .18s ease;
  display: flex; gap: 9px; align-items: flex-start;
}
.toast--ok     { border-inline-start: 3px solid var(--ok); }
.toast--error  { border-inline-start: 3px solid var(--danger); }
.toast--info   { border-inline-start: 3px solid var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(12, 20, 19, .45);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(620px, 100%);
  max-height: min(86dvh, 900px);
  display: flex; flex-direction: column;
  animation: pop .16s ease;
}
.modal--wide { width: min(940px, 100%); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
.modal__head {
  padding: 18px 22px 12px;
  display: flex; align-items: center; gap: 12px;
  border-block-end: 1px solid var(--line-soft);
}
.modal__head h2 { font-size: 1.05rem; }
.modal__body { padding: 18px 22px; overflow-y: auto; }
.modal__foot {
  padding: 14px 22px 18px;
  display: flex; gap: 10px; justify-content: flex-end;
  border-block-start: 1px solid var(--line-soft);
}

/* ── login ───────────────────────────────────────────────────────────── */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.auth__aside {
  background:
    radial-gradient(1100px 520px at 12% 8%, rgba(52, 184, 168, .30), transparent 60%),
    radial-gradient(760px 420px at 88% 92%, rgba(15, 118, 110, .42), transparent 62%),
    #0c2623;
  color: #eaf6f4;
  padding: 48px;
  display: flex; flex-direction: column; gap: 30px;
  position: relative;
  overflow: hidden;
}
.auth__aside::after {
  content: "";
  position: absolute; inset-inline-end: -80px; inset-block-end: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  border: 44px solid rgba(255, 255, 255, .05);
}
.auth__logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.1rem; }
.auth__logo .brand__mark { background: #fff; color: #0c2623; }
.auth__pitch { display: grid; gap: 16px; max-width: 460px; margin-block: auto; }
.auth__pitch h1 { font-size: 2.3rem; line-height: 1.15; letter-spacing: -.03em; }
.auth__pitch p { color: rgba(234, 246, 244, .78); font-size: 1rem; }
.auth__points { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.auth__points li { display: flex; gap: 11px; align-items: flex-start; font-size: .92rem; color: rgba(234,246,244,.9); }
.auth__points svg { flex: 0 0 auto; margin-block-start: 3px; color: #7dd3c8; }
.auth__langs { display: flex; gap: 8px; flex-wrap: wrap; }
.auth__langs span {
  padding: 3px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); font-size: .8rem;
}
.auth__foot { margin-block-start: auto; }
.auth__panel {
  display: grid; place-items: center;
  padding: 40px 28px;
  background: var(--surface);
}
.auth__form { width: min(384px, 100%); display: grid; gap: 18px; }
.auth__form h2 { font-size: 1.45rem; }
.auth__toggle {
  position: absolute; inset-block-start: 20px; inset-inline-end: 20px;
}

/* ── practice screen ─────────────────────────────────────────────────── */
.practice { display: grid; gap: 16px; }

.prompt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  display: grid; gap: 14px;
  box-shadow: var(--shadow-sm);
}
.prompt__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt__text {
  font-size: clamp(1.35rem, 2.4vw, 2.05rem);
  line-height: 1.45;
  font-weight: 620;
  letter-spacing: -.01em;
  word-break: break-word;
}
.prompt__text--word { font-size: clamp(1.9rem, 4vw, 2.9rem); }
.prompt__translation { color: var(--muted); font-size: .95rem; }

.reps { display: flex; align-items: center; gap: 10px; }
.reps__dots { display: flex; gap: 6px; }
.reps__dot {
  width: 26px; height: 6px; border-radius: 999px;
  background: var(--line);
}
.reps__dot--done { background: var(--ok); }

.recorder { display: grid; justify-items: center; gap: 14px; padding: 10px 0 4px; }

.mic {
  --size: 132px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px -12px var(--accent-ring), 0 0 0 10px var(--accent-bg);
  transition: transform .12s ease, background .15s ease, box-shadow .2s ease;
  position: relative;
}
.mic:hover { transform: scale(1.03); }
.mic:active { transform: scale(.98); }
.mic[disabled] { cursor: not-allowed; opacity: .55; transform: none; }
.mic--recording {
  background: var(--danger);
  box-shadow: 0 10px 30px -10px rgba(180, 35, 24, .5), 0 0 0 10px var(--danger-bg);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 30px -10px rgba(180,35,24,.45), 0 0 0 10px var(--danger-bg); }
  50%      { box-shadow: 0 10px 30px -10px rgba(180,35,24,.45), 0 0 0 22px transparent; }
}
.mic--busy { background: var(--muted); box-shadow: 0 0 0 10px var(--surface-2); }
.mic__label { font-weight: 620; font-size: .95rem; }
.mic__timer { font-variant-numeric: tabular-nums; font-size: 1.1rem; font-weight: 650; font-family: var(--mono); }
.mic__hint { font-size: .82rem; color: var(--muted); text-align: center; max-width: 380px; }

.verdict {
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; gap: 13px; align-items: flex-start;
  border: 1px solid transparent;
}
.verdict--ok   { background: var(--ok-bg);     border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.verdict--fail { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.verdict--info { background: var(--info-bg);   border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.verdict__icon { flex: 0 0 auto; margin-block-start: 2px; }
.verdict__body { display: grid; gap: 4px; }
.verdict__title { font-weight: 680; }
.verdict--ok .verdict__title { color: var(--ok); }
.verdict--fail .verdict__title { color: var(--danger); }

.heard {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .95rem;
}
.heard__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-block-end: 3px; }

/* token diff */
.diff {
  display: flex; flex-wrap: wrap; gap: 4px 5px;
  font-size: 1.02rem; line-height: 1.9;
}
.diff__tok {
  padding: 1px 6px;
  border-radius: 6px;
  white-space: pre-wrap;
}
.diff__tok--match { background: var(--ok-bg); color: var(--ok); }
.diff__tok--sub   { background: var(--danger-bg); color: var(--danger); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff__tok--del   { background: var(--danger-bg); color: var(--danger); text-decoration: line-through; opacity: .8; }
.diff__tok--ins   { background: var(--warn-bg); color: var(--warn); }
.diff__legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .76rem; color: var(--muted); }
.diff__legend span { display: flex; align-items: center; gap: 5px; }
.diff__swatch { width: 11px; height: 11px; border-radius: 3px; }

.accuracy {
  display: grid; gap: 6px;
}
.accuracy__head { display: flex; align-items: baseline; gap: 8px; }
.accuracy__value { font-size: 1.9rem; font-weight: 720; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.accuracy__target { font-size: .82rem; color: var(--muted); }

/* item list (homework) */
.item-list { display: grid; gap: 10px; }
.item-row {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: start;
  width: 100%;
  transition: border-color .12s ease, background .12s ease;
}
.item-row:hover { border-color: var(--accent-ring); background: var(--surface-2); }
.item-row.is-done { border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); }
.item-row__index {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; flex: 0 0 auto;
}
.item-row.is-done .item-row__index { background: var(--ok-bg); color: var(--ok); }
.item-row__body { display: grid; gap: 3px; min-width: 0; flex: 1; }
.item-row__text { font-weight: 560; overflow-wrap: anywhere; }
.item-row__trans { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.item-row__side { display: grid; gap: 5px; justify-items: end; flex: 0 0 auto; }

/* charts — drawn at real pixel width, so strokes and labels never stretch */
.chart-host { width: 100%; min-width: 0; }
.chart { width: 100%; display: block; }
.chart__bar { fill: var(--accent); opacity: .85; }
.chart__bar:hover { opacity: 1; }
.chart__axis { stroke: var(--line); stroke-width: 1; }
.chart__grid { stroke: var(--line-soft); stroke-width: 1; }
.chart__label {
  fill: var(--muted); font-family: var(--font);
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.chart__area { fill: var(--accent); fill-opacity: .12; }
.chart__line { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart__point { fill: var(--accent); }

.legend { display: grid; gap: 7px; }
.legend__row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: .86rem; }
.legend__bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.legend__fill { height: 100%; border-radius: 999px; background: var(--accent); }

/* misc */
.divider { height: 1px; background: var(--line-soft); margin-block: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }

.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.trial-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: .86rem;
  font-weight: 560;
  border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
}
.trial-banner--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }

/* loud strip shown while transcription is simulated */
.mock-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 26px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: .84rem;
  font-weight: 600;
  border-block-end: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--line-soft), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.filters {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 20px;
  border-block-end: 1px solid var(--line-soft);
}
.filters .field { gap: 4px; }
.filters .input, .filters .select { padding: 6px 10px; font-size: .85rem; }
.filters__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; }

.rec-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(12, 20, 19, .55);
  display: grid; place-items: center;
  color: #fff;
}
.rec-overlay__inner { display: grid; justify-items: center; gap: 14px; }

/* ── RTL niceties ────────────────────────────────────────────────────── */
[dir="rtl"] .chart text { direction: ltr; }
[dir="rtl"] .mono { direction: ltr; unicode-bidi: embed; }
[dir="rtl"] .prompt__text { line-height: 1.7; }

/* ── responsive ──────────────────────────────────────────────────────────
   Phone / tablet first: the dashboard tables become card lists, the sidebar
   becomes a drawer with a scrim, tap targets grow and form controls stay at
   16px so iOS never zooms into a focused field.
   ────────────────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }

/* records (the phone rendering of every dataTable) */
.record-list { display: none; }

@media (pointer: coarse), (max-width: 860px) {
  .btn { min-height: 40px; }
  .btn--sm { min-height: 34px; }
  .btn--sm:has(.ico:only-child) { min-width: 36px; }
  .nav-item { min-height: 44px; }
  /* < 16px makes iOS Safari zoom the whole page on focus */
  .input, .select, .textarea,
  .filters .input, .filters .select { font-size: 16px; }
  .check { min-height: 34px; }
  .check input { inline-size: 18px; block-size: 18px; }
}

@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .auth__panel { padding: 28px 20px; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: min(300px, 88vw);
    z-index: 100;
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
    overscroll-behavior: contain;
    padding-block-end: max(18px, env(safe-area-inset-bottom));
  }
  [dir="rtl"] .sidebar { transform: translateX(102%); }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { padding: 10px 14px; gap: 10px; }
  .content { padding: 16px; padding-block-end: max(16px, env(safe-area-inset-bottom)); }
  .menu-btn { display: inline-flex !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar__org { display: none; }
  .brand-chip { display: none; }
  .chart .chart__label { font-size: 11px; }
  .card__body { padding: 14px; }
  .card__head { padding: 12px 14px; }
  .card__head h2 { font-size: .95rem; }
  .pager { padding: 10px 14px; flex-wrap: wrap; justify-content: space-between; }
  body.is-drawer-open { overflow: hidden; }
}

/* data tables become stacked records */
@media (max-width: 720px) {
  .table-switch > .table-wrap { display: none; }
  .record-list { display: grid; gap: 10px; padding: 12px; }
  .record {
    display: grid; gap: 8px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .record__title { font-size: .95rem; }
  .record__body { display: grid; gap: 6px; }
  .record__row { display: grid; grid-template-columns: minmax(76px, 38%) 1fr; gap: 10px; align-items: baseline; }
  .record__label {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 700;
  }
  .record__value { font-size: .86rem; min-width: 0; overflow-wrap: anywhere; }
  .record__value .badge { font-size: .72rem; }
  .record__actions {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding-block-start: 8px;
    border-block-start: 1px solid var(--line-soft);
  }
  .record__actions .btn--ghost { border-color: var(--line); }
  .filters {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px; padding: 12px 14px;
  }
  .filters > .field:last-child { grid-column: 1 / -1; }
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat__value { font-size: 1.35rem; }
  .stat__label, .stat__hint { font-size: .72rem; }
  .form-grid { grid-template-columns: 1fr; }
  .trial-banner, .mock-banner { font-size: .82rem; padding: 10px 12px; }
}

/* phones */
@media (max-width: 560px) {
  .content { padding: 13px; padding-block-end: max(13px, env(safe-area-inset-bottom)); }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; margin-block-end: 14px; }
  .page-header__actions { width: 100%; }
  .page-header__actions .btn { flex: 1 1 auto; }
  .topbar__title { font-size: .95rem; }
  .topbar__user { display: none; }
  .topbar__avatar { display: grid; }
  .menu-btn, .topbar .btn--sm { min-width: 38px; min-height: 38px; }
  .prompt { padding: 18px; border-radius: var(--radius); }
  .prompt__text { font-size: clamp(1.2rem, 5.6vw, 1.7rem); }
  .prompt__text--word { font-size: clamp(1.7rem, 9vw, 2.3rem); }
  .mic { --size: 112px; }
  .item-row { flex-wrap: wrap; }
  .item-row__side {
    flex-direction: row; width: 100%; align-items: center;
    justify-content: space-between; flex-wrap: wrap;
  }
  .toasts { inset-inline: 12px; max-width: none; inset-block-end: max(12px, env(safe-area-inset-bottom)); }
  .brand-footer { padding: 14px 14px 18px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal--wide {
    width: 100%; max-height: 92dvh;
    border-start-start-radius: var(--radius-lg);
    border-start-end-radius: var(--radius-lg);
    border-end-start-radius: 0; border-end-end-radius: 0;
  }
  .modal__head { padding: 14px 16px 10px; }
  .modal__body { padding: 14px 16px; }
  .modal__foot {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .modal__foot .btn { flex: 1; }
  .grid-cards { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .record__row { grid-template-columns: 1fr; gap: 2px; }
  .record__label { font-size: .68rem; }
}

.menu-btn { display: none; }

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 99;
  background: rgba(12, 20, 19, .45);
  backdrop-filter: blur(1px);
  display: none;
}
.sidebar-scrim.is-open { display: block; }

@media print {
  .sidebar, .topbar, .filters { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
