/* pccoiq dashboard — RTL, Tajawal, site brand colors (navy #001659, orange #FF5E15) */
:root {
  --navy: #001659;
  --orange: #ff5e15;
  --orange-ink: #d94a08;
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --text: #16203a;
  --muted: #5f6b85;
  --border: #e1e5ef;
  --sidebar: #001659;
  --sidebar-text: #c9d2ea;
  --ok: #157347;
  --ok-bg: #e6f4ec;
  --danger: #c0262d;
  --danger-bg: #fdecec;
  --warn-bg: #fff4e5;
  --shadow: 0 1px 2px rgba(0, 22, 89, 0.06), 0 4px 16px rgba(0, 22, 89, 0.06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #131a2e; --surface-2: #1a2238; --text: #e6eaf5; --muted: #9aa5c0;
    --border: #263052; --sidebar: #070c1c; --sidebar-text: #aab5d3; --ok: #5ccf8f; --ok-bg: #12301f;
    --danger: #ff7a7f; --danger-bg: #3a1518; --warn-bg: #3a2a12; --orange-ink: #ff7a3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #131a2e; --surface-2: #1a2238; --text: #e6eaf5; --muted: #9aa5c0;
  --border: #263052; --sidebar: #070c1c; --sidebar-text: #aab5d3; --ok: #5ccf8f; --ok-bg: #12301f;
  --danger: #ff7a7f; --danger-bg: #3a1518; --warn-bg: #3a2a12; --orange-ink: #ff7a3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Tajawal", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6; }
a { color: var(--orange-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 18px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
/* The logo's blue wordmark disappears on navy/dark surfaces, so it sits on a light backing there. */
.brand-logo { display: inline-flex; flex-shrink: 0; background: #f4f6fa; border-radius: 10px; padding: 6px; }
.brand-logo img { display: block; height: 44px; width: auto; }
.brand-logo-lg { background: transparent; padding: 0; }
.brand-logo-lg img { height: 96px; }
:root[data-theme="dark"] .brand-logo-lg { background: #f4f6fa; padding: 10px; border-radius: 14px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo-lg { background: #f4f6fa; padding: 10px; border-radius: 14px; }
}
.brand strong { display: block; font-size: 1.05rem; font-weight: 800; line-height: 1.3; }
.brand small { color: var(--sidebar-text); font-size: 0.8rem; }
.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: var(--sidebar-text); text-decoration: none; font-weight: 500; }
.nav a i { width: 20px; text-align: center; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a[aria-current="page"] { background: var(--orange); color: #fff; }
.nav .badge { margin-inline-start: auto; background: var(--orange); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 0.8rem; font-weight: 700; min-width: 24px; text-align: center; }
.nav a[aria-current="page"] .badge { background: #fff; color: var(--orange-ink); }
.sidebar-foot { padding: 14px 12px 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; flex-direction: column; gap: 4px; }
.sidebar-foot a, .sidebar-foot button { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; color: var(--sidebar-text); text-decoration: none; background: none; border: 0; cursor: pointer; width: 100%; text-align: start; }
.sidebar-foot a:hover, .sidebar-foot button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.3rem; margin: 0; font-weight: 800; flex: 1; }
.topbar .user { color: var(--muted); font-size: 0.9rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.icon-btn:hover { border-color: var(--orange); color: var(--orange-ink); }
.menu-btn { display: none; }
#view { padding: 28px; max-width: 1200px; width: 100%; outline: none; }
.scrim { display: none; }

/* ---- Components ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1 1 260px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn:hover { border-color: var(--orange); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-ink); border-color: var(--orange-ink); }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-bg); }
.btn-sm { padding: 6px 12px; font-size: 0.9rem; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: 0.95rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; }
.field .error { color: var(--danger); font-size: 0.88rem; font-weight: 500; }
.input, select.input, textarea.input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.input:focus { border-color: var(--orange); outline: none; box-shadow: 0 0 0 3px rgba(255, 94, 21, 0.18); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.7; }
.input[dir="ltr"] { text-align: left; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.section-title { font-size: 1.05rem; font-weight: 800; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.section-title i { color: var(--orange); }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(-20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--orange); outline-offset: 2px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.pill.completed { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.in_progress { background: var(--warn-bg); color: var(--orange-ink); border-color: transparent; }
.pill.draft { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty i { font-size: 2.6rem; color: var(--border); display: block; margin-bottom: 12px; }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--warn-bg); margin-bottom: 18px; font-size: 0.93rem; }

/* ---- Projects list ---- */
.plist { list-style: none; margin: 0; padding: 0; }
.prow { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.prow:last-child { border-bottom: 0; }
.prow.dragging { opacity: 0.4; }
.prow.drop-target { box-shadow: inset 0 3px 0 var(--orange); }
.handle { cursor: grab; color: var(--muted); padding: 6px; border: 0; background: none; }
.prow .thumb { width: 72px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.prow .info { flex: 1; min-width: 0; }
.prow .info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.prow .actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.order-btns { display: flex; flex-direction: column; }
.order-btns button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 6px; line-height: 1.2; }
.order-btns button:hover { color: var(--orange-ink); }

/* ---- Images ---- */
.dropzone { display: block; border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color 0.2s, background 0.2s; background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--orange); background: rgba(255, 94, 21, 0.05); color: var(--text); }
.dropzone i { font-size: 2rem; color: var(--orange); display: block; margin-bottom: 8px; }
.igrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.icard { position: relative; border-radius: 10px; overflow: hidden; border: 2px solid var(--border); background: var(--surface-2); aspect-ratio: 4 / 3; cursor: grab; }
.icard.cover { border-color: var(--orange); }
.icard.dragging { opacity: 0.4; }
.icard.drop-target { box-shadow: 0 0 0 3px var(--orange); }
.icard img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.icard .tag { position: absolute; top: 8px; right: 8px; background: var(--orange); color: #fff; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.icard .ibtns { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; gap: 6px; padding: 6px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); }
.icard .ibtns button { border: 0; border-radius: 6px; padding: 4px 8px; font-size: 0.8rem; cursor: pointer; background: rgba(255, 255, 255, 0.92); color: #16203a; }
.icard .ibtns button.del { background: var(--danger); color: #fff; }
.upload-status { margin-top: 12px; font-size: 0.92rem; }
.upload-status li { color: var(--danger); }

/* ---- Inbox ---- */
.inbox { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
.inbox > *, .toolbar .grow { min-width: 0; }
.mlist { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 230px); overflow: auto; }
.mitem { display: block; width: 100%; text-align: start; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--border); background: none; cursor: pointer; }
.mitem:hover { background: var(--surface-2); }
.mitem[aria-current="true"] { background: rgba(255, 94, 21, 0.08); box-shadow: inset -4px 0 0 var(--orange); }
.mitem .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mitem .name { font-weight: 500; }
.mitem.unread .name { font-weight: 800; }
.mitem.unread .name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-inline-end: 8px; vertical-align: middle; }
.mitem .date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.mitem .preview { color: var(--muted); font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.mdetail h2 { margin: 0 0 4px; font-size: 1.3rem; }
.mdetail .kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; font-size: 0.95rem; }
.mdetail .kv dt { color: var(--muted); }
.mdetail .kv dd { margin: 0; overflow-wrap: anywhere; }
.mdetail .body { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 10px; padding: 16px; line-height: 1.9; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--border); }
.back-btn { display: none; }

/* ---- Overview / stats ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 14px; }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr 1fr; gap: 10px; } .kpi { padding: 12px; } .kpi-icon { width: 34px; height: 34px; font-size: .95rem; } .kpi-value { font-size: 1.5rem; } }
.kpi { padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label icon" "value icon" "sub sub"; gap: 2px 10px; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--orange); }
.kpi-icon { grid-area: icon; width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 94, 21, 0.1); color: var(--orange-ink); font-size: 1.1rem; }
.kpi-label { grid-area: label; color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.kpi-value { grid-area: value; font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.kpi-sub { grid-area: sub; color: var(--muted); font-size: 0.8rem; }
.grid-2.gap { gap: 20px; align-items: start; }
.chart-wrap { margin: 0; }
.chart { width: 100%; height: auto; display: block; direction: ltr; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: "Tajawal", sans-serif; }
.chart .bar { fill: var(--chart-bar); }
.chart .bar:hover { fill: var(--orange); }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.legend { display: flex; gap: 18px; justify-content: center; color: var(--muted); font-size: 0.88rem; margin-top: 6px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.sw-bar { background: var(--chart-bar); }
.sw-line { background: var(--chart-line); height: 4px !important; vertical-align: 3px !important; }
:root { --chart-bar: #b9c6dc; --chart-line: #ff5e15; }
:root[data-theme="dark"] { --chart-bar: #33416a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-bar: #33416a; } }
.blist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.blist-row { display: flex; justify-content: space-between; gap: 10px; font-size: 0.93rem; }
.blist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blist-n { color: var(--muted); white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.blist-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.blist-fill { height: 100%; background: var(--orange); border-radius: 999px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list a { display: flex; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.mini-list li:last-child a { border-bottom: 0; }
.mini-list a:hover { background: var(--surface-2); }
.mini-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.muted { color: var(--muted); }
.quick { display: grid; gap: 10px; }
.quick .btn { justify-content: flex-start; }

/* ---- Quote requests ---- */
.pill.st-new { background: rgba(255, 94, 21, 0.12); color: var(--orange-ink); border-color: transparent; }
.pill.st-contacted { background: rgba(65, 101, 138, 0.14); color: #2f5a86; border-color: transparent; }
.pill.st-site_visit { background: rgba(124, 77, 255, 0.12); color: #6a3fd1; border-color: transparent; }
.pill.st-quoted { background: var(--warn-bg); color: #9a6200; border-color: transparent; }
.pill.st-won { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.st-lost { background: var(--surface-2); color: var(--muted); }
:root[data-theme="dark"] .pill.st-contacted { color: #8fb4dd; }
:root[data-theme="dark"] .pill.st-site_visit { color: #b9a0ff; }
:root[data-theme="dark"] .pill.st-quoted { color: #f1c06b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill.st-contacted { color: #8fb4dd; }
  :root:not([data-theme="light"]) .pill.st-site_visit { color: #b9a0ff; }
  :root:not([data-theme="light"]) .pill.st-quoted { color: #f1c06b; }
}
.mitem .meta-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; min-width: 0; }
.mitem .meta-row .preview { flex: 1; min-width: 0; }
.mitem.unread .name::before { background: var(--orange); }
.qhead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.qhead h2 { margin: 0; }
.sub-title { font-size: 0.95rem; font-weight: 800; margin: 20px 0 10px; color: var(--muted); }
.steps { display: flex; flex-wrap: wrap; gap: 6px; }
.step { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; font-weight: 700; cursor: pointer; color: var(--muted); }
.step:hover { border-color: var(--orange); color: var(--text); }
.step.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.step.st-won.active { background: var(--ok); border-color: var(--ok); }
.step.st-lost.active { background: var(--muted); border-color: var(--muted); }
.qfiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.qfile { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: inherit; font-size: 0.82rem; min-width: 0; }
.qfile:hover { border-color: var(--orange); }
.qfile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.qfile-icon { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; color: var(--danger); background: var(--surface-2); border-radius: 6px; }
.qfile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.notes li { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.note-meta { color: var(--muted); font-size: 0.8rem; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-form { display: grid; gap: 8px; justify-items: start; }

/* ---- Toast + dialog ---- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; animation: pop 0.2s ease-out; }
.toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 420px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(0, 10, 40, 0.55); }
dialog p { margin: 0 0 20px; font-size: 1.05rem; }

/* ---- Login ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, var(--navy) 0%, #0a2a8a 100%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 34px 30px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.login-card .brand { color: var(--text); border: 0; padding: 0 0 22px; justify-content: center; flex-direction: column; text-align: center; gap: 10px; }
.login-card .brand small { color: var(--muted); }
.login-card h1 { font-size: 1.25rem; text-align: center; margin: 0 0 22px; }
.alert { padding: 11px 14px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); margin-bottom: 16px; font-weight: 500; font-size: 0.93rem; }
.w-100 { width: 100%; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox.has-detail .mlist-card { display: none; }
  .inbox:not(.has-detail) .mdetail { display: none; }
  .back-btn { display: inline-flex; }
  .mlist { max-height: none; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; right: 0; transform: translateX(100%); transition: transform 0.25s; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 10, 40, 0.45); z-index: 25; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .topbar .user { display: none; }
  #view { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .prow { flex-wrap: wrap; }
  .prow .info { flex-basis: calc(100% - 170px); }
  .prow .actions { width: 100%; justify-content: flex-end; }
  .handle { display: none; }
}

/* Vertical stack of cards; min-width:0 stops wide content (charts, long names) widening the page */
.stack { display: grid; gap: 20px; }
.stack > *, .grid-2 > *, .grid-3 > * { min-width: 0; }

/* ---- Site content editor ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.tab { display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 700; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-current="page"] { background: var(--orange); color: #fff; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; align-items: start; }
.ipick { display: grid; gap: 8px; }
.ipick-frame { aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.ipick-sm .ipick-frame { aspect-ratio: 4 / 5; max-width: 180px; }
.ipick-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ipick-empty { color: var(--muted); font-size: 2rem; }
.ipick-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.icon-select { display: flex; gap: 8px; align-items: center; }
.icon-select .input { flex: 1; }
.icon-prev { width: 42px; height: 42px; flex-shrink: 0; border-radius: 10px; background: rgba(255, 94, 21, 0.1); color: var(--orange-ink); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.ledit { display: grid; gap: 14px; }
.ledit-head { display: flex; gap: 6px; align-items: center; margin-bottom: 12px; }
.ledit-num { font-size: 1rem; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); }

/* ---- Backups ---- */
.card-alert { border-color: var(--danger); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: start; }
.table th { color: var(--muted); font-size: 0.88rem; font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px; font-size: 0.9rem; }
}
@media (max-width: 520px) {
  .sticky-actions { gap: 6px; padding: 8px 0; }
  .sticky-actions .btn { padding: 8px 12px; font-size: 0.88rem; }
}

/* ---- Users + activity log ---- */
.ulist { list-style: none; margin: 0; padding: 0; }
.urow { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.urow:last-child { border-bottom: 0; }
.urow.is-disabled .uinfo { opacity: 0.55; }
.uinfo .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.uactions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.plain { margin: 0; padding-inline-start: 18px; display: grid; gap: 6px; }
.secret-box { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--surface-2); border: 1px dashed var(--orange); border-radius: 10px; padding: 12px 14px; }
.secret-box code { font-size: 1.25rem; font-weight: 700; letter-spacing: 1px; user-select: all; }
.table .row-warn td { background: var(--danger-bg); }
@media (max-width: 860px) {
  .table thead { display: none; }
  .table tr { display: grid; gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: 0; }
}
