/* Double Vision — Brand Book v3 tokens */
:root {
  --ink: #0B0B0B; --ink-2: #141414; --ink-3: #1d1d1d; --line: #2a2a2a;
  --bone: #EDE6DC; --bone-dim: #a8a197; --ember: #F26A1B; --cherry: #6E1129; --steel: #4C5F8C;
  --ok: #7fae7a; --radius: 10px;
  /* semantic colours (dark theme) */
  --ok-line: #3d5a3a; --danger: #ff8c8c; --warn: #ff9a7a; --steel-text: #9fb2e0; --cherry-text: #ffb3c2; --cherry-bg: rgba(110,17,41,.35);
  --amber-text: #e6b98f; --amber-line: #5a4535; --on-ember: #0B0B0B; --backdrop: rgba(0,0,0,.65);
  color-scheme: dark;
  --f-ar: 'IBM Plex Sans Arabic', 'Space Grotesk', system-ui, sans-serif;
  --f-en: 'Space Grotesk', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --f-mono: 'Space Mono', ui-monospace, monospace;
}
/* Light theme — same brand (Ink / Bone / Ember), surfaces flipped */
html[data-theme=light] {
  --ink: #F5F1EA; --ink-2: #FFFFFF; --ink-3: #EFE9DF; --line: #DED6CA;
  --bone: #0B0B0B; --bone-dim: #5f5950; --ok: #2f7a3a; --ok-line: #a9cfa9;
  --danger: #b3261e; --warn: #c2410c; --steel-text: #4C5F8C; --cherry-text: #6E1129; --cherry-bg: rgba(110,17,41,.08);
  --amber-text: #8a5a2b; --amber-line: #d9bfa0; --backdrop: rgba(11,11,11,.35);
  color-scheme: light;
}
html[data-theme=light] .card, html[data-theme=light] .tbl-wrap, html[data-theme=light] .col { box-shadow: 0 1px 2px rgba(11,11,11,.04); }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--bone); }
body { font: 15px/1.5 var(--f-ar); -webkit-font-smoothing: antialiased; }
html[lang=en] body { font-family: var(--f-en); }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--f-mono); letter-spacing: .02em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--bone-dim); }
.num { font-family: var(--f-en); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--ink-2); border-inline-end: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 6px; }
.brand b { display: block; font-family: var(--f-en); font-size: 14px; letter-spacing: .08em; }
.brand small { color: var(--ember); font-size: 10px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav a { padding: 9px 12px; border-radius: 8px; color: var(--bone-dim); display: flex; align-items: center; gap: 10px; }
nav a:hover { background: var(--ink-3); color: var(--bone); }
nav a.on { background: var(--ink-3); color: var(--bone); box-shadow: inset 3px 0 0 var(--ember); }
html[dir=rtl] nav a.on { box-shadow: inset -3px 0 0 var(--ember); }
nav a .ic { width: 18px; text-align: center; opacity: .8; }
.side-foot { display: flex; flex-direction: column; gap: 8px; }
.me { font-size: 11px; color: var(--bone-dim); word-break: break-all; padding: 0 4px; }
.topbar { display: none; }
.view { padding: 28px 32px 80px; min-width: 0; }

/* page header */
.ph { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.ph .crumb { font-size: 12px; color: var(--bone-dim); margin-bottom: 4px; }
.ph .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* buttons & inputs */
.btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--ink-3); color: var(--bone); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #444; }
.btn.primary { background: var(--ember); border-color: var(--ember); color: var(--on-ember); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.on { border-color: var(--ember); color: var(--ember); }
input, select, textarea { font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ember); }
input[type=checkbox] { width: auto; accent-color: var(--ember); }
input[type=date], input[type=number], input[type=email] { direction: ltr; text-align: start; }
textarea { min-height: 80px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--bone-dim); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a, .seg button { padding: 6px 12px; font-size: 13px; color: var(--bone-dim); background: none; border: 0; font-family: inherit; cursor: pointer; }
.seg .on { background: var(--ink-3); color: var(--ember); }
.search { max-width: 240px; }

/* cards & grids */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2, .card h3 { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .lbl { font-size: 12px; color: var(--bone-dim); }
.kpi .val { font-size: 22px; font-weight: 600; margin-top: 6px; }
.kpi .val small { font-size: 12px; color: var(--bone-dim); font-weight: 400; }
.kpi .rows { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.kpi.accent { border-color: rgba(242,106,27,.5); }
.kpi.warn .val { color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--bone-dim); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-weight: 500; font-size: 12px; color: var(--bone-dim); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--ink-3); }
.card table td, .card table th { padding: 8px 6px; }
td.r, th.r { text-align: end; }

/* pills */
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; color: var(--bone-dim); }
.pill.draft { }
.pill.sent { border-color: var(--steel); color: var(--steel-text); }
.pill.paid { border-color: var(--ok-line); color: var(--ok); }
.pill.overdue { border-color: var(--cherry); background: var(--cherry-bg); color: var(--cherry-text); }
.pill.void { text-decoration: line-through; }
.pill.st-brief { color: var(--bone-dim); } .pill.st-pre { color: var(--steel-text); border-color: var(--steel); }
.pill.st-shoot { color: var(--ember); border-color: rgba(242,106,27,.5); } .pill.st-edit { color: var(--amber-text); border-color: var(--amber-line); }
.pill.st-delivered { color: var(--ok); border-color: var(--ok-line); }
.pill.pr-high { color: var(--ember); border-color: rgba(242,106,27,.5); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--bone-dim); }

/* kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 200px; display: flex; flex-direction: column; gap: 10px; }
.col.over { border-color: var(--ember); }
.col-h { display: flex; justify-content: space-between; font-size: 13px; color: var(--bone-dim); padding: 0 2px 4px; }
.kc { background: var(--ink-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: grab; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.kc:hover { border-color: #444; }
.kc .meta { font-size: 12px; color: var(--bone-dim); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kc.late .due { color: var(--warn); }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ember); }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal .dh { background: var(--ink-2); padding: 8px; font-size: 12px; color: var(--bone-dim); text-align: center; }
.cal .d { background: var(--ink-2); min-height: 108px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal .d.out { opacity: .35; }
.cal .d.today { box-shadow: inset 0 0 0 1px var(--ember); }
.cal .dn { font-size: 12px; color: var(--bone-dim); font-family: var(--f-en); }
.ev { font-size: 11.5px; padding: 2px 6px; border-radius: 4px; background: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-inline-start: 3px solid var(--bone-dim); }
.ev.shoot { border-color: var(--ember); } .ev.due { border-color: var(--cherry); } .ev.task { border-color: var(--steel); }
.ev.done { opacity: .5; text-decoration: line-through; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--bone-dim); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 6px; vertical-align: -1px; }
.legend .l-shoot::before { background: var(--ember); } .legend .l-due::before { background: var(--cherry); } .legend .l-task::before { background: var(--steel); }

/* timeline (gantt) */
.tl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-2); }
.tl-grid { display: grid; min-width: 900px; }
.tl-row { display: contents; }
.tl-lbl { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; inset-inline-start: 0; background: var(--ink-2); z-index: 1; }
.tl-lbl.grp { font-weight: 600; color: var(--bone); background: var(--ink-3); }
.tl-track { position: relative; border-bottom: 1px solid var(--line); min-height: 34px; }
.tl-track.grp { background: var(--ink-3); }
.tl-head { font-size: 11px; color: var(--bone-dim); border-bottom: 1px solid var(--line); position: relative; height: 30px; }
.tl-head span { position: absolute; top: 8px; font-family: var(--f-en); }
.tl-bar { position: absolute; top: 7px; height: 20px; border-radius: 5px; background: var(--steel); font-size: 11px; padding: 0 6px; line-height: 20px; white-space: nowrap; overflow: hidden; cursor: pointer; color: var(--bone); }
.tl-bar.done { opacity: .45; } .tl-bar.high { background: var(--ember); color: var(--ink); }
.tl-bar.proj { background: rgba(242,106,27,.18); border: 1px solid rgba(242,106,27,.5); top: 5px; height: 24px; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ember); opacity: .7; z-index: 0; }
.tl-wk { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }

/* invoice editor */
.items td { padding: 6px; }
.items input { padding: 6px 8px; }
.totals { margin-inline-start: auto; width: min(340px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14px; }
.totals .big { font-size: 20px; font-weight: 600; color: var(--ember); }

/* modal & toast */
.modal { position: fixed; inset: 0; background: var(--backdrop); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal[hidden] { display: none; }
.dlg { background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px; width: min(620px, 100%); padding: 22px; }
.dlg h2 { margin-bottom: 16px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.dlg .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.dlg .foot .del { margin-inline-end: auto; }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--bone); color: var(--ink); padding: 10px 18px; border-radius: 8px; font-weight: 500; z-index: 60; }
html[dir=rtl] .toast { transform: translateX(50%); }
.toast.err { background: var(--cherry); color: var(--bone); }
.empty { padding: 26px; text-align: center; color: var(--bone-dim); font-size: 14px; }
.chk { display: flex; align-items: center; gap: 8px; }

/* responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; align-content: start; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  html[dir=rtl] .side { transform: translateX(100%); }
  .side.open { transform: none !important; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--ink-2); position: sticky; top: 0; z-index: 30; }
  .view { padding: 20px 16px 60px; }
  .g4, .g3, .g2, .form { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .search { max-width: none; }
}

/* mixed Arabic/English text: let each label pick its own direction so truncation & arrows read right */
.ev, .tl-lbl, .tl-bar, .kc b, .kc span { unicode-bidi: plaintext; }
.tl-bar.proj { direction: ltr; }

/* permissions grid */
table.perm td, table.perm th { padding: 8px 10px; }
table.perm th { white-space: normal; min-width: 92px; line-height: 1.3; }
table.perm select { padding: 5px 6px; font-size: 13px; min-width: 104px; }
select.lv-none { color: var(--bone-dim); }
select.lv-view { color: var(--steel-text); border-color: var(--steel); }
select.lv-edit { color: var(--ember); border-color: rgba(242,106,27,.55); }
td.click { cursor: pointer; }

/* login */
.login { position: fixed; inset: 0; z-index: 70; background: radial-gradient(1200px 600px at 80% -10%, rgba(242,106,27,.14), transparent 60%), var(--ink); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login[hidden] { display: none; }
.login .box { width: min(400px, 100%); background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login .box h1 { font-size: 22px; }
.login .err { color: var(--cherry-text); font-size: 14px; min-height: 1em; }
.login .small { font-size: 12px; color: var(--bone-dim); }
.login .btn.primary { justify-content: center; padding: 11px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--line); vertical-align: 1px; }
.online-dot.on { background: #5fd17a; box-shadow: 0 0 0 3px rgba(95,209,122,.18); }
.who { display: flex; gap: 8px; flex-wrap: wrap; }
.who span { background: var(--ink-3); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-size: 13px; }
.side-foot .btn { justify-content: flex-start; }

/* password field with show/hide eye */
.pw { position: relative; display: block; }
.pw input { padding-inline-end: 42px; }
.pw .eye { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--bone-dim); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; }
.pw .eye:hover { color: var(--bone); background: var(--ink-3); }
.pw .eye svg { width: 18px; height: 18px; }
.pw-match { font-size: 12px; min-height: 1em; }
.pw-match.ok { color: var(--ok); } .pw-match.bad { color: var(--danger); }
.pw-meter { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 2px; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* settings */
.settings { max-width: 760px; display: flex; flex-direction: column; gap: 16px; }
.settings .card h2 { margin-bottom: 4px; }
.settings .sub { color: var(--bone-dim); font-size: 13px; margin: 0 0 14px; }
.choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice button { font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; text-align: start; }
.choice button.on { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember) inset; }
.choice .sw { width: 100%; height: 46px; border-radius: 6px; border: 1px solid var(--line); display: flex; overflow: hidden; }
.choice .sw i { flex: 1; }
.choice.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sess { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sess:last-child { border-bottom: 0; }
@media (max-width: 820px) { .choice { grid-template-columns: 1fr; } }

/* operations pack */
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--ember); color: var(--on-ember); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; margin-inline-start: auto; }
nav a .badge { margin-inline-start: auto; }
.kc .mv { display: flex; justify-content: space-between; margin-top: 2px; }
.kc .mv button { font: inherit; font-size: 16px; line-height: 1; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--ink-2); color: var(--bone-dim); cursor: pointer; }
.kc .mv button:hover { color: var(--ember); border-color: var(--ember); }
@media (hover: hover) and (pointer: fine) { .kc .mv { opacity: 0; transition: opacity .15s; } .kc:hover .mv { opacity: 1; } }
.comments .cm { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.comments .cm .row { gap: 8px; }
.dlg { max-height: none; }
#fAg .row { gap: 12px; align-items: flex-end; }
