/* NEXT GEN MOTOR SPARES — workshop-style theme.
   Dark chassis sidebar, brand steel-blue, hazard-stripe accents taken from the
   printed pad. Class names and element ids are shared with app.js — restyle
   freely, but don't rename them without updating the script. */
:root {
  --steel: #254d71;        /* brand blue, sampled from the logo */
  --steel-dark: #173249;
  --steel-light: #3a6e9c;
  --black: #0d1217;
  --chassis: #131a21;      /* sidebar */
  --chassis-2: #1c252e;
  --ink: #161b21;
  --paper: #ffffff;
  --muted: #667380;
  --border: #d5dbe1;
  --bg: #f2f4f6;
  --accent-bg: #eef2f6;
  --ok: #1c8a5a;
  --danger: #b3261e;
  --radius: 4px;
  --green: #1c8a5a;        /* used by status text in app.js */
  --sidebar-w: 264px;
  --stripes: repeating-linear-gradient(115deg, var(--steel-light) 0 9px, transparent 9px 15px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, Roboto, sans-serif;
}

/* ---------- App shell: dark sidebar + light workspace ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--chassis);
  color: #d8e0e8;
  display: flex;
  flex-direction: column;
  z-index: 60;
}
.sidebar::after {            /* hazard stripe along the bottom edge */
  content: "";
  height: 8px;
  flex: none;
  background: var(--stripes);
  opacity: 0.9;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 16px;
  background: var(--black);
  border-bottom: 3px solid var(--steel);
}
.sidebar-brand img.logo {
  height: 46px;
  width: 46px;
  object-fit: contain;
  flex: none;
  background: #fff;
  border-radius: 50%;
  padding: 2px;
}
.sidebar-brand .brand h1 {
  font-size: 0.86rem;
  margin: 0;
  color: #fff;
  letter-spacing: 1.4px;
  line-height: 1.25;
  font-weight: 800;
}
.sidebar-brand .brand p {
  margin: 4px 0 0;
  font-size: 0.66rem;
  color: #8fa6bb;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-group { margin-top: 12px; }
.nav-group:first-child { margin-top: 6px; }
.nav-group-label {
  padding: 6px 20px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #6f8498;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 10px 20px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #d8e0e8;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.nav-item .nav-icon { width: 17px; height: 17px; flex: none; color: #7f94a8; }
.nav-item:hover { background: var(--chassis-2); color: #fff; }
.nav-item:focus-visible { outline: 2px solid var(--steel-light); outline-offset: -2px; }
.nav-item.active {
  background: linear-gradient(90deg, var(--steel) 0%, rgba(37, 77, 113, 0.35) 100%);
  color: #fff;
  font-weight: 700;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: #fff;
}
.nav-item.active .nav-icon { color: #fff; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #26313c;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}
.sidebar-user-dot { width: 8px; height: 8px; border-radius: 2px; background: #4ade80; flex: none; }
#current-username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  border: 1px solid #3a4856;
  background: transparent;
  color: #d8e0e8;
  border-radius: 3px;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.btn-logout:hover { background: #fff; color: var(--black); border-color: #fff; }

.sidebar-backdrop { display: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.main-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 28px;
  min-height: 64px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.main-header::after {        /* thin blue/black rule under the title bar */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: linear-gradient(90deg, var(--steel) 0 120px, var(--black) 120px 168px, transparent 168px);
}
.page-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--black);
}
.menu-btn {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  color: var(--black);
  cursor: pointer;
  flex: none;
}
.menu-btn svg { width: 22px; height: 22px; }
.content { max-width: 1400px; margin: 0 auto; padding: 24px 28px 80px; }

/* Below 900px the sidebar becomes a slide-in drawer opened from the menu button. */
@media (max-width: 899px) {
  .sidebar {
    transform: translateX(-102%);
    visibility: hidden;                 /* keeps closed-drawer links out of the tab order */
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    box-shadow: none;
  }
  .app.nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.22s ease, visibility 0s;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
  }
  .app.nav-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 16, 0.6);
    z-index: 55;
  }
  .main { margin-left: 0; }
  .main-header {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0 12px;
    min-height: 56px;
  }
  .menu-btn { display: inline-flex; }
  .page-title { font-size: 0.95rem; }
  .content { padding: 14px 12px 80px; }
  body.nav-locked { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .app.nav-open .sidebar { transition: none; }
}

/* ---------- Login screen: one centred card ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-top: 3px solid var(--steel);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card img.logo { width: 100%; max-width: 240px; height: auto; margin: 0 0 18px; }
.login-card h1 {
  font-size: 1.15rem;
  margin: 0 0 18px;
  color: var(--black);
}
.login-card form { text-align: left; }
.login-error {
  background: #fdecea;
  color: var(--danger);
  border-left: 3px solid var(--danger);
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 0.82rem;
  margin: 0 0 12px;
}

.view { display: none; }
.view.active { display: block; }

.subview { display: none; }
.subview.active { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-top: 3px solid var(--steel);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(13, 18, 23, 0.04);
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--black);
  margin: 0 0 14px;
}
.card h2::before {
  content: "";
  width: 10px; height: 10px;
  background: var(--steel);
  transform: skewX(-20deg);
  flex: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--steel);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d5dbe1;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input[type="text"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="password"]:hover,
textarea:hover,
select:hover { border-color: #b8c2cc; }
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(37, 77, 113, 0.15);
}
textarea { resize: vertical; min-height: 64px; }
input[readonly] { background: var(--accent-bg); border-color: #e3e8ed; cursor: default; font-weight: 700; color: var(--steel-dark); }

/* Browsers force their own autofill tint via the user-agent stylesheet —
   override it so autofilled fields match the rest of the form. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  box-shadow: 0 0 0 1000px #fff inset;
  -webkit-text-fill-color: var(--ink);
}

.field { margin-bottom: 14px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--ink);
  margin-top: 6px;
}
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--steel); }

/* ---------- Items table (edit mode) ---------- */
.items-wrap { overflow-x: auto; }
table.items {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}
table.items th {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  background: var(--black);
  text-align: left;
  padding: 8px 8px;
}
table.items td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.items tbody tr:nth-child(even) { background: #f8fafb; }
table.items td input,
table.items td select {
  padding: 7px 9px;
  font-size: 0.9rem;
  border-radius: 6px;
}
table.items td.amount-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  padding-right: 8px;
}
.col-qty { width: 70px; }
.col-unit { width: 90px; }
.col-rate { width: 110px; }
.col-amt { width: 110px; }
.col-del { width: 36px; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
}

.add-row-btn {
  margin-top: 12px;
  border: 2px dashed #aebbc8;
  background: transparent;
  color: var(--steel);
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 10px 12px;
  border-radius: 3px;
  cursor: pointer;
  width: 100%;
  font-size: 0.85rem;
}
.add-row-btn:hover { background: var(--accent-bg); border-color: var(--steel); }

/* ---------- Totals ---------- */
.totals {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.totals .row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 300px;
  font-size: 0.9rem;
}
.totals .row.grand {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  background: var(--steel);
  padding: 9px 12px;
  border-radius: 3px;
}
.totals .row.grand span:first-child { color: #fff; }
.totals .row span:first-child { color: var(--muted); }

/* ---------- Action bar ---------- */
.actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  background: var(--bg);
  box-shadow: 0 -10px 10px -4px var(--bg);   /* soft fade above the bar; the status line needs a solid backdrop */
  padding: 10px 0 6px;
  flex-wrap: wrap;
}
.btn {
  border: none;
  border-radius: 3px;
  padding: 13px 18px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 120px;
  transition: background 0.12s, color 0.12s;
}
.btn-primary { background: var(--steel); color: #fff; }
.btn-primary:hover { background: var(--black); }
.btn-secondary { background: #fff; color: var(--black); border: 2px solid var(--black); }
.btn-secondary:hover { background: var(--black); color: #fff; }
.btn-ghost { background: transparent; color: var(--danger); border: 2px solid #e2c2bf; }
.btn-ghost:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:focus-visible { outline: 3px solid rgba(37, 77, 113, 0.4); outline-offset: 2px; }

/* Autosave status, shown above the buttons in the sticky bar */
.save-status {
  flex: 1 0 100%;
  min-height: 1.3em;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--muted);
}
.save-status.saved { color: var(--ok); }
.save-status.saving, .save-status.pending { color: var(--muted); }
.save-status.error, .save-status.conflict, .save-status.number_taken { color: var(--danger); }
.save-status-btn {
  margin-left: 6px;
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: #fff;
  color: var(--black);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

/* ---------- History ---------- */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  gap: 10px;
}
.history-item:hover { background: var(--accent-bg); border-left-color: var(--steel); }
.history-item:last-child { border-bottom: none; }
.history-meta { font-size: 0.85rem; }
.history-meta b { display: block; color: var(--black); letter-spacing: 0.3px; }
.history-meta span { color: var(--muted); font-size: 0.78rem; }
.history-actions { display: flex; gap: 6px; }
.history-actions button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--black);
  border-radius: 3px;
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
}
.history-actions button:hover { border-color: var(--steel); color: var(--steel); }
.history-actions button.danger { color: var(--danger); }
.history-actions button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.empty-note { color: var(--muted); font-size: 0.85rem; padding: 8px 0; }

/* ---------- Payment details editor (Statements tab) ---------- */
.bank-edit-row {
  border: 1px solid var(--border);
  border-left: 4px solid var(--steel);
  border-radius: 3px;
  padding: 12px;
  margin-bottom: 12px;
}
.bank-edit-row .field { margin-bottom: 8px; }
.bank-edit-row .field:last-of-type { margin-bottom: 0; }
.bank-edit-row textarea { min-height: 90px; }
.bank-edit-row .bank-remove-btn {
  border: 1px solid #e2c2bf;
  background: #fff;
  color: var(--danger);
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

/* =====================================================================
   PRINT SHEET — mirrors the physical NEXT GEN MOTOR SPARES pad.
   Hidden on screen, shown only inside the browser print dialog.
   ===================================================================== */
#printSheet, #printSheetStatement { display: none; }

.sheet {
  position: relative;
  width: 190mm;
  margin: 0 auto;
  background: #fff;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  padding: 10mm 8mm 8mm;
  border: 1.5px solid #000;
  border-radius: 14px;
  overflow: hidden;
}

/* blue hazard stripes in two corners, as printed on the pad */
.sheet-deco { position: absolute; height: 5mm; width: 30mm; }
.sheet-deco-tl {
  top: 0; left: 0;
  background: repeating-linear-gradient(115deg, #1f7cc0 0 3.6mm, transparent 3.6mm 5.4mm);
}
.sheet-deco-br {
  bottom: 0; right: 0;
  background: repeating-linear-gradient(115deg, #1f7cc0 0 3.6mm, transparent 3.6mm 5.4mm);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 5mm;
  padding-bottom: 5mm;
  margin-bottom: 5mm;
}
.sheet-head .logo-block { display: flex; align-items: center; flex: none; }
.sheet-head img.logo { height: 24mm; width: auto; }
.sheet-head .company-info {
  flex: 1;
  border-left: 1.2mm solid #000;
  padding-left: 4mm;
  text-align: left;
  font-size: 7.8pt;
  line-height: 1.45;
}
.sheet-head .company-info strong { font-size: 7.8pt; font-weight: 600; }
.sheet-head .company-info .ci-gap { display: block; height: 2.2mm; }

.sheet-sub {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 5mm;
  margin-bottom: 5mm;
}
.ms-box {
  flex: 1;
  border: 1.5px solid #000;
  border-radius: 10px;
  padding: 3mm 4mm;
  font-size: 10pt;
}
.ms-box .ms-label { font-weight: 800; font-size: 11pt; margin-right: 4px; }
.ms-lines div {
  border-bottom: 1.5px dotted #444;
  min-height: 5mm;
  padding-top: 1mm;
}
.ms-lines div:last-child { border-bottom: none; }

.doc-box { width: 62mm; display: flex; flex-direction: column; gap: 0; }
.doc-title {
  background: #000;
  color: #fff;
  border-radius: 10px 10px 0 0;
  padding: 2.2mm 4mm;
  text-align: center;
  font-weight: 800;
  font-size: 11pt;
  letter-spacing: 0.4px;
  white-space: nowrap;
  outline: 1px solid #fff;
  outline-offset: -2mm;
}
.doc-meta {
  flex: 1;
  border: 1.5px solid #000;
  border-top: none;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.doc-meta .dm-row {
  flex: 1;
  display: flex;
  border-bottom: 1px solid #000;
  font-size: 9.5pt;
}
.doc-meta .dm-row:last-child { border-bottom: none; }
.doc-meta .dm-label {
  width: 18mm;
  font-weight: 800;
  padding: 2mm 3mm;
  border-right: 1px solid #000;
}
.doc-meta .dm-val { flex: 1; padding: 2mm 3mm; }

/* The rounded outer frame lives on a wrapper, NOT on the table: a collapsed-
   border table straddles its edge, so clipping it (overflow:hidden + radius)
   shaved the outer lines off and they printed faint or missing.
   Sizes are whole pixels so every 1px line lands on a pixel boundary and
   prints at the same weight (fractional mm row heights made lines uneven). */
.sheet-table-frame {
  border: 2px solid #000;
  border-radius: 12px;
  overflow: hidden;
}
table.sheet-table {
  width: 100%;
  border-collapse: collapse;
  border: none;
  font-size: 9.5pt;
}
table.sheet-table th {
  background: #fff;
  border: 1px solid #000;
  padding: 7px 8px;
  line-height: 14px;
  height: 28px;
  font-size: 10.5pt;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}
table.sheet-table td {
  border: 1px solid #000;
  padding: 6px 8px;
  line-height: 14px;
  height: 26px;
  vertical-align: middle;
}
/* the frame draws the outer edge, so drop the cells' own outer borders */
table.sheet-table tr > :first-child { border-left: none; }
table.sheet-table tr > :last-child { border-right: none; }
table.sheet-table thead tr:first-child > * { border-top: none; }
table.sheet-table tfoot tr:last-child > * { border-bottom: none; }
table.sheet-table td.qty { width: 24mm; text-align: center; white-space: nowrap; }
table.sheet-table td.rate { width: 26mm; text-align: right; }
table.sheet-table td.amt { width: 30mm; text-align: right; font-weight: 600; }
table.sheet-table th.th-qty { width: 24mm; }
table.sheet-table th.th-rate { width: 26mm; }
table.sheet-table th.th-amt { width: 30mm; }

.sheet-foot-row td {
  font-weight: 800;
  border: 1px solid #000;
}

.sheet-note {
  text-align: center;
  font-style: italic;
  font-size: 8.5pt;
  margin: 4mm 0 3mm;
}

.words-line {
  font-size: 9pt;
  font-style: italic;
  border-bottom: 1.5px dotted #444;
  padding: 1mm 0;
  min-height: 5mm;
}

.sign-block {
  margin-top: 6mm;
  display: flex;
  justify-content: space-between;
  font-size: 9.5pt;
}
.sign-block .sig-line { min-width: 75mm; border-bottom: 1.5px dotted #444; padding-bottom: 1mm; white-space: nowrap; }

.dn-signoff {
  margin-top: 5mm;
  font-size: 9.5pt;
}
.dn-signoff .condition-line { text-align: center; font-size: 9pt; margin-bottom: 4mm; }
.dn-signoff .dn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5mm 10mm;
}
.dn-signoff .dn-field { border-bottom: 1.5px dotted #444; padding: 2mm 0 1mm; }
.dn-signoff .dn-label { font-weight: 400; font-size: 10.5pt; }

/* ---- Statement of accounts print layout ---- */
.stmt-title {
  text-align: center;
  font-weight: 700;
  text-decoration: underline;
  font-size: 12pt;
  margin: 2mm 0 6mm;
}
table.sheet-table td.order-no,
table.sheet-table th.th-order-no { width: 28mm; }
table.sheet-table td.delivery-date,
table.sheet-table th.th-delivery-date { width: 32mm; }
.stmt-spacer td { border: none; height: 24px; }
.stmt-payment-heading {
  font-weight: 700;
  text-decoration: underline;
  margin: 6mm 0 3mm;
  font-size: 10pt;
}
.stmt-payment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70mm, 1fr));
  border: 1.5px solid #000;
  border-radius: 10px;
  overflow: hidden;
}
.stmt-bank-block {
  padding: 3mm 4mm;
  font-size: 9.5pt;
  line-height: 1.6;
  border-right: 1px solid #000;
  border-top: 1px solid #000;
}
.stmt-bank-block:first-child,
.stmt-bank-block:nth-child(2) { border-top: none; }
.stmt-bank-block:last-child { border-right: none; }
.stmt-bank-name { font-weight: 700; margin-bottom: 1mm; }
.stmt-footer-row {
  display: flex;
  justify-content: space-between;
  gap: 4mm;
  font-size: 8.5pt;
  margin-top: 7mm;
  padding-top: 3mm;
  border-top: 2px solid var(--steel);
}
.stmt-footer-bar {
  height: 6mm;
  background: var(--steel);
  margin: 4mm -8mm -8mm -8mm;
}

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body * { visibility: hidden; }
  #loginScreen { display: none !important; }
  #app { display: none !important; }
  .print-active, .print-active * { visibility: visible; }
  .print-active { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  .sheet { border-color: #000; box-shadow: none; }
  /* Print backgrounds (the black title block, the blue stripes and statement
     bar) even if "Background graphics" is off in the print dialog; keep the
     page white. */
  html, body { background: #fff !important; }
  .sheet, .sheet * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Search-result match highlight (Statements → Search) */
mark { background: #ffe58a; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- Logout button (icon + label) ---------- */
.btn-logout { display: inline-flex; align-items: center; gap: 8px; }
.btn-logout svg { width: 16px; height: 16px; flex: none; }

/* ---------- Overview page ---------- */
.ov-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.ov-greeting { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--black); }
.ov-date { margin: 4px 0 0; color: var(--muted); font-size: 0.88rem; }
.ov-actions { display: flex; gap: 10px; }
.ov-actions .btn { flex: none; min-width: 150px; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 4px solid var(--steel);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--muted); }
.stat-value { margin-top: 6px; font-size: 1.9rem; font-weight: 800; color: var(--steel); font-variant-numeric: tabular-nums; }
.history-actions-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--black);
  border-radius: 3px;
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}
.history-actions-btn:hover { border-color: var(--steel); color: var(--steel); }

/* ---------- Document pages: form + live preview ---------- */
.doc-preview { display: none; }
.doc-layout.show-preview .doc-preview { display: block; margin-top: 18px; }
.doc-preview {
  background: #dde3e9;
  border-top: 3px solid var(--black);
  border-radius: var(--radius);
  padding: 12px;
}
.preview-head {
  margin: 0 0 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--steel-dark);
}
.preview-stage {
  background: #fff;
  overflow: hidden;
  position: relative;
  box-shadow: 0 1px 4px rgba(13, 18, 23, 0.25);
}
@media (min-width: 1180px) {
  .doc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(380px, 34vw, 560px);
    gap: 24px;
    align-items: start;
  }
  .doc-preview { display: block; position: sticky; top: 16px; margin-top: 0; }
  .doc-layout.show-preview .doc-preview { margin-top: 0; }
  .preview-toggle { display: none; }
}

@media (max-width: 640px) {
  .ov-top { align-items: flex-start; }
  .ov-actions { width: 100%; }
  .ov-actions .btn { flex: 1 1 0; min-width: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.5rem; }
}
