:root {
  --violet: #1e1b4b;
  --violet-soft: #4b47a0;
  --violet-container: #e9e7f7;
  --bg: #f1f2f6;
  --text: #171533;
  --muted: #6b6e85;
  --green: #1b8a5a;
  --red: #c4362e;
  --border: #e3e4ec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.good { color: var(--green); }
.bad { color: var(--red); }
.neutral { color: var(--violet); }
.error { color: var(--red); font-size: 13px; }

/* ---------- sign-in ---------- */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: #fff; border-radius: 20px; padding: 32px 28px; text-align: center; max-width: 360px; width: 100%; border: 1px solid var(--border); }
.card h1 { margin: 8px 0 4px; font-size: 22px; }
.logo { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; background: var(--violet); color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center; }
.btn { border: 1px solid var(--border); background: #fff; border-radius: 14px; padding: 12px 18px; font-weight: 600; }
.btn.primary { background: var(--violet); color: #fff; border-color: var(--violet); width: 100%; margin-top: 12px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }

.side { width: 208px; flex-shrink: 0; background: var(--violet); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 6px 20px; font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand-logo { width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; background: #fff; color: var(--violet); display: flex; align-items: center; justify-content: center; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: rgba(255, 255, 255, 0.72); padding: 9px 10px; border-radius: 10px; text-align: left; font-size: 14px; }
.nav button:hover { background: rgba(255, 255, 255, 0.08); }
.nav button.on { background: rgba(255, 255, 255, 0.14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.side-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.16); font-size: 13px; }
.sync { display: flex; align-items: center; gap: 7px; color: rgba(255, 255, 255, 0.7); font-size: 12px; margin-bottom: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #5fd49a; flex-shrink: 0; }
.dot.stale { background: #f3d67a; }
.who { font-weight: 600; margin-bottom: 8px; word-break: break-word; }
.signout { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: rgba(255, 255, 255, 0.72); padding: 0; font-size: 13px; }
.signout svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.main { flex: 1; min-width: 0; padding: 22px 28px 48px; }
.page { max-width: 1100px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 600; }

.banner { background: var(--violet-container); color: var(--violet); border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }

/* ---------- overview ---------- */
.stats { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 600; line-height: 1.4; }
.stat-note { font-size: 12px; color: var(--muted); }
.stat.hero { color: #fff; border-color: transparent; }
.stat.hero .stat-label, .stat.hero .stat-note { color: rgba(255, 255, 255, 0.85); }
.stat.hero .stat-value { font-size: 28px; }
.stat.hero.good { background: var(--green); }
.stat.hero.bad { background: var(--red); }
.stat.hero.warn { background: #e0a100; color: #3d2f00; }
.stat.hero.warn .stat-label, .stat.hero.warn .stat-note { color: rgba(61, 47, 0, 0.8); }

.cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

h3.section { margin: 0 0 8px 2px; font-size: 12px; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; }
.panel h3.section { margin-left: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-head h3.section { margin-bottom: 0; }
.linkbtn { border: 0; background: transparent; color: var(--violet-soft); font-size: 13px; font-weight: 600; padding: 0; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.tile:hover { border-color: #cfcbef; }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tile-label { font-size: 10px; letter-spacing: 0.04em; color: var(--muted); text-align: right; }
.tile-name { margin-top: 12px; font-size: 13px; font-weight: 600; }
.tile-amount { font-size: 17px; font-weight: 600; }
.tile-extra { font-size: 11px; color: var(--muted); }
.badge { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--violet-container); color: var(--violet); font-weight: 700; font-size: 9px; display: inline-flex; align-items: center; justify-content: center; }
.badge.good { background: #e1f2e9; color: var(--green); font-size: 13px; }
.badge.bad { background: #fbe9e7; color: var(--red); font-size: 13px; }

.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-wrap svg { width: 104px; height: 104px; flex-shrink: 0; }
.legend { flex: 1; min-width: 0; font-size: 13px; }
.legend div { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.legend div:last-child { margin-bottom: 0; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; }

.mini { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.mini:last-child { border-bottom: 0; padding-bottom: 0; }
.mini-amt { font-weight: 600; white-space: nowrap; }

.pill { display: inline-block; background: var(--violet-container); color: var(--violet); border-radius: 20px; padding: 1px 8px; font-size: 11px; font-weight: 600; margin-left: 2px; }

/* ---------- accounts ---------- */
.listrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.listrow.static { cursor: default; }

/* ---------- transactions ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.page-head select, .filters input, .filters select { font: inherit; border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: 10px 12px; min-width: 0; }
.filters input[type="search"] { flex: 1 1 260px; }

.summary { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 4px 4px 10px; }
.row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 170px 120px; gap: 4px 14px; align-items: start; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.row.head { background: transparent; border: 0; padding: 0 14px; margin-bottom: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.r-date { font-size: 12px; color: var(--muted); padding-top: 2px; }
.r-acct { font-size: 13px; color: var(--muted); }
.r-amt { text-align: right; font-weight: 600; white-space: nowrap; }

/* ---------- insights ---------- */
.big { font-size: 28px; font-weight: 600; margin-bottom: 4px; }
.bar { margin: 12px 0; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 4px; }
.track { background: rgba(30, 27, 75, 0.1); border-radius: 6px; height: 10px; flex: 1; overflow: hidden; }
.fill { background: var(--violet); height: 100%; border-radius: 6px; }
.trend { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.trend-month { width: 78px; flex-shrink: 0; }
.trend-amount { width: 100px; flex-shrink: 0; text-align: right; }

/* ---------- narrower screens ---------- */
@media (max-width: 1000px) {
  .cols, .cols-even { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px 12px; }
  .brand { padding: 0; }
  .nav { order: 3; width: 100%; flex-direction: row; }
  .nav button { flex: 1; justify-content: center; padding: 9px 4px; font-size: 13px; }
  .nav svg { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
  .sync, .who { margin: 0; }
  .main { padding: 16px 14px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat.hero { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 18px; }
}

@media (max-width: 700px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amt" "date acct"; }
  .row.head { display: none; }
  .r-main { grid-area: main; }
  .r-amt { grid-area: amt; }
  .r-date { grid-area: date; }
  .r-acct { grid-area: acct; text-align: right; }
}
