/* ==========================================================================
   Vault Ledger — UI Components
   Depends on colors_and_type.css
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }

/* ============ APP SHELL ============ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ============ TOPBAR ============ */
.topbar {
  position: sticky; top: 0; z-index: 80;
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: var(--sp-6);
  padding: var(--sp-3) var(--sp-5); height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: var(--fw-bold); font-size: var(--fs-lg); letter-spacing: var(--ls-snug); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  position: relative; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 4px 10px rgba(10,140,82,.35);
}
.brand-mark::before {
  content: ""; position: absolute; inset: 7px;
  background: #fff; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path d='M1 1 L7 13 L13 1 M4 5.5 H10' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path d='M1 1 L7 13 L13 1 M4 5.5 H10' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>") center/contain no-repeat;
}
.brand-name small { color: var(--fg-3); font-weight: var(--fw-medium); margin-left: 4px; }

.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 14px; border-radius: var(--r-full);
  color: var(--fg-2); font-weight: var(--fw-medium); font-size: var(--fs-sm);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: var(--surface-hover); color: var(--fg); }
.nav a.active { background: var(--fg); color: var(--bg); }

.actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-2); border: 1px solid var(--border);
  background: var(--surface); transition: all var(--t-fast) var(--ease-out);
}
.icon-btn:hover { color: var(--fg); border-color: var(--border-strong); background: var(--surface-hover); }
.icon-btn svg { width: 18px; height: 18px; }

/* Hamburger (mobile) */
.hamburger { display: none; }
@media (max-width: 820px) {
  .hamburger { display: inline-flex; }
  .nav {
    position: absolute; top: 64px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: var(--sp-3); gap: var(--sp-1);
    max-height: 0; overflow: hidden; transition: max-height var(--t-slow) var(--ease-out);
  }
  .nav.open { max-height: 80vh; padding-top: 12px; padding-bottom: 12px; }
  .nav a { padding: 12px 14px; border-radius: var(--r-sm); width: 100%; }
}

/* ============ MAIN ============ */
.main { max-width: 1240px; margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-9); width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.page-title { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); line-height: var(--lh-tight); }
.page-sub { color: var(--fg-3); font-size: var(--fs-sm); margin-top: 2px; }

/* ============ CARD ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
}
.card-tight { padding: var(--sp-4); }
.card-flat { background: var(--surface-2); border-color: transparent; }
.card-interactive { cursor: pointer; }
.card-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.card-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: var(--ls-snug); }
.card-sub { color: var(--fg-3); font-size: var(--fs-sm); }

/* ============ BUTTON ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--brand-500); color: #fff; }
.btn-accent { background: var(--accent); color: var(--accent-fg); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.btn-tonal { background: var(--surface-3); color: var(--fg); }
.btn-tonal:hover { background: var(--surface-hover); }
.btn-danger { background: var(--neg-bg); color: var(--neg); }
.btn-danger:hover { background: var(--neg); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-xs); }
.btn-lg { height: 48px; padding: 0 22px; font-size: var(--fs-md); }
.btn svg { width: 16px; height: 16px; }

/* ============ CHIP / SEGMENTED ============ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: var(--r-full);
  background: var(--surface-3); color: var(--fg-2);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.chip-outline { background: transparent; border: 1px solid var(--border); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.segmented {
  display: inline-flex; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-full);
  gap: 2px;
}
.segmented button {
  height: 30px; padding: 0 14px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--fg-3);
  transition: color var(--t-fast), background var(--t-fast);
}
.segmented button:hover { color: var(--fg); }
.segmented button.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-xs); }

/* ============ INPUT ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--fg-3); text-transform: uppercase; letter-spacing: var(--ls-wide); }
.input, .select {
  height: 44px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--fg); font-size: var(--fs-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-ring); background: var(--surface); }
.input::placeholder { color: var(--fg-3); }

.search {
  position: relative;
  display: flex; align-items: center;
}
.search .input { padding-left: 40px; height: 44px; border-radius: var(--r-full); }
.search svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--fg-3); pointer-events: none; }

/* ============ BADGE ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  background: var(--surface-3); color: var(--fg-2);
}
.badge-pos { background: var(--pos-bg); color: var(--pos); }
.badge-neg { background: var(--neg-bg); color: var(--neg); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ============ TABS ============ */
.tabs {
  display: inline-flex; padding: 4px;
  background: var(--surface-3); border-radius: var(--r-full);
  gap: 2px; margin-bottom: var(--sp-5);
}
.tab {
  height: 36px; padding: 0 18px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--fg-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: color var(--t-fast), background var(--t-fast);
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-xs); }
.tab .count { background: var(--surface-3); color: var(--fg-3); padding: 0 7px; height: 18px; border-radius: var(--r-full); font-size: 10px; display: inline-flex; align-items: center; }
.tab.active .count { background: var(--accent-tint); color: var(--accent); }

/* ============ TX ROW ============ */
.tx {
  display: grid; grid-template-columns: 44px 1fr auto; gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3); border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.tx:hover { background: var(--surface-hover); }
.tx + .tx { border-top: 1px solid var(--divider); border-radius: 0 0 var(--r-md) var(--r-md); }
.tx-ico {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface-3);
  font-size: 20px;
}
.tx-ico svg { width: 20px; height: 20px; color: var(--fg); }
.tx-main .tx-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: -0.005em; }
.tx-main .tx-meta { font-size: var(--fs-xs); color: var(--fg-3); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tx-main .tx-meta .sep { opacity: .5; }
.tx-amount { font-weight: var(--fw-bold); font-size: var(--fs-md); text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tx-amount small { font-weight: var(--fw-medium); color: var(--fg-3); font-size: 11px; margin-left: 2px; }
.tx-amount.pos { color: var(--pos); }
.tx-amount.neg { color: var(--fg); }
.tx-amount.transfer { color: var(--info); }

/* Day header between tx groups */
.tx-day-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-3) var(--sp-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--fg-3); text-transform: uppercase; letter-spacing: var(--ls-wide);
}
.tx-day-head .sum { color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* ============ CHART ============ */
.chart-svg { width: 100%; display: block; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart-axis { fill: var(--fg-3); font-size: 10px; }
.bar { transition: fill var(--t-fast); }

/* ============ CATEGORY BAR ============ */
.catbar { display: grid; grid-template-columns: 24px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; }
.catbar .dot { width: 10px; height: 10px; border-radius: 3px; justify-self: center; }
.catbar .track { position: relative; height: 8px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.catbar .fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; transition: width var(--t-slow) var(--ease-out); }
.catbar .meta { display: flex; align-items: baseline; gap: 6px; }
.catbar .meta .name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.catbar .meta .pct { font-size: var(--fs-xs); color: var(--fg-3); }
.catbar .val { font-size: var(--fs-sm); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; color: var(--fg-2); }

/* ============ CALENDAR ============ */
.cal {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-dow {
  padding: 8px 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--fg-3); text-transform: uppercase; letter-spacing: var(--ls-wide);
  text-align: left;
}
.cal-cell {
  min-height: 92px;
  padding: 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 4px;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  cursor: pointer;
  position: relative;
}
.cal-cell:hover { background: var(--surface-hover); }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--fg); background: var(--surface); }
.cal-cell.weekend { background: transparent; }
.cal-cell.heat-1 { background: var(--heat-1); }
.cal-cell.heat-2 { background: var(--heat-2); }
.cal-cell.heat-3 { background: var(--heat-3); }
.cal-cell.heat-4 { background: var(--heat-4); }
.cal-num { font-size: var(--fs-sm); font-weight: var(--fw-semibold); display: flex; justify-content: space-between; align-items: center; }
.cal-num .spend { color: var(--neg); font-size: 10px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.cal-today-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-evt {
  font-size: 10px; font-weight: var(--fw-semibold);
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface);
  color: var(--fg);
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid var(--cat-subs);
}
.cal-evt.sub { border-left-color: var(--cat-subs); }
.cal-evt.rent { border-left-color: var(--cat-rent); }
.cal-evt.debt { border-left-color: var(--cat-clothes); }
.cal-evt.salary { border-left-color: var(--cat-salary); }
.cal-more { font-size: 10px; color: var(--fg-3); font-weight: var(--fw-semibold); padding: 0 6px; }

/* month navigator */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav .month {
  font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight);
}
.cal-nav .year { color: var(--fg-3); font-weight: var(--fw-medium); margin-left: 6px; }

/* ============ ACCOUNT CARD ============ */
.acc {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  overflow: hidden;
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base), border-color var(--t-base);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.acc:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.acc-head { display: flex; align-items: center; gap: 10px; }
.acc-logo { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--fg); font-weight: var(--fw-bold); font-size: 13px; flex-shrink: 0; }
.acc-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-cur { font-size: 10px; font-weight: var(--fw-bold); padding: 2px 8px; border-radius: var(--r-full); background: var(--surface-3); color: var(--fg-2); letter-spacing: .04em; }
.acc-bal { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); font-variant-numeric: tabular-nums; margin-top: 4px; }
.acc-foot { display: flex; align-items: center; justify-content: space-between; color: var(--fg-3); font-size: var(--fs-xs); margin-top: auto; }
.acc-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.acc[data-cur="EUR"] .acc-stripe { background: var(--c-eur); }
.acc[data-cur="USD"] .acc-stripe { background: var(--c-usd); }
.acc[data-cur="RUB"] .acc-stripe { background: var(--c-rub); }
.acc[data-cur="KGS"] .acc-stripe { background: var(--c-kgs); }
.acc[data-cur="CRYPTO"] .acc-stripe { background: var(--c-crypto); }

/* ============ DEBT CARD ============ */
.debt {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4); display: flex; flex-direction: column; gap: 10px;
}
.debt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.debt-name { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.debt-sub { font-size: var(--fs-xs); color: var(--fg-3); margin-top: 2px; }
.debt-amt { font-size: var(--fs-xl); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; letter-spacing: var(--ls-tight); }
.debt-track { height: 6px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.debt-fill { height: 100%; background: linear-gradient(90deg, var(--brand-400), var(--brand-500)); border-radius: inherit; }
.debt-meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--fg-3); font-variant-numeric: tabular-nums; }

/* ============ SUB CARD ============ */
.sub {
  display: grid; grid-template-columns: 40px 1fr auto; gap: var(--sp-3); align-items: center;
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}
.sub:hover { border-color: var(--border-strong); }
.sub-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; font-weight: var(--fw-bold); color: #fff; }
.sub-name { font-weight: var(--fw-semibold); }
.sub-meta { font-size: var(--fs-xs); color: var(--fg-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sub-price { font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; text-align: right; }
.sub-price small { color: var(--fg-3); font-weight: var(--fw-medium); font-size: 11px; }

/* ============ KPI ============ */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-5); display: flex; flex-direction: column; gap: 4px;
  min-height: 120px;
  position: relative; overflow: hidden;
}
.kpi-label { font-size: var(--fs-xs); color: var(--fg-3); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--ls-wide); }
.kpi-value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: var(--fs-xs); color: var(--fg-3); margin-top: auto; display: flex; align-items: center; gap: 6px; }
.kpi-delta { display: inline-flex; gap: 3px; align-items: center; font-weight: var(--fw-semibold); }
.kpi-delta.pos { color: var(--pos); }
.kpi-delta.neg { color: var(--neg); }

/* ============ UTIL ============ */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-tight { display: flex; flex-direction: column; gap: var(--sp-2); }
.sep { height: 1px; background: var(--divider); margin: var(--sp-4) 0; }
.spacer { flex: 1; }
.hide-mobile { }
@media (max-width: 700px) { .hide-mobile { display: none !important; } }

/* page footer — tiny branding */
.foot {
  padding: var(--sp-6) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--fg-3);
  font-size: var(--fs-xs);
}

/* ============ CAPTURE ============ */
.capture-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.capture-input {
  width: 100%; min-height: 72px;
  font-size: var(--fs-xl); font-weight: var(--fw-semibold);
  color: var(--fg); background: transparent; border: 0;
  resize: none; padding: 0;
  font-family: var(--font-sans);
  letter-spacing: var(--ls-snug);
}
.capture-input::placeholder { color: var(--fg-3); font-weight: var(--fw-medium); }
.capture-input:focus { outline: none; }
.capture-hint {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.capture-hint-chip {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-2);
  background: var(--surface-3); padding: 4px 10px; border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-fast);
}
.capture-hint-chip:hover { background: var(--surface-hover); }

.parse-card {
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.parse-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); }
.parse-row .lbl { color: var(--fg-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--ls-wide); font-weight: var(--fw-semibold); }
.parse-row .val { font-weight: var(--fw-semibold); font-size: var(--fs-md); }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--fg); color: var(--bg);
  padding: 12px 20px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1080px) {
  .topbar-inner { gap: var(--sp-4); padding: var(--sp-3) var(--sp-4); }
  .main { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
}

@media (max-width: 820px) {
  .main { padding: var(--sp-4) var(--sp-3) var(--sp-8); }
  .page-head { margin-bottom: var(--sp-5); }
  .page-title { font-size: var(--fs-2xl); }
  .kpi-value { font-size: var(--fs-2xl); }
  .card { padding: var(--sp-4); }
  .toast {
    width: calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    border-radius: var(--r-md);
    text-align: center;
    padding: 12px 14px;
  }
}

/* ============ ANIMATIONS ============ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp var(--t-slow) var(--ease-out) both; }

/* ============ SPARKLINE ============ */
.spark { width: 100%; height: 32px; display: block; }
