/* ==========================================================================
   Poolot Account — "paper" design system
   Follows docs/design-board: warm paper, ink type, hairline rules instead of
   shadows, serif page titles, colour only where money moves.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;

  --bg: #f6f7f3;
  --bg-subtle: #eef0ea;
  --card: #ffffff;
  --card-hover: #fafbf8;
  --card-subtle: #fbfcf9;

  --ink: #12151a;
  --ink-2: #3a434d;
  --muted: #6f7883;
  --muted-light: #9aa29c;

  --line: #e3e6df;
  --line-strong: #cdd2c9;
  --line-subtle: #eceee8;

  /* Money: green in, brick out, amber needs attention */
  --in: #0d7a4f;
  --in-ink: #0a5c3c;
  --in-bg: #e8f4ed;
  --out: #b2412c;
  --out-ink: #8a3423;
  --out-bg: #fbece7;
  --warn: #8a5a06;
  --warn-ink: #6d4704;
  --warn-bg: #fbf1d9;
  --info: #2c4a72;
  --info-bg: #eaf0f8;

  --bar-in: #0d7a4f;
  --bar-out: #dcc3ba;
  --bar-neutral: #2c3540;

  --focus: #3a434d;
  --focus-ring: rgba(18, 21, 26, 0.1);

  --primary: #12151a;
  --primary-hover: #262c34;
  --primary-text: #ffffff;

  /* Rail stays dark in both themes */
  --rail: #14181e;
  --rail-line: #262c34;
  --rail-hover: #1c2128;
  --rail-active: #232a33;
  --rail-ink: #eef0ea;
  --rail-muted: #98a19b;
  --sidebar-w: 236px;

  --shadow-pop: 0 18px 40px -20px rgba(20, 24, 30, 0.35), 0 0 0 1px rgba(20, 24, 30, 0.06);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-full: 999px;

  --max-w: 1200px;
  --gutter: clamp(18px, 3vw, 40px);
}

[data-theme='dark'] {
  color-scheme: dark;

  --bg: #111418;
  --bg-subtle: #1a1e24;
  --card: #171b20;
  --card-hover: #1c2127;
  --card-subtle: #1a1e24;

  --ink: #eef0ea;
  --ink-2: #c4cac2;
  --muted: #8d968f;
  --muted-light: #5f6862;

  --line: #262b32;
  --line-strong: #343a42;
  --line-subtle: #20252b;

  --in: #4cb487;
  --in-ink: #7fcfa8;
  --in-bg: rgba(76, 180, 135, 0.13);
  --out: #e07a63;
  --out-ink: #f0a08c;
  --out-bg: rgba(224, 122, 99, 0.13);
  --warn: #d9a441;
  --warn-ink: #e8c27a;
  --warn-bg: rgba(217, 164, 65, 0.13);
  --info: #8fb1dc;
  --info-bg: rgba(143, 177, 220, 0.12);

  --bar-in: #4cb487;
  --bar-out: #6e5149;
  --bar-neutral: #aab2ab;

  --focus: #c4cac2;
  --focus-ring: rgba(238, 240, 234, 0.12);

  --primary: #eef0ea;
  --primary-hover: #d7dbd3;
  --primary-text: #111418;

  --rail: #0c0f12;
  --rail-line: #1f242a;
  --rail-hover: #161a1f;
  --rail-active: #1f252c;

  --shadow-pop: 0 24px 50px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.07);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  font-feature-settings: 'cv11', 'ss01';
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h1 {
  font: 400 clamp(28px, 2.6vw, 38px) / 1.06 var(--display);
  letter-spacing: -0.01em;
}

h2 {
  font-size: 14px;
}

h3 {
  font-size: 13.5px;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

strong,
b {
  font-weight: 600;
}

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

::selection {
  background: var(--in-bg);
}

[hidden],
.form-error[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 1000;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 500;
}

.skip-link:focus {
  left: 14px;
}

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

.num,
.tnum {
  font-variant-numeric: tabular-nums;
}

.font-bold {
  font-weight: 600;
}

.money-in {
  color: var(--in) !important;
}

.money-out,
.negative {
  color: var(--out) !important;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-ghost {
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--card-subtle);
  border-color: var(--muted-light);
}

.btn-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.btn-quiet:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.btn-quiet svg {
  width: 16px;
  height: 16px;
}

/* A quiet button that carries the row's main action gets a hairline. */
.btn.btn-quiet,
.btn-ghost.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn.btn-quiet:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.btn-danger,
.btn.btn-danger {
  background: var(--out);
  border-color: var(--out);
  color: #ffffff;
}

.btn-danger:hover,
.btn.btn-danger:hover {
  background: var(--out-ink);
  border-color: var(--out-ink);
}

.btn-quiet.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--out);
}

.btn-quiet.btn-danger:hover {
  background: var(--out-bg);
  color: var(--out);
}

.btn-sm {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12.5px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn:disabled,
.btn-quiet:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-theme-desktop {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.btn-theme-desktop:hover {
  color: var(--ink);
  background: var(--bg-subtle);
}

.btn-theme-desktop svg {
  width: 16px;
  height: 16px;
}

.link-inline,
.stat-note a {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-inline:hover,
.stat-note a:hover {
  text-decoration-color: currentColor;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > label,
.label,
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input[type='checkbox'],
input[type='radio'] {
  width: auto;
  min-height: 0;
  accent-color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-light);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--muted-light);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[disabled],
select[disabled],
textarea[disabled] {
  background: var(--card-subtle);
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.modal-form,
.inline-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inline-form {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.inline-form select,
.inline-form input {
  width: auto;
}

.form-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--out-bg);
  color: var(--out-ink);
  font-size: 13px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-wrap input {
  padding-right: 40px !important;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--ink);
  background: var(--bg-subtle);
}

.password-toggle svg {
  width: 16px;
  height: 16px;
}

.search {
  position: relative;
  flex: 0 1 280px;
  min-width: 200px;
}

.search input {
  padding-left: 34px;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

/* ---------- Shell: rail ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 22px;
  align-self: flex-start;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--rail);
  color: var(--rail-ink);
}

.sidebar .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px;
  color: var(--rail-ink);
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--rail-ink);
  color: var(--rail);
}

.brand-mark {
  width: 17px;
  height: 17px;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-tag {
  font-size: 14px;
  font-weight: 400;
  color: var(--rail-muted);
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  padding: 4px 10px 6px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rail-muted);
  opacity: 0.75;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--rail-muted);
  font-size: 13.5px;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-item svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--rail-hover);
  color: #ffffff;
}

.nav-item[aria-current='page'] {
  background: var(--rail-active);
  color: #ffffff;
  font-weight: 500;
}

.nav-item[aria-current='page'] svg {
  opacity: 1;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--rail-line);
}

.user-card {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.user-card .avatar {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2b333d;
  color: #e6e9e2;
  font-size: 11px;
  font-weight: 600;
}

.user-card .who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.user-card .who strong {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--rail-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card .who span {
  overflow: hidden;
  font-size: 11px;
  color: var(--rail-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-pill {
  font-size: 11px;
  color: var(--rail-muted);
  text-transform: capitalize;
}

.sidebar-actions {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: 2px;
}

.link-quiet {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--rail-muted);
  cursor: pointer;
}

.link-quiet:hover {
  background: var(--rail-hover);
  color: #ffffff;
}

.link-quiet svg {
  width: 15px;
  height: 15px;
}

.tabbar {
  display: none;
}

[data-theme='dark'] .sidebar {
  border-right: 1px solid var(--rail-line);
}

/* ---------- Page ---------- */

.main {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-width: calc(var(--max-w) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 28px var(--gutter) 72px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 20px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}

.page-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-actions-wrap,
.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.head-actions input[type='month'],
.head-actions input[type='date'],
.head-actions select {
  width: auto;
  min-width: 150px;
}

/* ---------- Figures (tiles, not cards) ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 20px 16px;
  border-left: 1px solid var(--line);
}

.stat:first-child {
  padding-left: 0;
  border-left: 0;
}

.stat-label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin-top: 6px;
  font-size: clamp(21px, 2vw, 25px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.stat-note {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

/* A one-line summary under the figures (used for payroll on Finance). */
.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  margin: -8px 0 24px;
  font-size: 13px;
  color: var(--muted);
}

.strip strong {
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.strip .strip-title {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.strip a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

/* ---------- Panels ---------- */

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.grid-two.split-expenses {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.62fr);
}

.grid-two.split-customers {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.6fr);
}

.grid-two.split-even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.panel[style*='padding:0'] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
}

.panel-head a,
.panel-head .sub {
  font-size: 12px;
  color: var(--muted);
}

.panel-head a:hover {
  color: var(--ink);
}

.panel > .hint:first-child {
  margin-bottom: 10px;
}

/* ---------- Chart ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: clamp(10px, 2vw, 22px);
  height: 168px;
  padding: 8px 4px 0;
  border-bottom: 1px solid var(--line);
}

.chart-col {
  display: flex;
  flex: 1;
  align-items: flex-end;
  min-width: 0;
  height: 100%;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
}

.chart-bar {
  flex: 0 1 18px;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
}

.chart-bar.income {
  background: var(--bar-in);
}

.chart-bar.expense {
  background: var(--bar-out);
}

.chart-axis {
  display: flex;
  gap: clamp(10px, 2vw, 22px);
  padding: 8px 4px 0;
}

.chart-axis span {
  flex: 1;
  min-width: 0;
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  font-size: 11.5px;
  color: var(--muted);
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.chart-legend span:first-child i {
  background: var(--bar-in) !important;
  opacity: 1 !important;
}

.chart-legend span:nth-child(2) i {
  background: var(--bar-out) !important;
  opacity: 1 !important;
}

/* Category bars */

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.cat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 12.5px;
}

.cat-amount {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.cat-track {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-subtle);
}

.cat-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--bar-neutral);
}

/* ---------- Tables ---------- */

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ledger th {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-strong);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.ledger th.num,
.ledger td.num {
  text-align: right;
}

.ledger td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

.ledger tbody tr:last-child td {
  border-bottom: 0;
}

.ledger tfoot td,
.ledger tfoot th {
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  font-weight: 600;
}

.ledger td.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger td.primary {
  font-weight: 500;
}

.ledger .sub,
.ledger td.primary .sub {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.ledger tr.clickable {
  cursor: pointer;
}

.ledger tr.clickable:hover td {
  background: var(--card-hover);
}

.ledger tr.clickable:focus-visible {
  outline-offset: -2px;
}

/* Tables sitting inside a padded panel line up with the panel heading. */
.panel:not([style*='padding:0']) > .ledger th:first-child,
.panel:not([style*='padding:0']) > .ledger td:first-child,
.panel:not([style*='padding:0']) > .table-responsive > .ledger th:first-child,
.panel:not([style*='padding:0']) > .table-responsive > .ledger td:first-child {
  padding-left: 0;
}

.panel:not([style*='padding:0']) > .ledger th:last-child,
.panel:not([style*='padding:0']) > .ledger td:last-child,
.panel:not([style*='padding:0']) > .table-responsive > .ledger th:last-child,
.panel:not([style*='padding:0']) > .table-responsive > .ledger td:last-child {
  padding-right: 0;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ledger-invoices {
  min-width: 560px;
}

.line-items {
  min-width: 480px;
}

.budget-table {
  min-width: 600px;
}

.team-table {
  min-width: 480px;
}

.split-expenses .ledger {
  min-width: 520px;
}

#tx-filters + .tx-totals + .ledger {
  min-width: 560px;
}

/* ---------- Status chips ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  text-transform: capitalize;
  white-space: nowrap;
}

.pill-dot {
  display: none;
}

.pill-paid,
.pill-paid_up,
.pill-approved {
  background: var(--in-bg);
  color: var(--in-ink);
}

.pill-sent {
  background: var(--info-bg);
  color: var(--info);
}

.pill-overdue,
.pill-unpaid,
.pill-rejected {
  background: var(--out-bg);
  color: var(--out-ink);
}

.pill-partial,
.pill-due_soon,
.pill-pending {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.pill-draft,
.pill-cancelled {
  background: var(--bg-subtle);
  color: var(--muted);
}

.pill-void {
  background: transparent;
  color: var(--muted-light);
  text-decoration: line-through;
}

/* ---------- Toolbars, filters, section tabs ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filters {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.filter:hover {
  background: var(--line);
  color: var(--ink);
}

.filter[aria-pressed='true'] {
  background: var(--primary);
  color: var(--primary-text);
}

.filter[aria-pressed='true'] span {
  color: inherit !important;
  opacity: 0.7;
}

/* Finance section tabs: an underline row, not buttons. */
.subnav {
  display: flex;
  gap: 22px;
  margin: -6px 0 22px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.subnav::-webkit-scrollbar {
  display: none;
}

.subnav .filter {
  padding: 8px 0 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.subnav .filter:hover {
  background: transparent;
  color: var(--ink);
}

.subnav .filter[aria-pressed='true'] {
  border-bottom-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

/* ---------- Empty states ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 24px;
  text-align: center;
}

.empty-icon {
  display: none;
}

.empty h3 {
  margin-bottom: 4px;
  font: 400 22px/1.2 var(--display);
}

.empty p {
  max-width: 360px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Banners ---------- */

.reminder-banner,
.notice-soft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 13px;
}

.reminder-banner strong {
  font-weight: 600;
}

.reminder-banner.overdue {
  background: var(--out-bg);
  color: var(--out-ink);
}

.reminder-banner .btn-quiet {
  border-color: currentColor;
  color: inherit;
  opacity: 0.85;
}

.notice-soft {
  display: block;
  background: var(--bg-subtle);
  color: var(--ink-2);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-text);
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.error {
  background: var(--out);
  color: #ffffff;
}

/* ---------- Modals ---------- */

.modal,
.viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.viewer {
  background: rgba(17, 20, 24, 0.55);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.45);
  animation: fadeIn 0.16s ease;
}

.modal-panel,
.viewer-panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-pop);
  animation: rise 0.18s ease;
}

.modal-panel.wide {
  max-width: 720px;
}

.modal-head,
.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font: 400 22px/1.15 var(--display);
}

.viewer-head > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.viewer-head span {
  font-size: 12px;
  color: var(--muted);
}

.modal-body {
  padding: 20px;
}

.modal.closing .modal-backdrop {
  opacity: 0;
  transition: opacity 0.16s ease;
}

.modal.closing .modal-panel {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.viewer-panel {
  max-width: min(900px, 92vw);
}

.viewer-img,
.proof-img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: var(--bg-subtle);
}

.proof-img {
  border-radius: var(--radius-sm);
}

.viewer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Sign in ---------- */

.auth-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}

.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px clamp(28px, 5vw, 64px);
  background: var(--rail);
  color: var(--rail-ink);
}

.auth-aside .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--rail-ink);
}

.auth-quote {
  max-width: 15ch;
  margin: 56px 0;
  font: 400 clamp(40px, 4.4vw, 64px) / 1.02 var(--display);
  letter-spacing: -0.01em;
}

.auth-quote small {
  display: block;
  max-width: 44ch;
  margin-top: 20px;
  font: 400 15px/1.6 var(--sans);
  letter-spacing: 0;
  color: var(--rail-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 48px clamp(24px, 5vw, 56px);
}

.auth-form h1 {
  font-size: clamp(32px, 3vw, 42px);
}

.auth-form form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 26px;
}

.auth-form form .btn {
  min-height: 40px;
  margin-top: 4px;
}

.auth-switch {
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.auth-switch button {
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.auth-switch button:hover {
  text-decoration-color: currentColor;
}

/* ---------- Invoice editor and document ---------- */

.invoice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.invoice-layout > aside,
.invoice-layout > .totals {
  position: sticky;
  top: 16px;
}

.line-items,
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.line-items {
  margin-top: 22px;
}

.line-items th,
.doc th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.line-items td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.line-items th:first-child,
.line-items td:first-child {
  padding-left: 0;
}

.line-items th:last-child,
.line-items td:last-child {
  padding-right: 0;
  text-align: right;
}

.line-items input {
  min-height: 34px;
}

.line-total {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Totals rows: the markup uses bare divs (.trow is the older name). */
.totals > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-2);
}

.totals > div > span:last-child {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.totals > .grand {
  margin-top: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.totals > .grand > span:last-child {
  font-size: 18px;
}

aside.panel > .totals {
  margin-top: 16px;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.totals {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.totals .trow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
}

.totals .trow span:last-child {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.totals .trow.grand {
  margin-top: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.totals .trow.grand span:last-child {
  font-size: 18px;
  font-weight: 600;
}

.doc {
  max-width: 820px;
  margin: 0 auto 28px;
  padding: clamp(24px, 4vw, 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: #12151a;
}

.doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid #12151a;
}

.doc-title {
  font: 400 34px/1 var(--display);
  color: #12151a;
}

.doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.doc-parties h3,
.doc-meta .label {
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #6f7883;
}

.doc-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 13px;
  color: #3a434d;
  text-align: right;
}

.doc-parties .label {
  display: block;
}

.doc th {
  color: #6f7883;
  border-bottom-color: #cdd2c9;
}

.doc td {
  padding: 10px;
  border-bottom: 1px solid #e3e6df;
  color: #12151a;
}

.doc th.num,
.doc td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.doc th:first-child,
.doc td:first-child {
  padding-left: 0;
}

.doc th:last-child,
.doc td:last-child {
  padding-right: 0;
}

.doc .pill {
  background: #e8f4ed;
  color: #0a5c3c;
}

.doc .pill-sent {
  background: #eaf0f8;
  color: #2c4a72;
}

.doc .pill-draft,
.doc .pill-void {
  background: #eef0ea;
  color: #6f7883;
}

.doc .totals {
  margin-left: auto;
  max-width: 320px;
  padding: 16px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.doc .totals > div,
.doc .totals > div > span:last-child {
  color: #12151a;
}

.doc .totals > .grand {
  border-top-color: #12151a;
}

.doc-notes,
.doc-foot {
  margin-top: 26px;
  font-size: 12.5px;
  color: #3a434d;
}

/* ---------- Receipts and files ---------- */

.receipt-cell {
  width: 56px;
  text-align: center;
}

.thumb-btn {
  display: inline-flex;
  overflow: hidden;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

.thumb-btn:hover {
  border-color: var(--line-strong);
}

.thumb-btn img {
  display: block;
  border-radius: 3px;
  object-fit: cover;
}

.receipt-drop {
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card-subtle);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
}

.receipt-drop:hover {
  border-color: var(--muted);
  color: var(--ink-2);
}

.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.receipt-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-subtle);
}

.receipt-preview img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  object-fit: cover;
}

.receipt-file {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  font-size: 12.5px;
}

.receipt-file strong {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-file small {
  color: var(--muted);
}

/* ---------- Budgets and progress ---------- */

.progress {
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--bg-subtle);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--bar-neutral);
}

.progress.over span {
  background: var(--out);
}

.budget-line {
  margin: 10px 0 2px;
  font-size: 13px;
  color: var(--ink-2);
}

.budget-line strong {
  color: var(--ink);
  font-weight: 500;
}

.budget-group .group-row th,
.budget-group .group-row td {
  padding-top: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.budget-group .group-row td.num {
  color: var(--ink-2);
  letter-spacing: 0;
  text-transform: none;
  font-size: 12.5px;
}

.indent {
  padding-left: 30px !important;
}

.amount-input {
  max-width: 130px;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bar-cell > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Finance: transactions ---------- */

.tx-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.tx-filters .field {
  flex: 0 1 160px;
}

.tx-filters .field.search {
  flex: 1 1 220px;
}

.tx-totals {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-strong);
  font-size: 12.5px;
  color: var(--muted);
}

.tx-totals strong {
  margin-left: 4px;
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.detail-amount {
  margin-bottom: 2px;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 0 0 22px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail-grid dt {
  margin-bottom: 2px;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink);
}

.detail-h {
  margin: 22px 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.proof-list,
.history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.proof-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.proof-list li .hint {
  margin-left: auto;
}

.history li {
  padding: 6px 0 6px 12px;
  border-left: 2px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
}

.history li strong {
  color: var(--ink);
  font-weight: 500;
}

.history li .diff {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.history-card {
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* ---------- Team ---------- */

.team-form {
  display: grid;
  /* auto-fit cannot share a template with an intrinsic track, so the button takes a cell too. */
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

/* ---------- Payroll ---------- */

.payroll-table {
  min-width: 990px;
}

.payroll-table th,
.payroll-table td {
  padding: 11px 10px;
}

.payroll-table th:first-child,
.payroll-table td:first-child {
  padding-left: 18px;
}

.payroll-table th:last-child,
.payroll-table td:last-child {
  padding-right: 18px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .invoice-layout {
    grid-template-columns: 1fr;
  }

  .invoice-layout > aside,
  .invoice-layout > .totals {
    position: static;
  }

  .stat-row,
  .stat-row-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }

  .stat:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .grid-two,
  .grid-two.split-expenses,
  .grid-two.split-customers,
  .grid-two.split-even {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
  }

  .shell {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar,
  .btn-theme-desktop {
    display: none;
  }

  .tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    overflow-x: auto;
    background: var(--rail);
    border-top: 1px solid var(--rail-line);
    scrollbar-width: none;
  }

  .tabbar::-webkit-scrollbar {
    display: none;
  }

  .tab-item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 46px;
    height: 52px;
    padding: 4px 2px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--rail-muted);
    white-space: nowrap;
    cursor: pointer;
  }

  .tab-item svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
  }

  .tab-item span {
    font-size: 10px;
    line-height: 1;
  }

  .tab-item[aria-current='page'] {
    color: #ffffff;
  }

  .main {
    max-width: 100%;
    padding: 20px 16px calc(80px + env(safe-area-inset-bottom, 12px));
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }

  .page-actions-wrap,
  .head-actions {
    width: 100%;
  }

  .head-actions .btn,
  .head-actions input[type='month'],
  .head-actions select {
    flex: 1 1 auto;
  }

  .grid-two.split-expenses,
  .grid-two.split-customers {
    display: flex;
    flex-direction: column;
  }

  .grid-two.split-expenses > section:nth-child(2),
  .grid-two.split-customers > section:nth-child(2) {
    order: -1;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .toolbar .filters::-webkit-scrollbar {
    display: none;
  }

  .toolbar .search {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .tx-filters {
    padding: 12px 14px;
  }

  .tx-filters .field {
    flex: 1 1 calc(50% - 5px);
    min-width: 120px;
  }

  .tx-filters .field.search {
    flex: 1 1 100%;
  }

  .tx-totals {
    gap: 12px;
    padding: 10px 14px;
  }

  .team-form {
    grid-template-columns: 1fr;
  }

  .auth-wrap {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    display: none;
  }

  .auth-form {
    padding: 36px 20px;
  }

  .toast {
    right: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom, 8px));
    left: 16px;
    justify-content: center;
  }
}

@media (max-width: 520px) {
  .stat-row,
  .stat-row-3 {
    grid-template-columns: 1fr;
  }

  .stat,
  .stat:nth-child(odd) {
    padding: 12px 0;
    border-left: 0;
  }

  .stat + .stat {
    border-top: 1px solid var(--line);
  }

  .doc {
    padding: 18px 16px;
  }

  .doc-head {
    flex-direction: column;
    gap: 12px;
  }

  .doc-parties,
  .doc-meta,
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-panel {
    max-height: calc(100vh - 24px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-head {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-actions .btn,
  .modal-actions .btn-quiet {
    width: 100%;
  }
}

/* ---------- Print ---------- */

@media print {
  .sidebar,
  .tabbar,
  .page-head,
  .subnav,
  .btn,
  .btn-quiet,
  .toast,
  .skip-link,
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }

  .main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .doc {
    padding: 0 !important;
    border: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
