@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('../fonts/poppins-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('../fonts/poppins-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('../fonts/poppins-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy-900: #0B1F3A;
  --navy-700: #13325C;
  --navy-50: #EEF2F7;
  --gold-500: #C9A24B;
  --gold-700: #8A6A1F;
  --gold-200: #E8D3A0;
  --bg: #F8F5EE;
  --surface: #FFFFFF;
  --border: #E3DCCB;
  --text: #1D2733;
  --text-muted: #5B6673;
  --ok-bg: #E3F1E6;
  --ok: #1E6B3A;
  --warn-bg: #FBEFD2;
  --warn: #7A5A00;
  --err-bg: #FADBD8;
  --err: #9B2C22;
  --sidebar-text: #D8E2EE;
  --nav-hover: rgba(201, 162, 75, 0.12);
  --nav-active: rgba(201, 162, 75, 0.2);
  --row-hover: #FBF9F4;
  --overlay: rgba(11, 31, 58, 0.55);
  --radius-control: 8px;
  --radius-card: 10px;
  --shadow: 0 2px 4px rgba(11, 31, 58, 0.05);
  --font-head: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: clamp(24px, 2.4vw, 30px); }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

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

:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

img, svg { vertical-align: middle; }

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--navy-900);
  padding: 12px 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--gold-500);
  font-weight: 600;
}
.skip-link:focus { top: 16px; }

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.is-negative { color: var(--err); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: var(--navy-900);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--nav-hover);
  text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--gold-500);
  color: var(--navy-900);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-mark .icon { width: 24px; height: 24px; }

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  flex: 0 0 auto;
}

.brand-name {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  color: var(--surface);
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.brand-sub {
  font-size: 11px;
  color: var(--gold-200);
  margin-top: 2px;
}

.nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-200);
  opacity: 0.8;
  padding: 12px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  color: var(--sidebar-text);
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav-link:hover {
  background: var(--nav-hover);
  color: var(--surface);
  text-decoration: none;
}
.nav-link.is-active {
  background: var(--nav-active);
  border-left-color: var(--gold-500);
  color: var(--surface);
}
.nav-link .icon { width: 19px; height: 19px; }

.sidebar-user {
  border-top: 1px solid var(--nav-hover);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold-500);
  color: var(--navy-900);
  display: grid;
  place-items: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 auto;
}
.user-meta { min-width: 0; flex: 1; }
.user-name {
  color: var(--surface);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { color: var(--gold-200); font-size: 11px; }
.logout-form { margin: 0; }
.logout-form .icon-btn { color: var(--gold-200); }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  cursor: pointer;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--navy-50); color: var(--navy-900); }
.icon-btn.danger:hover { background: var(--err-bg); color: var(--err); }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 16px;
  background: var(--navy-900);
  color: var(--surface);
  position: sticky;
  top: 0;
  z-index: 35;
}
.topbar .icon-btn { color: var(--gold-200); }
.topbar-brand {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  color: var(--surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .brand-logo { height: 26px; }
.topbar .avatar { width: 34px; height: 34px; margin-left: auto; font-size: 12px; }

.content {
  width: 100%;
  max-width: 1440px;
  padding: 32px;
  flex: 1;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title { margin: 0; }
.page-sub { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -12px 0;
  padding-right: 8px;
  font-size: 13px;
  font-weight: 500;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}
.footer-sign {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold-700);
  font-size: 13px;
  font-weight: 600;
}
.estex-mark { width: 16px; height: 16px; }
.footer-copy { font-size: 11px; }
.footer-tag { font-size: 11px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 45;
}
body.no-scroll { overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }

.btn-primary {
  background: var(--gold-500);
  color: var(--navy-900);
  border-color: var(--gold-500);
}
.btn-primary:hover { background: var(--gold-700); border-color: var(--gold-700); color: var(--surface); }

.btn-outline {
  background: transparent;
  color: var(--navy-700);
  border-color: var(--navy-700);
}
.btn-outline:hover { background: var(--navy-50); }

.btn-quiet {
  background: transparent;
  color: var(--gold-700);
  border-color: transparent;
}
.btn-quiet:hover { background: var(--navy-50); }

.btn-danger {
  background: transparent;
  color: var(--err);
  border-color: var(--err);
}
.btn-danger:hover { background: var(--err-bg); }

.btn-sm {
  min-height: 44px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-block { width: 100%; }

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { margin: 0; font-size: 16px; }
.card-sub { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.grid-2 > *, .grid-3 > * { min-width: 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  grid-column: span 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.kpi:nth-last-child(-n+2) { grid-column: span 3; }
.kpi-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}
.kpi-value {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kpi-currency {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.kpi-currency::after { content: "\00a0"; }
.kpi-note {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 6px;
}

.net-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold-500);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.net-banner.is-loss { border-left-color: var(--err); }
.net-label { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.net-value {
  font-family: var(--font-head);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.net-value.is-loss { color: var(--err); }
.net-meta { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ---------- Chips & banners ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.chip .icon { width: 13px; height: 13px; }
.chip-neutral { background: var(--navy-50); color: var(--navy-700); border-color: var(--border); }
.chip-gold { background: var(--gold-200); color: var(--navy-900); border-color: var(--gold-500); }
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bg); }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-bg); }
.chip-err { background: var(--err-bg); color: var(--err); border-color: var(--err-bg); }

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: 13px;
}
.banner .icon { width: 18px; height: 18px; margin-top: 1px; }
.banner-success { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok); }
.banner-error { background: var(--err-bg); border-color: var(--err-bg); color: var(--err); }
.banner-warn { background: var(--warn-bg); border-color: var(--warn-bg); color: var(--warn); }
.banner-info { background: var(--navy-50); border-color: var(--border); color: var(--navy-700); }
.banner-text { flex: 1; }
.gap-group + .gap-group { margin-top: 10px; }
.gap-list { margin-top: 4px; line-height: 1.8; }
.banner-close {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  margin: -8px -8px -8px 0;
  border-radius: 6px;
  opacity: 0.75;
}
.banner-close:hover { opacity: 1; }

/* ---------- Period & filters ---------- */
.period-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.period-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.period-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.period-chip:hover { border-color: var(--gold-500); text-decoration: none; }
.period-chip.is-active {
  background: var(--gold-200);
  border-color: var(--gold-500);
  color: var(--navy-900);
}
.period-custom { margin: 0; }
.period-custom summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.period-custom summary::-webkit-details-marker { display: none; }
.period-custom[open] summary { border-color: var(--gold-500); background: var(--gold-200); color: var(--navy-900); }
.period-custom-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}
.period-custom-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.period-current {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.filter-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  flex: 1 1 180px;
}
.filter-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.filter-field--wide { flex: 2 1 260px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filter-checks { display: flex; flex-wrap: wrap; gap: 0 16px; }
.filter-checks .check-field { min-height: 0; padding: 0; font-size: 13px; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.summary-item {
  padding: 14px 20px;
  background: var(--surface);
}
.summary-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.summary-value {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  white-space: nowrap;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  background: var(--navy-900);
  color: var(--gold-200);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  padding: 11px 12px;
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:hover td { background: var(--row-hover); }
.table tfoot td {
  background: var(--bg);
  border-top: 2px solid var(--border);
  font-weight: 600;
}
.table .num { text-align: right; }
.table th.num { text-align: right; }
.table-sticky th:first-child,
.table-sticky td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 110px;
}
.table-sticky thead th:first-child { background: var(--navy-900); z-index: 2; }
.table-sticky tbody tr:hover td:first-child { background: var(--row-hover); }
.table-sticky tfoot td:first-child { background: var(--bg); }

.table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.table-actions form { margin: 0; }
.route { font-weight: 500; }
.route-arrow { color: var(--gold-700); font-weight: 600; }
.note-line { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.table td .note-line { max-width: 130px; white-space: normal; }
.empty-cell { text-align: center; color: var(--text-muted); padding: 32px 16px !important; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.pagination-links { display: flex; gap: 8px; }

/* ---------- Forms ---------- */
.form-card { max-width: 1000px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.req { color: var(--gold-700); }
.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold-500);
  outline: 3px solid var(--gold-200);
  outline-offset: 0;
}
.textarea { min-height: 84px; resize: vertical; }
.input[readonly] { background: var(--bg); color: var(--text-muted); }
.field-help { font-size: 11px; color: var(--text-muted); }
.field-error { font-size: 11px; color: var(--err); font-weight: 500; }
.field-warning { font-size: 11px; color: var(--warn); font-weight: 600; }
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--err); }
.profit-line {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  text-align: right;
}
.profit-line__legend {
  padding: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.profit-line__seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  overflow: hidden;
  background: var(--surface);
}
.profit-line__opt { position: relative; display: flex; }
.profit-line__opt + .profit-line__opt { border-left: 1px solid var(--border); }
.profit-line__opt input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.profit-line__opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-700);
  cursor: pointer;
}
.profit-line__opt input:checked + span {
  background: var(--navy-900);
  color: var(--surface);
}
.profit-line__opt input:focus-visible + span {
  outline: 3px solid var(--gold-200);
  outline-offset: -3px;
}
.profit-line__hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  max-width: 280px;
  margin-left: auto;
}
.profit-line.is-locked .profit-line__opt input:disabled + span { opacity: 0.45; cursor: not-allowed; }
.check-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
}
.check-field input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--gold-500);
  flex: 0 0 auto;
}
.check-field label { font-size: 13px; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.form-actions .btn-primary { min-width: 150px; }
.rate-input { max-width: 150px; margin-left: auto; }
.table-stack .rate-input { margin-left: 0; }
.inline-link-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-link-form .select { width: auto; min-width: 0; max-width: 220px; }
.form-note {
  background: var(--navy-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--navy-700);
  margin-bottom: 16px;
}
.form-note .icon { width: 16px; height: 16px; margin-right: 6px; }
.form-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.form-side { position: sticky; top: 16px; }

.calc-card { background: var(--navy-900); color: var(--surface); border: 0; }
.calc-card .card-title { color: var(--surface); }
.calc-card .card-sub { color: var(--gold-200); }
.calc-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--nav-hover);
  font-size: 13px;
}
.calc-row span:first-child { color: var(--sidebar-text); }
.calc-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; }
.calc-total {
  border-bottom: 0;
  border-top: 1px solid var(--gold-500);
  margin-top: 4px;
  padding-top: 12px;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
}
.calc-negative { color: var(--err-bg) !important; }
.calc-note { color: var(--gold-200); font-size: 11px; margin-top: 12px; }

.section-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 12px;
}

/* ---------- Dashboard pieces ---------- */
.pnl { margin: 0; }
.pnl-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.pnl-row:last-child { border-bottom: 0; }
.pnl-value a { display: inline-flex; align-items: center; min-height: 44px; }
.pnl-label { color: var(--text); min-width: 0; }
.pnl-sub { color: var(--text-muted); font-size: 11px; }
.pnl-value { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; overflow-wrap: anywhere; }
.pnl-value--wrap { white-space: normal; }
.pnl-total {
  border-top: 2px solid var(--navy-900);
  border-bottom: 0;
  margin-top: 4px;
  padding-top: 12px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 16px;
}
.pnl-total .pnl-value { font-size: 20px; }

.expense-split { display: flex; flex-direction: column; gap: 12px; }
.expense-split-row {
  display: grid;
  grid-template-columns: 130px 1fr 110px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.expense-split-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--navy-50);
  overflow: hidden;
}
.expense-split-fill { display: block; height: 100%; background: var(--gold-500); border-radius: 999px; }
.expense-split-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.trend { display: flex; flex-direction: column; gap: 10px; }
.trend-row {
  display: grid;
  grid-template-columns: 68px 1fr 130px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.trend-track { height: 10px; background: var(--navy-50); border-radius: 999px; overflow: hidden; }
.trend-fill { display: block; height: 100%; border-radius: 999px; background: var(--navy-700); }
.trend-fill.is-negative { background: var(--err); }
.trend-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 40px 24px;
}
.empty-state--compact { padding: 0; }
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--navy-50);
  color: var(--navy-700);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); max-width: 480px; margin: 0 auto 16px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.recent-item:last-child { border-bottom: 0; }
a.recent-item { color: inherit; text-decoration: none; }
a.recent-item:hover { background: var(--row-hover); }
.recent-main { min-width: 0; }
.recent-title { font-weight: 500; }
.recent-sub { color: var(--text-muted); font-size: 11px; }
.recent-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* ---------- Auth & setup ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background: var(--bg);
}
.auth-panel {
  background: var(--navy-900);
  color: var(--surface);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand--stack { flex-direction: column; align-items: flex-start; gap: 10px; }
.auth-brand .brand-logo { height: 62px; }
.auth-brand-name {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  color: var(--surface);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.auth-brand-sub { color: var(--gold-200); font-size: 11px; }
.auth-headline {
  font-family: var(--font-head);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 600;
  line-height: 1.15;
  max-width: 460px;
  color: var(--surface);
}
.auth-headline .accent { color: var(--gold-500); }
.auth-copy { color: var(--sidebar-text); max-width: 430px; font-size: 14px; }
.auth-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--gold-200);
  font-size: 13px;
}
.auth-points li { display: flex; gap: 10px; align-items: flex-start; }
.auth-points .icon { width: 17px; height: 17px; margin-top: 2px; color: var(--gold-500); }
.auth-panel .app-footer {
  border-top-color: var(--nav-hover);
  color: var(--sidebar-text);
  padding: 16px 0 0;
  align-items: flex-start;
  text-align: left;
}
.auth-panel .footer-sign { color: var(--gold-200); }
.auth-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.auth-card h1 { font-size: 26px; margin-bottom: 4px; }
.auth-card .auth-sub { color: var(--text-muted); margin-bottom: 24px; }
.auth-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}
.auth-footer .footer-sign { color: var(--gold-700); }
.auth-card .app-footer { display: none; }
.auth-alt { margin-top: 16px; font-size: 12px; color: var(--text-muted); }
.password-reveal { position: relative; }
.password-reveal .input { padding-right: 54px; }
.password-reveal .icon-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.setup-shell {
  min-height: 100vh;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.setup-card {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 32px;
}
.setup-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.preflight {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 16px 0 24px;
}
.preflight-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg);
  font-size: 12px;
}
.preflight-item .icon { width: 16px; height: 16px; }
.preflight-item.ok { color: var(--ok); }
.preflight-item.bad { color: var(--err); }
.setup-section { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 20px; }
.setup-section h2 { font-size: 15px; margin-bottom: 4px; }
.setup-section .card-sub { margin-bottom: 16px; }

/* ---------- Dialog ---------- */
dialog.dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 440px;
  width: calc(100% - 32px);
}
dialog.dialog::backdrop { background: var(--overlay); }
.dialog-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(11, 31, 58, 0.18);
  padding: 24px;
}
.dialog-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.dialog-message { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.share-actions .btn { flex: 1 1 auto; justify-content: center; }
.share-hint { color: var(--text-muted); font-size: 12px; line-height: 1.5; margin-bottom: 16px; }
.share-dialog .dialog-message { margin-bottom: 12px; }

/* ---------- Print views ---------- */
.print-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px;
  background: var(--surface);
}
.print-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.print-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 3px solid var(--navy-900);
}
.print-brand { display: flex; align-items: center; gap: 12px; }
.print-brand .brand-logo { height: 44px; }
.print-title { font-family: var(--font-head); font-size: 24px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: .03em; }
.print-sub { color: var(--text-muted); font-size: 12px; }
.print-meta { text-align: right; font-size: 12px; color: var(--text-muted); }
.print-meta strong { color: var(--text); display: block; font-size: 13px; }
.print-section { margin-top: 24px; break-inside: avoid; }
.print-section h2 { font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 10px; }
.print-page .table { font-size: 11px; }
.print-page .table th { background: var(--navy-900); color: var(--gold-200); }
.print-page .app-footer { margin-top: 32px; }

/* Letterhead printed on statement, transport and settlement pages. */
.doc-letter { display: none; }
.doc-letter-brand { display: flex; align-items: center; gap: 12px; }
.doc-letter-name { font-family: var(--font-head); font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.doc-letter-sub { color: var(--text-muted); font-size: 12px; }
.doc-letter-meta { text-align: right; font-size: 11px; color: var(--text-muted); }

/* ---------- Points, mileage and offloadings ---------- */
.is-warn { color: var(--warn); }

#offloading,
#offloading-record { scroll-margin-top: 84px; }

.gas-balance {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold-500);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px 24px;
  margin-bottom: 16px;
}
.gas-balance.is-complete { border-left-color: var(--ok); }
.gas-balance.is-over { border-left-color: var(--err); }
.gas-balance.is-over .gas-value { color: var(--err); }
.gas-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.gas-value {
  font-family: var(--font-head);
  font-size: clamp(26px, 3.6vw, 34px);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.gas-value span { font-size: 0.5em; font-weight: 600; color: var(--text-muted); }
.gas-balance.is-complete .gas-value { color: var(--ok); }
.gas-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.gas-meter { min-width: 0; }
.gas-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }

.balance-bar { height: 8px; border-radius: 999px; background: var(--navy-50); overflow: hidden; }
.balance-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-700));
  transition: width 120ms ease;
}
.balance-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.offload-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg);
  padding: 14px;
}
.offload-rows { display: flex; flex-direction: column; gap: 10px; }
.offload-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 1.1fr) 44px;
  gap: 10px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 12px;
}
.offload-row .field { margin: 0; }
.offload-pricing {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.form-actions--inline { margin-top: 16px; padding-top: 14px; }
.form-actions--inline .muted { margin: 0; }
.form-actions--inline + .section-title { margin-top: 28px; }
.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 8px;
}
.filter-form--inline {
  padding: 0 0 14px;
  margin-bottom: 4px;
}
.offload-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.offload-balance {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}
.offload-balance .balance-bar { margin-top: 10px; }
.offload-balance.is-over { border-color: var(--err); background: var(--err-bg); }
.offload-balance.is-clear { border-color: var(--ok); }
.balance-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.balance-figures b { color: var(--text); font-weight: 600; }
.balance-remaining b { color: var(--navy-900); }
.offload-balance.is-over .balance-remaining b { color: var(--err); }
.balance-note { margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.offload-balance.is-over .balance-note { color: var(--err); font-weight: 600; }

.drop-form {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.drop-form-title { font-size: 15px; font-weight: 600; color: var(--navy-900); }
.drop-form-sub { color: var(--text-muted); font-size: 12px; margin: 4px 0 12px; }
.drop-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.drop-form-grid .field { margin: 0; }
.drop-form-grid .field--action .btn { width: 100%; }
[data-drop-preview].is-over { color: var(--err); font-weight: 600; }
.link-quiet {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
}

.inline-add {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.inline-add-title { font-size: 13px; font-weight: 600; color: var(--navy-900); margin-bottom: 10px; }
.inline-add-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-add-grid .field { flex: 1 1 200px; margin: 0; }
.inline-add-grid .field--action { flex: 0 0 auto; }
.field--action { display: flex; align-items: flex-end; }
.field--action .btn { justify-content: center; }
.field--action .btn .icon { margin-right: 4px; }

@media screen and (max-width: 767px) {
  .gas-balance { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .gas-side { justify-content: flex-start; }
  .offload-row,
  .drop-form-grid { grid-template-columns: 1fr; }
  .offload-pricing { grid-template-columns: 1fr; }
  .offload-row .offload-remove { justify-self: end; }
  .inline-add-grid { flex-direction: column; align-items: stretch; }
  .inline-add-grid .field--action { flex: 1 1 auto; }
  .inline-add-grid .field--action .btn { width: 100%; }
  .field--action .btn { width: 100%; }
}

/* ---------- Report navigation & new report blocks ---------- */
.page-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-700);
  margin-bottom: 4px;
}

.report-nav {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 12px;
  margin: -4px 0 8px;
  background: var(--bg);
  scrollbar-width: thin;
}
.report-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--navy-700);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.report-nav-link:hover {
  border-color: var(--gold-500);
  background: var(--gold-200);
  text-decoration: none;
}

.report-section { scroll-margin-top: 76px; }

.section-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-700);
  margin-bottom: 2px;
}

.unit { font-size: 0.55em; font-weight: 600; color: var(--text-muted); margin-left: 2px; }

.ageing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-top: 4px;
}
.ageing-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg);
  padding: 16px;
}
.ageing-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ageing-title { margin: 0; font-size: 15px; }
.ageing-panel .table-wrap { background: var(--surface); }
.ageing-panel .empty-state { padding: 12px 0; }
.ageing-panel .empty-state p { margin: 0; }

.share-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.share-meter {
  display: inline-block;
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: var(--navy-50);
  overflow: hidden;
  flex: 0 0 auto;
}
.share-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold-500);
}
.share-meter.is-over span { background: var(--err); }

.export-row { width: 100%; }
.export-row .btn { flex: 1 1 auto; }
.report-top-link {
  display: flex;
  justify-content: flex-end;
  margin: 16px 0 0;
  font-size: 12px;
}
.report-top-link a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .report-nav { top: 58px; }
  .report-section { scroll-margin-top: 134px; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 280px;
    max-width: 86vw;
    transform: translateX(-102%);
    transition: transform 160ms ease;
    box-shadow: 0 0 24px rgba(11, 31, 58, 0.2);
    z-index: 46;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay.is-visible { display: block; }
  .topbar { display: flex; }
  .content { padding: 24px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-split { grid-template-columns: 1fr; }
  .form-side { position: static; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-panel { padding: 28px 24px; gap: 20px; }
  .auth-headline { font-size: 28px; }
  .auth-points { display: none; }
  .auth-panel .app-footer { display: none; }
  .auth-card .app-footer { display: flex; }
  .auth-form-panel { padding: 32px 24px; }
}

@media (max-width: 767px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi, .kpi:nth-last-child(-n+2) { grid-column: auto; }
  .kpi:last-child { grid-column: 1 / -1; }
}

/* Wide ledgers become stacked cards below desktop width so no column is cut off. */
@media screen and (max-width: 1279px) {
  .table-wrap--stack {
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .table-stack,
  .table-stack tbody,
  .table-stack tfoot { display: block; width: 100%; }
  .table-stack thead { display: none; }
  .table-stack tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    margin: 0 0 10px;
    overflow: hidden;
  }
  .table-stack tbody tr:last-child { margin-bottom: 0; }
  .table-stack td {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 14px;
    border-top: 0;
    text-align: right;
  }
  .table-stack tbody td:first-child,
  .table-stack tfoot td:first-child {
    display: block;
    background: var(--bg);
    padding: 9px 14px;
    text-align: left;
    font-weight: 600;
  }
  .table-stack tfoot td:first-child { border-bottom: 1px solid var(--border); }
  .table-stack td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
  }
  .table-stack td:first-child::before,
  .table-stack td[data-label=""]::before,
  .table-stack td:not([data-label])::before { content: none; }
  .table-stack tbody td.empty-cell,
  .table-stack tfoot td.empty-cell {
    display: block;
    background: transparent;
    padding: 0 !important;
    text-align: center;
  }
  .table-stack td.empty-cell .empty-state { padding: 22px 16px; }
  .table-stack td[data-label=""],
  .table-stack td:not([data-label]) { justify-content: flex-end; }
  .table-stack td:empty { display: none; }
  .table-stack td:first-child,
  .table-stack th:first-child { position: static; min-width: 0; }
  .table-stack td .table-actions { justify-content: flex-end; }
  .table-stack td .note-line {
    flex: 1 0 100%;
    max-width: none;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .table-stack td:first-child .note-line { text-align: left; }
  .table-stack td.nowrap { white-space: normal; }
  .table-stack tbody tr:hover td,
  .table-stack tbody tr:hover td:first-child { background: transparent; }
  .table-stack tbody tr:hover td:first-child { background: var(--bg); }
}

/* Tighter cell gutters keep ten-column ledgers on-screen at 1280px windows. */
@media (min-width: 1200px) and (max-width: 1399px) {
  .table th, .table td { padding-left: 8px; padding-right: 8px; }
  .summary-item { padding-left: 14px; padding-right: 14px; }
  /* The consignment reference link already opens the load. */
  .icon-btn--open { display: none; }
}

/* Six money totals need two rows until the window is wide enough for one. */
@media (min-width: 1280px) and (max-width: 1535px) {
  .summary-strip--six { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 600px) and (max-width: 1279px) {
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .summary-item {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 4px 12px;
  }
  .summary-item > .note-line { grid-column: 1 / -1; margin-top: 0; }
  .summary-value { font-size: 17px; justify-self: end; }
}

@media (max-width: 599px) {
  .content { padding: 16px; padding-bottom: 24px; }
  body.has-sticky-actions .content { padding-bottom: 96px; }
  body.has-sticky-actions .app-footer { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 45%; justify-content: center; }
  .card-head { flex-wrap: wrap; }
  .card-head > .page-actions { flex-shrink: 1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi, .kpi:nth-last-child(-n+2) { grid-column: auto; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 4px 12px;
    padding: 10px 14px;
  }
  .summary-item > .note-line { grid-column: 1 / -1; margin-top: 0; }
  .summary-value { margin-top: 0; font-size: 16px; justify-self: end; }
  .period-current { width: 100%; margin-left: 0; }
  .period-custom-form { width: 100%; }
  .period-custom-form label { flex: 1 1 140px; }
  .form-grid { grid-template-columns: 1fr; }
  .profit-line { text-align: left; }
  .profit-line__seg { display: flex; width: 100%; }
  .profit-line__opt { flex: 1 1 0; }
  .profit-line__opt span { min-width: 0; width: 100%; }
  .profit-line__hint { margin-left: 0; max-width: none; }
  .input, .select, .textarea { font-size: 16px; }
  .form-actions--sticky {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(11, 31, 58, 0.06);
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .form-actions--sticky .btn { flex: 1; min-width: 0; }
  .form-card { padding: 16px; }
  .card { padding: 16px; }
  .report-nav { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .ageing-panel { padding: 12px; }
  .share-meter { width: 48px; }
  .net-banner { padding: 16px; }
  .net-value { font-size: 30px; }
  .period-bar { gap: 6px; }
  .period-chip { padding: 0 12px; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-field { flex: 1 1 auto; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; }
  .pagination { align-items: flex-start; }
  .trend-row { grid-template-columns: 56px 1fr 100px; }
  .expense-split-row { grid-template-columns: 1fr auto; }
  .expense-split-row .expense-split-bar { grid-column: 1 / -1; grid-row: 2; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 9px 10px; }
  .setup-shell { padding: 16px 12px; }
  .setup-card { padding: 20px 16px; }
  .auth-form-panel { padding: 24px 16px; }
  .auth-panel { padding: 20px 16px; }
  .auth-headline { font-size: 24px; }
  dialog.dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
  }
  dialog.dialog .dialog-card {
    min-height: 100%;
    border-radius: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  body { background: var(--surface); }
  .sidebar, .topbar, .sidebar-overlay, .page-actions, .period-bar, .filter-bar, .report-nav,
  .no-print, .form-actions, .pagination, .print-toolbar, .banner-close, .report-top-link { display: none !important; }
  .app-shell { display: block; }
  .content { max-width: none; padding: 0; }
  .card, .table-wrap, .net-banner, .kpi { box-shadow: none; }
  .app-footer { border-top: 1px solid #999; break-inside: avoid; }
  .print-page { padding: 0; max-width: none; }
  .doc-letter { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding-bottom: 12px; margin-bottom: 18px; border-bottom: 3px solid var(--navy-900); }
  .doc-letter .brand-logo { height: 42px; }
  .table th { background: #EEEEEE !important; color: #000000 !important; }
  .table td, .table th { border: 1px solid #CCCCCC; }
  .table-sticky th:first-child, .table-sticky td:first-child { position: static; }
  a { color: #000000; text-decoration: none; }
  @page { margin: 12mm; }
}
