:root {
  --navy: #0B3556;
  --navy-dark: #082741;
  --amber: #C97A21;
  --amber-dark: #A9640F;
  --bg: #F5F6F4;
  --paper: #FFFFFF;
  --ink: #1F2A33;
  --ink-soft: #5B6B77;
  --line: #D7DCE1;
  --line-soft: #E7EAED;
  --green: #2F7D5A;
  --green-bg: #E6F2EC;
  --amber-bg: #FBEEDD;
  --red: #B23A34;
  --red-bg: #FBEAE9;
  --yellow: #D4A600;
  --yellow-bg: #FFF9DB;
  --header-fill: #D9E2F3;
  --banner-fill: #2E75B6;
  --radius: 8px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; color: var(--navy); }

.hidden { display: none !important; }
.hidden-screen { display: none; }

button { font-family: var(--font-body); cursor: pointer; }
svg { display: block; }

/* ---------------- Buttons ---------------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--amber); color: #fff; box-shadow: 0 4px 12px rgba(201,122,33,0.28); }
.btn-primary:hover { background: var(--amber-dark); box-shadow: 0 6px 16px rgba(201,122,33,0.34); transform: translateY(-1px); }
.btn-primary:active { box-shadow: 0 2px 6px rgba(201,122,33,0.24); transform: translateY(1px) scale(0.98); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-dark); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-block { width: 100%; }
.btn-danger-text { color: var(--red); border-color: var(--red-bg); }
.btn-danger-text:hover { background: var(--red-bg); }
.btn-icon-danger {
  border: none; background: transparent; color: var(--ink-soft);
  font-size: 15px; line-height: 1; padding: 6px 8px; border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-icon-danger:hover { background: var(--red-bg); color: var(--red); }

.link-btn {
  border: none; background: transparent; color: var(--amber-dark);
  font-size: 12.5px; font-weight: 600; padding: 2px 0; text-align: left;
  align-self: flex-start;
}
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  border: 1px solid var(--line); background: var(--paper); color: var(--navy);
  border-radius: 10px; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--line-soft); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 18px; height: 18px; }

/* Keyboard focus for every button-like control — was previously missing,
   so tabbing through fell back to the browser's default blue outline,
   which clashed with the navy/amber palette. */
.btn:focus-visible,
.icon-btn:focus-visible,
.picker-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--amber);
}
.btn-primary:focus-visible { box-shadow: 0 0 0 2px var(--amber), 0 0 0 4px var(--amber-bg); }

/* ---------------- Fields ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.field span { font-weight: 600; letter-spacing: 0.01em; }
.field input, .field textarea {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  outline: none;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 56px; }
.field input:focus, .field textarea:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }

/* Live amount/volume preview shown under the entry field */
.amount-preview-box {
  display: none;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--yellow-bg);
  border: 1.5px solid var(--yellow);
  border-radius: var(--radius);
}
.amount-preview-box.visible { display: flex; }
.amount-preview-main {
  font-family: var(--font-mono);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
}
.amount-preview-words {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.35;
}
.amount-preview-words:empty { display: none; }

/* Password field with a show/hide eye button */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--ink-soft);
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.pw-toggle:hover { background: var(--line-soft); }
.pw-toggle svg { width: 18px; height: 18px; }

/* A field that opens a bottom sheet instead of a native <select> */
.picker-btn {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); width: 100%; text-align: left;
}
.picker-btn:hover { border-color: var(--amber); }
.picker-btn .chev { width: 16px; height: 16px; color: var(--ink-soft); transform: rotate(90deg); flex-shrink: 0; }

/* ================= AUTH / RECOVERY / ONBOARD SCREENS ================= */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  background:
    radial-gradient(circle at 15% 10%, rgba(201,122,33,0.10), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(11,53,86,0.12), transparent 50%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 12px 32px rgba(11,53,86,0.08);
}
.onboard-card { max-width: 460px; max-height: 88vh; overflow-y: auto; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-mark { width: 40px; height: 40px; flex-shrink: 0; }
.brand h1 { font-size: 19px; }
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }

.auth-tabs { display: flex; background: var(--bg); border-radius: var(--radius); padding: 3px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 8px 4px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  border-radius: 6px;
}
.auth-tab.active { background: var(--paper); color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

#authForm { display: flex; flex-direction: column; gap: 14px; }
.auth-msg { min-height: 18px; font-size: 13px; color: var(--red); margin: 12px 0 0; }
.auth-msg.success { color: var(--green); }
.auth-note { font-size: 12px; color: var(--ink-soft); margin-top: 14px; line-height: 1.5; }

#resetRequestBlock { display: flex; flex-direction: column; gap: 14px; }

.onboard-tank-rows { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.onboard-tank-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.onboard-tank-row input { font-family: var(--font-body); font-size: 13.5px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.onboard-tank-row input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }

/* ================= APP SHELL ================= */
.app-screen { min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 rgba(11,53,86,0);
  transition: box-shadow 0.25s ease;
}
/* Soft ambient glow, echoes the amber radial used on the auth screen so
   the two feel like one visual language. Purely decorative, sits behind
   the content. */
.app-topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% -20%, rgba(201,122,33,0.35), transparent 55%);
  pointer-events: none;
}
/* A thin amber line along the bottom edge with a slow ambient sweep —
   a nod to a flowing fuel line / gauge rather than decoration for its
   own sake. Very slow and low-contrast so it never competes with the
   content above it. */
.app-topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber) 45%, #FFD873 50%, var(--amber) 55%, transparent);
  background-size: 220% 100%;
  animation: topbar-line-sweep 7s ease-in-out infinite;
}
@keyframes topbar-line-sweep {
  0% { background-position: 100% 0; }
  50% { background-position: 0% 0; }
  100% { background-position: 100% 0; }
}
/* Once the page has scrolled under the sticky bar, lift it off the
   content with a real shadow (class toggled by ui.js). */
.app-topbar.is-scrolled { box-shadow: 0 6px 18px rgba(8,39,65,0.28); }

.topbar-text, .role-badge { position: relative; z-index: 1; } /* sit above ::before glow */
.topbar-text strong {
  display: block; font-family: var(--font-display); font-size: 16px;
  animation: topbar-in 0.32s ease both;
}
.topbar-sub {
  font-size: 12px; color: #C9D6E0;
  animation: topbar-in 0.32s ease 0.03s both;
}
@keyframes topbar-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.role-badge {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.22);
  color: #fff; white-space: nowrap; flex-shrink: 0;
  animation: topbar-badge-in 0.3s ease 0.08s both;
}
@keyframes topbar-badge-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* Logout / ghost buttons living inside the navy topbar want a white-tinted
   hover instead of the light-gray one meant for paper backgrounds. */
.app-topbar .btn-ghost { transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease; }
.app-topbar .btn-ghost:hover { background: rgba(255,255,255,0.14); }

.app-main {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px calc(100px + var(--safe-bottom));
}

.screen-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.screen-title { font-size: 18px; }
.screen-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.block-title { font-size: 15px; margin-bottom: 4px; }
.block-sub { margin: 0 0 12px; font-size: 12px; color: var(--ink-soft); line-height: 1.4; }

.settings-block {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.save-status { font-size: 12.5px; color: var(--green); min-height: 16px; }
.account-actions { display: flex; flex-direction: column; gap: 10px; }

.manage-list { display: flex; flex-direction: column; gap: 8px; }
.manage-item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 10px;
  background: #FBFCFB;
}
.manage-item input[type="text"] {
  border: 1px solid transparent; background: transparent; font-size: 13.5px;
  padding: 6px 8px; border-radius: 6px; flex: 1.4; min-width: 0; font-weight: 600; color: var(--ink);
}
.manage-item input[type="number"] {
  border: 1px solid transparent; background: transparent; font-family: var(--font-mono);
  font-size: 13px; padding: 6px 8px; border-radius: 6px; width: 100px; color: var(--ink-soft);
}
.manage-item input:focus { outline: none; border-color: var(--amber); background: var(--paper); box-shadow: 0 0 0 2px var(--amber-bg); }
.manage-item .item-email { font-size: 11px; color: var(--ink-soft); flex-shrink: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.add-inline-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-inline-row input {
  flex: 1; min-width: 130px; font-size: 13.5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.add-inline-row input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }

.stacked-add-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.stacked-add-form input {
  font-size: 13.5px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius);
}
.stacked-add-form input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }

/* ---------------- Bottom navigation ---------------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  z-index: 30;
  box-shadow: 0 -4px 16px rgba(11,53,86,0.06);
  animation: bottom-nav-in 0.26s ease both;
}
@keyframes bottom-nav-in { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }

.nav-btn {
  flex: 1; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 10px; color: var(--ink-soft);
  position: relative;
  transition: color 0.15s ease, transform 0.1s ease;
}
.nav-btn svg { width: 21px; height: 21px; position: relative; z-index: 1; transition: transform 0.15s ease; }
.nav-btn span { font-size: 10px; font-weight: 600; position: relative; z-index: 1; }
.nav-btn:hover { color: var(--navy); }
.nav-btn:active { transform: scale(0.93); }
.nav-btn:active svg { transform: scale(0.9); }
.nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--amber);
}

/* Amber pill behind the active tab's icon, popping in with a little
   overshoot the moment the page renders it (each tab is its own page
   load, so this plays once on arrival rather than sliding between tabs). */
.nav-btn.active { color: var(--amber-dark); }
.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 1px; left: 50%;
  width: 34px; height: 34px;
  transform: translateX(-50%) scale(0);
  background: var(--amber-bg);
  border-radius: 10px;
  animation: nav-pill-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}
@keyframes nav-pill-in { to { transform: translateX(-50%) scale(1); } }

/* ---------------- Floating action button ---------------- */
.fab {
  position: fixed; right: 18px; bottom: calc(74px + var(--safe-bottom));
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--amber); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(201,122,33,0.4);
  z-index: 25;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(0.94); }

/* ---------------- Excel-style grid tables ---------------- */
.excel-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
table.excel-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
  font-size: 12.5px;
}
table.excel-table thead th {
  background: var(--header-fill);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11.5px;
  padding: 8px 7px;
  text-align: center;
  border: 1px solid #BFCBE0;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.excel-table tbody td {
  border: 1px solid var(--line-soft);
  padding: 7px 8px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}
table.excel-table tbody td.cell-text { font-family: var(--font-body); white-space: normal; text-align: left; max-width: 160px; }
table.excel-table tbody tr { cursor: pointer; }
table.excel-table tbody tr:nth-child(even) { background: #FBFCFD; }
table.excel-table tbody tr:hover { background: var(--amber-bg); }
table.excel-table tbody tr.row-empty { color: var(--ink-soft); font-style: italic; }

.cell-appearance.val-Clear { color: var(--green); font-weight: 600; }
.cell-appearance.val-Hazy { color: var(--amber-dark); font-weight: 600; }
.cell-appearance.val-Water_Layer_at_bottom { color: var(--red); font-weight: 600; }

.cell-signed { display: flex; align-items: center; gap: 6px; justify-content: center; }
.cell-signed img { height: 22px; max-width: 54px; object-fit: contain; }
.cell-signed .sig-meta { display: flex; flex-direction: column; text-align: left; font-family: var(--font-body); }
.cell-signed .sig-name { font-size: 11px; font-weight: 600; color: var(--navy); }
.cell-signed .sig-time { font-size: 9.5px; color: var(--ink-soft); }
.cell-unsigned { color: var(--ink-soft); font-family: var(--font-body); font-size: 11.5px; }

.table-empty-row td { text-align: center; padding: 26px 10px; color: var(--ink-soft); font-family: var(--font-body); cursor: default; }

/* ---------------- Entry popup (vertical form) ---------------- */
.entry-modal-card { max-width: 460px; max-height: 90vh; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.entry-modal-scroll { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.entry-modal-title { font-size: 16px; margin: 0; }

.tank-section {
  border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; background: #FBFCFB;
}
.tank-section-title {
  font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--navy);
  margin-bottom: 10px; display: flex; align-items: baseline; gap: 6px;
}
.tank-section-title .cap { font-family: var(--font-mono); font-weight: 500; font-size: 10.5px; color: var(--ink-soft); }

.slot-block { margin-bottom: 10px; }
.slot-block:last-child { margin-bottom: 0; }
.slot-heading { font-size: 11px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.sub-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.sub-row:last-child { margin-bottom: 0; }
.sub-row label { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.sub-row input {
  font-family: var(--font-mono); font-size: 14px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 7px; width: 100%;
}
.sub-row input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }

.sign-section {
  border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; background: var(--bg);
}
.sign-section-title { font-size: 11px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.signed-as-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.signed-as-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--navy); color: #fff; font-family: var(--font-display); font-weight: 600;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.signed-as-text { display: flex; flex-direction: column; }
.signed-as-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.signed-as-meta { font-size: 11px; color: var(--ink-soft); }
.sig-wrap { border: 1.5px dashed var(--line); border-radius: 8px; background: #FCFCFB; overflow: hidden; }
.sig-canvas { width: 100%; height: 130px; touch-action: none; display: block; }
.sig-actions { display: flex; justify-content: flex-end; margin-top: 6px; }

.modal-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--paper); }
.modal-actions .right-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------------- Modal (generic) ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(11,53,86,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
}
.modal-card {
  background: var(--paper); border-radius: 12px; padding: 22px;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.25);
}

/* ---------------- Bottom sheet (custom picker, replaces native <select>) ---------------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(11,53,86,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 80; opacity: 0; transition: opacity 0.18s ease;
  pointer-events: none; /* closed: must not intercept taps on the page behind it */
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet-card {
  background: var(--paper); width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0; padding: 10px 8px calc(14px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
  transform: translateY(100%); transition: transform 0.2s ease;
  max-height: 70vh; overflow-y: auto;
}
.sheet-overlay.open .sheet-card { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet-title { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--navy); padding: 0 10px 8px; }
.sheet-options { display: flex; flex-direction: column; }
.sheet-option {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; text-align: left;
  padding: 13px 10px; font-size: 14.5px; color: var(--ink); border-radius: 10px;
}
.sheet-option:active { background: var(--line-soft); }
.sheet-option.selected { color: var(--amber-dark); font-weight: 600; }
.sheet-option .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sheet-option .opt-label { flex: 1; }
.sheet-option .check { width: 18px; height: 18px; color: var(--amber-dark); }
.sheet-cancel {
  width: 100%; margin-top: 6px; border: none; background: var(--bg);
  border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: calc(84px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px;
  border-radius: 30px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 90;
  max-width: 88vw; text-align: center;
}
.toast.error { background: var(--red); }

/* ---------------- Responsive ---------------- */
@media (min-width: 640px) {
  .app-main { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 480px) {
  .settings-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 22px; }
}

/* ---------------- Print ---------------- */
@media print {
  body { background: #fff; }
  .app-topbar, .bottom-nav, .fab, .toolbar-actions,
  #toast, #entryModal, #changePasswordModal { display: none !important; }

  .screen.hidden { display: none !important; }
  .screen { padding: 0; margin: 0; }
  .screen-toolbar { display: none !important; }
  #settingsScreen { display: none !important; }

  .print-header.hidden-screen { display: block !important; margin-bottom: 14px; }
  .print-header h1 { font-size: 18px; }
  .print-header p { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

  .app-main { max-width: 100%; padding: 12px; margin: 0; }
  .excel-scroll { border: none; }
  table.excel-table { min-width: 100%; }
  table.excel-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.excel-table tbody tr:hover { background: none; }
}

/* =========================================================
   FuelDesk additions on top of the base design system
   ========================================================= */

/* ---------------- Live rate/density strip (billing) ---------------- */
.stat-bar {
  display: flex; gap: 8px; padding: 10px 16px;
  background: var(--navy-dark); color: #fff;
}
.stat-chip {
  flex: 1; text-align: center; font-size: 12.5px; font-weight: 600;
  background: rgba(255,255,255,0.08); border-radius: 8px; padding: 6px 8px;
}
.stat-chip b { font-family: var(--font-mono); font-weight: 700; }

/* ---------------- Stepper (+/-) buttons, e.g. text size ---------------- */
.stepper-row { display: flex; align-items: center; gap: 10px; }
.stepper-btn {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--navy);
  font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.stepper-btn:active { background: var(--line-soft); }

/* ---------------- Extra button variant + small utilities ---------------- */
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #256a4c; }

.hint { font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.loading-veil { text-align: center; padding: 24px 0; color: var(--ink-soft); font-size: 13px; }
.empty-state { text-align: center; padding: 20px 0; color: var(--ink-soft); font-size: 13px; }

/* ---------------- Info tooltip (formatting commands) ---------------- */
.info-btn {
  width: 19px; height: 19px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--ink-soft); color: var(--ink-soft); background: transparent;
  font-size: 11px; font-weight: 800; line-height: 1; font-style: italic;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.info-btn:active { background: var(--line-soft); }
.field-label-row { display: flex; align-items: center; gap: 6px; }
.info-body { font-size: 13px; color: var(--ink); line-height: 1.6; }
.info-body code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-family: var(--font-mono); font-size: 12px; }
.info-body ul { margin: 4px 0 10px 18px; padding: 0; }
.info-body li { margin-bottom: 6px; }
.info-body p { color: var(--ink-soft); font-size: 12.5px; }

/* ---------------- Skeleton loading placeholders ---------------- */
@keyframes skeleton-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.skel { background: var(--line-soft); border-radius: 6px; animation: skeleton-pulse 1.1s ease-in-out infinite; }
.skel-line { height: 13px; margin-bottom: 8px; }
.skel-line.w-60 { width: 60%; } .skel-line.w-40 { width: 40%; } .skel-line.w-80 { width: 80%; }
.skel-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }

/* ---------------- Fade-in once real content is ready ---------------- */
.fade-in { animation: fade-in 0.22s ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Topbar icon buttons (e.g. Staff shortcut) ---------------- */
.topbar-icon-btn {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: rgba(255,255,255,0.14); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative; z-index: 1;
  transition: background 0.15s ease, transform 0.1s ease;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.22); }
.topbar-icon-btn:active { background: rgba(255,255,255,0.28); transform: scale(0.92); }
.topbar-icon-btn svg { width: 17px; height: 17px; }

/* ---------------- Segmented control (e.g. logo alignment) ---------------- */
.segmented { display: flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button {
  flex: 1; padding: 9px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  background: var(--paper); border: none; border-right: 1px solid var(--line); cursor: pointer;
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--navy); color: #fff; }

/* ---------------- Small preset chips (e.g. 58mm / 80mm) ---------------- */
.chip-row { display: flex; gap: 8px; margin-top: 8px; }
.chip-btn {
  padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--paper); font-size: 12px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.chip-btn.active { background: var(--amber); border-color: var(--amber); color: #fff; }

/* ---------------- Error page (error.html) ---------------- */
.error-card { text-align: center; }
.error-illustration { width: 100%; max-width: 260px; margin: 0 auto 18px; display: block; }
.error-title { font-family: var(--font-display); font-size: 21px; color: var(--navy); margin-bottom: 8px; }
.error-message { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 6px; line-height: 1.5; }
.error-status { font-size: 12px; color: var(--red); font-weight: 700; margin-bottom: 16px; min-height: 16px; }
.error-status.online { color: var(--green); }

/* ---------------- Offline overlay (shown over any app page) ---------------- */
.offline-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(11,53,86,0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.offline-card {
  background: var(--paper); border-radius: 16px; padding: 26px 22px;
  max-width: 340px; width: 100%; text-align: center;
  box-shadow: 0 20px 48px rgba(0,0,0,0.3);
}
.offline-illustration { width: 100%; max-width: 190px; margin: 0 auto 14px; display: block; }
.offline-card h2 { font-family: var(--font-display); font-size: 18px; color: var(--navy); margin-bottom: 8px; }
.offline-card p { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 10px; }
.offline-card .offline-status { font-weight: 700; color: var(--red); margin-bottom: 16px; }

/* ---------------- Subscription/hosting renewal warning banner ---------------- */
.subscription-banner {
  background: linear-gradient(90deg, #92400e, #b45309);
  color: #fff; font-size: 12.5px; font-weight: 700; text-align: center;
  padding: 9px 14px; position: relative; z-index: 30;
}

/* ---------------- App branding footer (web pages only, never the printed receipt) ---------------- */
.app-footer-brand {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: fit-content; margin: 22px auto 4px; padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--navy), var(--navy-dark));
  box-shadow: 0 4px 14px rgba(11,53,86,0.28);
  color: #fff; font-family: var(--font-display); font-size: 11.5px;
  font-weight: 700; letter-spacing: 0.3px; white-space: nowrap;
}
.app-footer-brand .bolt { color: var(--amber); font-size: 13px; line-height: 1; }

/* ---------------- Small status tags (light bg, for lists) ---------------- */
.tag {
  display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.4px; padding: 3px 7px; border-radius: 999px; margin-left: 6px;
}
.tag-admin { background: var(--header-fill); color: var(--navy); }
.tag-staff { background: var(--line-soft); color: var(--ink-soft); }
.tag-inactive { background: var(--red-bg); color: var(--red); }

/* ---------------- Staff / manage rows ---------------- */
.manage-item.staff-item { flex-wrap: wrap; }
.staff-item .staff-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.staff-item .staff-meta { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.staff-item .staff-main { flex: 1; min-width: 0; }
.staff-item .staff-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-xs { padding: 7px 11px; font-size: 12px; }
.btn-sm { padding: 9px 14px; font-size: 13px; width: auto; margin-top: 0; }

/* ---------------- Panel chooser (admin: billing vs admin) ---------------- */
.choice-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.choice-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  background: var(--paper); width: 100%;
}
.choice-card:active { background: var(--line-soft); }
.choice-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.choice-icon.navy { background: var(--navy); }
.choice-icon.amber { background: var(--amber); }
.choice-icon svg { width: 22px; height: 22px; }
.choice-text { flex: 1; min-width: 0; }
.choice-title { font-family: var(--font-display); font-size: 15px; color: var(--ink); font-weight: 600; }
.choice-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.choice-card .chev { width: 18px; height: 18px; color: var(--ink-soft); flex-shrink: 0; }

/* ---------------- Photo / logo upload ---------------- */
.photo-upload-row { display: flex; align-items: center; gap: 12px; }
.photo-preview {
  width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; color: var(--ink-soft); font-size: 10px; text-align: center;
}
.photo-preview img { width: 100%; height: 100%; object-fit: contain; }
.photo-upload-actions { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.photo-upload-actions input[type="file"] { display: none; }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--amber); }
.range-row .range-value {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft);
  width: 44px; text-align: right; flex-shrink: 0;
}

/* ---------------- Thermal receipt content styles ----------------
   These apply any time #thermal-receipt is visible — both the live
   preview on the Format page AND the moment it's actually printed —
   so what you see in the live editor is what comes out of the printer.
   Only the print-specific mechanics below are wrapped in @media print. */
#thermal-receipt {
  background: #fff; color: #000; padding: 0;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.2;
}
#thermal-receipt .text-center { text-align: center; }
#thermal-receipt .text-right { text-align: right; }
#thermal-receipt .text-left { text-align: left; }
#thermal-receipt .font-bold { font-weight: bold; }
#thermal-receipt .uppercase { text-transform: uppercase; }
#thermal-receipt .receipt-logo-box { display: inline-block; vertical-align: top; border: 1px solid #000; padding: 4px; width: 90px; font-size: 10px; line-height: 1; }
#thermal-receipt .receipt-logo-img { display: inline-block; vertical-align: top; max-width: 100%; height: auto; }

/* "Classic" dot-matrix style: label column + colon + value, aligned by
   a fixed-width label instead of manually padding with spaces. */
#thermal-receipt .classic-line { display: flex; margin-bottom: 1px; }
#thermal-receipt .classic-label { display: inline-block; width: 54px; flex-shrink: 0; }
#thermal-receipt .classic-circle-logo {
    width: 70px; height: 70px; border-radius: 50%; border: 2px solid #000;
    display: inline-flex; vertical-align: top; align-items: center; justify-content: center; position: relative;
}
#thermal-receipt .classic-circle-logo::before {
    content: ''; position: absolute; inset: 4px; border-radius: 50%; border: 1px solid #000;
}
#thermal-receipt .classic-circle-logo span { font-size: 9px; font-weight: bold; text-align: center; line-height: 1.1; }
#thermal-receipt .grid-3-col { display: grid; grid-template-columns: 90px 10px 1fr; row-gap: 2px; }
#thermal-receipt .grid-tax { display: grid; grid-template-columns: 105px 10px 1fr; row-gap: 2px; font-size: 10px; }
#thermal-receipt .flex-between { display: flex; justify-content: space-between; margin-bottom: 2px; }
#thermal-receipt .my-2 { margin-top: 8px; margin-bottom: 8px; }
#thermal-receipt .my-3 { margin-top: 12px; margin-bottom: 12px; }

/* ---------------- Hidden-until-print (billing.html / admin.html use this) ---------------- */
#thermal-receipt.print-only { display: none; }

@media print {
  body * { visibility: hidden !important; }
  body { background: #fff !important; }
  @page { margin: 0; size: 58mm auto; } /* overridden per-print by applyReceiptWidth() in ui.js */

  /* Elements like .app-screen (min-height:100vh) and html/body
     (height:100%) still reserve their full layout height even while
     hidden, which can push the page height past a single sheet and
     print a blank second page. Collapse them during print. */
  html, body { height: auto !important; min-height: 0 !important; }
  .app-screen { min-height: 0 !important; height: auto !important; }

  #thermal-receipt.print-only, #thermal-receipt.print-only * { visibility: visible !important; }
  #thermal-receipt.print-only {
    display: block !important; position: absolute; left: 0; top: 0; width: 58mm;
    page-break-after: avoid; page-break-inside: avoid;
  }
}

/* ---------------- On-screen "paper" presentation (Format page live preview) ---------------- */
.receipt-paper {
  margin: 0 auto; box-shadow: 0 6px 24px rgba(11,53,86,0.18);
  border: 1px solid var(--line); border-radius: 2px; overflow: hidden;
  transition: width 0.15s ease;
}

/*----------popup lock -----------*/
body.scroll-locked {
    position: fixed;
    top: var(--scroll-lock-offset, 0);
    left: 0;
    right: 0;
    width: 100%;
}

/* ---------------- Full-page loader ---------------- */
#page-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
#page-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
body.loader-active {
  overflow: hidden;
}
.page-loader-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.page-loader-word {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.02em;
}
.page-loader-ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--amber);
  animation: page-loader-spin 0.8s linear infinite;
}
@keyframes page-loader-spin {
  to { transform: rotate(360deg); }
}
/* ---------------- Copy protection (Billing entry screen only) ---------------- */
/* Ordinary text (labels, buttons, headings, receipt preview, etc.) can't be
   selected/copied. Actual input fields stay fully selectable & copyable. */
body.billing-page,
body.billing-page * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
body.billing-page input,
body.billing-page textarea {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

/* ---------------- Keyboard focus (topbar buttons) ---------------- */
/* Buttons had no focus style of their own and fell back to the browser's
   default blue outline, which clashes with the navy/amber palette. */
.topbar-icon-btn:focus-visible,
.app-topbar .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--navy), 0 0 0 4px var(--amber);
}

/* ---------------- Respect reduced-motion preference ---------------- */
@media (prefers-reduced-motion: reduce) {
  .app-topbar::after { animation: none; }
  .topbar-text strong, .topbar-sub, .role-badge { animation: none; }
  .bottom-nav { animation: none; }
  .nav-btn.active::before { animation: none; transform: translateX(-50%) scale(1); }
}
