:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --text: #17202a;
  --muted: #64707d;
  --border: #e2e7ec;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #ccfbf1;
  --danger: #c2410c;
  --up: #c2410c;
  --down: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1418;
    --surface: #161e24;
    --surface-2: #1d272e;
    --text: #e6edf2;
    --muted: #8b9aa6;
    --border: #26323b;
    --primary: #2dd4bf;
    --primary-ink: #04231f;
    --primary-soft: #133c38;
    --danger: #fb923c;
    --up: #fb923c;
    --down: #4ade80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.block { width: 100%; }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; padding-left: 0; }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .filters input, .filters select, .menu-row select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px; /* prevents iOS zoom */
}
.field input:focus, .field select:focus, .filters input:focus, .filters select:focus {
  outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent;
}
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0 10px; font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 18px; padding: 28px 22px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.auth-card .brand { justify-content: center; font-size: 22px; margin-bottom: 18px; }
.auth-tabs { width: 100%; margin-bottom: 18px; }
.auth-tabs button { flex: 1; }

/* ---------- layout ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo { font-size: 1.2em; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.active { color: var(--primary); background: var(--primary-soft); }
.menu-wrap { margin-left: auto; position: relative; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--primary); color: var(--primary-ink); font-weight: 700;
}
.menu {
  position: absolute; right: 0; top: 46px; width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; z-index: 30;
}
.menu-head { padding: 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head small { color: var(--muted); }
.menu-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 10px; border: 0; background: transparent; text-align: left;
  border-radius: 8px; cursor: pointer;
}
.menu-row:hover { background: var(--surface-2); }
.menu-row select { width: auto; padding: 4px 8px; font-size: 14px; }
.menu-row.danger { color: var(--danger); }

main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 110px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: none; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1; border: 0; background: transparent; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.bottom-nav button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button.active span { filter: none; opacity: 1; }

.fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--primary); color: var(--primary-ink); font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(15,118,110,.35); cursor: pointer;
}

/* ---------- summary ---------- */
.period-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.period-nav { display: flex; align-items: center; gap: 10px; }
#periodLabel { font-weight: 700; min-width: 120px; text-align: center; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; box-shadow: var(--shadow);
}
.kpi small { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.kpi strong { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { font-size: 13px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-width: 0; box-shadow: var(--shadow);
}
.card.wide { grid-column: 1 / -1; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.chart-wrap { position: relative; height: 240px; }
.chart-wrap.donut { height: 200px; margin-bottom: 12px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.pct-bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 4px; }
.pct-bar i { display: block; height: 100%; border-radius: 2px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pivot td:first-child, .pivot th:first-child { position: sticky; left: 0; background: var(--surface); }
.pivot td.zero { color: var(--muted); opacity: .5; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar-track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--primary); border-radius: 5px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }

/* ---------- transactions ---------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.filters:has(#fTag:not(.hidden)) { grid-template-columns: 2fr 1fr 1fr 1fr; }
.filter-summary { color: var(--muted); font-size: 14px; margin: 4px 2px 12px; }
.day-group { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px 6px; }
.day-items { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tx {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; width: 100%;
  background: transparent; border-left: 0; border-right: 0; border-top: 0; text-align: left;
}
.tx:last-child { border-bottom: 0; }
.tx:hover { background: var(--surface-2); }
/* category badge: icon on a tint of the category colour (--c) */
.cat-badge {
  --c: var(--muted);
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 9px; font-size: 17px; line-height: 1;
  font-weight: 700; color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 35%, transparent);
}
.cat-badge.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 13px; margin-right: 8px; vertical-align: middle; }
.cat-badge.lg { width: 48px; height: 48px; border-radius: 13px; font-size: 26px; }
.cat-badge.tx-icon { width: 40px; height: 40px; border-radius: 11px; font-size: 20px; }
.tx-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tx-main { flex: 1; min-width: 0; }
.tx-main strong { display: block; }
.tx-main small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- dialog ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 22px; width: min(440px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10, 15, 20, .5); }
dialog h3 { margin: 0 0 16px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px;
  padding: 5px 11px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.cat-chip { display: inline-flex; align-items: center; gap: 5px; }
.chip-ico { font-size: 14px; line-height: 1; }
.cat-chip.active {
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); border-color: var(--c);
  color: var(--text); box-shadow: inset 0 0 0 1px var(--c);
}

/* ---------- tags ---------- */
.tag-pill {
  display: inline-flex; align-items: center; gap: 2px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  color: var(--primary); background: var(--primary-soft); cursor: pointer;
}
.tag-pill.static { cursor: inherit; }
.tx .tag-pill:hover { box-shadow: inset 0 0 0 1px var(--primary); }
.tag-pill button {
  border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 3px;
  font-size: 15px; line-height: 1; opacity: .7;
}
.tag-pill button:hover { opacity: 1; }
.tag-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; cursor: text;
  padding: 7px 10px; min-height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.tag-box:focus-within { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.tag-list { display: contents; }
.tag-box .tag-pill { font-size: 13px; padding: 2px 6px 2px 10px; cursor: default; }
.field .tag-box input { flex: 1; min-width: 110px; border: 0; padding: 4px 0; outline: none; background: transparent; }
.tag-sugs { margin: 8px 0 0; }
.tag-sugs:empty { display: none; }
.tag-chip { color: var(--primary); font-weight: 600; }
.card-note { font-size: 12px; margin: 10px 0 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: calc(100vw - 32px);
}

/* ---------- categories manager ---------- */
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.link-btn { border: 0; background: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; font-size: 14px; }
.cat-filter { display: flex; gap: 6px; }
.cat-filter select { flex: 1; min-width: 0; }
.icon-btn.sq { border-radius: 10px; width: 44px; height: auto; font-size: 16px; flex-shrink: 0; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dlg-head h3 { margin: 0; }
.cat-add { display: flex; gap: 8px; }
.cat-add input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); font-size: 16px;
}
.cat-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.cat-item { border-bottom: 1px solid var(--border); padding: 10px 2px; }
.cat-item:last-child { border-bottom: 0; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-row .cat-name { flex: 1; min-width: 0; }
.cat-row .cat-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .cat-name small { color: var(--muted); }
.cat-row .icon-btn { width: 34px; height: 34px; font-size: 15px; }
.cat-row input, .cat-move select {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); font-size: 16px;
}
/* category style editor */
.badge-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 10px; display: inline-flex; }
.badge-btn:hover .cat-badge { box-shadow: inset 0 0 0 2px var(--c); }
.cat-list:has(.cat-style) { max-height: none; overflow: visible; } /* let the dialog scroll so Save is reachable */
.cat-style { padding: 4px 0; display: flex; flex-direction: column; gap: 10px; }
.style-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: -4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch.custom {
  position: relative; overflow: hidden; display: inline-block;
  background: conic-gradient(#ef4444, #eab308, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444);
}
.swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.emoji {
  height: 38px; border: 1px solid transparent; border-radius: 9px; background: var(--surface-2);
  font-size: 20px; cursor: pointer; padding: 0;
}
.emoji:hover { border-color: var(--border); }
.emoji.on { border-color: var(--primary); background: var(--primary-soft); }
.cat-move { margin-top: 8px; padding: 10px; background: var(--surface-2); border-radius: 10px; font-size: 14px; }
.cat-move .cat-row { margin-top: 8px; flex-wrap: wrap; }
.btn.sm { padding: 7px 12px; font-size: 14px; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.chip.manage { background: transparent; border-style: dashed; color: var(--primary); }

/* ---------- date picker ---------- */
dialog { max-height: 92dvh; overflow-y: auto; }
.date-bar { display: flex; gap: 8px; align-items: stretch; }
.date-bar .icon-btn { width: 44px; height: auto; border-radius: 10px; flex-shrink: 0; }
.date-display {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; text-align: left;
}
.date-display:hover { border-color: var(--primary); }
.date-display[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.date-main { font-weight: 700; white-space: nowrap; }
.date-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-icon { margin-left: auto; align-self: center; color: var(--muted); flex-shrink: 0; }
.date-quick { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.date-quick::-webkit-scrollbar { display: none; }
.date-quick .chip { white-space: nowrap; flex-shrink: 0; }

.calendar { margin-top: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head .icon-btn { width: 32px; height: 32px; font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-dow { font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 0; text-transform: uppercase; }
.cal-day {
  position: relative; height: 38px; border: 0; background: transparent; border-radius: 10px;
  cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day.future { color: var(--muted); opacity: .55; }
.cal-day.today { color: var(--primary); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-day.selected { background: var(--primary); color: var(--primary-ink); font-weight: 700; opacity: 1; }
.cal-day i, .cal-dot {
  display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.cal-day i { position: absolute; bottom: 4px; left: 50%; margin-left: -2px; }
.cal-dot { vertical-align: middle; margin-right: 4px; }
.cal-day.selected i { background: var(--primary-ink); }
.cal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; }

/* ---------- sync status ---------- */
.sync-badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sync-badge + .menu-wrap { margin-left: 0; }
.sync-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--down); flex-shrink: 0; }
.sync-badge.busy i { background: #d97706; animation: pulse 1s ease-in-out infinite; }
.sync-badge.warn { color: var(--danger); border-color: var(--danger); }
.sync-badge.warn i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.pending-dot {
  display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%;
  background: #d97706; vertical-align: middle; animation: pulse 1s ease-in-out infinite;
}
dialog.busy { cursor: progress; }
dialog.busy .cat-list, dialog.busy .cat-add { opacity: .6; pointer-events: none; }
@media (max-width: 640px) {
  .sync-badge.ok span { display: none; }
  .sync-badge.ok { padding: 8px; border-color: transparent; }
}

/* ---------- keyboard ---------- */
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 5px; border-radius: 5px; text-align: center;
  border: 1px solid var(--border); border-bottom-width: 2px; background: var(--surface-2);
  font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text);
}
.kb-hint { font-size: 12px; color: var(--muted); margin: -4px 0 12px; line-height: 2; }
.chip-key { display: none; min-width: 0; padding: 0 4px; margin-right: 5px; font-size: 10px; border-bottom-width: 1px; }
.chip.suggest { border-color: var(--primary); border-style: dashed; }
.keys th { padding-top: 14px; color: var(--primary); }
.keys td:first-child { white-space: nowrap; width: 1%; padding-right: 16px; }
.keys td:last-child { white-space: normal; }
.kb-only { display: none !important; }
@media (hover: hover) and (pointer: fine) {
  .kb-only { display: block !important; }
  .menu-row.kb-only { display: flex !important; }
  .chip-key { display: inline-block; }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .desktop-tabs { display: none; }
  .bottom-nav { display: flex; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
  .filters, .filters:has(#fTag:not(.hidden)) { grid-template-columns: 1fr 1fr; }
  .filters #fTag { grid-column: 1 / -1; }
  .filters input[type="search"] { grid-column: 1 / -1; }
  .period-bar { flex-direction: column; align-items: stretch; }
  .period-bar .seg { width: 100%; }
  .period-bar .seg button { flex: 1; }
  .period-nav { justify-content: space-between; }
  .kpi strong { font-size: 19px; }
  .card { padding: 14px; }
  dialog { margin: auto auto 0; border-radius: 18px 18px 0 0; width: 100vw; max-width: 100vw; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
