/* Mega Events OS: tokens and components. See DESIGN_NOTES.md. */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+20A0-20AB, U+20AD-20C0, U+2113; }

:root {
  --navy-900: #142238; --navy-800: #1b2c45; --navy-700: #24364f; --navy-600: #2f4563; --navy-300: #a9b6c8;
  --ink: #17233a; --ink-muted: #55627a; --ink-faint: #5d6a7f;
  --teal-800: #12635a; --teal-700: #18776b; --teal-600: #1f8a7c; --teal-100: #cfe8e3; --teal-50: #e7f3f1;
  --canvas: #f2f5f8; --surface: #ffffff; --surface-2: #f7f9fb; --line: #d9e0e8; --line-strong: #8a96a8;
  --green-text: #1b6b3f; --green-tint: #e3f3e9; --green-dot: #2e9a5b;
  --blue-text: #2b53a8; --blue-tint: #e7edfa; --blue-dot: #3f6fd1;
  --amber-text: #7a4f00; --amber-tint: #fff1d1; --amber-dot: #d99a17;
  --grey-text: #4e5a6e; --grey-tint: #eceff3; --grey-dot: #8592a6;
  --red-text: #a3241a; --red-tint: #fce9e7; --red-dot: #d2483c; --red-600: #b3261e;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 14px;
  --shadow-float: 0 12px 32px rgba(20, 34, 56, .18), 0 2px 6px rgba(20, 34, 56, .08);
  --sidebar-w: 236px; --topbar-h: 60px; --bottombar-h: 60px;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--teal-700);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 1rem; line-height: 1.5; color: var(--ink); background: var(--canvas); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.0625rem; } h4 { font-size: .9375rem; }
p { margin: 0 0 .75rem; }
a { color: var(--teal-700); text-underline-offset: 2px; }
a:hover { color: var(--teal-800); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-s); }
.skip-link:focus { top: 8px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-muted); }
.small { font-size: .8125rem; }
.pos { color: var(--teal-700); } .neg { color: var(--red-text); }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.s16 { width: 16px; height: 16px; }

/* ---------- shell ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; background: linear-gradient(to right, var(--navy-900) var(--sidebar-w), var(--canvas) var(--sidebar-w)); }
.sidebar { background: var(--navy-900); color: #fff; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--teal-700); display: grid; place-items: center; font-weight: 700; font-size: .9rem; letter-spacing: -.02em; }
.brand-name { font-weight: 600; line-height: 1.1; } .brand-name small { display: block; font-weight: 400; color: var(--navy-300); font-size: .75rem; }
.nav { list-style: none; margin: 4px 0; padding: 0 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: var(--radius-s); color: #dbe3ee; text-decoration: none; font-size: .9375rem; position: relative; }
.nav a:hover { background: var(--navy-700); color: #fff; }
.nav a[aria-current="page"] { background: var(--navy-700); color: #fff; font-weight: 500; }
.nav a[aria-current="page"]::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #4fc3b0; }
.nav .count { margin-left: auto; background: var(--teal-700); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 7px; min-width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--navy-700); font-size: .8125rem; color: var(--navy-300); }
.sidebar-foot strong { color: #fff; font-weight: 500; display: block; font-size: .875rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar h1 { font-size: 1.125rem; font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { display: none; }
.content { padding: 24px; max-width: 1360px; width: 100%; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 24px; font-size: .875rem; border-bottom: 1px solid var(--line); }
.banner.sample { background: var(--amber-tint); color: var(--amber-text); }
.banner.locked { background: var(--grey-tint); color: var(--grey-text); border-radius: var(--radius-m); border: 1px solid var(--line); padding: 10px 14px; }
.banner a { color: inherit; font-weight: 600; }
.bottombar { display: none; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-s); border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--canvas); }
.badge-dot { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red-600); color: #fff; font-size: .6875rem; font-weight: 600; display: grid; place-items: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 500; font-size: .9375rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn.primary:hover { background: var(--teal-800); border-color: var(--teal-800); color: #fff; }
.btn.danger { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.btn.danger:hover { background: #8f1e17; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--teal-700); }
.btn.ghost:hover { background: var(--teal-50); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: .875rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: #fff #fff transparent transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.primary):not(.danger).loading::after { border-color: var(--ink) var(--ink) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; }
.btn-group button { border: 0; background: var(--surface); padding: 0 12px; min-height: 36px; cursor: pointer; font-size: .875rem; }
.btn-group button + button { border-left: 1px solid var(--line); }
.btn-group button[aria-pressed="true"] { background: var(--navy-900); color: #fff; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-float); padding: 6px; }
.menu-list a, .menu-list button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; border-radius: var(--radius-s); text-align: left; color: var(--ink); text-decoration: none; cursor: pointer; font-size: .9375rem; }
.menu-list a:hover, .menu-list button:hover { background: var(--canvas); }

/* ---------- cards, KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 1rem; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.dash { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; text-decoration: none; color: var(--ink); }
a.kpi:hover { border-color: var(--teal-700); }
.kpi .label { font-size: .8125rem; color: var(--ink-muted); }
.kpi .value { font-size: 1.625rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.25; margin-top: 2px; }
.kpi .sub { font-size: .8125rem; color: var(--ink-muted); margin-top: 2px; }
.kpi.accent .value { color: var(--teal-700); }
.kpi.alert .value { color: var(--red-text); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .lede { color: var(--ink-muted); margin: 4px 0 0; font-size: .9375rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }
.section-title h2 { font-size: 1.0625rem; }

/* ---------- money trail (signature element) ---------- */
.trail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.trail-step { position: relative; padding: 14px 18px 14px 22px; }
.trail-step + .trail-step { border-left: 1px solid var(--line); }
.trail-step + .trail-step::before { content: ''; position: absolute; left: -7px; top: 50%; width: 12px; height: 12px; background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); }
.trail-step .label { font-size: .8125rem; color: var(--ink-muted); }
.trail-step .value { font-size: 1.375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.trail-step .note { font-size: .78rem; color: var(--ink-muted); }
.trail-step.cash { background: var(--teal-50); }
.trail-step.cash .value { color: var(--teal-800); }
.trail-extra { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 10px 2px 0; font-size: .875rem; color: var(--ink-muted); }
.trail-extra strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- event header band ---------- */
.ev-band { background: var(--navy-900); color: #fff; border-radius: var(--radius-l); padding: 20px 22px 16px; margin-bottom: 0; }
.ev-band .title-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.ev-band h2 { font-size: 1.375rem; font-weight: 600; }
.ev-band .meta { color: var(--navy-300); font-size: .875rem; margin-top: 4px; }
.ev-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.ev-fig { background: var(--navy-800); border-radius: var(--radius-m); padding: 12px 14px; }
.ev-fig .label { color: var(--navy-300); font-size: .8125rem; }
.ev-fig .value { font-size: 1.375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ev-fig .value.pos { color: #6fd8c4; } .ev-fig .value.neg { color: #ff9b91; }
.util { margin-top: 16px; }
.util .row { font-size: .875rem; color: #dbe3ee; }
.bar { height: 10px; border-radius: 999px; background: var(--navy-700); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: #3fb5a2; }
.bar.warn > span { background: #e8b13c; } .bar.over > span { background: #ff7a6e; }
.light .bar { background: var(--grey-tint); }
.light .bar > span { background: var(--teal-700); }
.light .bar.warn > span { background: var(--amber-dot); } .light .bar.over > span { background: var(--red-dot); }
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 18px 0 18px; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; font-size: .9375rem; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--teal-700); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 500; white-space: nowrap; background: var(--grey-tint); color: var(--grey-text); line-height: 1.6; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--grey-dot); }
.chip.green { background: var(--green-tint); color: var(--green-text); } .chip.green::before { background: var(--green-dot); }
.chip.blue { background: var(--blue-tint); color: var(--blue-text); } .chip.blue::before { background: var(--blue-dot); }
.chip.amber { background: var(--amber-tint); color: var(--amber-text); } .chip.amber::before { background: var(--amber-dot); }
.chip.red { background: var(--red-tint); color: var(--red-text); } .chip.red::before { background: var(--red-dot); }
.chip.plain::before { display: none; }
.chip.sample { background: #fff; color: var(--amber-text); border: 1px dashed var(--amber-dot); }
.chip.sample::before { display: none; }
.ev-band .chip { box-shadow: 0 0 0 1px rgba(255,255,255,.15); }

/* ---------- tables (cards on phones) ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table.dt { width: 100%; border-collapse: collapse; font-size: .875rem; }
.dt th { text-align: left; font-weight: 600; color: var(--ink-muted); font-size: .8125rem; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.dt th.num { text-align: right; }
.dt th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.dt th button:focus-visible { box-shadow: var(--focus); border-radius: 4px; }
.dt th[aria-sort="ascending"] button::after { content: '▲'; font-size: .6rem; }
.dt th[aria-sort="descending"] button::after { content: '▼'; font-size: .6rem; }
.dt td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr.clickable { cursor: pointer; }
.dt tbody tr.clickable:hover td { background: var(--teal-50); }
.dt tr.void td, .dt tr.cancelled td { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.dt tr.void td .chip, .dt tr.cancelled td .chip, .dt tr.void td a, .dt tr.cancelled td .actions { text-decoration: none; }
.dt tr.unverified td:first-child { box-shadow: inset 3px 0 0 var(--amber-dot); }
.dt tfoot td { font-weight: 600; border-top: 2px solid var(--line); background: var(--surface-2); }
.dt .primary-cell a { font-weight: 500; color: var(--ink); text-decoration: none; }
.dt .primary-cell a:hover { color: var(--teal-700); text-decoration: underline; }
.dt .sub { display: block; color: var(--ink-muted); font-size: .8125rem; }
.dt .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: .875rem; font-weight: 500; }
.field .hint { font-size: .8125rem; color: var(--ink-muted); }
.field .err { font-size: .8125rem; color: var(--red-text); font-weight: 500; }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); font-size: .9375rem; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--teal-700); box-shadow: 0 0 0 3px var(--teal-100); }
.input[aria-invalid="true"] { border-color: var(--red-600); }
.input.money { font-variant-numeric: tabular-nums; text-align: right; }
.money-wrap { position: relative; }
.money-wrap::before { content: '₹'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }
.money-wrap .input { padding-left: 26px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9375rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--teal-700); flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px 14px; margin: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: .875rem; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; flex: 0 1 190px; }
.filters .field.search { flex: 1 1 240px; }
.form-error { background: var(--red-tint); color: var(--red-text); border-radius: var(--radius-s); padding: 10px 12px; font-size: .9rem; }
.form-warn { background: var(--amber-tint); color: var(--amber-text); border-radius: var(--radius-s); padding: 10px 12px; font-size: .9rem; }
.form-info { background: var(--blue-tint); color: var(--blue-text); border-radius: var(--radius-s); padding: 10px 12px; font-size: .9rem; }
.choice-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice-tiles label { border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.choice-tiles input { accent-color: var(--teal-700); }
.choice-tiles label:has(input:checked) { border-color: var(--teal-700); background: var(--teal-50); }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m); padding: 14px; text-align: center; color: var(--ink-muted); font-size: .875rem; }
.dropzone.drag { border-color: var(--teal-700); background: var(--teal-50); }

/* ---------- dialog / sheet ---------- */
dialog.sheet { padding: 0; border: 0; margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(560px, 100vw); max-width: 100vw; background: var(--surface); box-shadow: var(--shadow-float); }
dialog.sheet.wide { width: min(880px, 100vw); }
dialog.sheet[open] { animation: slide-in .18s ease-out; display: flex; flex-direction: column; }
dialog.modal { padding: 0; border: 0; border-radius: var(--radius-l); width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-float); }
dialog::backdrop { background: rgba(20, 34, 56, .45); }
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.125rem; flex: 1; }
.sheet-body { padding: 18px; overflow-y: auto; flex: 1 1 auto; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-body { padding: 20px 22px 8px; }
.modal-body h2 { font-size: 1.125rem; margin-bottom: 8px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px 18px; }

/* ---------- toasts, states ---------- */
.toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: var(--radius-m); box-shadow: var(--shadow-float); font-size: .9375rem; animation: fade .2s ease-out; }
.toast.error { background: var(--red-600); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.empty { text-align: center; padding: 36px 20px; color: var(--ink-muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 1rem; }
.empty .btn { margin-top: 12px; }
.skeleton { background: linear-gradient(90deg, var(--grey-tint), #f6f8fa, var(--grey-tint)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-s); }
@keyframes shimmer { to { background-position: -200% 0; } }
.load-error { padding: 24px; border: 1px solid var(--red-tint); background: #fff; border-radius: var(--radius-m); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.list-plain > li:last-child { border-bottom: 0; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; text-decoration: none; color: var(--ink); }
.alert-item:hover .alert-title { color: var(--teal-700); text-decoration: underline; }
.sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; flex: none; background: var(--amber-dot); }
.sev.high { background: var(--red-dot); }
.upcoming-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); }
.date-tile { text-align: center; border-radius: var(--radius-s); background: var(--canvas); padding: 4px 0; line-height: 1.15; }
.date-tile b { display: block; font-size: 1.125rem; }
.date-tile span { font-size: .75rem; color: var(--ink-muted); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .9375rem; margin: 0; }
.dl dt { color: var(--ink-muted); } .dl dd { margin: 0; }

/* ---------- calendar ---------- */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-toolbar h2 { font-size: 1.25rem; min-width: 180px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: .75rem; color: var(--ink-muted); text-align: center; padding: 4px 0; font-weight: 600; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); min-height: 112px; padding: 4px 5px 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: var(--surface-2); }
.cal-day.other .cal-date { color: var(--ink-faint); }
.cal-day.today { border-color: var(--teal-700); box-shadow: inset 0 0 0 1px var(--teal-700); }
.cal-date { all: unset; cursor: pointer; font-size: .8125rem; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-date:hover { background: var(--teal-50); }
.cal-date:focus-visible { box-shadow: var(--focus); }
.cal-day.today .cal-date { background: var(--teal-700); color: #fff; }
.cal-ev { display: block; font-size: .75rem; line-height: 1.3; padding: 2px 6px; border-radius: 4px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid; }
.cal-ev.confirmed { background: var(--green-tint); color: var(--green-text); border-color: var(--green-dot); }
.cal-ev.planning { background: var(--blue-tint); color: var(--blue-text); border-color: var(--blue-dot); }
.cal-ev.tentative { background: var(--amber-tint); color: var(--amber-text); border-color: var(--amber-dot); }
.cal-ev.completed { background: var(--grey-tint); color: var(--grey-text); border-color: var(--grey-dot); }
.cal-ev.cancelled { background: var(--red-tint); color: var(--red-text); border-color: var(--red-dot); text-decoration: line-through; }
.cal-ev.clash { outline: 2px solid var(--red-dot); outline-offset: -1px; }
.cal-rem { font-size: .72rem; color: var(--ink-muted); display: flex; gap: 4px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-rem::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--amber-dot); flex: none; }
.cal-rem.task::before { background: var(--blue-dot); }
.cal-rem.invoice_due::before { background: var(--green-dot); }
.cal-more { font-size: .72rem; color: var(--teal-700); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .8125rem; color: var(--ink-muted); margin-top: 12px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 3px; border-left: 3px solid; display: inline-block; }
.week-list .day-block { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 8px; }
.week-list .day-head { padding: 8px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: .875rem; display: flex; justify-content: space-between; align-items: center; }
.week-list .day-head.today { color: var(--teal-700); }
.week-list .entries { padding: 6px 10px; display: flex; flex-direction: column; gap: 6px; }
.week-list .cal-ev { font-size: .875rem; padding: 6px 10px; white-space: normal; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--ink-muted); }
.chart .rev { fill: var(--teal-700); } .chart .exp { fill: #9aa7b8; } .chart .loss { fill: var(--red-dot); } .chart .gain { fill: var(--teal-600); }
.chart .axis { stroke: var(--line); }
.chart-legend { display: flex; gap: 14px; font-size: .8125rem; color: var(--ink-muted); padding: 0 20px 14px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- invoice paper ---------- */
.paper { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 36px 40px; max-width: 880px; }
.paper .inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-bottom: 2px solid var(--navy-900); padding-bottom: 16px; }
.paper .inv-title { font-size: 1.5rem; font-weight: 700; color: var(--navy-900); }
.paper table.lines { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: .9rem; }
.paper .lines th { background: var(--navy-900); color: #fff; padding: 8px 10px; text-align: left; font-weight: 500; }
.paper .lines td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.paper .totals { margin-left: auto; width: min(320px, 100%); font-size: .9375rem; }
.paper .totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.paper .totals .grand { border-top: 2px solid var(--navy-900); font-weight: 700; font-size: 1.0625rem; margin-top: 4px; padding-top: 8px; }
.paper .logo { max-height: 60px; max-width: 200px; }
.void-stamp { color: var(--red-text); border: 3px solid var(--red-dot); display: inline-block; padding: 2px 12px; font-weight: 700; transform: rotate(-6deg); border-radius: 6px; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); }
.auth-side { background: var(--navy-900); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .auth-hero { font-size: 2.25rem; font-weight: 600; line-height: 1.2; color: #fff; letter-spacing: -.02em; margin-top: 40px; max-width: none; }
.auth-side p { color: var(--navy-300); max-width: 34ch; font-size: 1.0625rem; }
.auth-side .trail-mini { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 28px; font-size: .875rem; }
.auth-side .trail-mini span { padding: 6px 12px; border-radius: 999px; background: var(--navy-700); color: #dbe3ee; }
.auth-side .trail-mini span.cash { background: var(--teal-700); color: #fff; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form form { width: min(380px, 100%); }
.auth-form h2 { font-size: 1.5rem; margin-bottom: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.dash { grid-template-columns: minmax(0, 1fr); }
  .ev-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) and (min-width: 768px) {
  .app { grid-template-columns: 72px 1fr; background: linear-gradient(to right, var(--navy-900) 72px, var(--canvas) 72px); }
  .brand-name, .nav a .label, .sidebar-foot, .nav .count { display: none; }
  .nav a { justify-content: center; padding: 11px; }
  .brand { justify-content: center; padding: 16px 0; }
}
@media (max-width: 767px) {
  .app { display: block; background: var(--canvas); padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .topbar { padding: 0 8px 0 16px; gap: 4px; }
  .topbar .topbar-actions .btn .label { display: none; }
  .topbar .topbar-actions .btn { padding: 0 10px; }
  .topbar .back { display: inline-grid; margin-left: -8px; }
  .content { padding: 16px; }
  .banner { padding: 10px 16px; }
  .bottombar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--navy-900); }
  .bottombar a, .bottombar button { all: unset; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #c9d3e0; font-size: .6875rem; cursor: pointer; min-height: 44px; }
  .bottombar [aria-current="page"] { color: #fff; font-weight: 600; }
  .bottombar [aria-current="page"] svg { color: #6fd8c4; }
  .bottombar a:focus-visible, .bottombar button:focus-visible { box-shadow: inset 0 0 0 2px #6fd8c4; }
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 1.25rem; }
  .form-grid { grid-template-columns: 1fr; }
  .choice-tiles { grid-template-columns: 1fr; }
  .trail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trail-step:nth-child(3) { border-left: 0; }
  .trail-step:nth-child(n+3) { border-top: 1px solid var(--line); }
  .trail-step:nth-child(3)::before { display: none; }
  .trail-step .value { font-size: 1.125rem; }
  .ev-band { padding: 16px; border-radius: var(--radius-m); }
  .ev-fig .value { font-size: 1.0625rem; }
  .ev-figs { gap: 8px; }
  dialog.sheet, dialog.sheet.wide { width: 100vw; }
  .filters .field, .filters .field.search { flex: 1 1 100%; }
  .page-head { align-items: stretch; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; }
  .auth-side .auth-hero { margin-top: 16px; font-size: 1.75rem; }
  .paper { padding: 20px 16px; }
  .cal-day { min-height: 64px; padding: 2px; }
  .cal-dots { display: flex; flex-wrap: wrap; gap: 3px; padding: 0 2px; }
  .cal-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--grey-dot); }
  .cal-dots i.confirmed { background: var(--green-dot); } .cal-dots i.planning { background: var(--blue-dot); }
  .cal-dots i.tentative { background: var(--amber-dot); } .cal-dots i.cancelled { background: var(--red-dot); }
  .cal-dots i.clash { box-shadow: 0 0 0 2px var(--red-tint), 0 0 0 3px var(--red-dot); }
  .cal-dots i.rem { background: transparent; border: 1.5px solid var(--amber-dot); }
  .cal-day .cal-date { width: 32px; height: 32px; }
  .cal-rem, .cal-more.desk { display: none; }
  .cal-date { width: 24px; height: 24px; font-size: .75rem; }
  /* tables become cards */
  .table-wrap.cards { background: transparent; border: 0; overflow: visible; }
  .cards table.dt, .cards .dt tbody, .cards .dt tfoot, .cards .dt tr, .cards .dt td { display: block; width: 100%; }
  .cards .dt thead { display: none; }
  .cards .dt tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 10px; padding: 8px 14px; }
  .cards .dt td { border: 0; padding: 4px 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; text-align: right; }
  .cards .dt td .sub { flex-basis: 100%; }
  .cards .dt td.num .sub { text-align: right; }
  .cards .dt td::before { content: attr(data-label); color: var(--ink-muted); font-size: .8125rem; text-align: left; flex: none; }
  .cards .dt td.primary-cell { display: block; text-align: left; font-size: .9375rem; padding: 6px 0 4px; }
  .cards .dt td.primary-cell::before { display: none; }
  .cards .dt td.empty-cell { display: none; }
  .cards .dt td .actions { justify-content: flex-end; }
  .cards .dt tfoot tr { background: var(--surface-2); }
  .cards .dt tfoot td { border: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- print (invoices, reports) ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .bottombar, .banner, .no-print, .toasts, .tabs, .filters, .page-head .btn, dialog { display: none !important; }
  .app { display: block; padding: 0; }
  .content { padding: 0; max-width: none; }
  .paper { border: 0; padding: 0; max-width: none; }
  .table-wrap, .card { border: 0; overflow: visible; }
  .dt th { background: #fff; border-bottom: 1.5px solid #000; color: #000; }
  .dt td { border-bottom: .5px solid #bbb; }
  .paper .lines th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
.card > table.dt th[scope="row"] { width: 42%; background: var(--surface-2); }
.card > table.dt td { overflow-wrap: anywhere; }
.card > table.dt th[scope="row"], .card > table.dt td.num { white-space: normal; }
.legend i.sw { width: 14px; height: 12px; border-radius: 3px; border-left: 3px solid; }
.legend i.sw.confirmed { background: var(--green-tint); border-color: var(--green-dot); }
.legend i.sw.planning { background: var(--blue-tint); border-color: var(--blue-dot); }
.legend i.sw.tentative { background: var(--amber-tint); border-color: var(--amber-dot); }
.legend i.sw.completed { background: var(--grey-tint); border-color: var(--grey-dot); }
.legend i.sw.cancelled { background: var(--red-tint); border-color: var(--red-dot); }
.topbar .back[hidden] { display: none !important; }
