/* Direction: Corporate — trusted professional. White & very light blue sections, deep navy text, confident blue primary, clean sans-serif. */

:root {
  --bg: #ffffff;
  --bg-soft: #f2f7fd;
  --bg-soft-2: #e7f0fa;
  --surface: #ffffff;
  --text: #0b2239;
  --text-2: #3d5166;
  --text-muted: #5a6b80;
  --border: #d8e3ef;
  --border-soft: #e6eef7;
  --border-strong: #c3d3e4;
  --primary: #1d4ed8;
  --primary-hover: #1a3fb0;
  --primary-soft: #eaf1fe;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --cat-travel: #1d4ed8;
  --cat-food: #d97706;
  --cat-software: #7c3aed;
  --cat-office: #0d9488;
  --cat-other: #64748b;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 1px 2px rgba(11, 34, 57, 0.05), 0 10px 28px rgba(11, 34, 57, 0.07);
  --shadow-lg: 0 4px 12px rgba(11, 34, 57, 0.1), 0 20px 44px rgba(11, 34, 57, 0.14);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; font-weight: 800; color: var(--text); }

:focus-visible { outline: 3px solid rgba(29, 78, 216, 0.4); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.container { max-width: 1160px; margin-inline: auto; padding-inline: 24px; }

section { scroll-margin-top: 92px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 600;
  height: 46px; padding: 0 20px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background 0.18s ease-out, border-color 0.18s ease-out, color 0.18s ease-out, box-shadow 0.18s ease-out;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #fff; color: var(--primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--primary-soft); border-color: var(--primary); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-soft-2); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }

.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: var(--radius-sm); }
.btn svg { width: 18px; height: 18px; }

.icon-btn {
  width: 40px; height: 40px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer;
  display: grid; place-items: center; transition: background 0.15s ease-out, color 0.15s ease-out;
}
.icon-btn:hover { background: var(--bg-soft-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 70px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.logo-mark svg { width: 20px; height: 20px; }
.logo small { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.2; }
.logo div { line-height: 1.1; }

.main-nav { display: flex; align-items: center; gap: 26px; }
.nav-link {
  font-size: 15px; font-weight: 600; color: var(--text-2); text-decoration: none;
  padding: 6px 2px; border-bottom: 2px solid transparent; transition: color 0.15s ease-out;
}
.nav-link:hover { color: var(--text); }
.nav-link[aria-current="true"] { color: var(--primary); border-color: var(--primary); }
.header-cta { height: 42px; padding: 0 16px; font-size: 14.5px; }

.nav-toggle { display: none; }

/* ---------- Hero ---------- */

.hero { background: linear-gradient(180deg, #ffffff 0%, var(--bg-soft) 100%); padding: clamp(60px, 8vw, 100px) 0 clamp(56px, 7vw, 88px); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(40px, 6vw, 72px); align-items: center; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 7px 14px; border-radius: 999px;
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }

.hero-title { font-size: clamp(2.3rem, 4.6vw, 3.5rem); line-height: 1.07; letter-spacing: -0.028em; margin: 22px 0 18px; }
.hero-title em { font-style: normal; color: var(--primary); }
.hero-sub { font-size: 18px; color: var(--text-2); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 30px; }

.trust-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 34px; }
.stars { display: inline-flex; gap: 2px; color: var(--warning); }
.stars svg { width: 18px; height: 18px; fill: currentColor; }
.trust-note { font-size: 14px; font-weight: 500; color: var(--text-muted); }

.hero-media { position: relative; }
.hero-media::before {
  content: ""; position: absolute; right: -20px; bottom: -20px;
  width: 68%; height: 68%; background: var(--bg-soft-2); border-radius: var(--radius-xl); z-index: 0;
}
.photo-card { position: relative; z-index: 1; }
.photo-card img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius-xl); border: 1px solid var(--border-soft); box-shadow: var(--shadow-lg);
}
.photo-chip {
  position: absolute; left: 18px; bottom: 18px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.97); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 12px 18px; box-shadow: var(--shadow);
}
.photo-chip .chip-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.photo-chip .chip-icon svg { width: 20px; height: 20px; }
.photo-chip strong { display: block; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.photo-chip span { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

/* ---------- Stats band ---------- */

.stats-band { background: var(--bg-soft); border-block: 1px solid var(--border-soft); padding: 36px 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; }
.stat-value { font-size: clamp(1.7rem, 2.6vw, 2.15rem); font-weight: 800; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-value span { color: var(--primary); }
.stat-label { font-size: 14px; color: var(--text-2); margin-top: 2px; }

/* ---------- Tracker ---------- */

.tracker { padding: clamp(64px, 9vw, 108px) 0; background: var(--bg); }
.tracker-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
.tracker-head h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
.tracker-head .sub { color: var(--text-2); margin-top: 6px; max-width: 60ch; }

.month-nav {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px; box-shadow: var(--shadow);
}
.month-select {
  height: 40px; border: none; background: transparent; font: inherit;
  font-size: 15.5px; font-weight: 700; color: var(--text); padding: 0 8px; cursor: pointer;
}

.tracker-grid { display: grid; grid-template-columns: 375px minmax(0, 1fr); gap: 28px; align-items: start; }
.form-col { position: sticky; top: 94px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-head { padding: 18px 24px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 16.5px; font-weight: 700; }
.card-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 24px; }

/* Add-expense form */

.form-card .card-body { padding-top: 20px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  font: inherit; font-size: 15.5px; color: var(--text); background: #fff;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
.textarea { height: auto; min-height: 84px; padding: 11px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233d5166' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px; cursor: pointer; }
.input-prefix { position: relative; }
.input-prefix .prefix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-weight: 600; pointer-events: none; }
.input-prefix .input { padding-left: 34px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.form-error { display: none; font-size: 13.5px; font-weight: 600; color: var(--danger); background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.form-error.show { display: block; }
.form-card .btn[type="submit"] { width: 100%; height: 48px; margin-top: 4px; }

/* Summary chips */

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow); }
.chip-label { font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); }
.chip-value { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.chip-value small { font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }

/* Chart */

.chart-wrap { position: relative; height: 300px; }

/* States */

.state { padding: 52px 24px; text-align: center; color: var(--text-muted); }
.state .state-icon { width: 44px; height: 44px; margin: 0 auto 14px; color: var(--border-strong); }
.state h3 { font-size: 16.5px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.state p { font-size: 14.5px; max-width: 44ch; margin: 0 auto 18px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.state.error .state-icon { color: var(--danger); }

.hidden { display: none !important; }

/* Expenses table */

.table-scroll { overflow-x: auto; }
table.expenses { width: 100%; border-collapse: collapse; font-size: 15px; }
.expenses thead th {
  text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-muted); background: var(--bg-soft);
  padding: 12px 18px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.expenses thead th.num, .expenses td.amount-cell { text-align: right; }
.expenses thead th.actions, .expenses td.actions-cell { text-align: right; }
.expenses tbody td { padding: 13px 18px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.expenses tbody tr:last-child td { border-bottom: none; }
.expenses tbody tr { transition: background 0.12s ease-out; }
.expenses tbody tr:hover { background: #f8fbff; }
.expenses tbody tr.editing { background: var(--primary-soft); }

.cat { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-Travel { background: var(--cat-travel); }
.dot-Food { background: var(--cat-food); }
.dot-Software { background: var(--cat-software); }
.dot-Office { background: var(--cat-office); }
.dot-Other { background: var(--cat-other); }

td.date-cell { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
td.note-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
td.payer-cell { white-space: nowrap; }
td.amount-cell { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions-cell { white-space: nowrap; }
td.actions-cell .btn + .btn { margin-left: 8px; }

.edit-input { min-width: 110px; }
.edit-input.select, .edit-input.input { height: 40px; font-size: 14.5px; padding: 0 10px; }
.edit-input.select { padding-right: 34px; }
td.editing-amount { text-align: right; }
td.editing-amount .input { text-align: right; }

/* Footer */

.site-footer { background: var(--bg-soft); border-top: 1px solid var(--border-soft); padding: 28px 0; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); }
.footer-inner strong { color: var(--text); }

/* Toasts */

.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: #fff; font-size: 14.5px; font-weight: 500;
  padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease-out;
}
.toast.error { background: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease-out, transform 0.3s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-media { max-width: 560px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 22px; }
  .tracker-grid { grid-template-columns: 1fr; }
  .form-col { position: static; }
  .chips { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .main-nav {
    display: none; position: absolute; top: 70px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 14px 24px 20px; box-shadow: var(--shadow-lg);
  }
  .site-header.nav-open .main-nav { display: flex; }
  .nav-link { padding: 12px 6px; border-bottom: 1px solid var(--border-soft); }
  .nav-link[aria-current="true"] { border-color: transparent; }
  .header-cta { width: 100%; margin-top: 10px; }
  .nav-toggle { display: grid; }
}

@media (max-width: 719px) {
  body { font-size: 16px; }
  .container { padding-inline: 18px; }
  .chips { grid-template-columns: 1fr; gap: 12px; }
  .chip { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px; }
  .chip-value { margin-top: 0; font-size: 21px; }

  .expenses thead { display: none; }
  .expenses, .expenses tbody, .expenses tr, .expenses td { display: block; width: 100%; }
  .expenses tbody tr { padding: 8px 18px 14px; border-bottom: 1px solid var(--border-soft); }
  .expenses tbody tr:last-child { border-bottom: none; }
  .expenses tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 7px 0; border: none; white-space: normal;
  }
  .expenses tbody td::before {
    content: attr(data-label);
    font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--text-muted); flex: none;
  }
  td.note-cell { max-width: none; white-space: normal; }
  td.editing-amount { text-align: left; }
  td.actions-cell { justify-content: flex-end; padding-top: 10px; }
  td.actions-cell::before { content: none; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .photo-chip { left: 12px; bottom: 12px; padding: 10px 14px; }
  .toast-stack { left: 18px; right: 18px; bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
