/* ==========================================================================
   Fuel Tracker - stylesheet
   ========================================================================== */
:root {
  --bg: #090d16; --surface: #101728; --surface-raised: #162038; --line: #222e4d;
  --tx: #f1f5f9; --mut: #8b9bb4; --pri: #4f46e5; --pri-light: #6366f1;
  --accent: #06b6d4; --emerald: #10b981; --amber: #f59e0b; --rose: #f43f5e;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden], .hide { display: none !important; }
body {
  margin: 0; min-height: 100vh; color: var(--tx); background-color: var(--bg);
  background-image: radial-gradient(at 0% 0%, rgba(79,70,229,.12) 0, transparent 50%),
                    radial-gradient(at 100% 0%, rgba(6,182,212,.08) 0, transparent 50%);
  background-attachment: fixed; font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1140px; margin: 0 auto; padding: 16px 14px 48px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.muted { color: var(--mut); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.err { color: var(--rose); }
.empty { text-align: center; color: var(--mut); padding: 24px; }
.dim { opacity: .55; }
.clickable { cursor: pointer; }
.clickable:hover { background: rgba(99,102,241,.06); }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px; padding: 12px 14px; border-radius: var(--radius);
  background: rgba(16,23,40,.8); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 10px; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 36px; height: 36px; min-width: 36px; border-radius: 10px; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--pri), var(--accent)); box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.brand-icon.admin { background: linear-gradient(135deg, #f59e0b, #f43f5e); box-shadow: 0 4px 12px rgba(244,63,94,.3); }
h1 { font-size: 17px; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
h1 span { background: linear-gradient(90deg, #38bdf8, #818cf8); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
h3 { font-size: 17px; margin: 0; }
nav {
  display: flex; background: var(--bg); border: 1px solid var(--line); padding: 3px; border-radius: 99px;
  overflow-x: auto; max-width: 100%;
}
nav button {
  border: 0; background: none; color: var(--mut); padding: 8px 14px; border-radius: 99px;
  font-weight: 600; font-size: 13px; font-family: inherit; cursor: pointer; white-space: nowrap; min-height: 36px; transition: .2s;
}
nav button.on { background: linear-gradient(135deg, var(--pri), var(--pri-light)); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.4); }
.user-meta { display: flex; align-items: center; gap: 8px; }
.ghost-btn, .timer-badge {
  background: var(--surface-raised); border: 1px solid var(--line); color: var(--mut); border-radius: 10px;
  padding: 8px 12px; font-weight: 600; font-size: 13px; font-family: inherit; text-decoration: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px;
}
.ghost-btn.small { padding: 6px 10px; min-height: 32px; font-size: 12px; }
.timer-badge { font-family: 'JetBrains Mono', monospace; color: #38bdf8; }
.ghost-btn:hover { color: var(--tx); border-color: #33406b; }

.sub-banner {
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); color: #fbbf24;
  padding: 10px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; font-weight: 600;
}

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.card.err { color: var(--rose); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.stat.wide { grid-column: 1 / -1; }
.stat > small, .veh-stats small { display: block; color: var(--mut); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat > div { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono', monospace; letter-spacing: -.02em; overflow-wrap: anywhere; }
.stat > div small { font-size: 13px; color: var(--mut); font-weight: 600; text-transform: none; letter-spacing: 0; margin: 0; }
.stat.err > div { font-size: 15px; color: var(--rose); font-family: inherit; }
.filter-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.filters-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters-row > div { flex: 1 1 170px; min-width: 0; }
.filters-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.form-card { max-width: 720px; margin-left: auto; margin-right: auto; }
.form-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-weight: 800; font-size: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.table-header-wrap { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- forms ---------- */
label {
  display: block; color: var(--mut); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; margin: 0 0 6px;
}
input, select {
  width: 100%; background: #0d1330; border: 1px solid var(--line); color: var(--tx);
  border-radius: 12px; padding: 12px; font-weight: 500; font-size: 15px; font-family: inherit; outline: none; min-height: 44px;
}
input:focus, select:focus { border-color: #6c8cff; box-shadow: 0 0 0 3px rgba(108,140,255,.15); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 18px; margin: 0; accent-color: var(--amber); }
input[type=file] { padding: 10px; }
.chk { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--mut); cursor: pointer; }
.hint { font-size: 12px; color: var(--mut); margin-top: 6px; min-height: 16px; }
.mini-select { width: auto; min-width: 180px; min-height: 36px; padding: 6px 10px; font-size: 13px; }
.table-search { width: 220px; max-width: 100%; min-height: 40px; }
.add-line { display: flex; gap: 8px; }
.add-line input { flex: 1; }
.calc-preview {
  display: flex; justify-content: space-between; align-items: center; margin-top: 12px;
  background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); border-radius: 12px; padding: 10px 14px; color: #6ee7b7; font-size: 13px;
}
.calc-preview strong { font-family: 'JetBrains Mono', monospace; font-size: 15px; }

button { font-family: inherit; }
.btn-primary, .btn-accent, .btn-danger, .btn-pdf, .btn-csv, .btn-wa {
  border: 0; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; min-height: 42px;
}
.btn-primary { width: 100%; margin-top: 14px; background: linear-gradient(135deg, #6c8cff, #8a5cff); box-shadow: 0 6px 18px rgba(108,140,255,.25); }
.btn-accent { background: linear-gradient(135deg, var(--emerald), var(--accent)); padding: 10px 14px; min-height: 40px; font-size: 14px; }
.btn-danger { width: 100%; background: linear-gradient(135deg, #f43f5e, #be123c); }
.btn-pdf { background: linear-gradient(135deg, #ef4444, #f97316); font-size: 13px; padding: 9px 14px; min-height: 36px; }
.btn-csv { background: linear-gradient(135deg, #10b981, #059669); font-size: 13px; padding: 9px 14px; min-height: 36px; }
.btn-wa { background: linear-gradient(135deg, #25d366, #128c7e); font-size: 13px; padding: 9px 14px; min-height: 36px; }
.btn-primary:disabled, .btn-danger:disabled, .btn-accent:disabled { opacity: .55; cursor: wait; }
.btn-del-cell {
  background: rgba(244,63,94,.12); color: var(--rose); border: 1px solid rgba(244,63,94,.3); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer; min-height: 32px;
}
.btn-del-cell:hover { background: rgba(244,63,94,.2); }

.msg { margin-top: 12px; font-size: 14px; min-height: 1em; word-break: break-word; }
.msg.ok { color: var(--emerald); }
.msg.err { color: var(--rose); }
.save-success {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3);
  padding: 8px 12px; border-radius: 999px; color: #6ee7b7; font-weight: 700; font-size: 13px; margin-bottom: 8px;
}
.tick { width: 18px; height: 18px; border-radius: 50%; background: var(--emerald); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.warn-badge { display: inline-block; background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35); color: #fbbf24; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; margin: 0 0 8px; }
.badge-spike { display: inline-block; margin-left: 6px; background: rgba(245,158,11,.15); color: #fbbf24; border-radius: 6px; padding: 2px 6px; font-size: 10px; font-weight: 800; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 11px; font-weight: 800; }
.badge.ok { background: rgba(16,185,129,.14); color: #6ee7b7; }
.badge.warn { background: rgba(245,158,11,.14); color: #fbbf24; }
.badge.bad { background: rgba(244,63,94,.14); color: #fda4af; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--mut); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid rgba(34,46,77,.6); vertical-align: middle; }
td.actions { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.bar-track { height: 4px; background: #0d1330; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar { height: 100%; background: linear-gradient(90deg, var(--pri), var(--accent)); border-radius: 4px; }
.canvas { position: relative; height: 320px; width: 100%; }
.canvas.small { height: 220px; }

/* ---------- lists & settings ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap;
  background: #0d1330; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.list-row input.inline { flex: 1 1 180px; background: transparent; border: 1px dashed transparent; padding: 6px 8px; min-height: 36px; }
.list-row input.inline:focus { border-color: var(--line); background: var(--bg); }
.feat-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #0d1330; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.feat-row.locked { opacity: .55; }
.lock-tag { font-size: 11px; font-weight: 800; color: var(--mut); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; text-transform: uppercase; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; min-height: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #2a3658; border-radius: 99px; transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: linear-gradient(135deg, var(--pri), var(--accent)); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .4; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; margin-top: 8px; }
.feat-item {
  display: flex; gap: 10px; align-items: flex-start; background: #0d1330; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; text-transform: none; letter-spacing: 0; margin: 0; cursor: pointer; color: var(--tx);
}
.feat-item b { display: block; font-size: 13px; font-weight: 700; }
.feat-item small { display: block; color: var(--mut); font-size: 11px; font-weight: 500; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.chip { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: #1a2442; color: #5b6a8f; }
.chip.on { background: rgba(99,102,241,.2); color: #a5b4fc; }

/* ---------- vehicles ---------- */
.veh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.veh-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.veh-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plate {
  font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 17px; letter-spacing: .04em;
  background: #fef3c7; color: #111827; border-radius: 8px; padding: 4px 10px; border: 2px solid #111827;
}
.fuel-tag { font-size: 11px; font-weight: 700; color: #a5b4fc; background: rgba(99,102,241,.15); border-radius: 6px; padding: 3px 8px; }
.veh-label { color: var(--mut); font-size: 13px; margin: 10px 0 12px; }
.veh-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.veh-stats b { font-family: 'JetBrains Mono', monospace; font-size: 15px; }
.veh-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,7,14,.75); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 200;
}
.modal-box {
  width: min(420px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
}
.modal-box.wide { width: min(640px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions > * { flex: 1 1 140px; }
.modal-box .ghost-btn { width: 100%; justify-content: center; }
.modal-box input { margin-bottom: 0; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card.admin { border-color: rgba(245,158,11,.35); }
.login-card input { margin-bottom: 14px; }
.login-card .btn-primary { margin-top: 6px; }
.login-brand { font-size: 34px; text-align: center; margin-bottom: 6px; }
.login-card h1 { text-align: center; margin-bottom: 4px; font-size: 20px; }
.login-card p.muted { text-align: center; margin: 0 0 22px; font-size: 14px; }
.login-switch { text-align: center; margin-top: 18px; font-size: 13px; }
.login-switch a { color: #a5b4fc; text-decoration: none; font-weight: 600; }

/* ---------- admin summary ---------- */
#tab-settings .card, #tab-backup .card { max-width: 820px; }
#tab-backup .btn-primary { margin-top: 14px; }

/* ---------- reminders & records ---------- */
.rem { display: flex; gap: 10px; align-items: baseline; padding: 10px 12px; border-radius: 10px; margin-top: 8px; font-size: 14px; border: 1px solid var(--line); background: #0d1330; }
.rem.danger { border-color: rgba(244,63,94,.45); background: rgba(244,63,94,.08); color: #fecdd3; }
.rem.warn { border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.07); color: #fde68a; }
.rem-veh { font-weight: 800; font-size: 12px; white-space: nowrap; }
.crud-grid { margin-bottom: 8px; }
.crud-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.crud-actions .btn-primary { width: auto; padding: 10px 16px; }

/* ---------- roles ---------- */
.who { font-size: 12px; color: var(--mut); font-weight: 600; white-space: nowrap; }
body.no-del [data-delentry], body.no-del [data-crud-del], body.no-del [data-vdel], body.no-del [data-mdel], body.no-del [data-tdel] { display: none !important; }
body.ro-fuel [data-edit], body.ro-fuel [data-attach], body.ro-fuel [data-delentry] { display: none !important; }
body.ro-vehicles [data-vedit], body.ro-vehicles [data-vdel] { display: none !important; }

/* ==========================================================================
   RESPONSIVE
   Desktop (default) · Tablet (<= 1024px) · Phone (<= 720px)
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.hdr-row { display: none; }

@media (max-width: 1024px) {
  .wrap { max-width: 100%; padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .veh-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}

@media (max-width: 720px) {
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .wrap { padding: 0 10px calc(20px + env(safe-area-inset-bottom)); }

  /* Header: compact, no floating effect (floating + blur would trap the bottom bar) */
  header {
    position: sticky; top: 0; z-index: 60;
    margin: 0 -10px 12px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    border-radius: 0 0 16px 16px; background: rgba(9,13,22,.96);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .brand { gap: 8px; }
  .brand-icon { width: 34px; height: 34px; min-width: 34px; font-size: 16px; }
  h1 { font-size: 15px; }
  .who { display: none; }
  .user-meta { gap: 6px; }
  .ghost-btn, .timer-badge { min-height: 40px; padding: 8px 10px; font-size: 12px; }
  .timer-badge { min-width: 52px; justify-content: center; }

  /* Bottom tab bar replaces the top menu on phones */
  header nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border: 1px solid var(--line); border-width: 1px 0 0 0; border-radius: 18px 18px 0 0;
    background: rgba(16,23,40,.98); justify-content: flex-start; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; box-shadow: 0 -8px 24px rgba(0,0,0,.35);
  }
  header nav::-webkit-scrollbar { display: none; }
  header nav button {
    flex: 0 0 auto; min-width: 70px; min-height: 54px; padding: 6px 8px; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; line-height: 1.15; text-align: center; white-space: normal; color: var(--mut);
  }
  header nav button.on { color: #fff; }
  header nav button::before {
    font-size: 17px; line-height: 1; margin-bottom: 2px;
  }
  header nav button[data-tab="dash"]::before { content: "▦"; }
  header nav button[data-tab="entry"]::before { content: "⛽"; }
  header nav button[data-tab="vehicles"]::before { content: "🚚"; }
  header nav button[data-tab="records"]::before { content: "🔧"; }
  header nav button[data-tab="reports"]::before { content: "📊"; }
  header nav button[data-tab="master"]::before { content: "👥"; }
  header nav button[data-tab="team"]::before { content: "🤝"; }
  header nav button[data-tab="settings"]::before { content: "⚙"; }
  header nav button[data-tab="activity"]::before { content: "🕘"; }
  header nav button[data-tab="users"]::before { content: "👤"; }
  header nav button[data-tab="backup"]::before { content: "💾"; }

  /* Page blocks */
  .sub-banner { margin: 0 0 12px; font-size: 12px; }
  .filter-card, .card { padding: 14px; border-radius: 14px; margin-bottom: 12px; }
  .filters-row { gap: 10px; }
  .filters-row > div { flex: 1 1 100%; }
  .filters-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters-actions > button { margin-top: 0; width: 100%; min-height: 44px; }
  .filters-actions .ghost-btn { grid-column: auto; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .stat { padding: 12px; border-radius: 14px; }
  .stat > div { font-size: 17px; }
  .stat > div small { font-size: 11px; }
  .stat.wide { grid-column: 1 / -1; }
  .canvas { height: 230px; }
  .canvas.small { height: 190px; }
  .form-card { max-width: none; }
  .form-title { font-size: 15px; }
  .row { grid-template-columns: 1fr; gap: 10px; }
  .table-header-wrap { flex-direction: column; align-items: stretch; }
  .table-header-wrap > label { margin-bottom: 0; }
  .table-search, .mini-select { width: 100%; }
  .veh-grid { grid-template-columns: 1fr; gap: 12px; }
  .feat-grid { grid-template-columns: 1fr; }
  .feat-row { padding: 10px 12px; }
  .add-line { flex-direction: column; }
  .add-line > .btn-accent, .add-line > .ghost-btn { width: 100%; }
  .list-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .list-row .actions { display: flex; gap: 8px; }
  .chk { min-height: 40px; }

  /* Touch-friendly controls. 16px inputs stop iOS zooming in */
  input, select, textarea { font-size: 16px; min-height: 48px; }
  input[type=checkbox] { width: 22px; height: 22px; min-height: 22px; }
  .btn-primary, .btn-accent, .btn-danger { min-height: 50px; font-size: 16px; }
  .btn-pdf, .btn-csv, .btn-wa { min-height: 44px; font-size: 14px; }
  .btn-del-cell { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .ghost-btn.small { min-height: 40px; padding: 8px 12px; font-size: 13px; }

  /* Modals become bottom sheets */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box, .modal-box.wide {
    width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .modal-actions { flex-direction: column; }
  .modal-actions > * { flex: 1 1 100%; width: 100%; }

  /* Tables become cards: each row shows label + value */
  .tw { overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  table { font-size: 14px; }
  thead tr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr {
    background: #0d1330; border: 1px solid var(--line); border-radius: 14px;
    padding: 6px 12px; margin-bottom: 10px;
  }
  tbody tr.hdr-row { display: none; }
  tbody tr.clickable:hover { background: #0d1330; }
  td {
    border: 0; padding: 8px 0; text-align: right; font-size: 14px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border-bottom: 1px dashed rgba(34,46,77,.7); overflow-wrap: anywhere;
  }
  tbody tr td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label); color: var(--mut); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; text-align: left; flex-shrink: 0;
  }
  td:not([data-label])::before, td[data-label=""]::before { content: none; }
  td[colspan] { display: block; text-align: center; }
  td:first-child { display: block; text-align: left; }
  td:first-child::before { display: block; margin-bottom: 4px; }
  td.actions { justify-content: flex-end; flex-wrap: wrap; }
  td.actions:not([data-label])::before { content: none; }
  .bar-track { margin-top: 6px; }

  /* Login card on phones */
  .login-card { padding: 22px; border-radius: 18px; }
}

@media (max-width: 380px) {
  .stat > div { font-size: 15px; }
  header nav button { min-width: 64px; font-size: 10px; }
  .who { display: none; }
}

@media (min-width: 721px) {
  header nav button::before { content: none; }
}
