:root {
  --g-950: #022c22;
  --g-900: #064e3b;
  --g-800: #065f46;
  --g-700: #047857;
  --g-600: #059669;
  --g-500: #10b981;
  --g-400: #34d399;
  --g-300: #6ee7b7;
  --g-200: #a7f3d0;
  --g-100: #d1fae5;
  --g-50: #ecfdf5;

  /* Daylight theme */
  color-scheme: light;
  --bg: #f2f7f4;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --field: #fcfdfd;
  --field-border: #a9bdb3;
  --field-border-hover: #7f9a8d;
  --field-shadow: inset 0 1px 2px rgba(4, 47, 36, 0.07);
  --border: #dfe9e4;
  --border-strong: #c9d9d1;
  --text: #11221b;
  --muted: #5d6f67;
  --faint: #8a9a93;
  --placeholder: #8a9c94;
  --accent: #047857;
  --accent-strong: #065f46;
  --tint: #ecfdf5;
  --tint-strong: #d1fae5;
  --hover: #f6fbf8;
  --glass: rgba(242, 247, 244, 0.85);
  --glass-2: rgba(255, 255, 255, 0.94);
  --grid: #edf2ef;
  --grid-base: #c9d6cf;
  --track: #eef4f1;
  --badge-bg: #eef2f0;
  --badge-fg: #4b5d55;
  --print-bg: #e3ebe7;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --violet: #7e22ce;
  --violet-bg: #f3e8ff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(4, 47, 36, 0.06);
  --shadow: 0 1px 2px rgba(4, 47, 36, 0.05), 0 10px 30px -10px rgba(4, 47, 36, 0.16);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Dark theme: follows the device unless the person picked daylight; the toggle can also force it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #08120f;
    --surface: #0f1c18;
    --surface-2: #0c1814;
    --field: #0b1713;
    --field-border: #34503f;
    --field-border-hover: #4d7060;
    --field-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
    --border: #1d3029;
    --border-strong: #2b4439;
    --text: #e4f1eb;
    --muted: #9ab2a7;
    --faint: #6b857a;
    --placeholder: #587166;
    --accent: #34d399;
    --accent-strong: #6ee7b7;
    --tint: rgba(16, 185, 129, 0.12);
    --tint-strong: rgba(16, 185, 129, 0.22);
    --hover: rgba(255, 255, 255, 0.03);
    --glass: rgba(8, 18, 15, 0.82);
    --glass-2: rgba(15, 28, 24, 0.94);
    --grid: #1a2b25;
    --grid-base: #30483e;
    --track: #182822;
    --badge-bg: #1b2b25;
    --badge-fg: #b3c8be;
    --print-bg: #08120f;
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --danger-text: #fca5a5;
    --danger-border: rgba(248, 113, 113, 0.35);
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, 0.12);
    --info: #93c5fd;
    --info-bg: rgba(96, 165, 250, 0.14);
    --violet: #c4b5fd;
    --violet-bg: rgba(167, 139, 250, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #08120f;
  --surface: #0f1c18;
  --surface-2: #0c1814;
  --field: #0b1713;
  --field-border: #34503f;
  --field-border-hover: #4d7060;
  --field-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  --border: #1d3029;
  --border-strong: #2b4439;
  --text: #e4f1eb;
  --muted: #9ab2a7;
  --faint: #6b857a;
  --placeholder: #587166;
  --accent: #34d399;
  --accent-strong: #6ee7b7;
  --tint: rgba(16, 185, 129, 0.12);
  --tint-strong: rgba(16, 185, 129, 0.22);
  --hover: rgba(255, 255, 255, 0.03);
  --glass: rgba(8, 18, 15, 0.82);
  --glass-2: rgba(15, 28, 24, 0.94);
  --grid: #1a2b25;
  --grid-base: #30483e;
  --track: #182822;
  --badge-bg: #1b2b25;
  --badge-fg: #b3c8be;
  --print-bg: #08120f;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-text: #fca5a5;
  --danger-border: rgba(248, 113, 113, 0.35);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --info: #93c5fd;
  --info-bg: rgba(96, 165, 250, 0.14);
  --violet: #c4b5fd;
  --violet-bg: rgba(167, 139, 250, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px -12px rgba(0, 0, 0, 0.7);
}

*, *::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);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 600 14px/1 var(--font);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible { outline: 3px solid rgba(16, 185, 129, 0.45); outline-offset: 2px; }
.btn[disabled] { opacity: 0.6; pointer-events: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--g-600), var(--g-700));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 14px -6px rgba(4, 120, 87, 0.6);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--g-700), var(--g-800)); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--accent-strong); }
.btn-secondary:hover { background: var(--tint); border-color: var(--g-300); color: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--tint); color: var(--accent-strong); }
.btn-ghost.danger:hover, .btn-secondary.danger:hover { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.btn-light { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16); color: #ecfdf5; }
.btn-light:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.btn-dashed { background: var(--surface-2); border: 1.5px dashed var(--border-strong); color: var(--accent); }
.btn-dashed:hover { background: var(--tint); border-color: var(--g-400); color: var(--accent-strong); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-sm .icon { width: 15px; height: 15px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--tint); color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn .icon { width: 16px; height: 16px; }

/* ------------------------------------------------------------ forms */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.field > span em { color: var(--danger); font-style: normal; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 1.5px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--field);
  box-shadow: var(--field-shadow);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: var(--field-border-hover); }
input[type='checkbox'], input[type='radio'] { box-shadow: none; }
input, select { height: 40px; }
textarea { min-height: 40px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g-500); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2); }
input[type='checkbox'], input[type='radio'] { width: 16px; height: 16px; padding: 0; accent-color: var(--g-600); flex: none; }
select {
  padding-right: 34px;
  appearance: none;
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6f67' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.align-end { align-self: end; min-height: 40px; }
.hint { margin: 2px 0 0; color: var(--faint); font-size: 12px; }

.grid { display: grid; gap: 14px 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}

.input-group { display: flex; }
.input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group select { flex: none; width: auto; border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background-color: var(--surface-2); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input + span {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 800;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.segmented small { color: var(--muted); font-size: 12px; font-weight: 500; }
.segmented input:checked + span { border-color: var(--g-600); background: var(--tint); color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14); }
.segmented input:focus-visible + span { outline: 3px solid rgba(16, 185, 129, 0.45); outline-offset: 2px; }
.cur-flag { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--tint-strong); color: var(--accent-strong); font-size: 13px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
.alert-error { border: 1px solid var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }

/* ------------------------------------------------------------ brand */

.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.brand:hover { color: #fff; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--g-400), var(--g-600));
  box-shadow: 0 6px 16px -6px rgba(16, 185, 129, 0.8);
}
.brand-mark .icon { width: 20px; height: 20px; color: #fff; }

/* ------------------------------------------------------------ login */

.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 44px 56px;
  overflow: hidden;
  color: #ecfdf5;
  background:
    radial-gradient(900px 500px at -10% -10%, rgba(16, 185, 129, 0.35), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(52, 211, 153, 0.22), transparent 60%),
    linear-gradient(160deg, var(--g-800), var(--g-950));
}
.auth-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 { max-width: 540px; margin: auto 0 18px; font-size: clamp(28px, 3.3vw, 44px); font-weight: 800; letter-spacing: -0.025em; }
.auth-hero h1 span { color: var(--g-300); }
.auth-lead { max-width: 480px; margin: 0 0 28px; color: #a7d9c3; font-size: 16px; }
.auth-features { display: grid; gap: 12px; margin: 0 0 auto; padding: 0; list-style: none; }
.auth-features li { display: flex; align-items: center; gap: 12px; color: #d1fae5; font-weight: 500; }
.auth-features .tick { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(52, 211, 153, 0.18); color: var(--g-300); flex: none; }
.auth-features .tick .icon { width: 14px; height: 14px; }
.auth-mock {
  position: absolute;
  right: -60px;
  bottom: -40px;
  width: 300px;
  padding: 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  color: #11221b;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45);
  transform: rotate(-8deg);
  opacity: 0.95;
}
.auth-mock .bar { height: 8px; margin-bottom: 8px; border-radius: 4px; background: #e6efea; }
.auth-mock .bar.g { width: 45%; background: var(--g-600); }
.auth-mock .row { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; font-weight: 700; }
.auth-mock .total { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--g-700); color: #fff; font-weight: 800; display: flex; justify-content: space-between; font-size: 14px; }
.auth-foot { margin: 28px 0 0; color: #6fb497; font-size: 12.5px; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 410px;
  padding: 36px 32px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card h2 { font-size: 25px; font-weight: 800; }
.auth-card .muted { margin: -8px 0 4px; }
.auth-badge { justify-self: start; padding: 4px 10px; border-radius: 999px; background: var(--tint); color: var(--accent); font-size: 12px; font-weight: 700; }
.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font: 600 12.5px var(--font);
  cursor: pointer;
  transform: translateY(-50%);
}
.pw-toggle:hover { background: var(--tint); }
.auth-card .btn-primary { height: 46px; margin-top: 4px; font-size: 15px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-hero { padding: 24px 20px 28px; }
  .auth-hero h1 { margin: 28px 0 10px; font-size: 26px; }
  .auth-lead { margin: 0; font-size: 14.5px; }
  .auth-features, .auth-mock, .auth-foot { display: none; }
  .auth-panel { align-items: start; padding: 24px 16px 40px; }
  .auth-card { padding: 28px 22px; }
}

/* ------------------------------------------------------------ app shell */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 26px;
  width: 248px;
  padding: 22px 16px 16px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--g-900), var(--g-950));
  color: #d1fae5;
  transition: transform 0.25s ease;
}
.sidebar .brand { padding: 0 6px; }
.nav { display: grid; gap: 4px; }
.nav-label { padding: 0 12px 6px; color: #5f9e83; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #a7d9c3; font-weight: 600; transition: background 0.15s, color 0.15s; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: rgba(52, 211, 153, 0.16); color: #fff; box-shadow: inset 3px 0 0 var(--g-400); }
.nav a.active .icon { color: var(--g-300); }
.nav-cta { display: grid; gap: 8px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
.sidebar-user strong { display: block; max-width: 120px; overflow: hidden; color: #fff; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { color: #7fbfa3; font-size: 12px; }
.sidebar-user .icon-btn { margin-left: auto; color: #a7d9c3; }
.sidebar-user .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: linear-gradient(135deg, var(--g-400), var(--g-600)); color: #fff; font-weight: 800; text-transform: uppercase; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; margin-left: 248px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(10px);
}
.topbar-company { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); font-weight: 700; }
.topbar-company:hover { color: var(--accent); }
.topbar-company img { max-width: 110px; height: 30px; object-fit: contain; }
.topbar-company span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-company .icon { color: var(--g-600); }
.topbar-date { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; }
.topbar-date .icon { width: 15px; height: 15px; color: var(--g-600); }
.topbar-user { display: none; align-items: center; gap: 4px; margin-left: auto; }
.topbar-user .avatar { width: 32px; height: 32px; font-size: 13px; }
.view { width: 100%; max-width: 1640px; padding: 28px; }

/* Mobile bottom navigation + "create" sheet */
.bottom-nav { display: none; }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(2, 44, 34, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 70;
  display: grid;
  gap: 10px;
  width: min(100%, 480px);
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -20px 50px -20px rgba(2, 44, 34, 0.4);
  transform: translate(-50%, 105%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
.sheet.open { transform: translate(-50%, 0); visibility: visible; transition: transform 0.25s ease; }
.sheet h2 { margin: 4px 4px 2px; font-size: 17px; }
.sheet-handle { justify-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); }
.sheet-option { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); }
.sheet-option:hover { border-color: var(--g-300); background: var(--tint); color: var(--text); }
.sheet-option strong { display: block; }
.sheet-option small { color: var(--muted); font-size: 12.5px; }
.sheet-option > .icon { margin-left: auto; color: var(--faint); }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { height: 58px; padding: 0 16px; }
  .topbar-date { display: none; }
  .topbar-user { display: flex; }
  .view { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: calc(66px + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: var(--glass-2);
    backdrop-filter: blur(12px);
    box-shadow: 0 -8px 24px -16px rgba(4, 47, 36, 0.25);
  }
  .bottom-nav a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: var(--faint); font-size: 11px; font-weight: 700; }
  .bottom-nav a .icon { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--accent); }
  .bn-fab {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-top: -26px;
    border: 4px solid var(--bg);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--g-500), var(--g-700));
    color: #fff;
    box-shadow: 0 10px 20px -8px rgba(4, 120, 87, 0.7);
    cursor: pointer;
  }
  .bn-fab .icon { width: 24px; height: 24px; }
  body[data-route='new'] .bottom-nav, body[data-route='edit'] .bottom-nav { display: none; }
  body[data-route='new'] .view, body[data-route='edit'] .view { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 26px; font-weight: 800; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.back-link .icon { width: 16px; height: 16px; }

.card { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { margin-bottom: 16px; font-size: 15.5px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
.card.flush .card-head { margin: 0; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-sub { margin: -10px 0 16px; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ icon tiles (shared) */

.tile-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 14px -6px var(--glow, rgba(4, 120, 87, 0.6));
}
.tile-icon .icon { width: 20px; height: 20px; }
.t-green { background: linear-gradient(135deg, #34d399, #059669); --glow: rgba(5, 150, 105, 0.65); }
.t-teal { background: linear-gradient(135deg, #2dd4bf, #0d9488); --glow: rgba(13, 148, 136, 0.65); }
.t-amber { background: linear-gradient(135deg, #fbbf24, #ea580c); --glow: rgba(234, 88, 12, 0.55); }
.t-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); --glow: rgba(124, 58, 237, 0.55); }
.t-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); --glow: rgba(37, 99, 235, 0.55); }
.t-rose { background: linear-gradient(135deg, #fb7185, #e11d48); --glow: rgba(225, 29, 72, 0.5); }
.head-with-icon { display: flex; align-items: center; gap: 12px; min-width: 0; }
.head-with-icon .card-title { margin: 0; }
.head-with-icon p { margin: 1px 0 0; }

.meter { --value: 0%; flex: none; width: 100%; height: 6px; overflow: hidden; border-radius: 999px; background: var(--tint-strong); }
.meter span { display: block; width: var(--value); height: 100%; border-radius: inherit; background: var(--g-600); }
.divider { height: 1px; margin: 18px 0; background: var(--border); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------------ dashboard */

.welcome {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 28px 32px;
  overflow: hidden;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(600px 300px at 85% 0%, rgba(52, 211, 153, 0.35), transparent 60%),
    radial-gradient(500px 260px at 0% 120%, rgba(16, 185, 129, 0.3), transparent 60%),
    linear-gradient(135deg, var(--g-700), var(--g-900) 60%, var(--g-950));
  box-shadow: 0 20px 40px -24px rgba(2, 44, 34, 0.7);
}
.welcome::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  mask-image: linear-gradient(90deg, #000, transparent 70%);
  pointer-events: none;
}
.welcome-text { position: relative; z-index: 1; max-width: 560px; }
.welcome-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: #d1fae5; font-size: 12.5px; font-weight: 600; }
.welcome-chip .icon { width: 15px; height: 15px; }
.welcome h1 { margin: 14px 0 6px; font-size: clamp(24px, 2.6vw, 32px); font-weight: 800; letter-spacing: -0.02em; }
.welcome p { margin: 0; color: #bfeedb; font-size: 15px; }
.welcome p strong { color: #fff; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn-white { background: #ffffff; color: #065f46; box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.4); }
.btn-white:hover { background: #ecfdf5; color: #064e3b; }
.btn-glass { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.btn-glass:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.welcome-art { position: relative; z-index: 1; flex: none; width: 300px; height: auto; margin: -12px -8px -16px 0; filter: drop-shadow(0 18px 24px rgba(2, 44, 34, 0.35)); }

.onboarding { margin-bottom: 20px; }
.onboarding .card-head { flex-wrap: wrap; }
.onboarding .meter { width: 180px; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); transition: border-color 0.15s, background 0.15s; }
.step:hover { border-color: var(--g-300); background: var(--tint); color: var(--text); }
.step strong { display: block; font-size: 13.5px; }
.step small { color: var(--muted); font-size: 12px; }
.step-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 1.5px dashed var(--border-strong); border-radius: 50%; color: var(--muted); }
.step-icon .icon { width: 16px; height: 16px; }
.step.done { background: var(--surface-2); }
.step.done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--g-400); }
.step.done .step-icon { border: 0; background: var(--g-600); color: #fff; }

.dash-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.seg-toggle { display: inline-flex; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.seg-toggle button { min-width: 64px; height: 32px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 13px var(--font); cursor: pointer; transition: background 0.15s, color 0.15s; }
.seg-toggle button:hover { color: var(--accent-strong); }
.seg-toggle button[aria-pressed='true'] { background: var(--g-700); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform 0.15s, box-shadow 0.15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { padding-top: 2px; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 26px; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; }
.kpi-value small { color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: auto; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-foot .icon { width: 15px; height: 15px; color: var(--g-600); }
.kpi-foot.bad { color: var(--danger-text); }
.kpi-foot.bad .icon { color: var(--danger-text); }
.kpi-foot .meter { margin-bottom: 2px; }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-grid > .card + .card { margin-top: 0; }
.dash-grid .span-2 { grid-column: span 2; }
.dash-side { display: grid; gap: 16px; }
.dash-side .card + .card { margin-top: 0; }
.head-figure { display: grid; text-align: right; }
.head-figure small { color: var(--muted); font-size: 12px; font-weight: 600; }
.head-figure strong { font-size: 16px; }

/* Revenue chart */
.chart { position: relative; padding-top: 22px; }
.chart-plot { position: relative; height: 220px; margin-left: 48px; }
.gridline { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--grid); }
.gridline.base { border-top-color: var(--grid-base); }
.gridline span { position: absolute; right: calc(100% + 10px); top: -8px; color: var(--faint); font-size: 11px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.col { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; padding: 0; border: 0; border-radius: 8px; background: transparent; cursor: default; }
.col:hover, .col:focus-visible { outline: none; background: rgba(16, 185, 129, 0.06); }
.bar { position: relative; width: min(24px, 45%); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--g-600); transition: filter 0.15s; }
.col:hover .bar, .col:focus-visible .bar { filter: brightness(1.15); }
.cap { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); color: var(--text); font-size: 12px; font-weight: 700; white-space: nowrap; }
.chart-x { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 8px 0 0 48px; color: var(--faint); font-size: 12px; font-weight: 600; text-align: center; }
.chart-x .current { color: var(--text); }
.chart-tip {
  position: absolute;
  top: 0;
  z-index: 3;
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  pointer-events: none;
}
.tip-title { margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.tip-row { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: 8px; font-size: 13px; }
.tip-row span { color: var(--muted); }
.tip-row .key { width: 12px; height: 2px; border-radius: 2px; background: var(--g-600); }
.tip-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }

/* Invoice status (thin segmented bar + legend) */
.seg-bar { display: flex; gap: 2px; height: 8px; margin: 4px 0 16px; overflow: hidden; border-radius: 999px; }
.seg-bar span { flex-basis: 0; min-width: 6px; }
.st-paid { background: #0ca30c; }
.st-awaiting { background: #fab219; }
.st-draft { background: #b9c6bf; }
.st-overdue { background: #d03b3b; }
.st-empty { flex-grow: 1; background: var(--tint-strong); }
.status-legend { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.status-legend li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; font-size: 13.5px; }
.status-legend i { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.status-legend .icon { width: 16px; height: 16px; color: var(--muted); }
.status-legend strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.mini-stat { display: grid; gap: 8px; }
.mini-stat > div:first-child { display: flex; align-items: baseline; justify-content: space-between; }
.mini-stat strong { font-size: 20px; }

/* Recent activity */
.card.flush > .card-head .card-title { margin: 0; }
.activity-list { display: grid; }
.activity { display: flex; align-items: center; gap: 14px; padding: 13px 22px; border-bottom: 1px solid var(--border); color: var(--text); transition: background 0.12s; }
.activity:last-child { border-bottom: 0; }
.activity:hover { background: var(--hover); color: var(--text); }
.activity .tile-icon { width: 38px; height: 38px; box-shadow: none; }
.activity .tile-icon .icon { width: 18px; height: 18px; }
.activity-main { display: grid; flex: 1; min-width: 0; }
.activity-main small, .activity-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-main small { color: var(--muted); font-size: 12.5px; }
.activity-end { display: grid; justify-items: end; gap: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Quick actions & top clients */
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick { display: grid; justify-items: start; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); color: var(--text); font-size: 13.5px; font-weight: 700; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.quick:hover { transform: translateY(-2px); border-color: var(--g-200); background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
.ranks { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.rank-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.rank-head .avatar { width: 30px; height: 30px; font-size: 12.5px; }
.rank-name { display: grid; flex: 1; min-width: 0; overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { color: var(--faint); font-size: 11.5px; font-weight: 500; }
.rank-head strong { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.rank-bar { height: 6px; border-radius: 999px; background: var(--track); }
.rank-bar span { display: block; min-width: 6px; height: 100%; border-radius: 999px; background: var(--g-600); }
.empty-note { margin: 0; }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-grid .span-2 { grid-column: auto; }
  .dash-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 760px) {
  .welcome { padding: 22px 20px; border-radius: 18px; }
  .welcome-art { display: none; }
  .welcome-actions .btn { flex: 1; }
  .dash-side { grid-template-columns: minmax(0, 1fr); }
  .kpis { gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .tile-icon { width: 34px; height: 34px; border-radius: 10px; }
  .kpi .tile-icon .icon { width: 17px; height: 17px; }
  .kpi-value { font-size: 20px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .onboarding .meter { width: 100%; }
  .activity { padding: 12px 16px; gap: 12px; }
  .chart-plot { height: 180px; margin-left: 40px; }
  .chart-x { margin-left: 40px; font-size: 11px; }
  .card-head { flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .client-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.strong { font-weight: 700; }
.doc-link { font-weight: 700; }
.sub { color: var(--faint); font-size: 12px; }
.row-actions { width: 1%; text-align: right; }
.row-actions > * { vertical-align: middle; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-fg); font-size: 12px; font-weight: 700; text-transform: capitalize; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-sent { background: var(--info-bg); color: var(--info); }
.badge-paid, .badge-accepted { background: var(--tint-strong); color: var(--accent-strong); }
.badge-overdue, .badge-rejected, .badge-cancelled { background: var(--danger-bg); color: var(--danger-text); }
.badge-expired { background: var(--warn-bg); color: var(--warn); }
.badge-converted { background: var(--violet-bg); color: var(--violet); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .icon { position: absolute; top: 50%; left: 12px; color: var(--faint); transform: translateY(-50%); }
.search input { padding-left: 38px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--muted); font: 600 12.5px var(--font); text-transform: capitalize; cursor: pointer; transition: all 0.15s; }
.chip:hover { border-color: var(--g-300); color: var(--accent-strong); }
.chip.active { border-color: var(--accent); background: var(--g-700); color: #fff; }
.chip .count { margin-left: 4px; opacity: 0.7; }
.list-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.list-foot strong { color: var(--text); }

.empty { padding: 52px 20px; color: var(--muted); text-align: center; }
.empty-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--tint); color: var(--g-600); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { margin: 14px 0 4px; color: var(--text); font-size: 16px; }
.empty p { margin: 0 0 16px; }

/* When the table's own container is narrow (phones, tablets, small laptops), each row becomes a compact card. */
.table-wrap { container-type: inline-size; }
.doc-table th, .doc-table td { padding-left: 12px; padding-right: 12px; }
.doc-table th:first-child, .doc-table td:first-child { padding-left: 18px; }
.doc-table .row-actions { padding-right: 12px; }
.doc-table .client-cell { max-width: 220px; }
@container (max-width: 900px) {
  .doc-table thead { display: none; }
  .doc-table, .doc-table tbody { display: block; }
  .doc-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'num status' 'client amount' 'date due' 'actions actions';
    gap: 4px 12px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
  }
  .doc-table tbody tr:last-child { border-bottom: 0; }
  .doc-table td, .doc-table td:first-child, .doc-table .row-actions { padding: 0; border: 0; white-space: normal; }
  .doc-table .c-num { grid-area: num; }
  .doc-table .c-num .sub { display: none; }
  .doc-table .c-status { grid-area: status; justify-self: end; }
  .doc-table .c-client { grid-area: client; max-width: none; font-weight: 600; }
  .doc-table .c-amount { grid-area: amount; align-self: center; }
  .doc-table .c-date, .doc-table .c-due { color: var(--muted); font-size: 12.5px; }
  .doc-table .c-date { grid-area: date; }
  .doc-table .c-due { grid-area: due; text-align: right; }
  .doc-table .c-date::before, .doc-table .c-due::before { content: attr(data-label) ' · '; color: var(--faint); }
  .doc-table .c-actions { grid-area: actions; display: flex; justify-content: flex-end; gap: 2px; width: auto; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
  .doc-table .c-actions .icon-btn { width: 36px; height: 36px; }
}
@container (min-width: 520px) and (max-width: 900px) {
  .doc-table tr { padding: 14px 20px 10px; }
}
@media (max-width: 760px) {
  .toolbar { padding: 14px 16px; }
  .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; width: calc(100% + 32px); margin: 0 -16px; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}

/* ------------------------------------------------------------ editor */

.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 0.82fr); gap: 22px; align-items: start; }
.editor-form { min-width: 0; }
.preview-pane { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; padding: 2px 2px 8px; }
.preview-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.preview-frame { position: relative; overflow: hidden; border-radius: 6px; background: #ffffff; box-shadow: 0 0 0 1px var(--border), 0 18px 40px -16px rgba(4, 47, 36, 0.35); }
.preview-scale { position: absolute; top: 0; left: 0; width: 210mm; transform-origin: 0 0; }
.editor-actions, .secondary-actions, .primary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (max-width: 760px) {
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head h1 { font-size: 22px; }
  .editor-actions { width: 100%; }
  .secondary-actions .btn-label { display: none; }
  .secondary-actions .btn { width: 40px; padding: 0; }
  .primary-actions {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--glass-2);
    backdrop-filter: blur(12px);
    box-shadow: 0 -10px 24px -16px rgba(4, 47, 36, 0.3);
  }
  .primary-actions .btn { height: 46px; }
}
.mobile-tabs { display: none; margin-bottom: 16px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.mobile-tabs button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 13.5px var(--font); cursor: pointer; }
.mobile-tabs button.active { background: var(--g-700); color: #fff; }
@media (max-width: 1279px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .mobile-tabs { display: flex; }
  .editor:not([data-tab='preview']) .preview-pane { display: none; }
  .editor[data-tab='preview'] .editor-form { display: none; }
  .preview-pane { position: static; max-height: none; overflow: visible; }
}

.items-head, .item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 116px 52px 108px 32px;
  grid-template-areas: 'd q p t a x';
  gap: 8px;
  align-items: start;
}
.items-head { padding: 0 2px 8px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.items-head span:nth-child(4) { text-align: center; }
.item-row { padding: 8px 0; border-top: 1px dashed var(--border); }
.item-row [data-f='description'] { grid-area: d; overflow: hidden; resize: none; }
.item-row [data-f='qty'] { grid-area: q; }
.item-row [data-f='price'] { grid-area: p; }
.item-row .tax-toggle { grid-area: t; }
.item-row .item-amount { grid-area: a; }
.item-row .icon-btn { grid-area: x; margin-top: 4px; }
.item-row input[type='number'] { text-align: right; }
.item-amount { display: flex; align-items: center; justify-content: flex-end; height: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tax-toggle { display: flex; align-items: center; justify-content: center; gap: 4px; height: 40px; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.tax-toggle span { display: none; }
#add-item { margin-top: 10px; }
@media (max-width: 700px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px; grid-template-areas: 'd d x' 'q p p' 't a a'; }
  .tax-toggle { justify-content: flex-start; }
  .tax-toggle span { display: inline; }
}

.totals-wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.discount { flex: 0 1 260px; }
.totals { display: grid; flex: 0 1 360px; gap: 6px; margin: 0; }
.totals > div { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .grand { margin-top: 6px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(150deg, var(--g-600), var(--g-800)); color: #fff; font-size: 16px; }
.totals .grand dt { color: #d1fae5; font-weight: 700; }
.totals .grand dd { font-weight: 800; }
.totals .equiv { padding: 0 14px; font-size: 13px; }
.totals .equiv dd { color: var(--muted); }

/* ------------------------------------------------------------ settings */

.settings { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.settings-side { display: grid; gap: 16px; }
.settings-side .card + .card { margin-top: 0; }
@media (max-width: 1100px) { .settings { grid-template-columns: minmax(0, 1fr); } }
.uploaders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .uploaders { grid-template-columns: minmax(0, 1fr); } }
.uploader { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.uploader-preview {
  display: grid;
  place-items: center;
  height: 112px;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: #fff repeating-conic-gradient(#f1f6f3 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}
.uploader-preview img { max-width: 90%; max-height: 96px; object-fit: contain; }
.uploader-preview .placeholder { display: grid; justify-items: center; gap: 4px; color: var(--faint); font-size: 12.5px; }
.uploader strong { display: block; font-size: 14px; }
.uploader small { color: var(--faint); font-size: 12px; }
.uploader-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.uploader .check { font-size: 12.5px; color: var(--muted); }
.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 12px 12px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--glass-2);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.save-bar.dirty { border-color: var(--g-300); }
.save-bar.dirty .muted { color: var(--accent); font-weight: 600; }
.user-list { display: grid; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.user-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.user-list .avatar { width: 30px; height: 30px; font-size: 13px; }
.user-list .you { padding: 2px 8px; border-radius: 999px; background: var(--tint); color: var(--accent); font-size: 11px; font-weight: 700; }
.user-list .icon-btn { margin-left: auto; }
.stack { display: grid; gap: 12px; }

/* ------------------------------------------------------------ toasts & misc */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--g-900);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px -10px rgba(2, 44, 34, 0.5);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast .icon { color: var(--g-300); }
.toast-error { background: #7f1d1d; }
.toast-error .icon { color: #fca5a5; }
.toast.leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 960px) {
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .save-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .toasts { right: 16px; left: 16px; }
  .save-bar { padding-left: 14px; }
  .save-bar .muted { font-size: 12px; }
  .card { padding: 18px 16px; }
  .card.flush { padding: 0; }
  .card.flush .card-head { padding: 16px; }
}

.loading { display: grid; place-items: center; gap: 12px; padding: 80px 20px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--tint-strong); border-top-color: var(--g-600); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ print page */

.print-body { background: var(--print-bg); }
.print-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(90deg, var(--g-900), var(--g-800));
  color: #fff;
}
.print-title { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.print-tip { margin: 14px 16px 0; color: var(--muted); font-size: 13px; text-align: center; }
.paper-wrap { padding: 18px 16px 48px; overflow-x: auto; }
.paper { width: 210mm; margin: 0 auto; box-shadow: 0 24px 60px -24px rgba(4, 47, 36, 0.45); }
@media (max-width: 600px) { .print-toolbar .btn span { display: none; } }

@media print {
  .print-body { background: var(--surface); }
  .print-toolbar, .print-tip { display: none !important; }
  .paper-wrap { padding: 0; overflow: visible; }
  .paper { margin: 0; box-shadow: none; }
}

/* ------------------------------------------------------------ appearance picker (Daylight / Dark / Auto) */

.theme-picker { display: inline-flex; flex: none; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.theme-picker button { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s; }
.theme-picker button .icon { width: 16px; height: 16px; }
.theme-picker button:hover { color: var(--accent); }
.theme-picker button[aria-pressed="true"] { background: var(--g-700); color: #fff; }
.theme-picker button:focus-visible { outline: 3px solid rgba(16, 185, 129, 0.45); outline-offset: 1px; }
.topbar .theme-picker { margin-left: 4px; }
.auth-panel { position: relative; }
.auth-theme { position: absolute; top: 20px; right: 20px; }
@media (max-width: 960px) {
  .topbar .theme-picker { margin-left: auto; }
  .topbar .theme-picker button { width: 28px; height: 28px; }
  .topbar-user { margin-left: 0; }
}
@media (max-width: 900px) {
  .auth-theme { top: -56px; right: 16px; border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.1); }
  .auth-theme button { color: #d1fae5; }
}
@media (max-width: 380px) { .topbar-company span { display: none; } }

.appearance-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.appearance-option { display: grid; justify-items: center; gap: 8px; padding: 12px 8px; border: 1.5px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--text); font: 700 13px var(--font); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.appearance-option:hover { border-color: var(--g-400); }
.appearance-option[aria-pressed="true"] { border-color: var(--g-500); background: var(--tint); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
.appearance-option small { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.appearance-preview { width: 100%; height: 54px; overflow: hidden; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 9px; }
.appearance-preview.light { background: linear-gradient(90deg, #064e3b 0 26%, #f2f7f4 26%); }
.appearance-preview.dark { background: linear-gradient(90deg, #064e3b 0 26%, #0f1c18 26%); }
.appearance-preview.system { background: linear-gradient(90deg, #064e3b 0 26%, #f2f7f4 26% 63%, #0f1c18 63%); }

/* ------------------------------------------------------------ shell additions */

.sidebar-user-link { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.sidebar-user-link:hover { color: inherit; }
.sidebar-user-link:hover strong { text-decoration: underline; }
.topbar-user a.avatar:hover { color: #fff; filter: brightness(1.1); }
.bottom-nav button:not(.bn-fab) { display: grid; justify-items: center; gap: 3px; padding: 6px 0; border: 0; background: none; color: var(--faint); font: 700 11px var(--font); cursor: pointer; }
.bottom-nav button:not(.bn-fab) .icon { width: 22px; height: 22px; }
.bottom-nav button:not(.bn-fab).active { color: var(--accent); }
.sheet-signout { width: 100%; background: none; font: inherit; text-align: left; cursor: pointer; }
.btn-danger { background: linear-gradient(180deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 6px 14px -6px rgba(220, 38, 38, 0.6); }
.btn-danger:hover { background: linear-gradient(180deg, #dc2626, #b91c1c); color: #fff; }
.form-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.form-fieldset:disabled input, .form-fieldset:disabled select, .form-fieldset:disabled textarea { background: var(--surface-2); color: var(--muted); }
.form-fieldset:disabled .btn-dashed, .form-fieldset:disabled [data-remove-item] { display: none; }
.primary-actions.single { grid-template-columns: 1fr !important; }
.doc-meta { margin: 6px 0 0; }
.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 12px; background: var(--warn-bg); color: var(--text); font-size: 13.5px; font-weight: 600; }
.notice .icon { color: var(--warn); }
.hint .icon { width: 14px; height: 14px; margin-right: 2px; vertical-align: -2px; }
.stack-lg { display: grid; gap: 16px; align-content: start; }
.stack-lg .card + .card { margin-top: 0; }
.bad-text { display: inline-flex; align-items: center; gap: 4px; color: var(--danger-text); }
.warn-text { color: var(--warn); font-weight: 700; }
.link-list { display: grid; gap: 8px; }
.link-list a { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); transition: border-color 0.15s, background 0.15s; }
.link-list a:hover { border-color: var(--g-300); background: var(--tint); color: var(--text); }
.link-list strong { display: block; font-size: 13.5px; }
.link-list small { color: var(--muted); font-size: 12px; }
.link-list a > .icon { margin-left: auto; color: var(--faint); }
.link-list .tile-icon { width: 36px; height: 36px; box-shadow: none; }

.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-fg); font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-green { background: var(--tint-strong); color: var(--accent-strong); }
.pill-red { background: var(--danger-bg); color: var(--danger-text); }
.role-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.role-admin { background: var(--tint-strong); color: var(--accent-strong); }
.role-manager { background: var(--info-bg); color: var(--info); }
.role-staff { background: var(--violet-bg); color: var(--violet); }
.role-viewer { background: var(--warn-bg); color: var(--warn); }
.you { margin-left: 4px; padding: 2px 8px; border-radius: 999px; background: var(--tint); color: var(--accent); font-size: 11px; font-weight: 700; vertical-align: 1px; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-cell .avatar { width: 34px; height: 34px; font-size: 13.5px; }
.user-cell small { display: block; color: var(--faint); font-size: 12px; }
.item-name { display: inline-flex; align-items: center; gap: 8px; }
.item-name .icon { width: 15px; height: 15px; color: var(--accent); }
tr.is-off td { opacity: 0.6; }

/* ------------------------------------------------------------ pop-up dialogs */

.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5); }
.modal-sm { width: min(440px, calc(100vw - 24px)); }
.modal-wide { width: min(720px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(2, 30, 23, 0.55); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in 0.18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.modal-card { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; font-weight: 800; }
.modal-body { display: grid; gap: 14px; padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-text { margin: 0; color: var(--muted); line-height: 1.6; }
.modal-text strong { color: var(--text); }
@media (max-width: 560px) {
  .modal, .modal-sm, .modal-wide { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .modal-card { max-height: 92dvh; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; height: 44px; }
}
.cred-box { display: grid; gap: 8px; margin: 0; padding: 14px; border: 1px dashed var(--g-400); border-radius: 12px; background: var(--tint); }
.cred-box div { display: flex; justify-content: space-between; gap: 12px; }
.cred-box dt { color: var(--muted); font-size: 13px; }
.cred-box dd { margin: 0; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13.5px; font-weight: 700; word-break: break-all; text-align: right; }

.role-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .role-picker { grid-template-columns: minmax(0, 1fr); } }
.role-option { position: relative; cursor: pointer; }
.role-option input { position: absolute; opacity: 0; pointer-events: none; }
.role-card { display: flex; align-items: flex-start; gap: 12px; height: 100%; padding: 12px; border: 1.5px solid var(--border-strong); border-radius: 14px; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.role-card .tile-icon { width: 34px; height: 34px; border-radius: 10px; box-shadow: none; }
.role-card .tile-icon .icon { width: 17px; height: 17px; }
.role-card strong { display: block; font-size: 14px; color: var(--text); }
.role-card small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; }
.role-option input:checked + .role-card { border-color: var(--g-500); background: var(--tint); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
.role-option input:focus-visible + .role-card { outline: 3px solid rgba(16, 185, 129, 0.45); outline-offset: 2px; }
.role-option input:disabled + .role-card { opacity: 0.55; cursor: not-allowed; }
.switch-row { align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.switch-row input { margin-top: 2px; }
.switch-row strong { display: block; font-size: 14px; }
.switch-row small { color: var(--muted); font-size: 12.5px; }
.select-all { font-weight: 700; }
.import-list { display: grid; max-height: 46vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.import-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.import-row:last-child { border-bottom: 0; }
.import-row:hover { background: var(--hover); }
.import-name { flex: 1; min-width: 0; }
.import-name strong { display: block; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.import-name small { color: var(--faint); font-size: 12px; }
.import-price { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; }

/* ------------------------------------------------------------ users & account */

.role-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1100px) { .role-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .role-summary { grid-template-columns: minmax(0, 1fr); } }
.role-tile { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.role-tile .tile-icon { width: 34px; height: 34px; border-radius: 10px; box-shadow: none; }
.role-tile .tile-icon .icon { width: 17px; height: 17px; }
.role-tile strong { display: block; font-size: 14px; }
.role-tile small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.matrix th.c, .matrix td.c { text-align: center; }
.matrix td { white-space: normal; }
.matrix .yes { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--tint-strong); color: var(--accent); }
.matrix .yes .icon { width: 14px; height: 14px; }
.matrix .no { color: var(--faint); }
.account-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.account-grid > .card { margin-top: 0; }
@media (max-width: 960px) { .account-grid { grid-template-columns: minmax(0, 1fr); } }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-head h2 { font-size: 20px; }
.profile-head p { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 0; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.perm-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.perm-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.perm-list li:last-child { border-bottom: 0; }
.perm-list .icon { width: 16px; height: 16px; }
.perm-list .yes .icon { color: var(--accent); }
.perm-list .no { color: var(--faint); }

/* ------------------------------------------------------------ responsive data tables (rows become cards when narrow) */

.rtable tfoot td { padding: 12px 16px; border-top: 2px solid var(--border-strong); background: var(--surface-2); font-weight: 800; white-space: nowrap; }
.rtable tr.is-zero td { color: var(--faint); }
.rtable .r-actions { white-space: nowrap; }
@container (max-width: 700px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tfoot { display: block; }
  .rtable tr { display: grid; gap: 4px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .rtable td, .rtable tfoot td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0; border: 0; background: none; text-align: right; white-space: normal; }
  .rtable td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; }
  .rtable td:empty { display: none; }
  .rtable td.r-title { justify-content: flex-start; margin-bottom: 4px; text-align: left; font-size: 15px; }
  .rtable td.r-actions { justify-content: flex-end; width: auto; margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--border); }
  .rtable td.r-actions .icon-btn { width: 36px; height: 36px; }
  .rtable tfoot tr { background: var(--surface-2); }
  .rtable tfoot td.r-title { font-size: 14px; }
  .rtable .share { justify-content: flex-end; }
}

/* ------------------------------------------------------------ reports */

.report-filters { margin-bottom: 14px; padding: 16px 18px; }
.filter-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.2fr 1fr 1.4fr; gap: 12px; }
@media (max-width: 1280px) { .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filter-grid .field:first-child, .filter-grid .field:last-child { grid-column: 1 / -1; } }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; padding: 4px; overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { display: inline-flex; flex: 1; align-items: center; justify-content: center; gap: 8px; min-width: max-content; height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: 700 13.5px var(--font); cursor: pointer; transition: background 0.15s, color 0.15s; }
.tabs button .icon { width: 16px; height: 16px; }
.tabs button:hover { color: var(--accent); }
.tabs button[aria-selected='true'] { background: var(--g-700); color: #fff; box-shadow: 0 6px 14px -8px rgba(4, 120, 87, 0.7); }
.report-body { display: grid; gap: 16px; transition: opacity 0.15s; }
.report-body.is-loading { opacity: 0.5; pointer-events: none; }
.report-body > .card + .card { margin-top: 0; }
.report-body .kpis { margin-bottom: 0; }
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1500px) { .kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.nav-label:not(:first-child) { margin-top: 14px; }
.kpis-stack { grid-template-columns: minmax(0, 1fr); align-content: start; }
.kpis-stack .kpi-value { font-size: 22px; }
.report-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 16px; align-items: start; }
.report-split .card { margin: 0; }
@media (max-width: 900px) { .report-split { grid-template-columns: minmax(0, 1fr); } .kpis-stack { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
.rank-no { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 8px; background: var(--tint-strong); color: var(--accent-strong); font-size: 12px; font-weight: 800; }
.sortable button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.sortable button:hover { color: var(--accent); }
.sortable.sorted { color: var(--accent); }
.sort-dir { font-size: 12px; }
.share { display: inline-flex; align-items: center; gap: 8px; }
.share-bar { width: 56px; height: 6px; overflow: hidden; border-radius: 999px; background: var(--track); }
.share-bar i { display: block; height: 100%; border-radius: inherit; background: var(--g-600); }
.table-note { margin: 0; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.print-only { display: none; }

/* ------------------------------------------------------------ item suggestions in the editor */

.item-row { position: relative; }
.suggest {
  position: absolute;
  left: 0;
  z-index: 30;
  display: grid;
  width: min(460px, 100%);
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.suggest-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font: 600 13.5px var(--font); text-align: left; cursor: pointer; }
.suggest-item.active, .suggest-item:hover { background: var(--tint); }
.suggest-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.suggest-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-name .icon { width: 15px; height: 15px; color: var(--accent); }
.suggest-item small { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.suggest mark { background: none; color: var(--accent); font-weight: 800; }

/* ------------------------------------------------------------ printing app pages (reports) */

@media print {
  body:not(.print-body) { background: #fff; color: #000; }
  body:not(.print-body) .sidebar, body:not(.print-body) .topbar, .bottom-nav, .toasts, .no-print, .sheet, .scrim, .chart-tip { display: none !important; }
  body:not(.print-body) .main { margin: 0; }
  body:not(.print-body) .view { max-width: none; padding: 0; }
  .print-only { display: block; }
  .report-print-head h1 { font-size: 20px; }
  .report-print-head p { margin: 4px 0 12px; color: #444; }
  .card, .kpi { break-inside: avoid; box-shadow: none !important; border-color: #ccc !important; background: #fff !important; color: #000 !important; }
  .kpi:hover { transform: none; }
  .table th { background: #f2f2f2 !important; color: #333 !important; }
  .table-wrap { overflow: visible; container-type: normal; }
}
