:root {
  --bg: #0c0c0b;
  --panel: #151513;
  --panel-2: #1c1c19;
  --line: #2a2924;
  --text: #ecebe6;
  --muted: #9a978c;
  --gold: #c9a54a;
  --gold-soft: rgba(201, 165, 74, .14);
  --green: #1f9d55;
  --green-soft: rgba(31, 157, 85, .15);
  --red: #d9534f;
  --red-soft: rgba(217, 83, 79, .14);
  --radius: 10px;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
main { min-width: 0; }
.side { background: var(--panel); border-inline-start: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--green); display: grid; place-items: center; font-weight: 700; color: #fff; letter-spacing: -.5px; }
.brand b { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--gold-soft); color: var(--gold); }
.nav .ic { width: 18px; text-align: center; }
.side .foot { margin-top: auto; }
main { padding: 28px 32px 80px; max-width: 1400px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 14px; }

/* ---------- Pieces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.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)); }
.split-a { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.split-b { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.split-c { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.kpi b { display: block; font-size: 28px; line-height: 1.2; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.warn b { color: var(--red); }
.kpi.good b { color: var(--green); }

.btn { border: 1px solid var(--line); background: var(--panel-2); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.btn:hover { border-color: #3a3932; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #17140b; }
.btn.gold:hover { filter: brightness(1.07); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: progress; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.tag.green { background: var(--green-soft); color: #4fc887; border-color: transparent; }
.tag.red { background: var(--red-soft); color: #ef7b77; border-color: transparent; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=url], input[type=date], input[type=number], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 80px; }
textarea.script { min-height: 220px; font-size: 16px; line-height: 1.9; }
.field { margin-bottom: 12px; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; margin: 0; cursor: pointer; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }

.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; flex: none; background: var(--gold); }
.dot.red { background: var(--red); }
.dot.green { background: var(--green); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--gold); border-color: var(--gold); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.col h3 { display: flex; justify-content: space-between; font-size: 14px; padding: 2px 4px 8px; }
.col.over { border-color: var(--gold); }
.ad { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.ad:hover { border-color: #3a3932; }
.ad b { display: block; font-size: 14px; font-weight: 600; }
.ad .row { gap: 6px; margin-top: 6px; }
.ad.late { border-color: rgba(217, 83, 79, .55); }

/* ---------- Coverage ---------- */
.cov { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cov .cell { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); cursor: pointer; }
.cov .cell b { font-size: 13px; }
.cov .cell p { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cov .cell.has { border-color: rgba(31, 157, 85, .5); }
.cov .cell.best { background: var(--green-soft); }
.cov .cell.none { border-style: dashed; }

.shotlist .item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.shotlist .item.done span { text-decoration: line-through; color: var(--muted); }
.shotlist input { margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 760px; padding: 22px; }
.modal.wide { max-width: 1100px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }

.script-view { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; line-height: 1.9; }
.code { color: var(--gold); font-weight: 600; }
.warn-box { background: var(--red-soft); color: #f2a3a0; border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.info-box { background: var(--gold-soft); color: #e4cd8e; border-radius: 8px; padding: 8px 12px; font-size: 13px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 99; font-weight: 500; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); color: #fff; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { justify-content: center; padding-bottom: 22px; }

@media print {
  .side, .no-print, .mnav { display: none !important; }
  .shell { display: block; }
  body, .card { background: #fff; color: #000; border-color: #ccc; }
  main { padding: 0; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .split-a, .split-b { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  main { padding: 18px 14px 96px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .mnav { display: flex !important; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}
@media (max-width: 560px) {
  .g2, .g3 { grid-template-columns: 1fr; }
}
.mnav { display: none; position: fixed; bottom: 0; inset-inline: 0; background: var(--panel); border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
.mnav a { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 6px; }
.mnav a .ic { font-size: 18px; }
.mnav a.on { color: var(--gold); }
