/* =========================================================
   CBC Tasks — stylesheet (RTL, mobile-first, light & dark)
   ========================================================= */

:root {
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e8ecf4;
  --border: #e3e7ef;
  --border-strong: #cbd3e1;
  --text: #0e1726;
  --text-2: #4a5568;
  --text-3: #8490a5;

  --brand: #2350d8;
  --brand-btn: #2350d8;
  --brand-btn-hover: #1b40b6;
  --brand-soft: #ebf0ff;
  --brand-ink: #1b3da6;
  --ring: rgba(35, 80, 216, .18);

  --navy: #0e1a3d;
  --navy-2: #172552;
  --navy-text: #c9d3ee;

  --success: #0b9a6a;
  --success-btn: #0b9a6a;
  --success-soft: #e4f6ee;
  --success-ink: #067452;
  --warning: #c27400;
  --warning-soft: #fff2d9;
  --warning-ink: #8f5600;
  --danger: #d93545;
  --danger-btn: #d93545;
  --danger-soft: #fdebee;
  --danger-ink: #b02334;
  --info: #0b7fc4;
  --info-soft: #e2f2fc;
  --info-ink: #075c8f;

  --shadow-sm: 0 1px 2px rgba(14, 23, 38, .05);
  --shadow: 0 1px 3px rgba(14, 23, 38, .06), 0 6px 18px rgba(14, 23, 38, .05);
  --shadow-lg: 0 24px 60px rgba(10, 18, 40, .22);

  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 11px;
  --nav-h: 66px;
  --top-h: 58px;
  --backdrop: rgba(8, 13, 30, .52);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1e;
    --surface: #121a2e;
    --surface-2: #182239;
    --surface-3: #202b47;
    --border: #232e4a;
    --border-strong: #34415f;
    --text: #e8ecf5;
    --text-2: #a8b1c6;
    --text-3: #6f7b95;

    --brand: #6f8fff;
    --brand-btn: #3f63ea;
    --brand-btn-hover: #5073f0;
    --brand-soft: rgba(111, 143, 255, .14);
    --brand-ink: #aebfff;
    --ring: rgba(111, 143, 255, .32);

    --navy: #0c1429;
    --navy-2: #16213f;

    --success: #31c48f;
    --success-btn: #12875a;
    --success-soft: rgba(49, 196, 143, .13);
    --success-ink: #62d9ab;
    --warning: #f0a73a;
    --warning-soft: rgba(240, 167, 58, .14);
    --warning-ink: #f6c46f;
    --danger: #f2606e;
    --danger-btn: #cf3444;
    --danger-soft: rgba(242, 96, 110, .14);
    --danger-ink: #f78d97;
    --info: #3da9f0;
    --info-soft: rgba(61, 169, 240, .14);
    --info-ink: #7cc4f5;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
    --backdrop: rgba(2, 5, 14, .66);

    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
html.has-layer, html.has-layer body { overflow: hidden; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
h1 { font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -.2px; }
h2 { font-size: 16px; font-weight: 700; }
small { font-size: 12.5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--brand-soft); }

.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i.fill { fill: currentColor; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.grow { flex: 1; }
.print-only { display: none; }

.noscript { padding: 40px 20px; text-align: center; }

/* ---------- Boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 22px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--brand);
  animation: spin .75s linear infinite; display: inline-block;
}
.btn .spinner { width: 18px; height: 18px; border-color: rgba(255, 255, 255, .45); border-top-color: #fff; }
.btn-secondary .spinner, .btn-ghost .spinner, .btn-soft .spinner { border-color: var(--border-strong); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Brand mark ---------- */
.mark {
  --m: 38px;
  width: var(--m); height: var(--m); flex: none;
  display: inline-grid; place-items: center;
  border-radius: calc(var(--m) * .3);
  background: linear-gradient(140deg, #3d6dff 0%, #2350d8 45%, #16318f 100%);
  color: #fff; font-weight: 700; letter-spacing: .4px;
  font-size: calc(var(--m) * .32); line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 6px 16px rgba(35, 80, 216, .28);
  font-family: var(--font);
}
.mark-sm { --m: 32px; }
.mark-lg { --m: 64px; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.content { min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
  }
}
.topbar.scrolled { border-bottom-color: var(--border); }
.tb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-brand b { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-brand small { display: block; color: var(--text-3); font-size: 11.5px; line-height: 1.2; }
.tb-user { display: inline-flex; border-radius: 50%; }

.main {
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 8px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}

.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(14, 23, 38, .04);
}
.bottom-nav a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11.5px; font-weight: 600;
}
.bottom-nav a .i { width: 23px; height: 23px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.active::before {
  content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand);
}
.nav-badge {
  position: absolute; top: 8px; inset-inline-start: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger-btn); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
  border: 2px solid var(--surface);
}

.fab {
  position: fixed; z-index: 44;
  inset-inline-end: 18px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 18px; border: 0;
  display: grid; place-items: center;
  background: var(--brand-btn); color: #fff;
  box-shadow: 0 10px 26px rgba(35, 80, 216, .38), 0 2px 6px rgba(35, 80, 216, .25);
  transition: transform .15s, background .15s;
}
.fab .i { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:active { transform: scale(.95); }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 6px;
    padding: 22px 16px 18px;
    background: var(--navy); color: #fff;
    background-image: radial-gradient(120% 60% at 100% 0%, rgba(61, 109, 255, .22), transparent 60%);
  }
  .sb-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
  .sb-brand b { display: block; font-size: 17px; }
  .sb-brand small { color: var(--navy-text); opacity: .8; font-size: 12px; }
  .sb-nav { display: grid; gap: 4px; }
  .sb-nav a {
    display: flex; align-items: center; gap: 12px;
    height: 46px; padding: 0 14px; border-radius: 12px;
    color: var(--navy-text); font-weight: 600; font-size: 14.5px;
    transition: background .15s, color .15s;
  }
  .sb-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .sb-nav a { position: relative; }
  .sb-nav a.active { background: rgba(255, 255, 255, .1); color: #fff; }
  .sb-nav a.active::before { content: ''; position: absolute; inset-inline-start: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: #6f8fff; }
  .sb-nav .nav-badge { position: static; margin-inline-start: auto; border: 0; }
  .sb-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
  .sb-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: #fff; min-width: 0; }
  .sb-user:hover { background: rgba(255, 255, 255, .06); }
  .sb-user b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sb-user small { display: block; color: var(--navy-text); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sb-user > div { min-width: 0; }
  .sb-logout {
    display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px;
    border: 0; border-radius: 12px; background: transparent; color: var(--navy-text); font-weight: 600; font-size: 14px;
  }
  .sb-logout:hover { background: rgba(242, 96, 110, .14); color: #ffb3ba; }
  .topbar, .bottom-nav, .fab { display: none; }
  .main { padding: 30px 36px 56px; }
  .hide-desktop { display: none !important; }
}
@media (max-width: 959.98px) {
  .hide-mobile { display: none !important; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 2px; font-size: 14px; }
.page-head .eyebrow { color: var(--text-3); font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 960px) { h1 { font-size: 26px; } .page-head { margin: 0 0 24px; } }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.back-link:hover { color: var(--brand); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 2px 12px; }
.section-title h2 { display: flex; align-items: center; gap: 8px; }
.link { font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 14.5px; line-height: 1; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .06s;
  -webkit-user-select: none; user-select: none; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn .i { width: 19px; height: 19px; }
.btn-primary { background: var(--brand-btn); color: #fff; box-shadow: 0 1px 2px rgba(35, 80, 216, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--brand-btn-hover); }
.btn-success { background: var(--success-btn); color: #fff; }
.btn-success:hover { filter: brightness(1.05); }
.btn-danger { background: var(--danger-btn); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover { filter: brightness(.98); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-lg { height: 52px; font-size: 16px; border-radius: 14px; padding: 0 22px; }
.btn-sm { height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.busy { opacity: .6; pointer-events: none; }
.text-danger { color: var(--danger) !important; }

.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[disabled] { opacity: .35; pointer-events: none; }
.icon-btn.bordered { border: 1px solid var(--border-strong); background: var(--surface); width: 44px; height: 44px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span, .field-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field em { color: var(--danger); font-style: normal; }
.hint { color: var(--text-3); font-size: 12.5px; line-height: 1.5; }
.row-2 { display: grid; gap: 16px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }

.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 16px; /* prevents iOS zoom on focus */
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { height: auto; min-height: 110px; padding: 12px 14px; line-height: 1.7; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.input[type="datetime-local"] { direction: ltr; text-align: right; }
.select {
  padding-inline-start: 14px; padding-inline-end: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238490a5' 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-size: 18px; background-position: left 14px center;
}
.input-sm { height: 40px; font-size: 15px; }

.pw { position: relative; }
/* Password inputs are LTR: text starts on the left, the eye toggle sits on the right. */
.pw.has-toggle .input { padding-right: 50px; }
.pw .pw-toggle { position: absolute; right: 3px; top: 3px; }
.pw-row { display: flex; gap: 8px; }
.pw-row .pw { flex: 1; }

.form-error {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 11px 14px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger-ink); font-size: 14px; font-weight: 500;
}
.form-error .i { width: 18px; height: 18px; margin-top: 2px; }

/* Switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; cursor: pointer; }
.switch-row b { display: block; font-size: 14.5px; font-weight: 600; }
.switch-row small { display: block; color: var(--text-3); }
.switch {
  -webkit-appearance: none; appearance: none; flex: none;
  position: relative; width: 50px; height: 30px; margin: 0; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer;
  transition: background .2s, border-color .2s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch:checked { background: var(--success-btn); border-color: var(--success-btn); }
.switch:checked::after { transform: translateX(-20px); }
[dir="ltr"] .switch:checked::after { transform: translateX(20px); }

/* Segmented control */
.seg { display: inline-flex; gap: 3px; padding: 4px; border-radius: 13px; background: var(--surface-3); max-width: 100%; }
.seg > button, .seg > label > span {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s; cursor: pointer;
}
.seg > button.active, .seg > label > input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg > label { display: contents; }
.seg > label > input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.seg > label > input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
.seg-block { display: flex; width: 100%; }
.seg-block > button, .seg-block > label > span { flex: 1; }
.seg .count { font-size: 12px; color: var(--text-3); font-weight: 600; }
.seg .active .count { color: var(--brand); }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 6px; scroll-padding: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 12px;
  background: var(--surface-2); color: var(--text-2);
}
.chip.active .count { background: rgba(255, 255, 255, .18); color: inherit; }
.chip .count:empty, .seg .count:empty { display: none; }
.chip.tone-danger .count:not(:empty) { background: var(--danger-soft); color: var(--danger-ink); }
.chip.active.tone-danger .count { background: rgba(255, 255, 255, .18); color: inherit; }
.chip-sm { height: 34px; padding: 0 13px; font-size: 13.5px; }
@media (min-width: 960px) { .chips { margin: 0; padding: 2px 0 6px; flex-wrap: wrap; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-head h2 { display: flex; align-items: center; gap: 9px; font-size: 15.5px; }
.card-head h2 .i { color: var(--text-3); width: 19px; height: 19px; }
.card-body { padding: 14px 18px 18px; }
.account-wrap > .card + .card { margin-top: 14px; }

.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 960px) { .grid-2 { grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; } .stack { gap: 18px; } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (min-width: 960px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; } }
.kpi {
  display: grid; gap: 12px; padding: 16px; color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi-icon .i { width: 21px; height: 21px; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.kpi-label { color: var(--text-2); font-size: 13.5px; font-weight: 500; margin-top: 6px; }
.kpi.tone-danger .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.kpi.tone-danger.has-value .kpi-value { color: var(--danger); }
.kpi.tone-success .kpi-icon { background: var(--success-soft); color: var(--success); }
.kpi.tone-warning .kpi-icon { background: var(--warning-soft); color: var(--warning); }
@media (min-width: 960px) { .kpi { padding: 20px; } .kpi-value { font-size: 34px; } }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--surface-2); color: var(--text-2);
}
.pill .i { width: 13px; height: 13px; stroke-width: 2.4; }
.pill-brand { background: var(--brand-soft); color: var(--brand-ink); }
.pill-success { background: var(--success-soft); color: var(--success-ink); }
.pill-warning { background: var(--warning-soft); color: var(--warning-ink); }
.pill-danger { background: var(--danger-soft); color: var(--danger-ink); }
.pill-info { background: var(--info-soft); color: var(--info-ink); }
.pill-neutral { background: var(--surface-2); color: var(--text-2); }
.pill-solid-brand { background: var(--brand-btn); color: #fff; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }

.tone-success { --tone: var(--success); }
.tone-brand { --tone: var(--brand); }
.tone-info { --tone: var(--info); }
.tone-warning { --tone: var(--warning); }
.tone-danger { --tone: var(--danger); }
.tone-neutral { --tone: var(--text-3); }
.tone-text { color: var(--tone); }

/* ---------- Avatar ---------- */
.avatar {
  --sz: 40px;
  width: var(--sz); height: var(--sz); flex: none;
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--av); color: #fff;
  font-weight: 700; font-size: calc(var(--sz) * .4); line-height: 1;
  -webkit-user-select: none; user-select: none;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .avatar { background: color-mix(in srgb, var(--av) 15%, var(--surface)); color: var(--av); }
  @media (prefers-color-scheme: dark) {
    .avatar { background: color-mix(in srgb, var(--av) 26%, var(--surface)); color: color-mix(in srgb, var(--av) 55%, #fff); }
  }
}

/* ---------- Task cards ---------- */
.task-list { display: grid; gap: 10px; }
.task {
  position: relative; display: flex; align-items: flex-start; gap: 13px;
  padding: 14px 14px 14px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, opacity .2s, transform .2s;
}
.task:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.task::before { content: ''; position: absolute; inset-inline-start: -1px; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.task.pr-urgent::before { background: var(--danger); }
.task.pr-high::before { background: var(--warning); }
.task.is-done::before { background: transparent; }
.task.st-overdue { border-color: color-mix(in srgb, var(--danger) 28%, var(--border)); }
.task.is-new { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); box-shadow: 0 0 0 3px var(--ring); }

.task-check {
  position: relative; flex: none; width: 28px; height: 28px; margin-top: 1px;
  display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface); color: transparent;
  transition: background .18s, border-color .18s, color .18s, transform .18s;
}
.task-check::after { content: ''; position: absolute; inset: -9px; }
.task-check .i { width: 16px; height: 16px; stroke-width: 3; }
.task-check:hover { border-color: var(--success); color: color-mix(in srgb, var(--success) 45%, transparent); }
.task.is-done .task-check { background: var(--success-btn); border-color: var(--success-btn); color: #fff; }
.task-check.pop { animation: pop .35s ease; }
.task-check[disabled] { cursor: default; }
@keyframes pop { 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

.task-main { flex: 1; min-width: 0; }
.task-top { display: flex; align-items: flex-start; gap: 8px; }
.task-title { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.task.is-done .task-title { color: var(--text-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.task-top .pills { flex: none; }
.task-desc {
  margin-top: 3px; color: var(--text-2); font-size: 13.5px; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.task.is-done .task-desc { display: none; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 9px; font-size: 12.5px; color: var(--text-2); }
.meta { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.meta .i { width: 15px; height: 15px; }
.meta .avatar { --sz: 20px; font-size: 9px; }
.due-overdue { color: var(--danger); font-weight: 600; }
.due-soon { color: var(--warning); font-weight: 600; }
.due-done { color: var(--success); font-weight: 600; }
.due-done_late { color: var(--warning); font-weight: 600; }
.task-thumb { width: 54px; height: 54px; flex: none; border-radius: 10px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }

.group-title {
  display: flex; align-items: center; gap: 8px;
  margin: 20px 4px 10px; font-size: 13px; font-weight: 700; color: var(--text-2);
}
.group-title:first-child { margin-top: 4px; }
.group-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--text-3)); }
.group-title .count { color: var(--text-3); font-weight: 600; }

/* Compact rows (dashboard lists) */
.rows { display: grid; }
.trow {
  display: flex; align-items: center; gap: 12px; padding: 11px 18px;
  border-top: 1px solid var(--border); cursor: pointer; color: var(--text); min-width: 0;
  transition: background .15s;
}
.rows > .trow:first-child { border-top: 0; }
.trow:hover { background: var(--surface-2); }
.trow-main { flex: 1; min-width: 0; }
.trow-main b { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow-main small { display: block; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow > .i { color: var(--text-3); width: 18px; height: 18px; }
.card .rows { padding: 6px 0 8px; }
.card .rows .trow { padding-inline: 18px; }

/* ---------- Stars ---------- */
.stars { display: inline-flex; gap: 1px; color: #f5b301; }
.stars .i { width: 14px; height: 14px; }
.stars .off { color: var(--border-strong); }
.stars-input { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.star-btn {
  width: 40px; height: 40px; border: 0; background: transparent; border-radius: 10px;
  display: grid; place-items: center; color: var(--border-strong); transition: color .12s, transform .12s;
}
.star-btn .i { width: 28px; height: 28px; stroke-width: 1.6; }
.star-btn.on { color: #f5b301; }
.star-btn.on .i { fill: currentColor; }
.star-btn:hover { transform: scale(1.1); }
.stars-caption { margin-inline-start: 8px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.stars-input.compact { flex: none; flex-wrap: nowrap; gap: 0; }
.stars-input.compact .star-btn { width: 30px; height: 30px; }
.stars-input.compact .star-btn .i { width: 21px; height: 21px; }

/* ---------- Task detail ---------- */
.detail { display: grid; gap: 16px; }
.detail-title { font-size: 20px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.detail-desc { padding: 2px 0; }
.detail-desc a { text-decoration: underline; word-break: break-all; }

/* Structured descriptions (see richText in core.js) */
.rich { display: grid; gap: 12px; font-size: 15px; line-height: 1.85; color: var(--text); overflow-wrap: anywhere; }
.rich-p { margin: 0; }
.rich-p b { font-weight: 700; }
.rich-h { display: flex; align-items: center; gap: 8px; margin: 8px 0 -2px; font-size: 15.5px; font-weight: 700; line-height: 1.5; }
.rich-h::before { content: ''; flex: none; width: 4px; height: 17px; border-radius: 4px; background: var(--brand); }
.rich > .rich-h:first-child { margin-top: 0; }
.rich-sub { margin: 2px 0 -4px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.rich-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.rich-list li { position: relative; padding-inline-start: 18px; line-height: 1.75; }
.rich-list li::before { content: ''; position: absolute; inset-inline-start: 3px; top: .72em; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.rich-step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.rich-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 13px; line-height: 1; margin-top: 1px; }
.rich-step-body { display: grid; gap: 8px; min-width: 0; }
.rich-step-title { line-height: 1.75; }
.rich-step.has-body .rich-step-title { font-weight: 700; }
.rich-code {
  margin: 0; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  direction: ltr; text-align: left; unicode-bidi: isolate;
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.65;
  white-space: pre; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.rich-quote { margin: 0; padding: 10px 14px; border-radius: 12px; border-inline-start: 3px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); font-size: 14px; line-height: 1.8; white-space: pre-wrap; }
.rich-tag { display: inline-block; margin-inline-end: 2px; padding: 0 7px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-ink); font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; font-weight: 700; line-height: 1.8; vertical-align: 1px; unicode-bidi: isolate; }
.detail-image { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.detail-image img { width: 100%; max-height: 340px; object-fit: contain; }
.facts { display: grid; gap: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.facts > div { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--border); }
.facts > div:first-child { border-top: 0; }
.facts dt { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.facts dt .i { width: 17px; height: 17px; color: var(--text-3); }
.facts dd { text-align: end; font-weight: 600; font-size: 14px; min-width: 0; }
.facts dd small { display: block; font-weight: 500; color: var(--text-3); }
.facts dd .ok { color: var(--success); display: inline-flex; align-items: center; gap: 4px; }
.facts dd small.due-overdue { color: var(--danger); }
.facts dd small.due-soon, .facts dd small.due-done_late { color: var(--warning); }
.facts dd small.due-done { color: var(--success); }
.facts dd .ok .i { width: 16px; height: 16px; }

.callout { display: flex; gap: 10px; padding: 13px 14px; border-radius: 14px; background: var(--info-soft); color: var(--info-ink); font-size: 14px; line-height: 1.7; }
.callout .i { margin-top: 3px; width: 18px; height: 18px; }
.callout b { display: block; }
.callout.tone-warning { background: var(--warning-soft); color: var(--warning-ink); }
.callout.tone-success { background: var(--success-soft); color: var(--success-ink); }
.callout.tone-brand { background: var(--brand-soft); color: var(--brand-ink); }
.callout p { white-space: pre-wrap; color: var(--text); }

.review-box { display: grid; gap: 10px; padding: 16px; border-radius: 16px; border: 1px dashed var(--border-strong); background: var(--surface-2); }
.review-box h4 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.review-box h4 .i { color: #f5b301; }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.review-box .textarea { min-height: 70px; background: var(--surface); }
.review-actions { display: flex; justify-content: flex-end; }

/* ---------- Task form ---------- */
.assignees { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; }
.assignee { display: block; cursor: pointer; }
.assignee input { position: absolute; opacity: 0; pointer-events: none; }
.assignee-box {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; min-width: 0;
  border: 1.5px solid var(--border); border-radius: 13px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.assignee-text { flex: 1; min-width: 0; line-height: 1.35; }
.assignee-text b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assignee-text small { display: block; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assignee-check { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: transparent; }
.assignee-check .i { width: 14px; height: 14px; stroke-width: 3; }
.assignee input:checked + .assignee-box { border-color: var(--brand); background: var(--brand-soft); }
.assignee input:checked + .assignee-box .assignee-check { background: var(--brand-btn); border-color: var(--brand-btn); color: #fff; }
.assignee input:focus-visible + .assignee-box { box-shadow: 0 0 0 4px var(--ring); }

.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-dates .chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }

.image-drop {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 16px;
  border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2);
  color: var(--text-2); text-align: start; transition: border-color .15s, background .15s;
}
.image-drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.image-drop .i { width: 26px; height: 26px; color: var(--brand); }
.image-drop b { display: block; color: var(--text); font-weight: 600; }
.image-drop small { display: block; color: var(--text-3); }
.image-preview { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.image-preview img { width: 100%; max-height: 240px; object-fit: contain; }
.image-preview .image-remove { position: absolute; top: 8px; inset-inline-end: 8px; background: rgba(10, 15, 30, .65); color: #fff; }
.image-preview .image-remove:hover { background: rgba(217, 53, 69, .9); color: #fff; }
.image-busy { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--text-2); }

/* ---------- Sheets / dialogs ---------- */
.layer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.layer-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity .25s; }
.layer.open .layer-backdrop { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .85, .25, 1);
}
.layer.open .sheet { transform: none; }
.sheet::before { content: ''; flex: none; width: 42px; height: 5px; border-radius: 5px; background: var(--border-strong); margin: 9px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px 8px 18px; }
[dir="rtl"] .sheet-head { padding: 6px 18px 8px 12px; }
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 18px 20px; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.sheet-foot .btn { min-width: 0; }
@media (min-width: 720px) {
  .layer { align-items: center; padding: 28px; }
  .sheet {
    max-width: 580px; max-height: min(88vh, 920px); border-radius: 22px;
    opacity: 0; transform: translateY(14px) scale(.985); transition: transform .22s ease, opacity .22s ease;
  }
  .sheet.sheet-sm { max-width: 440px; }
  .sheet.sheet-wide { max-width: 720px; }
  .layer.open .sheet { opacity: 1; transform: none; }
  .sheet::before { display: none; }
  .sheet-head { padding-top: 16px; }
  .sheet-foot { padding-bottom: 14px; border-radius: 0 0 22px 22px; }
}
.confirm-msg { color: var(--text-2); font-size: 15px; line-height: 1.8; white-space: pre-line; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: rgba(4, 7, 16, .92); opacity: 0; transition: opacity .2s; padding: 56px 12px 76px; }
.lightbox.open { opacity: 1; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox-bar { position: absolute; inset-inline: 0; top: 0; display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
.lightbox .icon-btn { color: #fff; background: rgba(255, 255, 255, .12); }
.lightbox .btn { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 150; inset-inline: 0; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  display: grid; justify-items: center; gap: 8px; padding: 0 14px; pointer-events: none;
}
html.has-layer .toasts { bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { .toasts { bottom: 24px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  width: min(460px, 100%); padding: 12px 12px 12px 16px; border-radius: 14px;
  background: #121a2e; color: #fff; box-shadow: var(--shadow-lg); font-size: 14.5px; font-weight: 500;
  transform: translateY(14px); opacity: 0; transition: transform .25s, opacity .25s;
}
[dir="rtl"] .toast { padding: 12px 16px 12px 12px; }
@media (prefers-color-scheme: dark) { .toast { background: #26324f; } }
.toast.show { transform: none; opacity: 1; }
.toast-icon { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .12); }
.toast-icon .i { width: 16px; height: 16px; stroke-width: 2.6; }
.toast-success .toast-icon { background: #0b9a6a; }
.toast-error .toast-icon { background: #d93545; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action { flex: none; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; font-size: 13.5px; height: 34px; padding: 0 12px; border-radius: 10px; }
.toast-action:hover { background: rgba(255, 255, 255, .22); }

/* ---------- Empty / error / skeleton ---------- */
.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 20px; text-align: center; }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); margin-bottom: 4px; }
.empty-icon .i { width: 28px; height: 28px; }
.empty-icon.tone-success { background: var(--success-soft); color: var(--success); }
.empty h3 { font-size: 16px; font-weight: 700; }
.empty p { color: var(--text-2); font-size: 14px; max-width: 360px; }
.empty .btn { margin-top: 8px; }
.card .empty { padding: 26px 18px; }

.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 10px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skel-task { height: 86px; border-radius: var(--radius-md); }
.skel-line { height: 14px; margin: 10px 0; }
.skel-card { height: 110px; border-radius: var(--radius); }

/* ---------- Toolbar / search ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 220px; }
.search .i { position: absolute; top: 50%; inset-inline-start: 14px; transform: translateY(-50%); color: var(--text-3); width: 19px; height: 19px; pointer-events: none; }
.search .input { padding-inline-start: 44px; }
.toolbar .select { flex: 1 1 180px; width: auto; }
@media (min-width: 960px) { .toolbar .select { flex: 0 0 240px; } }
.input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; gap: 14px; }
@media (min-width: 960px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; } }
.onboard { display: grid; gap: 14px; padding: 22px; margin-bottom: 14px; background: linear-gradient(135deg, var(--brand-soft), var(--surface)); }
.onboard h2 { font-size: 18px; }
.onboard p { color: var(--text-2); }
.steps { display: grid; gap: 10px; counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.steps li::before { counter-increment: s; content: counter(s); width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--brand-btn); color: #fff; font-weight: 700; font-size: 13px; }
.steps li.done::before { content: '✓'; background: var(--success-btn); }

.lrow { display: flex; align-items: center; gap: 12px; padding: 10px 18px; color: var(--text); border-top: 1px solid var(--border); transition: background .15s; }
.rows > .lrow:first-child { border-top: 0; }
.lrow:hover { background: var(--surface-2); }
.lrow-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.lrow-main b { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow-score { font-size: 18px; font-weight: 700; min-width: 34px; text-align: center; color: var(--tone, var(--text-3)); }
.rank { width: 24px; flex: none; text-align: center; font-weight: 700; color: var(--text-3); font-size: 14px; }
.rank-1 { color: #d49b00; } .rank-2 { color: #8a97ad; } .rank-3 { color: #b8743d; }

/* Progress bars */
.bar { position: relative; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: inherit; background: var(--tone, var(--brand)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar-sm { height: 6px; }

/* ---------- Greeting (employee) ---------- */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 8px 0 16px; }
.hello-sub { color: var(--text-3); font-weight: 500; font-size: 14px; }
.hello p.role { color: var(--text-2); font-size: 14px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.mini-stats.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .mini-stats.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mini { padding: 13px 14px; display: grid; gap: 2px; color: var(--text); }
.mini b { font-size: 24px; font-weight: 700; line-height: 1.2; color: var(--tone, var(--text)); }
.mini span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
a.mini:hover { border-color: var(--border-strong); }
.tabs { margin-bottom: 14px; }

/* ---------- People ---------- */
.people { display: grid; gap: 12px; }
@media (min-width: 720px) { .people { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .people { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.person { display: grid; gap: 14px; padding: 16px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.person:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.person.inactive { opacity: .65; }
.person-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-info { flex: 1; min-width: 0; }
.person-info b { display: flex; align-items: center; gap: 6px; font-size: 15.5px; font-weight: 700; }
.person-info b span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-info small { display: block; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.person-score { text-align: center; flex: none; }
.person-score b { display: block; font-size: 22px; line-height: 1; color: var(--tone, var(--text-3)); }
.person-score small { color: var(--text-3); font-size: 11px; }
.person-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.person-stats > div { background: var(--surface-2); border-radius: 11px; padding: 8px 10px; text-align: center; }
.person-stats b { display: block; font-size: 17px; line-height: 1.3; }
.person-stats span { font-size: 11.5px; color: var(--text-2); }
.person-stats .danger b { color: var(--danger); }

.profile { padding: 20px; display: grid; gap: 18px; }
.profile-top { display: flex; align-items: center; gap: 16px; }
.profile-top h1 { font-size: 21px; }
.profile-top p { color: var(--text-2); }
.profile-top .pills { margin-top: 8px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-actions .btn { flex: 1 1 auto; }
@media (min-width: 720px) { .profile-actions .btn { flex: 0 0 auto; } }
.profile-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.profile-facts > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.profile-facts dt { font-size: 12px; color: var(--text-3); font-weight: 500; }
.profile-facts dd { font-weight: 600; font-size: 14px; }

.perf { display: grid; gap: 20px; align-items: center; }
@media (min-width: 720px) { .perf { grid-template-columns: auto 1fr; gap: 28px; } }
.perf-score { display: grid; justify-items: center; gap: 8px; text-align: center; }
.perf-score .pill { height: 28px; font-size: 13px; padding: 0 12px; }
.perf-score p { color: var(--text-2); font-size: 13px; max-width: 220px; }

/* Score ring */
.ring { --sz: 120px; position: relative; width: var(--sz); height: var(--sz); color: var(--tone, var(--text-3)); }
.ring svg { width: 100%; height: 100%; display: block; }
.ring-bg { fill: none; stroke: var(--surface-3); }
.ring-fg { fill: none; stroke: currentColor; stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.ring-val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-val b { font-size: calc(var(--sz) * .3); line-height: 1; color: var(--text); letter-spacing: -1px; }
.ring-val small { color: var(--text-3); font-size: 11.5px; margin-top: 2px; }

/* Criteria */
.crit-list { display: grid; gap: 14px; }
.crit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.crit-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.crit-label .i { width: 18px; height: 18px; color: var(--tone, var(--text-3)); }
.crit-head b { font-size: 15px; }
.crit small { display: block; margin-top: 5px; color: var(--text-3); font-size: 12.5px; }
.crit-grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .crit-grid { grid-template-columns: 1fr 1fr; } }
.crit-card { padding: 16px; }
.crit-card .crit-head b { font-size: 20px; }

/* ---------- Reports ---------- */
.period { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.period-nav { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 3px; }
.period-label { min-width: 160px; text-align: center; line-height: 1.3; padding: 0 6px; }
.period-label b { display: block; font-size: 14.5px; }
.period-label small { color: var(--text-3); font-size: 11.5px; }
@media (max-width: 559.98px) { .period > .seg, .period-nav { width: 100%; } .period > .seg > button { flex: 1; } .period-label { flex: 1; } }

.team-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (min-width: 960px) { .team-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.tile { padding: 14px 16px; display: grid; gap: 4px; }
.tile span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.tile b { font-size: 26px; line-height: 1.15; color: var(--tone, var(--text)); }
.tile small { color: var(--text-3); }

.board { display: grid; gap: 10px; }
.lb {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 14px 16px; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.lb:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.lb-who { min-width: 0; }
.lb-who b { display: block; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-who small { display: block; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { display: grid; justify-items: center; gap: 4px; grid-column: 4; grid-row: 1; }
.lb-score b { font-size: 24px; line-height: 1; color: var(--tone, var(--text-3)); }
.lb-crit { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.lb-counts { grid-column: 1 / -1; grid-row: 3; display: flex; flex-wrap: wrap; gap: 6px; }
.mbar { display: grid; gap: 4px; min-width: 0; }
.mbar-head { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--text-2); }
.mbar-head span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mbar-head b { color: var(--text); font-weight: 600; }
@media (min-width: 1100px) {
  .lb { grid-template-columns: 30px 44px minmax(160px, 1.1fr) minmax(0, 2.4fr) 90px; }
  .lb-crit { grid-column: 4; grid-row: 1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lb-counts { display: none; }
  .lb-score { grid-column: 5; grid-row: 1; }
}

.method { padding: 0; }
.method summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; cursor: pointer; font-weight: 700; }
.method summary::-webkit-details-marker { display: none; }
.method summary .chev { transition: transform .2s; color: var(--text-3); }
.method[open] summary .chev { transform: rotate(180deg); }
.method .card-body { padding-top: 0; display: grid; gap: 14px; }
.method-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.method-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.method-list li .i { color: var(--brand); margin-top: 3px; }
.method-list b { display: block; font-size: 14px; }
.method-list small { color: var(--text-2); font-size: 13px; }
.grades { display: flex; flex-wrap: wrap; gap: 6px; }
.policy { font-size: 13.5px; color: var(--text-2); line-height: 1.9; }

.report-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.report-head h1 { font-size: 21px; }
.report-head p { color: var(--text-2); }

.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .counts { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.counts > div { padding: 12px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.counts b { display: block; font-size: 20px; line-height: 1.3; color: var(--tone, var(--text)); }
.counts span { font-size: 12px; color: var(--text-2); }

/* Report table (desktop + print) */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--text-2); font-weight: 600; font-size: 12.5px; background: var(--surface-2); }
.table td.num, .table th.num { text-align: center; }

/* ---------- Settings: evaluation weights ---------- */
.form-section { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; padding-top: 16px; margin-top: 2px; border-top: 1px solid var(--border); }
.form-section .i { color: var(--brand); width: 19px; height: 19px; }
.weights { display: grid; gap: 8px; }
@media (min-width: 560px) { .weights { grid-template-columns: 1fr 1fr; } }
.weight { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: text; }
[dir="rtl"] .weight { padding: 8px 12px 8px 8px; }
.weight-label { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.4; }
.weight-label .i { width: 18px; height: 18px; color: var(--brand); }
.weight-input { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.weight-input .input { width: 70px; height: 40px; padding: 0 6px; text-align: center; font-weight: 700; }
.weight-input b { color: var(--text-3); font-weight: 600; }
.weights-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.weight-sum { font-weight: 600; font-size: 13px; }
.weight-sum.ok { color: var(--success); }
.weight-sum.bad { color: var(--danger); }
.crit-weight { margin-inline-start: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); font-size: 11.5px; font-weight: 600; white-space: nowrap; }

/* ---------- Account ---------- */
.profile-mini { display: flex; align-items: center; gap: 14px; padding: 18px; }
.profile-mini b { display: block; font-size: 16px; }
.profile-mini small { display: block; color: var(--text-2); }
.app-version { text-align: center; color: var(--text-3); font-size: 12.5px; margin: 20px 0 6px; }
.account-wrap { max-width: 640px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; background: var(--bg); }
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  padding: calc(28px + env(safe-area-inset-top)) 22px 64px;
  background: linear-gradient(150deg, #1d3fb4 0%, #10245f 55%, #0b1638 100%);
}
.auth-hero::after {
  content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  inset-inline-end: -160px; top: -200px; background: radial-gradient(circle, rgba(111, 143, 255, .45), transparent 65%);
}
.auth-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.auth-brand b { font-size: 19px; }
.auth-brand small { display: block; opacity: .75; font-size: 12.5px; }
.auth-hero h2 { position: relative; z-index: 1; margin-top: 26px; font-size: 24px; line-height: 1.45; font-weight: 700; }
.auth-hero p { position: relative; z-index: 1; margin-top: 8px; opacity: .8; font-size: 14.5px; }
.hero-points { position: relative; z-index: 1; display: none; gap: 14px; margin: 34px 0 0; padding: 0; list-style: none; }
.hero-points li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.hero-points .i { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: rgba(255, 255, 255, .12); }
.auth-main { display: flex; flex-direction: column; align-items: center; padding: 0 16px 30px; margin-top: -40px; position: relative; z-index: 2; }
.auth-card { width: 100%; max-width: 430px; padding: 26px 22px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 22px; }
.auth-card .sub { color: var(--text-2); margin-top: -8px; font-size: 14.5px; }
.auth-foot { margin-top: 22px; color: var(--text-3); font-size: 12.5px; text-align: center; }
@media (min-width: 960px) {
  .auth { grid-template-columns: minmax(380px, 46%) 1fr; }
  .auth-hero { display: flex; flex-direction: column; padding: 48px 56px; }
  .auth-hero h2 { margin-top: auto; font-size: 34px; }
  .auth-hero p { font-size: 16px; max-width: 460px; }
  .hero-points { display: grid; margin-bottom: auto; }
  .auth-main { justify-content: center; margin-top: 0; padding: 40px; }
  .auth-card { padding: 34px 32px; box-shadow: var(--shadow); }
}

.fatal { min-height: 100vh; display: grid; place-content: center; padding: 24px; }
.fatal .card { max-width: 480px; padding: 28px; text-align: center; display: grid; gap: 12px; justify-items: center; }

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

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #f3f5f9; --surface-3: #e6eaf1;
    --border: #d8dde7; --border-strong: #c3cad8; --text: #0b1220; --text-2: #3a4353; --text-3: #6b7486;
    color-scheme: light;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; font-size: 12.5px; }
  .sidebar, .topbar, .bottom-nav, .fab, .toasts, .layer, .lightbox, .no-print, .period-nav button { display: none !important; }
  .shell { display: block; }
  .main { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-only { display: block !important; }
  .screen-only { display: none !important; }
  a { color: inherit; }
  .print-head { display: flex !important; align-items: center; justify-content: space-between; border-bottom: 2px solid #0b1220; padding-bottom: 10px; margin-bottom: 16px; }
  .print-head h1 { font-size: 18px; }
  .print-head small { color: #555; }
  .print-foot { display: grid !important; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; break-inside: avoid; }
  .print-foot div { display: grid; gap: 30px; font-size: 12px; font-weight: 600; }
  .print-foot i { display: block; border-bottom: 1px solid #0b1220; }
  .table { font-size: 11.5px; }
  .table th, .table td { padding: 6px 8px; }
}
