/* ==========================================================================
   Collection Pager Pro - web-app styles (dashboard, terminal, super admin)
   Mobile first. Plain CSS, no frameworks.
   ========================================================================== */

:root {
  --navy: #14213d;
  --navy-2: #1f3160;
  --amber: #fca311;
  --amber-dark: #e08e00;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e3e6ef;
  --text: #121826;
  --text-2: #4b5368;
  --muted: #6b7286;
  --good: #128a4b;
  --good-bg: #e3f6ec;
  --warn: #a15c00;
  --warn-bg: #fff3dc;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --info: #1d5fc4;
  --info-bg: #e7f0fd;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 40px rgba(16, 24, 40, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1424;
    --surface: #172036;
    --surface-2: #1c2741;
    --border: #2a3654;
    --text: #eef1f8;
    --text-2: #c2c8d8;
    --muted: #97a0b6;
    --good: #43c486;
    --good-bg: #133626;
    --warn: #f5b84d;
    --warn-bg: #3a2c10;
    --bad: #ff7b7b;
    --bad-bg: #3d1a1d;
    --info: #79aaf5;
    --info-bg: #182b4d;
    --series-1: #3987e5;
    --series-2: #d95926;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1424; --surface: #172036; --surface-2: #1c2741; --border: #2a3654;
  --text: #eef1f8; --text-2: #c2c8d8; --muted: #97a0b6;
  --series-1: #3987e5; --series-2: #d95926;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, .mono-box { font-family: var(--mono); font-size: .9em; }
img { max-width: 100%; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }

/* ---------- Layout ---------- */
.main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.page-head { margin-bottom: 20px; }
.page-head h1 i { color: var(--amber); }
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
.grid-top { align-items: start; gap: 16px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Top bar / navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--navy); color: #fff; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  box-shadow: 0 2px 12px rgba(0, 0, 0, .15);
}
.topbar-admin { background: #2b1747; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.brand i { color: var(--amber); font-size: 1.3rem; }
.brand:hover { text-decoration: none; }
.nav-toggle { background: none; border: 0; color: #fff; font-size: 1.4rem; padding: 6px 8px; cursor: pointer; }
.nav { display: none; width: 100%; flex-direction: column; padding: 8px 0 4px; }
.nav.open { display: flex; }
.nav a { color: #dfe5f5; padding: 11px 10px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 12px; }
.nav a i { width: 20px; text-align: center; color: var(--amber); }
.nav a:hover, .nav a.active { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }
@media (min-width: 1100px) {
  .nav-toggle { display: none; }
  .nav { display: flex; flex-direction: row; width: auto; padding: 0; gap: 2px; }
  .nav a { padding: 8px 10px; font-size: .92rem; gap: 7px; }
}
.impersonate-bar { background: #6d28d9; color: #fff; text-align: center; padding: 8px 12px; font-size: .9rem; }
.impersonate-bar a { color: #fff; text-decoration: underline; font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.form-card { max-width: 720px; }
.section-title { font-size: 1.05rem; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--amber); }
h2.section-title + .kpi-grid { margin-top: 0; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 14px; color: var(--text-2); }
label small { font-weight: 400; display: block; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 25%, transparent); }
textarea { resize: vertical; min-height: 120px; }
.input-icon { position: relative; display: block; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); margin-top: 3px; color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 42px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--amber); flex-shrink: 0; }
.code-input { text-align: center; font-size: 1.8rem !important; letter-spacing: .35em; font-family: var(--mono); margin-bottom: 14px; }
.captcha { margin: 6px 0 16px; min-height: 78px; display: flex; justify-content: center; }
.inline-form { display: inline; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent; min-height: 44px;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #1b1300; }
.btn-primary:hover { background: var(--amber-dark); border-color: var(--amber-dark); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.92); border-color: var(--bad); }
.btn-danger-outline { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.btn-danger-outline:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-link { background: none; border: 0; color: var(--info); padding: 8px 4px; min-height: 0; }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 24px; font-size: 1.05rem; }
.btn-sm { padding: 7px 12px; font-size: .85rem; min-height: 36px; }
.btn-icon { padding: 7px 10px; min-height: 36px; }
.btn-hero {
  font: inherit; font-size: 1.25rem; font-weight: 800; width: 100%; max-width: 520px;
  padding: 22px 26px; border: 0; border-radius: 18px; cursor: pointer; color: #1b1300;
  background: linear-gradient(135deg, #ffc046, var(--amber) 55%, #f48c06);
  box-shadow: 0 10px 30px rgba(252, 163, 17, .35); display: inline-flex; align-items: center; justify-content: center; gap: 12px;
}
.btn-hero:disabled { filter: grayscale(1); opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Alerts / badges ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .95rem; }
.alert i { margin-top: 3px; }
.alert-success { background: var(--good-bg); color: var(--good); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--info); }
.auth-card .alert, .main > .alert { width: 100%; }
.main > .alert { max-width: 1180px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); vertical-align: middle; text-transform: none; }
.badge-good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge-warn, .badge-warning { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-error, .badge-security { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-muted { opacity: .8; }
.callout { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 16px 18px; border-radius: var(--radius); margin-bottom: 20px; }
.callout > i { font-size: 1.6rem; }
.callout > div { flex: 1; min-width: 200px; }
.callout p { margin: 2px 0 0; }
.callout-warning { background: var(--warn-bg); color: var(--warn); }
.callout-info { background: var(--info-bg); color: var(--info); }

/* ---------- Auth ---------- */
.area-auth { background: radial-gradient(circle at 20% 0%, #24386b 0%, var(--navy) 55%, #0a1226 100%); }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px;
  padding: 30px 24px; box-shadow: var(--shadow-lg);
}
.auth-card-wide { max-width: 620px; }
.auth-card h1 { text-align: center; font-size: 1.5rem; }
.auth-logo { width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; font-size: 1.9rem; background: var(--navy); color: var(--amber); }
.auth-logo-admin { background: #2b1747; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 18px; font-size: .9rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.checklist .ok i { color: var(--good); }
.checklist .bad { color: var(--bad); }
.checklist .warn i { color: var(--warn); }
.mono-box { display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; word-break: break-all; margin-top: 6px; }

/* ---------- Dashboard ---------- */
.hero-action { margin: 6px 0 22px; text-align: center; }
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 22px; }
@media (min-width: 860px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; display: block; }
.kpi-label i { color: var(--amber); }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-value-sm { font-size: 1.1rem; }
.kpi-sub, .kpi-delta { font-size: .8rem; color: var(--muted); }
.kpi-delta.up { color: var(--good); }
.kpi-delta.down { color: var(--bad); }
.tile-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
.tile:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--amber); }
.tile i { grid-row: span 2; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--navy); color: var(--amber); font-size: 1.3rem; }
.tile span { color: var(--muted); font-size: .88rem; }
.start-terminal { max-width: 620px; margin: 30px auto; padding: 34px 22px; }
.big-icon { font-size: 3rem; color: var(--amber); margin-bottom: 12px; }
.steps { padding-left: 20px; }
.totp-setup { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-bottom: 16px; }
.qr-box { width: 200px; height: 200px; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--border); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.billing-status { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 18px; }
.billing-status > div { display: flex; flex-direction: column; gap: 4px; }

/* Images */
.progress-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: .9rem; color: var(--muted); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress span { display: block; height: 100%; background: var(--amber); border-radius: 99px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px 16px; cursor: pointer;
  background: var(--surface-2); transition: border-color .15s;
}
.dropzone:hover { border-color: var(--amber); }
.dropzone > i { font-size: 2.2rem; color: var(--amber); }
.dropzone input[type=file] { margin-top: 10px; max-width: 100%; font-size: .85rem; }
.image-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .image-grid { grid-template-columns: repeat(4, 1fr); } }
.image-card { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.image-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.image-card figcaption { display: flex; gap: 6px; align-items: center; padding: 8px; }
.image-pos { font-weight: 700; color: var(--muted); margin-right: auto; font-size: .85rem; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty i { font-size: 2.6rem; margin-bottom: 8px; display: block; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-logs td { font-size: .85rem; }
.ctx summary { cursor: pointer; color: var(--info); font-size: .8rem; }
.ctx pre { font-size: .75rem; background: var(--surface-2); padding: 8px; border-radius: 8px; overflow-x: auto; max-width: 480px; white-space: pre-wrap; word-break: break-all; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin: 20px 0; }
.pager a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.pager a.active { background: var(--amber); border-color: var(--amber); color: #1b1300; }

/* ---------- Super admin ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-bar input, .filter-bar select { margin: 0; flex: 1 1 180px; width: auto; }
.filter-grid { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .filter-grid { grid-template-columns: repeat(4, 1fr); } }
.filter-actions { display: flex; gap: 10px; align-items: end; margin-bottom: 14px; }
.account-card { display: flex; flex-direction: column; gap: 12px; }
.account-card h3 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.account-card p { margin: 4px 0 8px; }
.meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; margin: 0; font-size: .88rem; }
@media (min-width: 720px) { .meta { grid-template-columns: repeat(3, 1fr); } }
.meta dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.meta dd { margin: 0; }
.meta-block { grid-template-columns: 1fr !important; margin-bottom: 16px; }
.inline-delete { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-delete input { width: auto; margin: 0; flex: 1 1 160px; }
.log-mini { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 10px; font-size: .9rem; }
.log-mini small { display: block; }
.sticky-save { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); margin-bottom: 16px; }

/* ---------- Stats ---------- */
.stats-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: flex-end; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; box-shadow: var(--shadow); }
.segmented button { font: inherit; font-size: .88rem; font-weight: 600; border: 0; background: none; color: var(--text-2); padding: 8px 12px; border-radius: 9px; cursor: pointer; min-height: 38px; }
.segmented button.active { background: var(--navy); color: #fff; }
.segmented-sm button { font-size: .8rem; padding: 6px 10px; min-height: 32px; }
.stats-loading { text-align: center; padding: 60px; font-size: 2rem; color: var(--amber); }
.kpi-grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpi-grid-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi-hero { background: linear-gradient(140deg, var(--navy), var(--navy-2)); color: #fff; border: 0; }
.kpi-hero .kpi-label { color: #b9c3dd; }
.kpi-hero .kpi-delta { color: #c7cfe4; }
.kpi-hero .kpi-delta.up { color: #6ee7a8; }
.kpi-hero .kpi-delta.down { color: #ffa4a4; }
.chart-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .chart-grid { grid-template-columns: 1fr 1fr; } .chart-wide { grid-column: span 2; } }
.chart-card { margin: 0; }
.chart-card h2 { font-size: 1rem; }
.chart-box { position: relative; height: 260px; }
.heat-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.heat-head h2 { margin: 0; }
.heatmap { display: grid; grid-template-columns: 38px repeat(24, minmax(14px, 1fr)); gap: 2px; overflow-x: auto; padding-bottom: 6px; min-width: 0; }
.heatmap .hm-cell { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); cursor: default; transition: transform .1s; min-width: 14px; }
.heatmap .hm-cell:hover { transform: scale(1.25); outline: 2px solid var(--surface); position: relative; z-index: 2; }
.heatmap .hm-day, .heatmap .hm-hour { font-size: .7rem; color: var(--muted); display: flex; align-items: center; }
.heatmap .hm-hour { justify-content: center; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--muted); margin-top: 8px; }
.heat-scale { flex: 0 1 180px; height: 10px; border-radius: 99px; background: linear-gradient(90deg, #deebfb, #2a78d6, #0d3a75); }
.heat-scale.avg { background: linear-gradient(90deg, #fde4d8, #eb6834, #8a2a07); }
.tooltip { position: fixed; z-index: 300; pointer-events: none; background: var(--navy); color: #fff; font-size: .8rem; padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 220px; }
.table-view summary { cursor: pointer; font-weight: 600; }
.table-view .table-wrap { max-height: 360px; overflow-y: auto; margin-top: 10px; }

/* ---------- Terminal ---------- */
.area-terminal { background: #0b1222; color: #eef1f8; }
.terminal-main { min-height: 100vh; }
.term { min-height: 100vh; display: flex; flex-direction: column; }
.term-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--navy); border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.term-title { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; min-width: 0; }
.term-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-title i { color: var(--amber); }
a.term-title:hover { text-decoration: none; }
.term-links { display: flex; gap: 4px; align-items: center; }
.term-links a { color: #cdd5ea; padding: 8px 10px; border-radius: 9px; display: flex; gap: 7px; align-items: center; font-size: .9rem; }
.term-links a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; }
.term-links a span { display: none; }
@media (min-width: 700px) { .term-links a span { display: inline; } }
.term-grid { flex: 1; display: grid; grid-template-columns: 1fr; gap: 14px; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
@media (min-width: 820px) { .term-grid { grid-template-columns: 1fr 1fr; gap: 22px; padding: 22px; } }
.term-left, .term-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.btn-add-order {
  font: inherit; font-size: 1.5rem; font-weight: 800; color: #1b1300; border: 0; border-radius: 18px;
  padding: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(135deg, #ffc046, var(--amber) 55%, #f48c06); box-shadow: 0 10px 30px rgba(252, 163, 17, .3);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn-add-order:active { transform: scale(.98); }
.term-upcoming { background: #131d34; border: 1px solid #22304f; border-radius: 18px; padding: 14px; }
.term-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.term-sub h2 { font-size: 1rem; margin: 0; color: #cdd5ea; }
.term-sub h2 i { color: var(--amber); }
.term-avg { font-size: .85rem; color: #9fb0d6; }
.order-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.order-list li button {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  font: inherit; color: #fff; background: #1b2744; border: 2px solid #26375e; border-radius: 14px;
  padding: 12px 14px; cursor: pointer; touch-action: manipulation; transition: background .15s, border-color .15s;
}
.order-list li button:hover { border-color: #3a5288; }
.order-list li button.confirming { background: var(--good); border-color: var(--good); }
.order-list .o-num { font-size: 1.7rem; font-weight: 800; min-width: 64px; font-variant-numeric: tabular-nums; }
.order-list .o-meta { flex: 1; display: flex; flex-direction: column; font-size: .82rem; color: #9fb0d6; }
.order-list .o-meta strong { color: #fff; font-size: .95rem; }
.order-list .o-go { font-size: 1.3rem; color: var(--amber); }
.order-list .empty-row { text-align: center; color: #7d8bb0; padding: 18px; }
.keypad-display {
  background: #050a16; border: 2px solid #22304f; border-radius: 16px; min-height: 84px;
  display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: 800;
  letter-spacing: .08em; font-variant-numeric: tabular-nums; color: var(--amber);
}
.kp-placeholder { font-size: 1.05rem; font-weight: 500; letter-spacing: 0; color: #5d6d93; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  font: inherit; font-size: 2rem; font-weight: 700; color: #fff; background: #1b2744; border: 0;
  border-radius: 16px; padding: 16px 0; cursor: pointer; min-height: 70px; touch-action: manipulation;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); -webkit-tap-highlight-color: transparent; user-select: none;
}
.keypad button:active { background: #2b3c66; transform: scale(.97); }
.keypad .kp-fn { font-size: 1.5rem; color: #9fb0d6; background: #141e36; }
.btn-ready {
  font: inherit; font-size: 1.3rem; font-weight: 800; color: #fff; border: 0; border-radius: 16px;
  padding: 20px; cursor: pointer; background: linear-gradient(135deg, #1fae63, #128a4b); touch-action: manipulation;
  display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 24px rgba(18, 138, 75, .3);
}
.btn-ready:disabled { opacity: .5; }
.btn-ready:active { transform: scale(.98); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.qr-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(5, 10, 22, .92); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.qr-panel { background: #fff; color: #121826; border-radius: 24px; padding: 22px 20px; width: 100%; max-width: 440px; text-align: center; animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.qr-label { margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #6b7286; font-size: .8rem; }
.qr-number { font-size: 5rem; font-weight: 900; line-height: 1; margin: 4px 0 8px; color: var(--navy); font-variant-numeric: tabular-nums; }
.qr-code { width: min(300px, 70vw); aspect-ratio: 1; margin: 10px auto 16px; }
.qr-code svg { width: 100%; height: 100%; display: block; }
.qr-actions { display: grid; gap: 10px; }
.qr-panel .btn { background: #f4f5f9; color: #121826; border-color: #e3e6ef; }
.qr-panel .btn-primary { background: var(--amber); border-color: var(--amber); color: #1b1300; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 400; max-width: calc(100% - 32px); padding: 14px 20px; border-radius: 14px; font-weight: 600;
  background: #1b2744; color: #fff; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center;
}
.toast.good { background: var(--good); }
.toast.bad { background: #c62828; }

/* All orders */
.all-orders-wrap { padding: 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.all-orders-wrap h1 { font-size: 1.3rem; display: flex; gap: 10px; align-items: center; }
.order-table { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.order-table li { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: #131d34; border: 1px solid #22304f; border-radius: 14px; padding: 12px 14px; }
.order-table .o-num { font-size: 1.8rem; font-weight: 800; min-width: 70px; }
.order-table .o-meta { flex: 1; min-width: 140px; font-size: .85rem; color: #9fb0d6; display: flex; flex-direction: column; }
.order-table .o-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.order-table .btn { background: #1b2744; color: #fff; border-color: #2a3a63; }
.order-table .btn-collect { background: var(--good); border-color: var(--good); }
.order-table .btn-cancel { color: #ff9c9c; }
.order-table .empty-row { justify-content: center; color: #7d8bb0; padding: 30px; }
.area-terminal .badge-info { background: #213760; color: #cfe0ff; }

/* ---------- Confirm modal ---------- */
.cpp-modal { position: fixed; inset: 0; z-index: 500; background: rgba(5, 10, 22, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.cpp-modal-card { background: var(--surface); color: var(--text); border-radius: 18px; padding: 24px 20px 18px; max-width: 400px; width: 100%; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; text-align: center; }
.cpp-modal-card .modal-icon { font-size: 2rem; color: var(--warn); margin-bottom: 8px; }
.cpp-modal-card p { font-size: 1.05rem; font-weight: 600; }
.cpp-modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media print { .topbar, .nav, .btn { display: none !important; } }
