/* Tally design system for Bills, adapted from design/design-system/.
   Night (dark) only for this app; tokens and component classes (ty-*) are
   ported from design/src/design-system/{tokens,components}.css. */
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500&display=swap");

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #111111;
  --surface-raised: #1c1c1c;
  --line: #262626;
  --line-strong: #6b6b6b;
  --ink: #ffffff;
  --ink-muted: #a3a3a3;
  --action: var(--ink);
  --on-action: var(--bg);
  --positive: #34d27b;
  --positive-soft: #0f2a1b;
  --warning: #ffb020;
  --warning-soft: #2e2208;
  --negative: #ff5a4f;
  --negative-soft: #2e0f0d;
  --on-negative: #000000;
  --info: #8ab4ff;
  --focus: var(--ink);
  --scrim: rgba(0, 0, 0, 0.72);
  --shadow-overlay: 0 24px 64px rgba(0, 0, 0, 0.6);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --font-sans: Geist, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, Menlo, monospace;
}

.display { font-family: var(--font-sans); font-size: 64px; line-height: 60px; font-weight: 600; letter-spacing: -0.035em; }
.title-1 { font-family: var(--font-sans); font-size: 40px; line-height: 44px; font-weight: 600; letter-spacing: -0.025em; margin: 0; }
.title-2 { font-family: var(--font-sans); font-size: 28px; line-height: 32px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.title-3 { font-family: var(--font-sans); font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.body { font-family: var(--font-sans); font-size: 16px; line-height: 24px; font-weight: 400; }
.body-strong { font-family: var(--font-sans); font-size: 16px; line-height: 24px; font-weight: 500; }
.small { font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 400; }
.caption { font-family: var(--font-sans); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.02em; }
.mono { font-family: var(--font-mono); font-size: 14px; line-height: 20px; font-weight: 400; }

/* ---- Base / reset ---- */
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { color: var(--ink); font-family: var(--font-sans); margin: 0; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font-family: inherit; }
.ty-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.ty-icon { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: -0.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ty-icon-lg { width: 28px; height: 28px; }
.ty-btn:focus-visible, .ty-seg-btn:focus-visible, .ty-row:focus-visible, .ty-icon-btn:focus-visible, .ty-navlink:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

/* ---- Button ---- */
.ty-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); border: 0; cursor: pointer; font: 500 16px/24px var(--font-sans); border-radius: var(--radius-pill); padding: var(--space-3) var(--space-6); transition: opacity .15s, background .15s; white-space: nowrap; text-decoration: none; }
.ty-btn-sm { font-size: 14px; line-height: 20px; padding: var(--space-2) var(--space-4); }
.ty-btn-lg { font-size: 18px; line-height: 24px; padding: var(--space-4) var(--space-8); }
.ty-btn-block { width: 100%; }
.ty-btn-primary { background: var(--action); color: var(--on-action); }
.ty-btn-primary:hover { opacity: .86; }
.ty-btn-secondary { background: var(--surface-raised); color: var(--ink); }
.ty-btn-secondary:hover { background: var(--line); }
.ty-btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ty-btn-ghost:hover { background: var(--surface); }
.ty-btn-danger { background: var(--negative); color: var(--on-negative); }
.ty-btn-danger:hover { opacity: .86; }
.ty-btn:disabled, .ty-btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.ty-icon-btn { width: 36px; height: 36px; border-radius: var(--radius-pill); border: 0; background: transparent; color: var(--ink-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; text-decoration: none; }
.ty-icon-btn:hover { background: var(--surface-raised); color: var(--ink); }

/* ---- Amount ---- */
.ty-amount { font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.ty-amount-in { color: var(--positive); }

/* ---- StatusBadge ---- */
.ty-badge { display: inline-flex; align-items: center; gap: var(--space-1); font: 500 12px/16px var(--font-sans); letter-spacing: .02em; text-transform: uppercase; padding: var(--space-1) 10px var(--space-1) var(--space-2); border-radius: var(--radius-pill); white-space: nowrap; }
.ty-badge .ty-icon { width: 14px; height: 14px; }
.ty-badge-paid { background: var(--positive-soft); color: var(--positive); }
.ty-badge-due { background: var(--warning-soft); color: var(--warning); }
.ty-badge-overdue { background: var(--negative-soft); color: var(--negative); }
.ty-badge-scheduled { background: var(--surface-raised); color: var(--ink); }
.ty-badge-review { background: transparent; color: var(--ink-muted); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ---- Avatar ---- */
.ty-avatar { width: 44px; height: 44px; border-radius: var(--radius-pill); background: var(--surface-raised); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font: 600 15px/1 var(--font-sans); letter-spacing: -0.01em; flex: none; }

/* ---- Row / List ---- */
.ty-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); cursor: pointer; text-align: left; width: 100%; background: transparent; border: 0; color: inherit; font: inherit; text-decoration: none; }
.ty-row:hover { background: var(--surface-raised); }
.ty-row-static { cursor: default; }
.ty-row-static:hover { background: transparent; }
.ty-row-static > .ty-icon { color: var(--ink-muted); }
.ty-row-main { flex: 1; min-width: 0; }
.ty-row-payee { font: 500 16px/24px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ty-row-meta { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ty-row-end { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); flex: none; }

.ty-list { display: flex; flex-direction: column; gap: var(--space-6); }
.ty-group-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 var(--space-4) var(--space-2); border-bottom: 1px solid var(--line); margin-bottom: var(--space-2); }
.ty-group-total { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.ty-list-empty { padding: var(--space-12) var(--space-4); text-align: center; color: var(--ink-muted); font: 400 16px/24px var(--font-sans); }

/* ---- SummaryCard ---- */
.ty-card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-6); }
.ty-summary-label { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); margin: 0 0 var(--space-2); }
.ty-summary-foot { display: flex; gap: var(--space-6); margin-top: var(--space-6); flex-wrap: wrap; }
.ty-summary-stat { display: flex; flex-direction: column; gap: 2px; }
.ty-summary-stat-label { display: inline-flex; align-items: center; gap: 6px; font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.ty-summary-stat-value { font: 500 16px/24px var(--font-sans); }
.ty-dot { width: 8px; height: 8px; border-radius: var(--radius-pill); display: inline-block; flex: none; }

/* ---- SegmentedControl ---- */
.ty-seg { display: inline-flex; gap: 2px; padding: var(--space-1); background: var(--surface); border-radius: var(--radius-pill); flex-wrap: wrap; }
.ty-seg-btn { border: 0; background: transparent; color: var(--ink-muted); font: 500 14px/20px var(--font-sans); padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
.ty-seg-btn:hover { color: var(--ink); }
.ty-seg-btn[aria-pressed="true"] { background: var(--action); color: var(--on-action); }
.ty-seg-count { font-variant-numeric: tabular-nums; opacity: .7; }

/* ---- Field shell (TextField, Select) ---- */
.ty-field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.ty-label { font: 500 14px/20px var(--font-sans); color: var(--ink); }
.ty-control { display: flex; align-items: center; gap: var(--space-2); background: var(--bg); border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--line-strong); padding: 0 var(--space-4); min-height: 52px; transition: box-shadow .15s; }
.ty-control:focus-within { box-shadow: inset 0 0 0 2px var(--focus); }
.ty-control-invalid, .ty-control-invalid:focus-within { box-shadow: inset 0 0 0 2px var(--negative); }
.ty-control input, .ty-control select, .ty-control textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 400 16px/24px var(--font-sans); padding: var(--space-3) 0; appearance: none; -webkit-appearance: none; }
.ty-control textarea { min-height: 96px; resize: vertical; padding-top: var(--space-3); }
.ty-control input::placeholder { color: var(--ink-muted); }
.ty-control select { cursor: pointer; }
.ty-control > .ty-icon { color: var(--ink-muted); }
.ty-hint { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); margin: 0; }
.ty-error { font: 500 14px/20px var(--font-sans); color: var(--negative); display: block; margin: 0; }

/* ---- Switch ---- */
.ty-switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); cursor: pointer; }
.ty-switch-text { display: flex; flex-direction: column; }
.ty-switch-label { font: 500 16px/24px var(--font-sans); }
.ty-switch-hint { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.ty-switch-track { position: relative; width: 52px; height: 32px; border-radius: var(--radius-pill); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong); flex: none; transition: background .15s; }
.ty-switch-track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: var(--radius-pill); background: var(--ink-muted); transition: transform .15s, background .15s; }
.ty-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ty-switch input:checked + .ty-switch-track { background: var(--action); box-shadow: none; }
.ty-switch input:checked + .ty-switch-track::after { transform: translateX(20px); background: var(--on-action); }
.ty-switch input:focus-visible + .ty-switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- DropZone (input kept focusable but visually hidden, so Tab/Enter/Space work natively) ---- */
.ty-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; padding: var(--space-8) var(--space-6); border-radius: var(--radius-lg); background: var(--surface); border: 1.5px dashed var(--line-strong); cursor: pointer; transition: border-color .15s, background .15s; }
.ty-drop:hover { border-color: var(--ink); border-style: solid; }
.ty-drop:focus-within { border-color: var(--ink); border-style: solid; outline: 2px solid var(--focus); outline-offset: 2px; }
.ty-drop-icon { width: 48px; height: 48px; border-radius: var(--radius-pill); background: var(--bg); display: inline-flex; align-items: center; justify-content: center; }
.ty-drop-title { font: 600 20px/26px var(--font-sans); letter-spacing: -0.01em; margin: 0; }
.ty-drop-hint { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); margin: 0; }
.ty-drop input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---- ImportItem ---- */
.ty-import { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); background: var(--surface); border-radius: var(--radius-md); }
.ty-import-file { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--bg); display: inline-flex; align-items: center; justify-content: center; color: var(--ink-muted); flex: none; }
.ty-import-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ty-import-name { font: 500 15px/20px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ty-import-meta { font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.ty-import-meta-error { color: var(--negative); font-weight: 500; }

/* ---- Alerts ---- */
.ty-alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font: 400 14px/20px var(--font-sans); margin-bottom: var(--space-4); }
.ty-alert-success { background: var(--positive-soft); color: var(--positive); }
.ty-alert-warning { background: var(--warning-soft); color: var(--warning); }
.ty-alert-error, .ty-alert-danger { background: var(--negative-soft); color: var(--negative); }
.ty-alert-info, .ty-alert-debug { background: var(--surface-raised); color: var(--ink); }

/* ---- App shell ---- */
.ty-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-6); background: var(--bg); border-bottom: 1px solid var(--line); }
.ty-wordmark { font: 600 20px/1 var(--font-sans); letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.ty-logo { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--ink); transition: opacity .15s; }
.ty-logo:hover { opacity: .8; }
.ty-logo-mark { width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--action); color: var(--on-action); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ty-logo-mark .ty-icon { width: 16px; height: 16px; }
.ty-page { max-width: 640px; margin: 0 auto; padding: var(--space-8) var(--space-6) var(--space-16); }
.ty-page-wide { max-width: 1024px; }
.ty-container-narrow { max-width: 480px; margin: 0 auto; }
.ty-page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-8); flex-wrap: wrap; }
.ty-form-actions { display: flex; gap: var(--space-3); margin-top: var(--space-8); }
.ty-overview-cta { margin: var(--space-6) 0 var(--space-8); }
.ty-pagination { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-8); }

@media (min-width: 1024px) {
  .ty-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--space-8); align-items: start; }
  .ty-overview > .ty-card { position: sticky; top: var(--space-8); }
  .ty-page { padding-left: var(--space-8); padding-right: var(--space-8); }
  .ty-page-wide { max-width: 1024px; }
  .ty-topbar { display: none; }
  .ty-app { padding-left: 280px; }
}

/* ---- Nav sheet ---- */
.ty-scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 40; }
body.ty-scrim-open .ty-scrim { opacity: 1; pointer-events: auto; }
.ty-sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 86vw); background: var(--surface); box-shadow: var(--shadow-overlay); transform: translateX(100%); transition: transform .2s ease; z-index: 41; display: flex; flex-direction: column; padding: var(--space-6); overflow-y: auto; }
.ty-sheet-open { transform: translateX(0); }
.ty-sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-6); }
.ty-sheet-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ty-sheet-footer { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-6); border-top: 1px solid var(--line); margin-top: var(--space-6); }
.ty-navlink { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); color: var(--ink); text-decoration: none; font: 500 16px/24px var(--font-sans); }
.ty-navlink:hover { background: var(--surface-raised); }
.ty-navlink-active { background: var(--surface-raised); }
.ty-navlink .ty-icon { color: var(--ink-muted); }
.ty-navlink-active .ty-icon { color: var(--ink); }

/* Above 1024px the sheet stays permanently open, docked to the left as a sidebar. */
@media (min-width: 1024px) {
  .ty-scrim { display: none; }
  .ty-sheet {
    position: fixed;
    top: 0; left: 0; right: auto; bottom: 0;
    width: 280px;
    transform: none;
    box-shadow: none;
    border-right: 1px solid var(--line);
  }
  .ty-sheet [data-ty-sheet-close] { display: none; }
}

/* ---- Auth shell ---- */
.ty-auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.ty-auth-shell { width: 100%; max-width: 360px; }

/* ---- Table (Price history) ---- */
.ty-table-wrap { overflow-x: auto; }
.ty-table { width: 100%; border-collapse: collapse; font: 400 14px/20px var(--font-sans); }
.ty-table th, .ty-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.ty-table th { color: var(--ink-muted); font-weight: 500; }
.ty-table td.ty-num, .ty-table th.ty-num { text-align: right; }
