/* ==========================================================================
   NG Master Staging — ops dashboard stylesheet
   NG_MASTER_UI_CLAUDE_V1 · 2026-09-21 · English-only · voucher-pdf-1
   Dark MARAS theme: navy #2B3E6B · orange #F7941D

   Sticky model (why it works):
   - body is block (not flex) — see NG_MASTER_UI_CLAUDE_V1_STICKY_FIX.
   - html/body/main never set overflow → app bar + filter toolbar stick to
     the viewport.
   - .table-wrap is the ONLY scroll container for tables (both axes, capped
     height) → <th> sticks to its top, NG column sticks to its left.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --navy: #2B3E6B;
  --navy-700: #22325a;
  --navy-800: #1a2748;
  --navy-900: #121c35;
  --orange: #F7941D;
  --orange-600: #e0820f;
  --orange-soft: rgba(247, 148, 29, 0.14);

  --bg: #0c1426;
  --surface: #131d33;
  --surface-2: #17233d;
  --surface-3: #1d2b49;
  --row-alt: #152038;
  --row-hover: #1f2f52;
  --border: #25365a;
  --border-strong: #34497a;

  --text: #eef2f8;
  --text-2: #b8c3d9;
  --text-3: #8391ad;

  --ok: #34c77b;
  --ok-bg: rgba(52, 199, 123, 0.14);
  --warn: #f5b841;
  --warn-bg: rgba(245, 184, 65, 0.14);
  --danger: #f06470;
  --danger-bg: rgba(240, 100, 112, 0.15);
  --info: #5aa9f5;
  --info-bg: rgba(90, 169, 245, 0.14);
  --violet: #a78bfa;
  --violet-bg: rgba(167, 139, 250, 0.15);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.22);
  --appbar-h: 60px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--appbar-h) + 16px); }

/* NG_MASTER_UI_CLAUDE_V1_STICKY_FIX
   body was display:flex; flex-direction:column which made .appbar a flex item
   and broke position:sticky (header scrolled away). Restore block layout like
   Pro V3 bak so appbar/toolbar stick to the viewport; footer stays in normal flow. */
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 20px 48px; /* full viewport width; keep side padding */
}

/* ---------- 3. App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: var(--navy);
  border-bottom: 3px solid var(--orange);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff; flex-shrink: 0; }
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--orange);
  color: var(--navy-900);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--orange);
}

.nav { display: flex; align-items: center; gap: 4px; flex: 1; }

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  color: #d6def0;
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; text-decoration: none; }
.nav a.active { background: var(--orange); color: var(--navy-900); }

.appbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  color: #d6def0;
  font-size: 12.5px;
  white-space: nowrap;
}
.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--navy-800);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
}
.user-snap { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }

.nav-logout {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}
.nav-logout:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }

/* ---------- 4. Page header ---------- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange);
}
.page-title { margin: 0; font-size: 26px; font-weight: 750; letter-spacing: -0.015em; color: #fff; }
.page-subtitle { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.page-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
}
.pill b { color: var(--text); font-weight: 600; }

/* ---------- 5. KPI cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-auto-rows: 1fr;             /* equal height */
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 112px;
  padding: 16px 18px 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
  color: var(--text);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--navy);
}
.card.accent::before { background: var(--orange); }
.card.ok::before { background: var(--ok); }
.card.warn::before { background: var(--warn); }
.card.danger::before { background: var(--danger); }

.card .l { display: flex; flex-direction: column; gap: 2px; }
.card .l-primary {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
}
.card .l-meta { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.card .n {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.card.warn .n { color: var(--warn); }
.card.danger .n { color: var(--danger); }
.card.ok .n { color: var(--ok); }

.card-link { transition: transform 0.12s, border-color 0.12s; }
.card-link:hover { text-decoration: none; border-color: var(--orange); transform: translateY(-1px); }
.card-link .card-go { font-size: 12px; font-weight: 600; color: var(--orange); }

/* ---------- 6. Notes / tips ---------- */
.tip-collapse {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}
.tip-collapse summary {
  cursor: pointer;
  padding: 8px 14px;
  color: var(--text-2);
  font-weight: 600;
  list-style: none;
}
.tip-collapse summary::-webkit-details-marker { display: none; }
.tip-collapse summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--orange); }
.tip-collapse[open] summary::before { content: "▾"; }
.tip-panel { padding: 0 14px 12px 32px; color: var(--text-2); }

.tip-bar {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
}
.tip-icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--info-bg);
  color: var(--info);
  font-weight: 800;
  font-size: 11px;
}

/* ---------- 7. Filter toolbar (sticky under app bar) ---------- */
.toolbar {
  position: sticky;
  top: var(--appbar-h);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 -24px 12px;
  padding: 12px 24px;
  background: rgba(12, 20, 38, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.toolbar .f-search { flex: 1 1 320px; }
.toolbar .f-select { flex: 0 1 220px; }
.toolbar-actions { display: flex; gap: 8px; }

input[type="search"], input[type="email"], input[type="password"], input[type="text"], input[type="number"], input[type="date"], input[type="month"], select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: #46609a; }
input:focus, select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
                    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
select option { background: var(--surface-2); color: var(--text); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--orange);
  border-radius: var(--radius-sm);
  background: var(--orange);
  color: var(--navy-900);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: var(--orange-600); border-color: var(--orange-600); text-decoration: none; }
.btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }

.showing { margin: 0 0 10px; color: var(--text-3); font-size: 12.5px; }
.showing b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- 8. Table ---------- */
.table-wrap {
  position: relative;
  overflow: auto;                  /* the single scroll container */
  max-height: calc(100vh - var(--appbar-h) - 150px);
  min-height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.table-wrap.short { max-height: none; min-height: 0; }

table {
  width: 100%;
  border-collapse: separate;       /* required for sticky cells + borders */
  border-spacing: 0;
  font-size: 13px;
}

th, td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--navy-800);
  color: #dbe3f3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--orange);
}

td { color: var(--text-2); font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 160px; max-width: 280px; }
td.muted, .muted { color: var(--text-3); }
td.num { text-align: right; }
th.num { text-align: right; }
td.mono { font-family: var(--mono); font-size: 12px; }

tbody tr > * { background: var(--surface); }
tbody tr:nth-child(even) > * { background: var(--row-alt); }
tbody tr:hover > * { background: var(--row-hover); }
tbody tr:last-child > * { border-bottom: none; }

/* Sticky NG column */
.col-sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  border-right: 1px solid var(--border-strong);
  box-shadow: 4px 0 6px -4px rgba(0, 0, 0, 0.5);
}
thead th.col-sticky { z-index: 4; }
td.col-sticky { color: #fff; font-weight: 700; font-family: var(--mono); font-size: 12.5px; }

/* Row states: left marker on NG cell + tint */
tbody tr.row-danger > * { background: #2a1a26; }
tbody tr.row-danger:hover > * { background: #34202e; }
tbody tr.row-danger > .col-sticky { box-shadow: inset 3px 0 0 var(--danger), 4px 0 6px -4px rgba(0, 0, 0, 0.5); }
tbody tr.row-warn > * { background: #262417; }
tbody tr.row-warn:hover > * { background: #2f2c1c; }
tbody tr.row-warn > .col-sticky { box-shadow: inset 3px 0 0 var(--warn), 4px 0 6px -4px rgba(0, 0, 0, 0.5); }

td.empty { padding: 36px 12px; text-align: center; color: var(--text-3); font-style: italic; white-space: normal; }

/* ---------- 9. Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(52, 199, 123, 0.3); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(245, 184, 65, 0.3); }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(240, 100, 112, 0.35); }
.badge.eta-overdue::before { content: "●"; font-size: 8px; }

/* Status badges (pipeline stage) */
.badge.st-port { background: var(--ok-bg); color: var(--ok); }
.badge.st-land { background: var(--orange-soft); color: var(--orange); }
.badge.st-sea { background: var(--info-bg); color: var(--info); }
.badge.st-confirmed { background: var(--violet-bg); color: var(--violet); }
.badge[class*="st-"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- 10. Exception sections ---------- */
.section { margin-top: 28px; scroll-margin-top: calc(var(--appbar-h) + 16px); }
.section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}
.section-note { margin: 0 0 10px; color: var(--text-3); font-size: 13px; }
.section.is-empty .table-wrap { opacity: 0.75; }

/* ---------- 11. Login ---------- */
body.page-login {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(247, 148, 29, 0.14), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(43, 62, 107, 0.55), transparent 60%),
    var(--bg);
}
body.page-login main {
  display: grid;
  place-items: center;
  padding: 40px 16px;
  min-height: calc(100vh - 48px); /* keep login card centered without body flex */
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.login-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 28px;
  background: var(--navy);
  border-bottom: 3px solid var(--orange);
}
.login-head .brand-mark { width: 44px; height: 44px; font-size: 22px; border-radius: 10px; }
.login-head h1 { margin: 0; font-size: 20px; color: #fff; }
.login-tag { margin: 2px 0 0; font-size: 12.5px; color: #c7d1e6; }

.login-body { padding: 24px 28px 28px; }
.login-body form { display: flex; flex-direction: column; gap: 6px; }
.login-body label { margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.login-body button { width: 100%; margin-top: 18px; height: 44px; font-size: 15px; }

.login-hint {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  color: var(--text-3);
  font-size: 12.5px;
}
.login-hint b { color: var(--text-2); font-weight: 600; }
.login-hint-extra { display: block; margin-top: 4px; color: var(--warn); }

.error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid rgba(240, 100, 112, 0.4);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- 12. Footer ---------- */
footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--navy-900);
  color: var(--text-3);
  font-size: 11.5px;
  text-align: center;
}

/* ---------- 12b. Write MVP: staging banner, New order, order form ---------- */
/* Fixed to the viewport bottom so it is always visible without touching the
   sticky app bar / toolbar offsets. */
.staging-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 6px 16px;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  background: var(--warn);
  color: var(--navy-900);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.02em;
}
body { padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px)); }

.btn-new { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-new.is-current { box-shadow: 0 0 0 2px #fff; }

.row-action { font-weight: 600; font-size: 12.5px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.flash {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.flash.ok { background: var(--ok-bg); border: 1px solid rgba(52, 199, 123, 0.35); color: var(--ok); }

.order-form { max-width: 1100px; }
.order-form fieldset {
  margin: 0 0 16px;
  padding: 16px 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.order-form legend {
  padding: 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--orange);
}
.ff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; }
.ff { display: flex; flex-direction: column; gap: 4px; }
.ff-label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.ff-label abbr { color: var(--orange); text-decoration: none; }
.ff-hint { font-size: 11.5px; color: var(--text-3); }
.ff-error { font-size: 12px; font-weight: 600; color: var(--danger); }
.ff.has-error input, .ff.has-error select { border-color: var(--danger); }
.ff-note { margin: 0 0 12px; font-size: 12.5px; color: var(--text-3); }
.order-form input[type="date"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  color-scheme: dark;
}
.order-form input[readonly] { opacity: 0.7; cursor: not-allowed; }
.form-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.page-header + .error { margin: 0 0 16px; }

/* ---------- 13. Responsive + mobile / iPad ---------- */

/* Nav hamburger (hidden on desktop) */
.nav-toggle-input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.nav-toggle-btn {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle-bars {
  display: inline-block;
  width: 18px;
  height: 12px;
  background:
    linear-gradient(#fff, #fff) 0 0 / 100% 2px no-repeat,
    linear-gradient(#fff, #fff) 0 5px / 100% 2px no-repeat,
    linear-gradient(#fff, #fff) 0 10px / 100% 2px no-repeat;
}
.nav-toggle-btn:hover { background: rgba(255, 255, 255, 0.12); }

.toolbar-spacer { flex: 1 1 8px; min-width: 8px; }
.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Accounting section tabs */
.acct-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.acct-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.acct-nav a:hover { background: var(--surface-3); color: #fff; text-decoration: none; }
.acct-nav a.active,
.acct-nav a[aria-current="page"] {
  background: var(--orange);
  color: var(--navy-900);
}
.acct-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.acct-nav a.active .acct-nav-count { background: rgba(18, 28, 53, 0.25); }

.card .n.n-sm { font-size: 1.15rem; line-height: 1.25; word-break: break-word; }
.col-balance { color: #fff !important; font-weight: 800; }
td.col-balance strong { color: var(--orange); font-size: 14px; }
.row-primary-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  color: #fff;
}
.row-primary-link:hover { color: var(--orange); }
.btn-touch, .btn.btn-touch { min-height: 44px; }
.form-actions-full { grid-column: 1 / -1; margin-top: 4px; }
.ledger-form {
  max-width: 720px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ledger-form label { display: flex; flex-direction: column; gap: 4px; }
.ledger-form input[type="number"],
.ledger-form input[type="date"],
.ledger-form input[type="text"],
.ledger-form select {
  width: 100%;
  min-height: 44px;
  height: 44px;
}

.nav-logout { min-height: 44px; display: inline-flex; align-items: center; }
.btn-new { min-height: 44px; height: 44px; }

@media (max-width: 1200px) {
  .col-hide-md { display: none; }
}

/* iPad portrait / narrow laptop: keep Accounting reachable */
@media (max-width: 900px) {
  .col-hide-sm { display: none; }
  .user-chip .user-snap { display: none; }
  .user-chip span:not(.user-avatar) { max-width: 88px; overflow: hidden; text-overflow: ellipsis; }

  :root { --appbar-h: 60px; }
  .appbar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--appbar-h);
    padding: 8px 14px;
    gap: 8px 12px;
    align-items: center;
  }
  .nav-toggle-btn { display: inline-flex; }
  .nav {
    display: none;
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 6px;
    max-height: none;
    overflow: visible;
  }
  .nav-toggle-input:checked ~ .nav {
    display: flex;
  }
  /* Horizontal scroll fallback when menu closed is unused; when open wrap */
  .nav a { min-height: 44px; }
  .brand-name { font-size: 13.5px; }
  .appbar-right { gap: 8px; }
  .btn-new { padding: 0 12px; font-size: 12.5px; }

  main { padding: 16px 14px 56px; } /* extra bottom for staging banner + Safari chrome */
  .toolbar {
    margin: 0 -14px 12px;
    padding: 10px 14px;
    align-items: stretch;
  }
  .toolbar .f-search { flex: 1 1 100%; }
  .toolbar .f-select { flex: 1 1 140px; }
  .toolbar-filters { width: 100%; }
  .page-title { font-size: 22px; }
  .card .n { font-size: 28px; }
  .ledger-form { grid-template-columns: 1fr; max-width: none; }
  .settings-tabs { flex-wrap: wrap; }
  .settings-tabs a { min-height: 44px; display: inline-flex; align-items: center; }

  /* Prefer auto height tables on tablet so sticky header doesn't trap content */
  .table-wrap { max-height: none; }
}

@media (max-width: 720px) {
  .user-chip { display: none; }
  .nav-toggle-label { display: none; } /* icon-only on phone */
  .brand-sub { display: none; }
}

/* Phone: card-style key lists + statement timeline */
@media (max-width: 640px) {
  .login-card { max-width: none; border-radius: 12px; }
  .login-head, .login-body { padding: 20px 18px; }
  body.page-login main { padding: 24px 12px 48px; align-items: start; }

  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .acct-hub .card { min-height: 96px; }

  /* Ledger list → stacked cards */
  .ledger-list table.table-touch thead { display: none; }
  .ledger-list table.table-touch,
  .ledger-list table.table-touch tbody,
  .ledger-list table.table-touch tr,
  .ledger-list table.table-touch td {
    display: block;
    width: 100%;
  }
  .ledger-list table.table-touch tr.row-link {
    margin: 0 0 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .ledger-list table.table-touch tr.row-link > * {
    background: transparent !important;
    border: none;
    padding: 4px 0;
    white-space: normal;
  }
  .ledger-list table.table-touch td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 2px;
  }
  .ledger-list table.table-touch td.col-balance {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border) !important;
  }
  .ledger-list table.table-touch td.col-action { margin-top: 8px; }
  .ledger-list table.table-touch td.col-action .btn { width: 100%; }

  /* Statement timeline cards */
  .statement-timeline table.table-touch thead { display: none; }
  .statement-timeline table.table-touch,
  .statement-timeline table.table-touch tbody,
  .statement-timeline table.table-touch tr,
  .statement-timeline table.table-touch td {
    display: block;
    width: 100%;
  }
  .statement-timeline table.table-touch tbody tr {
    position: relative;
    margin: 0 0 12px;
    padding: 12px 14px 12px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    border-left: 3px solid var(--orange);
  }
  .statement-timeline table.table-touch tbody tr > * {
    background: transparent !important;
    border: none;
    padding: 3px 0;
    white-space: normal;
  }
  .statement-timeline table.table-touch td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 88px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    margin-right: 8px;
  }
  .statement-timeline table.table-touch td.empty::before { display: none; }

  input[type="search"], input[type="email"], input[type="password"],
  input[type="text"], input[type="number"], input[type="date"],
  input[type="month"], select,
  button, .btn {
    min-height: 44px;
    height: 44px;
  }
  .ff-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}

@media print {
  .appbar, .toolbar, footer, .tip-collapse, .acct-nav, .nav-toggle-btn, .staging-banner { display: none !important; }
  .table-wrap { max-height: none; overflow: visible; }
}


/* ---- Accounting mobile aliases (2026-09-21) ---- */
.acct-tabs { /* alias */ }
.section-tight { margin-top: 16px; }
.section-subhead {
  margin: 18px 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.flash.err {
  background: var(--danger-bg);
  border: 1px solid rgba(240, 100, 112, 0.4);
  color: var(--danger);
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.acct-subnav {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  max-width: 100%;
}
.acct-subnav .btn { flex-shrink: 0; }
.ledger-entry-form { /* alias of .ledger-form */ }
.form-actions-row { grid-column: 1 / -1; margin-top: 4px; }


@media (max-width: 640px) {
  /* iOS avoid zoom */
  input[type="search"], input[type="email"], input[type="password"],
  input[type="text"], input[type="number"], input[type="date"],
  input[type="month"], select {
    font-size: 16px;
  }
}

/* ---- Users + Notifications MVP (2026-09-21) ---- */
.bell-wrap { position: relative; }
.bell-wrap > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  position: relative;
}
.bell-wrap > summary::-webkit-details-marker { display: none; }
.bell-wrap > summary:hover { background: rgba(255,255,255,0.16); }
.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--orange, #F5A623);
  color: var(--navy-900, #1a2744);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.bell-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, 92vw);
  background: #1e2d4f;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  z-index: 50;
  padding: 10px 12px;
}
.bell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.bell-head a { color: #9ec1ff; font-size: 12px; }
.bell-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.bell-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
}
.bell-list a { color: #fff; text-decoration: none; }
.bell-list a:hover { text-decoration: underline; }
.bell-empty { font-size: 12px; color: rgba(255,255,255,0.65); margin: 8px 0; }
.bell-foot { margin-top: 8px; }
.bell-foot button, .inline-form button, .linkish {
  background: transparent;
  border: 0;
  color: #9ec1ff;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.inline-form { display: inline; margin: 0; }
.settings-card { margin-bottom: 20px; padding: 16px 18px; }
.settings-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 12px;
  max-width: 480px;
}
.settings-form label { font-size: 13px; margin-top: 6px; }
.settings-form .hint { font-weight: 400; opacity: 0.7; font-size: 12px; }
.settings-form input, .settings-form select {
  width: 100%;
}
.flash.ok { background: rgba(80,180,120,0.15); border: 1px solid rgba(80,180,120,0.4); padding: 8px 12px; border-radius: 8px; }
.flash.err, .flash.error, p.error { background: var(--danger-bg); border: 1px solid rgba(240, 100, 112, 0.4); color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); }
tr.is-inactive { opacity: 0.55; }
tr.is-unread td { font-weight: 600; }
.btn-danger {
  background: #8b2e2e;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}
.muted { opacity: 0.65; font-size: 12px; }


.settings-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}
.settings-tabs a {
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e8eef8);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.settings-tabs a.active,
.settings-tabs a[aria-current="page"] {
  background: rgba(91,140,255,0.22);
  border-color: rgba(91,140,255,0.45);
  color: #fff;
}

/* ---- Accounting + Cost UI simplify (2026-09-21) ---- */
.page-header-compact { margin-bottom: 12px; }
.page-header-compact .page-subtitle { margin-top: 2px; }

.acct-status-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.acct-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.acct-pill b {
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 800;
}
.acct-pill.has-count {
  border-color: rgba(247, 148, 29, 0.45);
}
.acct-pill.active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--navy-900);
}
.acct-pill.active b { color: var(--navy-900); }
.acct-pill.static {
  cursor: default;
  pointer-events: none;
}
.acct-pill:hover:not(.static):not(.active) {
  background: var(--surface-3);
  color: #fff;
  text-decoration: none;
}

.toolbar-compact { margin-bottom: 12px; }
.acct-primary-table .btn { white-space: nowrap; }
.warn-hint { color: #F7941D !important; font-size: 12px; margin-top: 2px; }

.acct-kpi-strip { margin-bottom: 16px; }

@media (max-width: 640px) {
  .acct-status-strip { gap: 6px; }
  .acct-pill { min-height: 40px; padding: 8px 12px; font-size: 12.5px; }
  .page-header-compact .page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}


/* Light secondary filters + cost page helpers (acct-cost-simple-1) */
.toolbar-acct-simple { margin-bottom: 8px; }
.acct-filters-light {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin: 0 0 14px;
  padding: 4px 0 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
}
.acct-filters-light a {
  color: #94a3b8;
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.acct-filters-light a:hover { color: #e2e8f0; text-decoration: none; }
.acct-filters-light a.active {
  color: #F7941D;
  font-weight: 600;
  border-bottom-color: #F7941D;
}
.acct-filters-light .acct-nav-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(247,148,29,0.15);
  color: #F7941D;
  font-size: 11px;
  font-weight: 700;
}
.cards-compact { margin-bottom: 12px; }
.flash-short { padding: 8px 12px; margin: 0 0 8px; font-size: 13px; }
.acct-simple-list td { vertical-align: middle; }


/* ---- Cost page sticky grand + FS title (acct-cost-simplify) ---- */
.fs-title-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
  border-bottom: 3px solid #F7941D; padding-bottom: 10px;
}
.fs-title {
  margin: 0; font-size: 1.2rem; letter-spacing: 0.06em;
  color: #fff; font-weight: 700;
}
.fs-status-pill {
  background: #F7941D; color: #121c35; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; font-size: 12px;
}
.fs-compact-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin-bottom: 12px; font-size: 13px; color: #cbd5e1;
}
.fs-compact-meta b { color: #F7941D; margin-right: 4px; }
.fs-grand-banner {
  position: sticky; bottom: 0; z-index: 5;
  margin-top: 12px; padding: 12px 14px;
  background: rgba(247,148,29,0.18);
  border: 1px solid rgba(247,148,29,0.45);
  border-radius: 10px;
}
.fs-grand-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.fs-grand-label {
  font-size: 11px; color: #F7941D; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.fs-grand-value {
  font-size: 1.35rem; color: #fff; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.cs-actions-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.cs-actions-bar form { margin: 0; }
.btn-primary-action {
  background: var(--orange, #F7941D) !important;
  color: var(--navy-900, #121c35) !important;
  font-weight: 800;
  min-height: 44px;
}
.fs-table-basic { min-width: 480px; }
.fs-extra-collapse { margin-top: 12px; }
.warn-hint { color: #F7941D !important; font-size: 12px; margin-top: 2px; }
@media (max-width: 560px) {
  .fs-title { font-size: 1.05rem; }
  .fs-grand-value { font-size: 1.2rem; }
}

/* ---- Ledger statement UX v2 (2026-09-21) ---- */
.ledger-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.ledger-status-filters .chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.ledger-status-filters .chip:hover { border-color: var(--orange); color: #fff; }
.ledger-status-filters .chip.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #121c35;
}
.pill-warn { background: rgba(247, 148, 29, 0.22); color: #ffd59a; }
.pill-danger { background: rgba(240, 100, 112, 0.22); color: #ffb4bc; }
.row-overdue td.col-balance strong { color: #ff8a95; }
.row-outstanding td.col-balance strong { color: var(--orange); }

.stmt-balance-hero {
  margin: 0 0 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(43, 62, 107, 0.55), rgba(18, 28, 53, 0.9));
}
.stmt-balance-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stmt-balance-value {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.stmt-balance-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--text-2);
}
.stmt-balance-by-ccy {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.stmt-balance-by-ccy li {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  font-size: 13px;
}
.stmt-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stmt-filters .f-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 600;
}
.stmt-filters .f-check input { width: 18px; height: 18px; }
.custom-dates {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.custom-dates label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.stmt-table td.num { font-variant-numeric: tabular-nums; }

.record-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: min(560px, 96vw);
  width: 100%;
  background: var(--bg, #121c35);
  color: #fff;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
}
.record-dialog::backdrop { background: rgba(0,0,0,0.55); }
.record-dialog .ledger-form {
  margin: 0;
  padding: 16px 18px 20px;
  max-width: none;
}
.record-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1 / -1;
  margin-bottom: 4px;
}
.record-dialog-head h2 { margin: 0; font-size: 18px; }

@media (max-width: 640px) {
  .stmt-actions { width: 100%; }
  .stmt-actions .btn { flex: 1 1 auto; justify-content: center; }
  .stmt-balance-hero { padding: 14px 16px; }
  .custom-dates { width: 100%; }
  .custom-dates label { flex: 1 1 140px; }
}


/* Ledger list chips — party counts */
.ledger-status-filters .chip .chip-count {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
  color: var(--text-2);
}
.ledger-status-filters .chip.active .chip-count {
  background: rgba(255, 122, 26, 0.2);
  color: #fff;
}
.ledger-list table.table-touch tr.row-link { cursor: pointer; }
.ledger-list table.table-touch tr.row-link:hover td { background: rgba(255, 122, 26, 0.06); }


/* Receipt / payment voucher PDF row actions */
.stmt-row-actions {
  white-space: nowrap;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: flex-end;
}
.stmt-row-actions .inline-form { display: inline; margin: 0; }
