:root {
  /* هوية CODE: أبيض وأسود، أرقام بخط أحادي المسافة */
  --bg: #f2f2f2; --surface: #fff; --surface-2: #f7f7f7; --border: #e2e2e2;
  --text: #0b0b0b; --muted: #6e6e6e; --accent: #0b0b0b; --accent-ink: #fff; --accent-2: #ececec;
  --neg: #b4362d; --pos: #1e7a46; --warn-bg: #f6f1e4; --warn: #7a5a12;
  --side: #0b0b0b; --side-text: #a8a8a8; --radius: 10px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070707; --surface: #111; --surface-2: #171717; --border: #262626;
    --text: #f2f2f2; --muted: #8c8c8c; --accent: #f2f2f2; --accent-ink: #0b0b0b; --accent-2: #1d1d1d;
    --neg: #ef7d74; --pos: #5fcf8f; --warn-bg: #241e10; --warn: #e3c271;
    --side: #000; --side-text: #8c8c8c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; direction: ltr; display: inline-block; }

.shell { display: flex; min-height: 100vh; }
.side { width: 236px; background: var(--side); color: var(--side-text); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 22px; }
.brand b { color: #fff; display: block; font-size: 16px; }
.brand small { font-size: 12px; opacity: .7; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { color: var(--side-text); padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side nav a svg { width: 18px; height: 18px; opacity: .8; }
.side nav a:hover { background: rgba(255,255,255,.06); }
.side nav a.on { background: var(--accent); color: #fff; }
.side-foot { font-size: 13px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot a { color: #fff; }

.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.top h1 { font-size: 22px; margin: 0; flex: 1; font-weight: 800; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 18px; cursor: pointer; }
.year-pick { display: flex; align-items: center; gap: 8px; }
.year-pick label { color: var(--muted); font-size: 13px; }
.year-pick select { font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card.narrow { max-width: 640px; }
.link { font-size: 13px; font-weight: 500; cursor: pointer; color: var(--accent); }
.muted { color: var(--muted); font-size: 13.5px; }
.warn-text { color: var(--warn); font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 > .card { margin-bottom: 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 13px; display: block; }
.kpi b { font-size: 21px; font-weight: 800; display: block; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.hero { background: var(--accent); border-color: var(--accent); color: #fff; }
.kpi.hero span, .kpi.hero small { color: rgba(255,255,255,.85); }
.neg { color: var(--neg); } .pos { color: var(--pos); }
.kpi.hero .neg { color: #fff; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: var(--surface-2); }
tfoot td { font-weight: 700; border-bottom: 0; }
td.nowrap { direction: ltr; text-align: right; }
td.actions { display: flex; gap: 6px; justify-content: flex-end; }
td.actions form { margin: 0; }
table.calc td:last-child { text-align: left; font-weight: 700; }
table.calc tr.total td { font-size: 17px; border-top: 2px solid var(--text); border-bottom: 0; }
.chart-box { position: relative; height: 260px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 14px; align-items: end; }
.form-grid .wide { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.switch { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
label.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 8px; }
.btn { font: inherit; font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 16px; cursor: pointer; display: inline-block; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.danger { color: var(--neg); }
.btn.sm { padding: 3px 10px; font-size: 13px; font-weight: 500; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--accent-2); color: var(--text); border: 1px solid var(--border); }
.flash.err { background: #fde8e6; color: #8f2620; }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
@media (prefers-color-scheme: dark) { .flash.err { background: #3a1916; color: #f5b0aa; } }

.bars { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { position: relative; display: flex; justify-content: space-between; padding-bottom: 6px; }
.bars i { position: absolute; bottom: 0; right: 0; height: 4px; background: var(--accent); border-radius: 2px; }
.total-line { margin: 14px 0 0; }
.chips { list-style: none; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chips a { display: block; padding: 4px 14px; border-radius: 999px; background: var(--accent-2); font-weight: 700; }

.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center; margin-bottom: 14px; }
.drop.over { border-color: var(--accent); background: var(--accent-2); }
.drop input { display: none; }
.q-item { display: grid; grid-template-columns: 1fr 180px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.q-item .status { font-size: 13px; }

body.bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth h2 { margin: 0; }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .side { position: fixed; right: -260px; z-index: 20; transition: right .2s; }
  .side.open { right: 0; }
  .menu-btn { display: block; }
  .main { padding: 16px; }
  .form-grid .wide { grid-column: auto; }
  .q-item { grid-template-columns: 1fr; }
}

/* ---------- CODE identity overrides ---------- */
.logo, .side nav a.on, .btn.primary, .kpi.hero { color: var(--accent-ink); }
.kpi.hero span, .kpi.hero small { color: var(--accent-ink); opacity: .7; }
.kpi.hero .neg { color: var(--accent-ink); }
.side { border-left: 1px solid #1c1c1c; }
.side nav a.on { background: #fff; color: #0b0b0b; }
.side nav a.on svg { opacity: 1; }
.brand { padding-bottom: 26px; }
.wordmark { font-family: var(--mono); font-weight: 700; font-size: 22px; color: #fff; letter-spacing: .5px; direction: ltr; }
.wordmark i { font-style: normal; color: #6e6e6e; }
.brand small { font-family: var(--mono); font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase; color: #6e6e6e; }
.kpi b, table, .total-line b, .chips a, .year-pick select, input, td.nowrap {
  font-family: var(--mono), 'IBM Plex Sans Arabic', sans-serif;
}
.kpi b { font-size: 19px; letter-spacing: -.3px; }
.kpi span, th, .eyebrow { font-family: var(--mono), 'IBM Plex Sans Arabic', sans-serif; font-size: 11.5px; letter-spacing: .4px; }
.top h1 { font-size: 26px; letter-spacing: -.3px; }
.eyebrow { color: var(--muted); display: block; margin-bottom: 2px; direction: ltr; text-align: right; }
.card h3 { font-size: 15px; }
.btn.add-year { font-family: var(--mono); font-size: 13px; }
.bars i { background: var(--text); }
.chips a { background: var(--accent-2); color: var(--text); }
th { background: transparent; border-bottom: 1px solid var(--text); }
.wordmark.dark { color: var(--text); }
.auth .wordmark { align-self: flex-end; }
.brand small { display: block; margin-top: 4px; }
.grid2 > * { min-width: 0; }
.main { overflow-x: hidden; }
.wordmark { display: inline-block; unicode-bidi: isolate; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-2); margin: 2px; }
.tag.dark { background: var(--text); color: var(--bg); }
td.wrap { white-space: normal; max-width: 420px; }
fieldset.perms { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
fieldset.perms legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.small { font-size: 12px; }
.pass-wrap { display: flex; gap: 6px; align-items: center; }
.pass-wrap input { flex: 1; }
