/* ============================================================
   CONNEXION — "Control Room" dark-luxury design system (RTL)
   ============================================================ */
:root {
  /* surfaces */
  --bg: #0a0e13;
  --bg-2: #0d1219;
  --surf: #12181f;
  --surf-2: #161d26;
  --surf-3: #1b232d;
  --line: #242e3a;
  --line-2: #2f3b49;
  /* ink */
  --ink: #eef2f7;
  --ink-2: #9fb0c3;
  --mut: #6c7a8c;
  /* signature */
  --gold: #e3b45f;
  --gold-2: #f0cd86;
  --gold-deep: #b98a34;
  --gold-glow: rgba(227, 180, 95, .35);
  /* signals */
  --ok: #37d9a0; --ok-bg: rgba(55, 217, 160, .12);
  --info: #5fb2ff; --info-bg: rgba(95, 178, 255, .12);
  --warn: #e3b45f; --warn-bg: rgba(227, 180, 95, .12);
  --danger: #ff6b6b; --danger-bg: rgba(255, 107, 107, .12);
  --mut-bg: rgba(159, 176, 195, .1);

  --r: 14px; --r-sm: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.34);
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-disp: "Tajawal", "IBM Plex Sans Arabic", sans-serif;
  --f-mono: "IBM Plex Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--f-body); color: var(--ink); font-size: 14px; line-height: 1.55;
  background:
    radial-gradient(90% 55% at 100% -5%, rgba(227,180,95,.09), transparent 55%),
    radial-gradient(70% 50% at -10% 110%, rgba(95,178,255,.06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
/* subtle film grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.028'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
::selection { background: var(--gold-glow); }
.mono { font-family: var(--f-mono); direction: ltr; letter-spacing: -.2px; }

#app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; position: relative; z-index: 1; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, #0c1118 0%, #090d12 100%);
  border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; }
.logo {
  width: 44px; height: 44px; border-radius: 13px; overflow: hidden; display: grid; place-items: center;
  background: #0e1420; box-shadow: 0 6px 18px rgba(0,0,0,.4), inset 0 0 0 1px var(--line);
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.powered { color: var(--mut); font-size: 10px; letter-spacing: .3px; text-align: center; opacity: .8; }
.powered b { color: var(--gold-2); font-weight: 700; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.4; }
.brand-txt b { font-size: 15px; letter-spacing: .4px; font-family: var(--f-disp); font-weight: 800; }
.brand-txt span { font-size: 11px; color: var(--mut); letter-spacing: 1px; }
nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 11px;
  color: var(--ink-2); font-weight: 600; font-size: 13.5px; transition: .18s ease; position: relative;
}
.nav-item .ic { width: 20px; text-align: center; font-size: 15px; opacity: .7; font-style: normal; }
.nav-item:hover { background: var(--surf); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(227,180,95,.16), rgba(227,180,95,.04));
  color: var(--gold-2);
}
.nav-item.active .ic { opacity: 1; color: var(--gold); }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 22%; bottom: 22%; width: 3px;
  border-radius: 3px; background: var(--gold); box-shadow: 0 0 10px var(--gold-glow);
}
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.ver { color: var(--mut); font-size: 10px; letter-spacing: .5px; text-align: center; }

/* ── Topbar ────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 16px 30px; background: rgba(10,14,19,.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.page-head { text-align: start; }
.eyebrow { font-size: 10px; letter-spacing: 3px; color: var(--gold); font-weight: 700; font-family: var(--f-mono); }
.page-head h1 { font-size: 20px; margin: 1px 0 0; font-weight: 800; font-family: var(--f-disp); }
.search-wrap { position: relative; width: 340px; }
.s-ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--mut); font-size: 16px; }
#globalSearch {
  width: 100%; padding: 11px 40px 11px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surf); outline: none; transition: .18s;
}
#globalSearch::placeholder { color: var(--mut); }
#globalSearch:focus { border-color: var(--gold-deep); background: var(--surf-2); box-shadow: 0 0 0 3px var(--gold-glow); }
.search-results {
  position: absolute; top: 50px; inset-inline-start: 0; width: 400px; background: var(--surf-2);
  border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; display: none; z-index: 40; max-height: 60vh; overflow-y: auto;
}
.search-results.open { display: block; }
.sr-item { padding: 12px 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: center; transition: .12s; }
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--surf-3); }

/* ── View / layout ─────────────────────────────────────── */
.view { padding: 26px 30px 70px; animation: fadeUp .4s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-actions h2 { margin: 0; font-size: 17px; font-family: var(--f-disp); font-weight: 800; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 22px; }
.two-col { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }
@media (max-width: 960px) and (min-width: 701px) { .two-col { grid-template-columns: 1fr; } #app { grid-template-columns: 68px 1fr; } .brand-txt, .nav-item span, .ver, .side-foot .block span { display: none; } }

/* ── Stat tiles ────────────────────────────────────────── */
.tile {
  background: linear-gradient(160deg, var(--surf-2), var(--surf));
  border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px;
  position: relative; overflow: hidden; transition: .2s; box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--line-2); transform: translateY(-2px); }
.tile::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 2px; background: var(--gold); opacity: .55; }
.tile.ok::before { background: var(--ok); } .tile.info::before { background: var(--info); }
.tile.warn::before { background: var(--warn); } .tile.danger::before { background: var(--danger); }
.tile.muted::before { background: var(--mut); }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px; padding: 10px 14px; background: var(--surf-2, var(--bg-2));
  border: 1px solid var(--gold-deep); border-radius: 10px; }
.bulk-bar > span { font-weight: 700; color: var(--gold-2); }
.map-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.map-controls input[type="date"], .map-controls select { color: var(--ink); background: var(--bg-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #11161f; color: var(--ink); }
.leaflet-container { font-family: inherit; }
.link-a { color: var(--gold-2); text-decoration: none; font-weight: 600; }
.link-a:hover { text-decoration: underline; }
.tile .k { color: var(--ink-2); font-size: 12px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.tile .v { font-size: 34px; font-weight: 800; line-height: 1; font-family: var(--f-disp); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.tile .sub { font-size: 11.5px; color: var(--mut); margin-top: 8px; }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--gold-deep); box-shadow: var(--shadow), 0 0 0 1px var(--gold-deep); }
.tile .go { margin-top: 10px; font-size: 11.5px; font-weight: 700; color: var(--gold); opacity: 0; transition: .18s; }
.tile.clickable:hover .go { opacity: 1; }
@media (max-width: 700px) { .tile .go { opacity: 1; } }

/* ── Cards ─────────────────────────────────────────────── */
.card { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-family: var(--f-disp); font-weight: 700; }
.card-body { padding: 18px 20px; }

/* ── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 13px 14px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: var(--surf-2); color: var(--ink-2); font-size: 11.5px; font-weight: 700; letter-spacing: .3px; position: sticky; top: 0; z-index: 1; }
table.data tbody tr { transition: .12s; }
table.data tbody tr:hover td { background: var(--surf-2); }
table.data .mono { font-family: var(--f-mono); direction: ltr; font-weight: 600; color: var(--gold-2); }
.row-click { cursor: pointer; }
.empty { text-align: center; color: var(--mut); padding: 54px 20px; }
.empty .big { font-size: 40px; opacity: .35; margin-bottom: 10px; }
.empty .cta { margin-top: 16px; }

/* ── Badges (LED dot) ──────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-info { color: var(--info); background: var(--info-bg); }
.b-warn { color: var(--warn); background: var(--warn-bg); }
.b-danger { color: var(--danger); background: var(--danger-bg); }
.b-muted { color: var(--ink-2); background: var(--mut-bg); }
.b-muted::before { box-shadow: none; opacity: .6; }

/* ── Buttons ───────────────────────────────────────────── */
.btn, .ghost, .danger-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
  border-radius: 11px; border: 1px solid transparent; font-weight: 700; font-size: 13.5px; transition: .18s;
}
.btn, .btn.accent {
  background: linear-gradient(145deg, var(--gold-2), var(--gold-deep)); color: #1a1206;
  box-shadow: 0 4px 16px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.ghost { background: var(--surf-2); border-color: var(--line-2); color: var(--ink); }
.ghost:hover { border-color: var(--gold-deep); color: var(--gold-2); }
.ghost.block { width: 100%; }
.ghost.sm, .btn.sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.danger-btn { background: var(--danger-bg); border-color: rgba(255,107,107,.25); color: var(--danger); }
.danger-btn:hover { background: rgba(255,107,107,.2); }
.icon-btn { border: 1px solid transparent; background: transparent; padding: 6px 9px; border-radius: 8px; color: var(--ink-2); font-size: 15px; transition: .15s; }
.icon-btn:hover { background: var(--surf-3); color: var(--gold-2); border-color: var(--line); }

/* ── Chips / filters ───────────────────────────────────── */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surf); font-size: 12.5px; font-weight: 600; color: var(--ink-2); transition: .15s; }
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.active { background: linear-gradient(145deg, var(--gold-2), var(--gold-deep)); color: #1a1206; border-color: transparent; box-shadow: 0 3px 12px var(--gold-glow); }
input.chip { color: var(--ink); }
input.chip::placeholder { color: var(--mut); }
input.chip:focus { outline: none; border-color: var(--gold-deep); }

/* ── Forms ─────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-l { display: flex; flex-direction: column; gap: 7px; }
.field-l.full { grid-column: 1 / -1; }
.field-l label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field-l input, .field-l select, .field-l textarea {
  padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg-2); outline: none; transition: .16s;
}
.field-l input:focus, .field-l select:focus, .field-l textarea:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 3px var(--gold-glow); }
.field-l input[readonly] { opacity: .6; }
.field-l select option { background: var(--surf-2); }
.check { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--ink-2); padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; transition: .15s; }
.check:hover { border-color: var(--line-2); }
.check input { width: 17px; height: 17px; accent-color: var(--gold); }
.hint-txt { font-size: 12px; color: var(--mut); }

/* ── Modal ─────────────────────────────────────────────── */
#modalRoot:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(4,7,11,.66); display: grid; place-items: center; z-index: 100; padding: 22px; backdrop-filter: blur(4px); animation: fadeUp .2s; }
.modal { background: var(--surf); border: 1px solid var(--line-2); border-radius: 18px; width: 100%; max-width: 720px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal.wide { max-width: 1000px; }
.modal-head { padding: 19px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; font-family: var(--f-disp); font-weight: 800; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--bg-2); border-radius: 0 0 18px 18px; }

/* ── Toasts ────────────────────────────────────────────── */
.toast-root { position: fixed; bottom: 24px; inset-inline-start: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { padding: 13px 20px; border-radius: 12px; background: var(--surf-3); color: var(--ink); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: 600; font-size: 13px; animation: slidein .22s; max-width: 400px; border-inline-start: 3px solid var(--gold); }
.toast.ok { border-inline-start-color: var(--ok); } .toast.err { border-inline-start-color: var(--danger); } .toast.warn { border-inline-start-color: var(--warn); }
@keyframes slidein { from { transform: translateX(12px); opacity: 0; } }

/* ── Alerts ────────────────────────────────────────────── */
.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert { display: flex; align-items: center; gap: 11px; padding: 12px 15px; border-radius: 11px; font-weight: 600; font-size: 13px; border: 1px solid var(--line); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: rgba(95,178,255,.2); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(227,180,95,.2); }

/* ── Misc ──────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding: 12px 0; border-inline-start: 2px solid var(--line); padding-inline-start: 18px; margin-inline-start: 6px; position: relative; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid var(--surf); box-shadow: 0 0 8px var(--gold-glow); }
.tl-date { font-size: 11px; color: var(--gold); min-width: 88px; font-family: var(--f-mono); }
.item-line { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; margin-bottom: 9px; background: var(--surf-2); }
.item-line .mono { flex: 1; }
.thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; border: 1px solid var(--line-2); }
.loading { text-align: center; padding: 60px; color: var(--mut); }
.loading::after { content: "◈"; display: block; font-size: 26px; color: var(--gold); margin-top: 10px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.qr-preview { width: 100%; background: #fff; border-radius: 10px; padding: 8px; }
.picker-row td { vertical-align: middle; }
.picker-note { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); }
/* form controls inside dark tables (pickers, return flow) */
table.data select, table.data input[type="text"], table.data input:not([type]) {
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; outline: none; width: 100%;
}
table.data select:focus, table.data input:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 2px var(--gold-glow); }
table.data select option { background: var(--surf-2); color: var(--ink); }
table.data input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--gold); }
.count-pill { font-family: var(--f-mono); background: var(--surf-3); border: 1px solid var(--line-2); padding: 2px 9px; border-radius: 999px; font-size: 12px; color: var(--gold-2); }

/* ── Login ─────────────────────────────────────────────── */
#authRoot { display: none; }
.login-bg {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(227,180,95,.12), transparent 55%),
    radial-gradient(70% 50% at 0% 100%, rgba(95,178,255,.07), transparent 55%), var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surf); border: 1px solid var(--line-2);
  border-radius: 20px; padding: 34px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.login-brand b { display: block; font-family: var(--f-disp); font-weight: 800; font-size: 16px; }
.login-brand span { font-size: 11.5px; color: var(--mut); letter-spacing: 1px; }
.login-card h2 { margin: 0 0 20px; font-family: var(--f-disp); font-size: 20px; }
.login-err { color: var(--danger); font-size: 12.5px; font-weight: 600; margin-top: 12px; min-height: 16px; }
.login-hint { font-size: 11.5px; color: var(--mut); margin-top: 16px; text-align: center; }

/* ── User chip ─────────────────────────────────────────── */
.user-chip { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--surf); border: 1px solid var(--line); border-radius: 11px; }
.user-chip .av { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(145deg, var(--gold-2), var(--gold-deep)); color: #1a1206; display: grid; place-items: center; font-weight: 800; font-family: var(--f-disp); flex-shrink: 0; }
.user-chip .who { flex: 1; min-width: 0; line-height: 1.35; }
.user-chip .who b { font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { font-size: 10.5px; color: var(--gold); }
.user-chip .logout { border: none; background: transparent; color: var(--mut); font-size: 15px; cursor: pointer; padding: 4px; border-radius: 7px; }
.user-chip .logout:hover { color: var(--danger); background: var(--danger-bg); }
.ro-hidden { display: none !important; }

/* ── Box media gallery ─────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.media-item { position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden; border: 1px solid var(--line-2); background: var(--bg-2); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .media-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; background: rgba(0,0,0,.28); pointer-events: none; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.media-item .media-del { position: absolute; top: 5px; inset-inline-end: 5px; width: 24px; height: 24px; border: none; border-radius: 7px; background: rgba(10,14,19,.78); color: #ff8080; font-size: 13px; cursor: pointer; display: grid; place-items: center; }
.media-item .media-del:hover { background: var(--danger); color: #fff; }

/* Reviewer = read-only: hide create/delete/backup actions (backend also enforces) */
body[data-role="reviewer"] .view .btn.accent,
body[data-role="reviewer"] .view .danger-btn,
body[data-role="reviewer"] .view .icon-btn[data-del],
body[data-role="reviewer"] #backupBtn { display: none !important; }

/* =========================================================
   Mobile / phone — placed LAST so these overrides win.
   Sidebar becomes a slide-in drawer; content goes full width;
   forms single-column; modals become bottom sheets.
   ========================================================= */
.hamburger { display: none; width: 42px; height: 42px; border: 1px solid var(--line-2); border-radius: 11px;
  background: var(--surf-2); color: var(--gold-2); font-size: 19px; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(4,7,11,.6); z-index: 110; }

@media (max-width: 700px) {
  #app { grid-template-columns: 1fr !important; }
  .hamburger { display: inline-flex; order: 1; }

  .sidebar { position: fixed; top: 0; right: 0; height: 100vh; width: 264px;
    transform: translateX(100%); transition: transform .26s ease; z-index: 120; }
  #app.drawer-open .sidebar { transform: translateX(0); box-shadow: -12px 0 40px rgba(0,0,0,.5); }
  #app.drawer-open .drawer-overlay { display: block; }
  .brand-txt, .nav-item span, .ver { display: revert; }

  .two-col { grid-template-columns: 1fr; }
  .view { padding: 16px 13px 76px; }
  .topbar { padding: 11px 14px; gap: 10px; flex-wrap: wrap; }
  .search-wrap { width: 100%; order: 3; }
  .page-head { order: 2; text-align: start; }
  .page-head h1 { font-size: 17px; }

  .page-actions { gap: 10px; }
  .page-actions h2 { font-size: 15px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
  .tile { padding: 15px 16px; }
  .tile .v { font-size: 27px; }

  .form-grid { grid-template-columns: 1fr !important; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn, .modal-foot .ghost, .modal-foot .danger-btn { flex: 1 1 auto; }

  table.data th, table.data td { padding: 10px 9px; }
}

/* ── Print (reports) ───────────────────────────────────── */
@media print {
  .sidebar, .topbar, .hamburger, .drawer-overlay, #backupBtn,
  .page-actions button, [data-csv], .tile .go { display: none !important; }
  #app { grid-template-columns: 1fr !important; }
  body { background: #fff !important; }
  body::before { display: none; }
  .view { padding: 8px; animation: none; }
  .card, .tile { background: #fff !important; border: 1px solid #ccc !important; box-shadow: none !important; color: #111; }
  .card *, .tile * { color: #111 !important; }
  table.data th { background: #eee !important; color: #111 !important; }
  .badge { border: 1px solid #999; }
  @page { size: A4; margin: 12mm; }
}
