/* Basqat Al-Qassim — unified reporting system */
:root {
  --deep: #0b3b24;
  --green: #076b37;
  --green-2: #0d8243;
  --leaf: #3bb34a;
  --g50: #f2f7f3;
  --g100: #e3efe6;
  --g200: #c8dfcf;
  --gold: #c9a227;
  --gold-d: #8a6d12;
  --gold-l: #f8f0d8;
  --cream: #fbf8f0;
  --ink: #17251d;
  --ink-2: #3c4b42;
  --muted: #6b7a71;
  --line: #dde5df;
  --line-2: #c6d2ca;
  --bg: #f4f6f2;
  --card: #ffffff;
  --ok: #1f7a3a;
  --ok-l: #e2f2e6;
  --warn: #a35f00;
  --warn-l: #fff0d6;
  --bad: #b3261e;
  --bad-l: #fbe5e2;
  --info: #1e5ba8;
  --info-l: #e3edf9;
  --r: 14px;
  --r-s: 9px;
  --shadow: 0 1px 2px rgba(11, 59, 36, .06), 0 6px 22px rgba(11, 59, 36, .07);
  --shadow-h: 0 2px 4px rgba(11, 59, 36, .08), 0 14px 34px rgba(11, 59, 36, .13);
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --side: 268px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
.ic { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(201, 162, 39, .55); outline-offset: 2px; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 11px; border: 1px solid transparent; background: var(--g100); color: var(--green); font-weight: 600; cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--g200); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--green-2), var(--green)); color: #fff; box-shadow: 0 6px 16px rgba(7, 107, 55, .25); }
.btn.primary:hover { box-shadow: 0 8px 22px rgba(7, 107, 55, .34); }
.btn.gold { background: linear-gradient(180deg, #d9b23a, var(--gold)); color: #2b2205; box-shadow: 0 6px 16px rgba(201, 162, 39, .28); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn.ghost:hover { background: var(--g50); }
.btn.danger { background: var(--bad-l); color: var(--bad); }
.btn.danger:hover { background: #f7d2cd; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }

/* ---------------------------------------------------------------- chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--g100); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-l); color: var(--ok); }
.chip.warn { background: var(--warn-l); color: var(--warn); }
.chip.bad { background: var(--bad-l); color: var(--bad); }
.chip.info { background: var(--info-l); color: var(--info); }
.chip.muted { background: #eef1ee; color: var(--muted); }
.chip.gold { background: var(--gold-l); color: var(--gold-d); }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--cream); }
.login-brand { position: relative; overflow: hidden; color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 110% -10%, rgba(59, 179, 74, .35), transparent 60%), radial-gradient(900px 500px at -20% 120%, rgba(201, 162, 39, .28), transparent 60%), linear-gradient(160deg, #0b3b24 0%, #076b37 70%, #0d8243 100%); }
.login-brand::before, .login-brand::after { content: ''; position: absolute; border-radius: 50%; border: 54px solid rgba(255, 255, 255, .05); }
.login-brand::before { width: 620px; height: 620px; left: -230px; bottom: -260px; }
.login-brand::after { width: 420px; height: 420px; right: -150px; top: -170px; border-color: rgba(201, 162, 39, .12); }
.login-brand .logo-w { width: 230px; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .18)); position: relative; z-index: 1; }
.login-brand h1 { font-size: 40px; line-height: 1.25; margin: 0 0 14px; font-weight: 700; position: relative; z-index: 1; }
.login-brand p { margin: 0; font-size: 17px; opacity: .88; max-width: 480px; position: relative; z-index: 1; }
.brand-stats { display: flex; gap: 14px; flex-wrap: wrap; position: relative; z-index: 1; }
.brand-stats div { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); backdrop-filter: blur(6px); border-radius: 14px; padding: 12px 18px; min-width: 120px; }
.brand-stats b { display: block; font-size: 24px; color: #f3d77a; }
.brand-stats span { font-size: 13px; opacity: .85; }
.login-side { display: grid; place-items: center; padding: 32px 22px; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 22px; padding: 34px 30px; box-shadow: var(--shadow-h); border: 1px solid var(--line); animation: rise .5s ease both; }
.login-card .logo { width: 170px; display: block; margin: 0 auto 18px; }
.login-card h2 { text-align: center; margin: 0 0 4px; font-size: 22px; color: var(--deep); }
.login-card .sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .ic { position: absolute; inset-inline-start: 13px; color: var(--muted); pointer-events: none; }
.input-wrap input { padding-inline-start: 42px; }
.input-wrap .eye { position: absolute; inset-inline-end: 6px; }
.inp, .field input, .field select, .field textarea { width: 100%; min-height: 46px; border: 1.5px solid var(--line-2); border-radius: 12px; background: #fff; padding: 0 14px; transition: border .2s, box-shadow .2s; }
.field textarea { padding: 10px 14px; min-height: 90px; resize: vertical; }
.inp:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px rgba(7, 107, 55, .12); }
.login-card .btn { width: 100%; min-height: 50px; font-size: 16px; margin-top: 6px; }
.form-err { background: var(--bad-l); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 22px; }
.secure-note { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; background: linear-gradient(180deg, #0b3b24, #08301d); color: #dfeee4; display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.side .brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px 18px; border-bottom: 1px solid rgba(255, 255, 255, .1); margin-bottom: 12px; }
.side .brand img { width: 150px; }
.side .brand span { font-size: 12.5px; opacity: .75; }
.nav { display: grid; gap: 3px; }
.nav-title { font-size: 11.5px; letter-spacing: .3px; opacity: .55; margin: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; color: inherit; text-decoration: none; font-weight: 500; font-size: 14.5px; transition: background .15s; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.on { background: linear-gradient(90deg, rgba(59, 179, 74, .22), rgba(59, 179, 74, .08)); color: #fff; box-shadow: inset -3px 0 0 var(--gold); }
.nav a .badge { margin-inline-start: auto; background: var(--gold); color: #2b2205; border-radius: 99px; font-size: 11px; padding: 1px 8px; font-weight: 700; }
.side .me { margin-top: auto; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .06); display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold), #e5c45a); color: #2b2205; font-weight: 700; flex: none; }
.side .me b { display: block; font-size: 13.5px; color: #fff; }
.side .me small { font-size: 12px; opacity: .7; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 28px; background: rgba(244, 246, 242, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 19px; color: var(--deep); font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu-btn { display: none; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 60px; width: 100%; max-width: 1480px; margin: 0 auto; animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.scrim { display: none; }

/* ---------------------------------------------------------------- cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.h2 { font-size: 18px; margin: 0; color: var(--deep); }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .t { flex: 1; min-width: 240px; }
.page-head h2 { margin: 0 0 4px; font-size: 24px; color: var(--deep); }
.page-head p { margin: 0; color: var(--muted); }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 20px; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--g200); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic { width: 44px; height: 44px; color: var(--g200); margin-bottom: 8px; }

/* ---------------------------------------------------------------- dashboard */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 26px 28px; color: #fff; margin-bottom: 22px; background: radial-gradient(700px 300px at 0% 0%, rgba(201, 162, 39, .35), transparent 60%), linear-gradient(120deg, #0b3b24, #076b37 65%, #0d8243); box-shadow: var(--shadow-h); }
.hero::after { content: ''; position: absolute; left: -80px; top: -120px; width: 360px; height: 360px; border-radius: 50%; border: 40px solid rgba(255, 255, 255, .06); }
.hero h2 { margin: 0 0 6px; font-size: 26px; }
.hero p { margin: 0; opacity: .88; }
.hero .row { position: relative; z-index: 1; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 20px; position: relative; z-index: 1; }
.stat { background: rgba(255, 255, 255, .11); border: 1px solid rgba(255, 255, 255, .15); border-radius: 14px; padding: 12px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; color: #fff; }
.stat span { font-size: 13px; opacity: .85; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.rep-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; transition: transform .18s, box-shadow .2s, border-color .2s; text-align: start; overflow: hidden; }
.rep-card::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(180deg, var(--leaf), var(--green)); }
.rep-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-h); border-color: var(--g200); }
.rep-top { display: flex; gap: 12px; align-items: flex-start; }
.rep-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--g100), #fff); color: var(--green); border: 1px solid var(--g200); flex: none; }
.rep-ic .ic { width: 25px; height: 25px; }
.rep-no { font-size: 12px; font-weight: 700; color: var(--gold-d); }
.rep-title { font-weight: 700; color: var(--deep); line-height: 1.35; }
.rep-unit { font-size: 13px; color: var(--muted); }
.rep-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rep-kpis div { background: var(--g50); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.rep-kpis b { display: block; font-size: 15px; color: var(--deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-kpis span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-kpis .bad b { color: var(--bad); } .rep-kpis .ok b { color: var(--ok); } .rep-kpis .warn b { color: var(--warn); }
.rep-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; }

/* ---------------------------------------------------------------- tables (lists) */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); }
table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; }
table.list th { text-align: start; font-size: 13px; color: var(--muted); font-weight: 600; padding: 12px 14px; background: var(--g50); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { transition: background .15s; }
table.list tbody tr.click:hover { background: #fafcf9; cursor: pointer; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: embed; letter-spacing: .2px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.seg button.on { background: var(--green); color: #fff; }

/* ---------------------------------------------------------------- report form */
.rbar { position: sticky; top: 64px; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin: -6px 0 16px; border-radius: 16px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.rbar .ttl { flex: 1; min-width: 220px; }
.rbar .ttl b { display: block; color: var(--deep); font-size: 16px; }
.rbar .ttl span { color: var(--muted); font-size: 13px; }
.save-state { font-size: 12.5px; color: var(--muted); }
.steps { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 8px; scrollbar-width: thin; }
.step { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 14px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px; color: var(--ink-2); transition: all .15s; }
.step i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--g100); color: var(--green); font-size: 12.5px; }
.step.on { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(7, 107, 55, .22); }
.step.on i { background: rgba(255, 255, 255, .2); color: #fff; }
.step .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.sec { margin-bottom: 18px; overflow: hidden; }
.sec-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: linear-gradient(90deg, var(--deep), var(--green)); color: #fff; }
.sec-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; flex: 1; }
.sec-head .btn { min-height: 32px; background: rgba(255, 255, 255, .14); color: #fff; }
.sec-head .btn:hover { background: rgba(255, 255, 255, .24); }
.sec-body { padding: 14px; }
.sec-note { font-size: 12.5px; color: var(--muted); padding: 8px 16px 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pair > .sec { margin-bottom: 18px; }
.ftable-wrap { overflow-x: auto; }
table.ft { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
table.ft th { background: var(--g50); color: var(--deep); font-weight: 600; font-size: 12.5px; padding: 8px 6px; border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); text-align: center; line-height: 1.3; vertical-align: bottom; }
table.ft th.grp { background: var(--g100); border-bottom: 1px solid var(--line-2); }
table.ft td { border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); padding: 3px; text-align: center; vertical-align: middle; }
table.ft td.lab { background: #fbfcfb; font-weight: 600; color: var(--deep); text-align: start; padding: 6px 10px; min-width: 120px; }
table.ft td.num { color: var(--muted); font-size: 12.5px; width: 34px; }
table.ft td.calc { background: #f6f8f6; font-weight: 600; color: var(--ink-2); padding: 6px 8px; white-space: nowrap; }
table.ft tfoot td { background: var(--g100); font-weight: 700; color: var(--deep); padding: 8px 6px; }
table.ft tr:hover td:not(.calc):not(.lab) { background: #fcfdfb; }
.cell { width: 100%; min-width: 74px; min-height: 36px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 4px 7px; text-align: center; transition: border .15s, background .15s; }
.cell:hover { border-color: var(--line-2); background: #fff; }
.cell:focus { outline: none; border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(7, 107, 55, .12); }
.cell.wide { min-width: 150px; text-align: start; }
.cell.mark { min-width: 58px; font-weight: 700; }
select.cell { appearance: none; -webkit-appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: 12px 52%, 7px 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 7px; padding-inline-start: 20px; }
.cell.bad, .tone-bad { color: var(--bad) !important; }
.cell.warn, .tone-warn { color: var(--warn) !important; }
.cell.ok, .tone-ok { color: var(--ok) !important; }
.tone-muted { color: var(--muted) !important; }
td.tone-bg-bad { background: var(--bad-l) !important; } td.tone-bg-warn { background: var(--warn-l) !important; } td.tone-bg-ok { background: var(--ok-l) !important; }
.row-del { opacity: .45; } .row-del:hover { opacity: 1; color: var(--bad); }
.add-row { display: flex; justify-content: center; padding: 10px; border-top: 1px dashed var(--line); }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pair .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv .field { margin: 0; }
.kv .calcv { min-height: 46px; display: flex; align-items: center; padding: 0 14px; border-radius: 12px; background: #f6f8f6; font-weight: 700; color: var(--deep); border: 1.5px dashed var(--line-2); }
.lines { display: grid; gap: 8px; }
.lines .ln { display: flex; gap: 8px; align-items: center; }
.lines .ln span { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--g100); color: var(--green); font-size: 12.5px; font-weight: 700; flex: none; }
.lines input { flex: 1; min-height: 42px; border: 1.5px solid var(--line-2); border-radius: 11px; padding: 0 12px; }
.lines input:focus { outline: none; border-color: var(--green); }
.ro-text { padding: 6px 2px; min-height: 30px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; top: 0; inset-inline: 0; height: 3px; background: var(--gold); }
.kpi span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 22px; color: var(--deep); margin: 2px 0; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.bad b { color: var(--bad); } .kpi.ok b { color: var(--ok); } .kpi.warn b { color: var(--warn); }
.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--g50); font-size: 14px; }
.check.e { background: var(--bad-l); color: var(--bad); } .check.w { background: var(--warn-l); color: var(--warn); } .check.ok { background: var(--ok-l); color: var(--ok); }
.timeline { display: grid; gap: 10px; }
.tl { display: flex; gap: 10px; font-size: 13.5px; }
.tl .d { width: 10px; height: 10px; border-radius: 50%; background: var(--green); margin-top: 7px; flex: none; }
.dup-warn { background: var(--warn-l); color: var(--warn); padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; }

/* ---------------------------------------------------------------- dialogs & toasts */
.backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(11, 30, 20, .45); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .2s; }
.backdrop.in { opacity: 1; }
.dialog { width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); transform: translateY(10px) scale(.98); transition: transform .2s; }
.dialog.wide { width: min(820px, 100%); }
.backdrop.in .dialog { transform: none; }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h3 { margin: 0; flex: 1; font-size: 17px; color: var(--deep); }
.dialog-body { padding: 18px 20px; overflow-y: auto; }
.dialog-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toasts { position: fixed; z-index: 200; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); display: grid; gap: 8px; pointer-events: none; width: min(460px, calc(100% - 32px)); }
html[dir='rtl'] .toasts { transform: translateX(50%); }
.toast { background: var(--deep); color: #fff; border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-h); opacity: 0; transform: translateY(10px); transition: all .25s; font-size: 14.5px; }
.toast.in { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); } .toast.warn { background: var(--warn); }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; letter-spacing: 1px; direction: ltr; text-align: center; background: var(--gold-l); border: 1px dashed var(--gold); border-radius: 12px; padding: 12px; user-select: all; }
.perm-list { display: grid; gap: 8px; }
.perm-list label, .chk { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.perm-list input, .chk input { width: 18px; height: 18px; accent-color: var(--green); }
.code-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.code-chips label { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-size: 13px; }
.code-chips input { accent-color: var(--green); }
.list-editor table { width: 100%; border-collapse: collapse; }
.list-editor td, .list-editor th { border-bottom: 1px solid var(--line); padding: 4px; }
.list-editor th { font-size: 12.5px; color: var(--muted); text-align: start; }
.list-editor input { width: 100%; min-height: 38px; border: 1px solid var(--line-2); border-radius: 9px; padding: 0 10px; }
.drag { cursor: grab; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.ok { background: var(--leaf); box-shadow: 0 0 0 4px rgba(59, 179, 74, .18); }
.status-dot.bad { background: var(--bad); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; inset-block: 0; inset-inline-start: 0; width: 280px; transform: translateX(110%); transition: transform .25s ease; box-shadow: var(--shadow-h); }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .35); }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 8px 14px; }
  .content { padding: 18px 14px 80px; }
  .rbar { top: 58px; }
  .pair { grid-template-columns: 1fr; gap: 0; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px 22px 36px; min-height: auto; gap: 18px; }
  .login-brand h1 { font-size: 26px; }
  .login-brand .logo-w { width: 150px; }
  .brand-stats { display: none; }
  .login-side { padding: 0 16px 32px; margin-top: -22px; }
  .kv, .pair .kv { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .stat-row { gap: 10px; }
  .stat b { font-size: 21px; }
  .hero { padding: 20px 18px; border-radius: 16px; }
  .hero h2 { font-size: 21px; }
  .page-head h2 { font-size: 20px; }
  .rep-grid { grid-template-columns: 1fr; }
  .kv, .pair .kv { grid-template-columns: 1fr; }
  .rbar { position: static; margin-top: 0; }
  .rbar .btn span.lbl { display: none; }
  /* form tables become cards */
  table.ft.cards, table.ft.cards tbody, table.ft.cards tr, table.ft.cards td, table.ft.cards tfoot { display: block; width: 100%; }
  table.ft.cards thead { display: none; }
  table.ft.cards tr { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; background: #fff; }
  table.ft.cards td { border: 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 6px 10px; text-align: start; }
  table.ft.cards td::before { content: attr(data-label); flex: 0 0 42%; font-size: 12.5px; color: var(--muted); font-weight: 600; }
  table.ft.cards td.lab { background: var(--g100); font-size: 14.5px; }
  table.ft.cards td.lab::before, table.ft.cards td.num::before { content: none; }
  table.ft.cards td.num { width: auto; background: var(--g50); font-weight: 700; color: var(--green); }
  table.ft.cards .cell { text-align: start; min-width: 0; border-color: var(--line); background: #fff; }
  table.ft.cards td.calc { justify-content: flex-start; }
  table.ft.cards tfoot tr { background: var(--g100); }
  table.ft.cards tfoot td:empty { display: none; }
  table.list.cards thead { display: none; }
  table.list.cards, table.list.cards tbody, table.list.cards tr, table.list.cards td { display: block; width: 100%; }
  table.list.cards tr { border-bottom: 1px solid var(--line); padding: 10px 4px; }
  table.list.cards td { border: 0; padding: 3px 10px; }
  table.list.cards td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- form helpers */
.cell.invalid, .inp.invalid, .lines input.invalid, .list-editor input.invalid { border-color: var(--bad) !important; background: var(--bad-l) !important; }
td.calc.b { font-weight: 700; color: var(--deep); }
td.act { width: 42px; }
table.ft.marks .cell.mark { min-width: 64px; padding-inline: 4px 16px; font-size: 13px; }
.calcv.tone-bad { color: var(--bad); } .calcv.tone-warn { color: var(--warn); } .calcv.tone-ok { color: var(--ok); }
.list-editor .icon-btn[disabled] { opacity: .3; cursor: default; }
.pane { animation: fade .2s ease both; }
.rbar .rep-ic { width: 42px; height: 42px; border-radius: 12px; }
.page-head .rep-ic { align-self: center; }
select.cell.ok, input.cell.ok { color: var(--ok); font-weight: 600; }
select.cell.warn, input.cell.warn { color: var(--warn); font-weight: 600; }
select.cell.bad, input.cell.bad { color: var(--bad); font-weight: 600; }
select.cell.tone-muted { color: var(--muted); }
.dialog .sheet-wrap { margin: -6px -8px; }
@media (max-width: 720px) {
  table.ft.cards td.act { justify-content: flex-end; }
  table.ft.cards td.act::before { content: none; }
  table.ft.marks.cards .cell.mark { min-width: 0; }
}
