/* Colors come from Telegram themeParams (set as --tg-* in applyTheme); --fb-* are fallbacks outside Telegram. */
:root {
  --fb-bg: #f2f2f7;
  --fb-card: #ffffff;
  --fb-text: #1c1c1e;
  --fb-hint: #8e8e93;
  --fb-accent: #2f7d5b;
  --fb-accent-text: #ffffff;
  --fb-link: #2f7d5b;
  --fb-danger: #e5484d;

  --bg: var(--tg-secondary-bg, var(--fb-bg));
  --card: var(--tg-section-bg, var(--tg-bg, var(--fb-card)));
  --text: var(--tg-text, var(--fb-text));
  --hint: var(--tg-subtitle-text, var(--tg-hint, var(--fb-hint)));
  --accent: var(--tg-button, var(--fb-accent));
  --accent-contrast: var(--tg-button-text, var(--fb-accent-text));
  --link: var(--tg-accent-text, var(--tg-link, var(--fb-link)));
  --danger: var(--tg-destructive-text, var(--fb-danger));
  --section-header: var(--tg-section-header-text, var(--hint));
  --separator: var(--tg-section-separator, color-mix(in srgb, var(--text) 10%, transparent));
  --soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --field: color-mix(in srgb, var(--text) 5%, var(--card));
  --warning: #c98a1b;
  --radius: 14px;
  --nav-height: 62px;

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --fb-bg: #000000;
    --fb-card: #1c1c1e;
    --fb-text: #f2f2f7;
    --fb-hint: #8d8d93;
    --fb-accent: #4cae82;
    --fb-link: #5cc294;
    --fb-danger: #ff5c5f;
    color-scheme: dark;
  }
}
:root[data-scheme="dark"] { color-scheme: dark; --warning: #e5a93a; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--link); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.4px; }
h2 { font-size: 20px; line-height: 1.25; font-weight: 650; }
h3 { font-size: 16px; font-weight: 600; }
p { line-height: 1.45; }
small, .small { font-size: 13px; }
.muted { color: var(--hint); }
svg { width: 22px; height: 22px; flex-shrink: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.app-shell {
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 16px calc(var(--nav-height) + 28px + env(safe-area-inset-bottom));
}
#main { outline: 0; transition: opacity .15s; }
#main.is-loading { opacity: .55; pointer-events: none; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 8px 4px 14px; }
.page-heading-text { min-width: 0; }
.page-heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-subtitle { font-size: 14px; color: var(--hint); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-heading-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.icon-button {
  border: 0; background: transparent; color: var(--hint);
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; flex-shrink: 0;
}
.icon-button:active { background: var(--field); }
.icon-button.accent { background: var(--accent); color: var(--accent-contrast); }
.refresh-button[data-working] svg { animation: spin .8s linear infinite; }

/* Period and currency controls */
.period-toolbar { display: grid; gap: 8px; margin-bottom: 14px; }
.segmented { display: flex; background: color-mix(in srgb, var(--text) 7%, transparent); padding: 3px; border-radius: 11px; gap: 2px; }
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 8px;
  padding: 8px 6px; font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap;
}
.segmented button.active { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.date-caption { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--hint); padding: 0 4px; }
.date-caption svg { width: 15px; height: 15px; }
.currency-switch { margin-bottom: 14px; }

/* Totals */
.hero {
  background: var(--accent); color: var(--accent-contrast);
  border-radius: 20px; padding: 18px 20px 20px; margin-bottom: 14px;
}
.hero-label { font-size: 15px; opacity: .85; }
.hero-value { font-size: 38px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; margin: 4px 0 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-meta { font-size: 14px; opacity: .85; }
.hero-extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--accent-contrast) 25%, transparent); font-size: 14px; opacity: .9; }
.hero-extra strong { font-weight: 650; }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.quick-action {
  border: 0; border-radius: var(--radius); background: var(--card); color: var(--link);
  padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600;
}
.quick-action svg { width: 24px; height: 24px; }
.quick-action.primary { background: var(--soft); }
.quick-action:active, .list-action:active, .expense-row:active, .category-stat:active { filter: brightness(.95); }

.draft-banner {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 0; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px;
  background: color-mix(in srgb, var(--warning) 16%, var(--card)); color: var(--text); font-size: 15px;
}
.draft-banner svg:first-child { color: var(--warning); }
.draft-banner span { flex: 1; }
.draft-banner svg:last-child { width: 18px; color: var(--hint); }

/* Grouped sections (Telegram settings style) */
.block, .day-group { margin-bottom: 20px; }
.block-header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 0 16px 7px;
}
.block-header h2 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; color: var(--section-header); }
.block-header > span { font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; text-align: right; }
.block-footer { font-size: 13px; color: var(--hint); padding: 7px 16px 0; line-height: 1.4; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.list-card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.hint-text { color: var(--hint); font-size: 14px; }
.text-button {
  background: none; border: 0; color: var(--link); font-size: 14px; font-weight: 500;
  padding: 4px 0; display: inline-flex; gap: 4px; align-items: center;
}
.text-button svg { width: 16px; height: 16px; }
.block-header .text-button { font-size: 14px; text-transform: none; letter-spacing: 0; }

.list-link, .list-action {
  width: 100%; display: flex; align-items: center; gap: 12px; border: 0; background: none;
  color: var(--link); font-size: 16px; padding: 13px 16px; text-align: left; position: relative;
}
.list-link { justify-content: center; font-size: 15px; font-weight: 500; }
.list-link svg { width: 18px; height: 18px; }
.list-action { color: var(--text); }
.list-action > svg:first-child { color: var(--link); }
.list-action span { flex: 1; }
.list-action .chevron { width: 16px; height: 16px; color: var(--hint); opacity: .7; }
.list-action.danger, .list-action.danger > svg:first-child { color: var(--danger); }

/* Separators between rows, inset like native lists */
.list-card > * + *:not(.stacked-bar)::before {
  content: ""; position: absolute; top: 0; right: 0; left: 64px; border-top: .5px solid var(--separator);
}
.list-card > .stacked-bar + *::before { display: none; }
.list-card > .list-link::before, .list-card > .list-action::before { left: 16px; }
.list-card > .list-action + .list-action::before { left: 50px; }

/* Expense rows */
.expense-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: none; padding: 11px 16px; position: relative; min-height: 62px;
}
.expense-row.deleted { opacity: .55; }
.category-icon {
  --c: #8e8e93;
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in srgb, var(--c) 17%, transparent); color: var(--c);
}
.category-icon svg { width: 20px; height: 20px; }
.expense-content { min-width: 0; flex: 1; display: grid; gap: 2px; }
.expense-title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-meta { color: var(--hint); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-side { display: grid; gap: 2px; justify-items: end; flex-shrink: 0; }
.expense-amount { font-size: 16px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.expense-date { font-size: 13px; color: var(--hint); white-space: nowrap; }
.expense-title, .expense-meta, .expense-amount, .expense-date { display: block; }

/* Search & filters */
.filters-form { margin-bottom: 14px; }
.search-row { display: flex; gap: 8px; }
.search-wrap { position: relative; flex: 1; display: block; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--hint); pointer-events: none; }
.search-wrap input { padding-left: 38px; background: var(--card); border-color: transparent; }
.filter-toggle {
  position: relative; border: 0; border-radius: 12px; background: var(--card); color: var(--hint);
  width: 46px; display: grid; place-items: center; flex-shrink: 0;
}
.filter-toggle.open { color: var(--link); background: var(--soft); }
.filter-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--accent); color: var(--accent-contrast); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; padding: 0 5px;
}
.filter-panel { margin-top: 10px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.list-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 10px; font-size: 14px; color: var(--hint); font-variant-numeric: tabular-nums; }

/* Categories breakdown */
.stacked-bar { display: flex; gap: 2px; height: 10px; margin: 16px 16px 6px; border-radius: 5px; overflow: hidden; }
.stacked-bar span { min-width: 3px; }
.category-stat {
  width: 100%; display: flex; align-items: center; gap: 12px; border: 0; background: none;
  padding: 10px 16px; text-align: left; position: relative;
}
.category-stat-body { flex: 1; min-width: 0; display: grid; gap: 7px; }
.category-stat-top { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.category-stat-top .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-stat-top .value { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.category-stat .share, .bar-label .share { color: var(--hint); font-size: 13px; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { display: block; height: 5px; background: color-mix(in srgb, var(--text) 7%, transparent); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar-row + .bar-row { margin-top: 16px; }
.bar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; margin-bottom: 7px; }
.bar-label strong { font-weight: 600; font-variant-numeric: tabular-nums; display: flex; gap: 8px; }

.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.chart-bars { height: 170px; display: flex; align-items: flex-end; gap: 6px; }
.chart-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.chart-bar-fill { background: color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 5px 5px 2px 2px; width: min(100%, 28px); }
.chart-bar-fill.max { background: var(--accent); }
.chart-bar-label { font-size: 11px; color: var(--hint); margin-top: 6px; white-space: nowrap; }
.chart-tooltip { font-size: 11px; color: var(--hint); margin-bottom: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Settings */
.member-row, .category-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; position: relative; min-height: 56px; }
.member-info { flex: 1; font-size: 16px; }
.member-info small { display: block; color: var(--hint); font-size: 13px; margin-top: 1px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--soft); color: var(--link); font-size: 14px; font-weight: 700; border: 0;
}
.category-row { min-height: 50px; padding-top: 6px; padding-bottom: 6px; font-size: 16px; }
.category-row > span:not(.category-icon) { flex: 1; min-width: 0; }
.category-row.archived { opacity: .55; }
.category-row .icon-button { width: 36px; height: 36px; }
.category-row .icon-button svg { width: 18px; height: 18px; }
.settings-copy { font-size: 14px; color: var(--hint); margin: 6px 0 14px; }
.setting-section-title { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; color: var(--section-header); margin: 22px 0 8px; }
.app-footer { text-align: center; font-size: 12px; color: var(--hint); padding: 4px 0 8px; }

/* Bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border-top: .5px solid var(--separator);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.bottom-nav button {
  flex: 1; max-width: 150px; border: 0; background: none; color: var(--hint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 500; padding: 4px 4px 2px; height: calc(var(--nav-height) - 12px);
}
.bottom-nav button.active { color: var(--link); }
.bottom-nav svg { width: 26px; height: 26px; }

/* Buttons & forms */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 12px;
  padding: 12px 18px; font-size: 16px; font-weight: 600; text-decoration: none; min-height: 50px;
}
.button:active { filter: brightness(.93); }
.button.secondary { background: var(--soft); color: var(--link); }
.button.outline { background: var(--field); color: var(--text); }
.button.danger { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.button.small { font-size: 14px; min-height: 38px; padding: 8px 14px; border-radius: 10px; }
.button.full { width: 100%; }
.button svg { width: 20px; height: 20px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.button-row > .button { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--hint); min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field small { font-size: 12px; font-weight: 400; line-height: 1.4; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 11px 12px;
  border: 1px solid transparent; border-radius: 11px; outline: 0;
  background: var(--field); color: var(--text);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--hint) 50%), linear-gradient(135deg, var(--hint) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder, textarea::placeholder { color: var(--hint); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--soft); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[name$="amount"] { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }
.form-actions .button { flex: 1; }
.form-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-radius: 11px; padding: 11px 13px; font-size: 14px; line-height: 1.45; margin: 14px 0 0; }
.form-error:empty { display: none; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--soft); color: var(--text); font-size: 14px; line-height: 1.45; margin: 14px 0; }
.notice.warning { background: color-mix(in srgb, var(--warning) 15%, transparent); }
.notice:empty { display: none; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.4; font-weight: 400; color: var(--text); }
.checkbox input { width: 20px; height: 20px; min-height: 0; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.separator { border: 0; border-top: .5px solid var(--separator); margin: 20px 0; }
.stack { display: grid; gap: 10px; }
.badge { display: inline-flex; border-radius: 6px; padding: 3px 7px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--link); white-space: nowrap; }
.badge.warning { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.empty { padding: 20px 8px; text-align: center; display: grid; justify-items: center; gap: 8px; color: var(--hint); font-size: 14px; }
.empty svg { width: 34px; height: 34px; color: var(--hint); opacity: .7; }
.empty strong { color: var(--text); font-weight: 600; font-size: 16px; }
.empty .button { margin-top: 6px; }

/* Onboarding & welcome */
.welcome { max-width: 420px; margin: 64px auto; text-align: center; display: grid; justify-items: center; gap: 18px; padding: 0 8px; }
.welcome > svg { width: 44px; height: 44px; color: var(--hint); }
.welcome h1 { font-size: 30px; }
.welcome p { font-size: 15px; color: var(--hint); max-width: 340px; }
.brand-symbol { display: grid; place-items: center; background: var(--accent); color: var(--accent-contrast); font-weight: 800; }
.large-mark { width: 76px; height: 76px; font-size: 54px; border-radius: 22px 22px 22px 7px; line-height: 1; }
.eyebrow { font-size: 13px; text-transform: uppercase; font-weight: 600; letter-spacing: .6px; color: var(--hint); margin-bottom: 6px; }
.welcome-card { margin: 16px auto; }
.welcome-card > h1 { margin-bottom: 8px; }
.welcome-card > p { font-size: 15px; color: var(--hint); margin-bottom: 20px; }
.welcome-card .panel { margin-bottom: 16px; }
.welcome-card .panel h2 { font-size: 18px; margin-bottom: 4px; }
.loading-panel { min-height: 50vh; display: grid; place-items: center; }
.loading-spinner { width: 26px; height: 26px; border: 2.5px solid var(--soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

/* Bottom sheet */
dialog {
  border: 0; padding: 0; margin: auto auto 0; inset: auto 0 0 0;
  width: 100%; max-width: 600px; max-height: 92dvh;
  background: var(--bg); color: var(--text);
  border-radius: 16px 16px 0 0; box-shadow: 0 -6px 40px rgb(0 0 0 / .18);
  overscroll-behavior: contain;
}
dialog[open] { animation: sheet-in .22s cubic-bezier(.2, .8, .3, 1); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
#sheet-body { padding: 6px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--hint); opacity: .35; margin: 0 auto 4px; }
.sheet-heading {
  position: sticky; top: 0; z-index: 2; margin: 0 -16px 14px; padding: 6px 8px 8px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg);
}
.sheet-heading h2 { font-size: 20px; font-weight: 700; }
.sheet-heading .icon-button { background: var(--field); width: 32px; height: 32px; }
.sheet-heading .icon-button svg { width: 18px; height: 18px; }
.sheet-subtitle { font-size: 15px; color: var(--hint); line-height: 1.45; margin: -6px 0 16px; }
.sheet-tabs { margin-bottom: 16px; }
#sheet-body > form, #sheet-body > .form-grid { background: var(--card); border-radius: var(--radius); padding: 16px; }
#sheet-body > form#confirm-form { background: none; padding: 0; }

/* Expense card */
.receipt { background: var(--card); border-radius: var(--radius); padding: 20px 16px; text-align: center; display: grid; justify-items: center; gap: 4px; }
.receipt .category-icon { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 6px; }
.receipt .category-icon svg { width: 26px; height: 26px; }
.receipt-amount { font-size: 34px; font-weight: 700; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.receipt-title { font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.details-grid { background: var(--card); border-radius: var(--radius); margin: 12px 0 16px; padding: 0; }
.details-grid > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; font-size: 15px; }
.details-grid > div + div { border-top: .5px solid var(--separator); }
.details-grid dt { color: var(--hint); }
.details-grid dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.history-row { padding: 12px 16px; background: var(--card); font-size: 14px; line-height: 1.5; }
.history-row:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
.history-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.history-row:only-of-type { border-radius: var(--radius); }
.history-row + .history-row { border-top: .5px solid var(--separator); }
.history-row .muted { font-size: 13px; }
.history-fields { color: var(--hint); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

/* Jobs, drafts, voice, import */
.job-card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 10px; }
.job-card h3 { font-size: 16px; }
.job-card .panel-header { margin-bottom: 6px; }
.job-card p { font-size: 15px; margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.job-card .button-row { margin-top: 12px; }
#sheet-body > .expense-row { background: var(--card); border-radius: var(--radius); margin-bottom: 6px; }
.draft-edit { border: 0; border-radius: 12px; padding: 14px; margin: 0 0 12px; background: var(--field); }
.draft-edit input, .draft-edit select { background: var(--card); }
.draft-edit h3 { font-size: 15px; }
.voice-center { text-align: center; padding: 12px 0; }
.voice-center h3 { font-size: 18px; }
.voice-center p { font-size: 15px; color: var(--hint); margin: 8px 0 16px; }
.voice-orb { width: 96px; height: 96px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--link); margin: 8px auto 18px; }
.voice-orb svg { width: 40px; height: 40px; }
.voice-orb.recording { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); animation: pulse 1.3s infinite; }
.voice-time { font-size: 36px; font-weight: 600; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.recording-wave { display: flex; justify-content: center; gap: 5px; height: 30px; align-items: center; margin: 12px; }
.recording-wave i { background: var(--danger); opacity: .6; width: 4px; height: 10px; border-radius: 3px; animation: wave 1s infinite alternate; }
.recording-wave i:nth-child(2n) { animation-delay: .3s; }
.recording-wave i:nth-child(3n) { animation-delay: .6s; }
#voice-area .button-row { margin-top: 14px; }
.import-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
.import-summary > div { background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--hint); }
.import-summary strong { display: block; font-size: 24px; color: var(--text); }
.import-rows { background: var(--card); border-radius: var(--radius); padding: 0 16px; margin-bottom: 14px; }
.import-row { padding: 12px 0; font-size: 14px; line-height: 1.5; }
.import-row + .import-row { border-top: .5px solid var(--separator); }
.import-row h3 { font-size: 15px; }
.import-row .issues { color: var(--warning); margin: 6px 0; }
.import-row select { font-size: 15px; min-height: 40px; padding: 8px 32px 8px 10px; margin-top: 6px; }
.import-row button { margin-top: 6px; }
.code-field { font-family: ui-monospace, Menlo, monospace; word-break: break-all; font-size: 14px; background: var(--card); padding: 14px; border-radius: 12px; margin: 12px 0; user-select: all; }

/* Toasts sit above the tab bar; while a sheet is open they are moved into it (top layer). */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--nav-height) + 14px + env(safe-area-inset-bottom));
  width: min(430px, calc(100% - 24px)); display: grid; gap: 8px; pointer-events: none;
}
dialog .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
.toast {
  background: color-mix(in srgb, var(--text) 88%, var(--bg)); color: var(--bg);
  border-radius: 12px; box-shadow: 0 6px 24px rgb(0 0 0 / .2);
  padding: 12px 16px; font-size: 15px; line-height: 1.4; animation: toast-in .2s ease;
}
.toast.error { background: var(--danger); color: #fff; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--danger) 14%, transparent); } }
@keyframes wave { to { height: 28px; } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } }

@media (min-width: 640px) {
  dialog { margin: auto; inset: 0; border-radius: 18px; max-height: 88dvh; }
}
@media (max-width: 360px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .hero-value { font-size: 32px; }
  .segmented button { font-size: 13px; }
  .filters, .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
