:root {
  --bg:#0f1220; --panel:#171a2b; --panel2:#1e2238; --line:#2a2f4a;
  --text:#e7e9f3; --muted:#9aa0bf; --accent:#6c7bff; --accent2:#4cd1a0;
  --danger:#ff6b6b; --warn:#ffb454; --radius:12px;
  color-scheme:dark; /* native UI (scrollbars etc.) renders in dark mode */
}
* { box-sizing:border-box; }
body { margin:0; font:15px/1.5 -apple-system,"Segoe UI",Roboto,sans-serif;
  background:linear-gradient(180deg,#0c0f1c,var(--bg)); color:var(--text); min-height:100vh; }
a { color:var(--accent); }
.muted { color:var(--muted); }
.spacer { flex:1; }
.hidden { display:none !important; }

#topbar { display:flex; align-items:center; gap:16px; padding:12px 20px; background:var(--panel);
  border-bottom:1px solid var(--line); position:sticky; top:0; z-index:10; }
.brand { font-weight:700; font-size:17px; }
#nav { display:flex; gap:4px; flex-wrap:wrap; }
#nav a { padding:7px 12px; border-radius:9px; color:var(--muted); text-decoration:none; font-weight:600; cursor:pointer; }
#nav a:hover { background:var(--panel2); color:var(--text); }
#nav a.active { background:var(--accent); color:#fff; }
#whoami { font-size:13px; }

main { padding:24px; max-width:1100px; margin:0 auto; }
.loader,.empty { color:var(--muted); padding:36px; text-align:center; }
h1 { font-size:22px; margin:0 0 6px; }
.sub { color:var(--muted); margin:0 0 18px; }
h2 { font-size:16px; margin:0 0 12px; }

.card { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:18px; margin-bottom:16px; }
.grid { display:grid; gap:14px; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); }
.stat { background:var(--panel2); border-radius:var(--radius); padding:16px; }
.stat .v { font-size:23px; font-weight:700; }
.stat .k { color:var(--muted); font-size:13px; margin-top:4px; }

.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; border:0; border-radius:9px; padding:9px 14px; font-weight:600; cursor:pointer; background:var(--accent); color:#fff; font-size:14px; line-height:1.1; white-space:nowrap; }
.btn:hover { filter:brightness(1.08); }
.btn:disabled { opacity:.5; cursor:default; }
.btn.ghost { background:transparent; border:1px solid var(--line); color:var(--text); }
.btn.ok { background:var(--accent2); color:#06281d; }
.btn.warn { background:var(--warn); color:#3a2400; }
.btn.danger { background:var(--danger); }
.btn.sm { padding:5px 10px; font-size:13px; }
.row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

label { display:block; font-size:13px; color:var(--muted); margin:10px 0 4px; }
input,select,textarea { width:100%; padding:10px 12px; border-radius:9px; border:1px solid var(--line);
  background:var(--panel2); color:var(--text); font:inherit; }
input:focus,select:focus,textarea:focus { outline:2px solid var(--accent); border-color:transparent; }
form.narrow { max-width:440px; }
/* Make native dropdown options readable on the dark theme + custom arrow. */
select { appearance:none; -webkit-appearance:none; cursor:pointer; padding-right:34px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa0bf' d='M6 8 1 3h10z'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center; }
select option { background:var(--panel2); color:var(--text); }

/* Password field with a show/hide toggle. */
.pw { position:relative; }
.pw input { padding-right:44px; }
.pw-toggle { position:absolute; right:6px; top:50%; transform:translateY(-50%); width:auto;
  background:transparent; border:0; cursor:pointer; font-size:16px; color:var(--muted); padding:4px 6px; line-height:1; }
.pw-toggle:hover { color:var(--text); }

/* Custom dropdown (replaces native <select>). */
.cselect { position:relative; width:100%; }
.cselect[data-inline] { display:inline-block; width:auto; min-width:150px; vertical-align:middle; }
.cselect-ctrl { width:100%; display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:10px 12px; border-radius:9px; border:1px solid var(--line); background:var(--panel2);
  color:var(--text); font:inherit; cursor:pointer; text-align:left; }
.cselect[data-inline] .cselect-ctrl { padding:6px 10px; font-size:13px; }
.cselect-ctrl:hover { border-color:var(--accent); }
.cselect.open .cselect-ctrl { outline:2px solid var(--accent); border-color:transparent; }
.cselect-arr { color:var(--muted); font-size:12px; }
.cselect-menu { position:absolute; z-index:40; left:0; right:0; top:calc(100% + 4px); background:var(--panel);
  border:1px solid var(--line); border-radius:10px; padding:5px; max-height:280px; overflow:auto;
  box-shadow:0 12px 34px rgba(0,0,0,.45); }
.cselect[data-inline] .cselect-menu { right:auto; min-width:100%; white-space:nowrap; }
.cselect-opt { padding:9px 11px; border-radius:7px; cursor:pointer; }
.cselect-opt:hover { background:var(--panel2); }

/* Custom calendar date field. */
.cdate { position:relative; width:100%; min-width:160px; }
.cdate-ctrl { width:100%; display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:10px 12px; border-radius:9px; border:1px solid var(--line); background:var(--panel2);
  color:var(--text); font:inherit; cursor:pointer; text-align:left; }
.cdate-ctrl:hover { border-color:var(--accent); }
.cdate.open .cdate-ctrl { outline:2px solid var(--accent); border-color:transparent; }
.cdate-val.ph { color:var(--muted); }
.cdate-ic { font-size:14px; }
.cdate-pop { position:absolute; z-index:45; left:0; top:calc(100% + 4px); width:266px; box-sizing:border-box;
  background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:10px; box-shadow:0 12px 34px rgba(0,0,0,.45); }
.cdate-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.cdate-title { font-weight:600; }
.cdate-nav { background:transparent; border:1px solid var(--line); color:var(--text); border-radius:8px;
  width:30px; height:30px; cursor:pointer; font-size:17px; line-height:1; }
.cdate-nav:hover { border-color:var(--accent); }
.cdate-grid { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:3px; width:100%; }
.cdate-wd { display:flex; align-items:center; justify-content:center; font-size:11px; color:var(--muted); height:24px; }
.cdate-day { display:flex; align-items:center; justify-content:center; width:100%; height:32px; min-width:0; padding:0;
  margin:0; background:transparent; border:0; color:var(--text); border-radius:8px; cursor:pointer; font:inherit; line-height:1; }
.cdate-day:hover:not(.empty) { background:var(--panel2); }
.cdate-day.empty { cursor:default; pointer-events:none; }
.cdate-day.today { outline:1px solid var(--line); outline-offset:-1px; }
.cdate-day.sel { background:var(--accent); color:#fff; font-weight:700; }
.cdate-foot { display:flex; justify-content:space-between; margin-top:8px; }
.cdate-act { background:transparent; border:0; color:var(--accent); cursor:pointer; font:inherit; font-size:13px; padding:4px 6px; }
.cdate-act:hover { text-decoration:underline; }

table { width:100%; border-collapse:collapse; }
th,td { text-align:left; padding:10px 8px; border-bottom:1px solid var(--line); font-size:14px; vertical-align:top; }
th { color:var(--muted); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
tr:hover td { background:rgba(255,255,255,.02); }

.badge { display:inline-block; padding:3px 9px; border-radius:999px; font-size:12px; font-weight:700; white-space:nowrap; }
.badge.gray { background:#2a2f4a; color:#b9c0e0; }
.badge.green { background:rgba(76,209,160,.18); color:var(--accent2); }
.badge.blue { background:rgba(108,123,255,.2); color:#aeb8ff; }
.badge.amber { background:rgba(255,180,84,.18); color:var(--warn); }
.badge.red { background:rgba(255,107,107,.18); color:var(--danger); }

.center { min-height:84vh; display:grid; place-items:center; }
.auth { width:360px; }
.auth h1 { text-align:center; }
.linkrow { text-align:center; margin-top:14px; font-size:14px; }
.code { font-family:ui-monospace,monospace; font-size:24px; letter-spacing:3px; background:var(--panel2);
  padding:14px; border-radius:9px; text-align:center; margin:10px 0; }
.filters { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.filters select,.filters input { width:auto; min-width:150px; }
small.mono { font-family:ui-monospace,monospace; color:var(--muted); }
.toast { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); background:var(--panel2);
  border:1px solid var(--line); padding:12px 18px; border-radius:10px; z-index:50; max-width:90vw; }
.toast.err { border-color:var(--danger); }
.toast.ok { border-color:var(--accent2); }
.actions { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
td.mid { vertical-align:middle; }
/* Couriers table: each action is its own column → buttons line up across rows.
   Buttons fill their column so every row's button has identical width. */
.couriers td.act, .orders td.act { padding:8px 6px; }
.couriers td.act .btn, .orders td.act .btn { width:100%; }
.couriers .cselect[data-inline], .orders .cselect[data-inline] { min-width:0; width:100%; }
/* High-value toggle: ✓/✗ marker has a fixed width so the label never shifts. */
.hvbtn { justify-content:flex-start; }
.hvbtn .mk { display:inline-block; width:12px; text-align:center; }
.tglink { font-family:ui-monospace,monospace; font-size:13px; white-space:nowrap; }

/* Modal (in-app prompt). */
.modal-ov { position:fixed; inset:0; background:rgba(6,8,18,.6); display:grid; place-items:center; z-index:100; }
.modal { width:360px; max-width:92vw; background:var(--panel); border:1px solid var(--line);
  border-radius:var(--radius); padding:20px; box-shadow:0 18px 50px rgba(0,0,0,.5); }
.modal h3 { margin:0 0 12px; font-size:17px; }
.modal .pw { margin-top:4px; }
.modal-err { color:var(--danger); font-size:13px; margin-top:8px; }
.modal-row { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
