:root {
  --bg: #eef3f6;
  --surface: #ffffff;
  --text: #101820;
  --muted: #68747d;
  --line: #d9e2e7;
  --accent: #0f766e;
  --accent-2: #c2410c;
  --accent-3: #2563eb;
  --soft: #edf6f3;
  --danger: #b42318;
  --ok: #137333;
  --warning: #a16207;
  --shadow: 0 18px 46px rgba(16, 24, 32, .10);
  --shadow-soft: 0 8px 24px rgba(16, 24, 32, .07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #f8fbfc 0%, var(--bg) 38%, #e9f0f4 100%);
  color: var(--text);
}
button, input, select {
  font: inherit;
}
button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
button:hover {
  transform: translateY(-1px);
}
#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  background: #101820;
  color: #f6fbf8;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #10b981;
  color: #06271f;
  font-weight: 800;
  box-shadow: inset 0 -10px 18px rgba(6, 39, 31, .12);
}
.brand small, .sidebar-foot small { display: block; color: #aebbb5; }
.nav { display: grid; gap: 8px; }
.nav-item, .icon-text {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  background: transparent;
}
.nav-item { justify-content: flex-start; }
.nav-item.active, .nav-item:hover, .icon-text:hover {
  background: rgba(255,255,255,.10);
}
.sidebar svg, .topbar svg, .quick-entry svg, .toolbar svg, .upload-zone svg, .export-actions svg { width: 18px; height: 18px; }
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 6px;
}
.main {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 38px);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.eyebrow {
  color: var(--muted);
  margin: 0 0 4px;
  font-size: 13px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 36px; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 0; letter-spacing: 0; }
.view { display: none; }
.view.active { display: block; }
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 16px;
}
.quick-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}
.quick-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.quick-suggestions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-suggestions button {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: #eef4f7;
  color: #2e3a42;
  border: 1px solid #d8e4ea;
  font-weight: 700;
  font-size: 13px;
}
.quick-suggestions button:hover {
  background: #e2f3ee;
  border-color: #b8ded3;
}
.hero-status {
  border-radius: 8px;
  padding: 16px;
  background: #101820;
  color: #f7fbfa;
  display: grid;
  align-content: center;
  gap: 6px;
  box-shadow: var(--shadow);
}
.hero-status small { color: #b8c7c1; }
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, .16);
}
.primary {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.primary:hover {
  box-shadow: 0 12px 24px rgba(15, 118, 110, .20);
}
.ghost {
  color: var(--accent);
  background: transparent;
  font-weight: 700;
}
.danger {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--danger);
  font-weight: 700;
}
.square {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
.square:hover {
  border-color: #bdd4dd;
  box-shadow: var(--shadow-soft);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric, .panel, .upload-zone, .reconcile-actions, .lock-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}
.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.metric.featured {
  background: #0f766e;
  color: white;
  border-color: #0f766e;
}
.metric.featured span, .metric.featured small { color: #d7f3ec; }
.metric span, .muted, .tx-meta, .setting-row small { color: var(--muted); }
.metric span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.metric svg { width: 16px; height: 16px; }
.metric strong { font-size: 26px; }
.metric small { color: var(--muted); }
.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.insight-card {
  min-height: 86px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 6px;
}
.insight-card strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.insight-card svg { width: 17px; height: 17px; }
.insight-card small { color: var(--muted); line-height: 1.45; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 18px;
}
.dashboard-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, .75fr) minmax(320px, .9fr);
  align-items: start;
}
.panel { padding: 18px; }
.panel-head {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.bars { display: grid; gap: 12px; }
.bar-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  margin: 0 -8px;
  border-radius: 8px;
  cursor: pointer;
}
.bar-row:hover { background: #f2f7f9; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar-track { height: 10px; border-radius: 999px; background: #e8eee8; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent-2); border-radius: inherit; transition: width .28s ease; }
.chart-panel canvas {
  width: 100%;
  height: 260px;
  display: block;
}
.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  gap: 10px;
  margin-bottom: 14px;
}
.export-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.export-actions .icon-text {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
}
.transaction-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.summary-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  display: grid;
  gap: 3px;
}
.summary-pill span { color: var(--muted); font-size: 12px; }
.summary-pill strong { font-size: 16px; }
.list { display: grid; gap: 10px; }
.list.compact { gap: 8px; }
.tx-card {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tx-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  border-color: #c9d9e0;
}
.tx-main { min-width: 0; display: grid; gap: 4px; }
.tx-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-side { text-align: right; display: grid; gap: 4px; }
.tx-status, .badge {
  justify-self: end;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #edf2ef;
  color: #42524b;
}
.badge.ok { background: #e5f4eb; color: var(--ok); }
.tx-actions { display: flex; gap: 6px; }
.tx-actions .square { width: 38px; height: 38px; }
.upload-zone {
  padding: 34px 20px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.upload-zone input { display: none; }
.upload-zone.dragging {
  border-color: var(--accent);
  background: #eefaf6;
}
.reconcile-actions {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.diagnostic-card {
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #f0d6a8;
  background: #fff8eb;
  display: grid;
  gap: 10px;
}
.diagnostic-card small {
  color: #6f5b2d;
  line-height: 1.45;
}
.diagnostic-card pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: #2f2612;
  background: rgba(255, 255, 255, .64);
  border: 1px solid #f0d6a8;
  border-radius: 8px;
  padding: 10px;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .75fr);
  gap: 18px;
}
.settings-form { display: grid; gap: 12px; }
.setting-row {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(120deg, rgba(11, 18, 32, .92), rgba(15, 118, 110, .88)),
    url("./icon.svg");
  background-size: cover, 180px;
  background-position: center;
  backdrop-filter: blur(10px);
}
.lock-screen.hidden, .hidden { display: none !important; }
.lock-panel {
  width: min(920px, 100%);
  min-height: 430px;
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  background: rgba(255, 255, 255, .94);
  border-color: rgba(255, 255, 255, .48);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .32);
}
.lock-copy {
  min-height: 430px;
  padding: 34px;
  color: white;
  background:
    linear-gradient(150deg, rgba(11, 18, 32, .98), rgba(15, 118, 110, .86)),
    url("./icon.svg");
  background-size: cover, 220px;
  background-position: center, right 24px bottom 20px;
  display: grid;
  align-content: space-between;
  gap: 28px;
}
.lock-copy h2 {
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1;
  margin: 0 0 12px;
}
.lock-copy p {
  max-width: 440px;
  color: #d7eee9;
  line-height: 1.55;
}
.lock-brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.lock-brand span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #10b981;
  color: #06271f;
}
.lock-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.lock-preview article {
  min-height: 92px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .20);
  backdrop-filter: blur(8px);
  display: grid;
  align-content: end;
  gap: 6px;
}
.lock-preview small { color: #bfe4dc; }
.lock-preview strong { font-size: 26px; }
.lock-form {
  padding: 34px;
  display: grid;
  align-content: center;
  gap: 14px;
}
.lock-form #lockHint {
  color: var(--muted);
  line-height: 1.5;
}
.auth-box {
  display: grid;
  gap: 12px;
}
.auth-box + .auth-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 32, .56);
  backdrop-filter: blur(5px);
}
.modal-panel {
  width: min(620px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal-head, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head { margin-bottom: 16px; }
.modal-actions { margin-top: 18px; justify-content: flex-end; }
.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
}
.edit-grid label:first-child {
  grid-column: 1 / -1;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  background: #101820;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  transition: .2s ease;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed;
    z-index: 10;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    height: 64px;
    border-radius: 12px;
    padding: 8px;
    flex-direction: row;
    align-items: center;
    box-shadow: var(--shadow);
  }
  .brand, .sidebar-foot { display: none; }
  .nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .nav-item {
    min-height: 48px;
    justify-content: center;
    padding: 0;
  }
  .nav-item span { display: none; }
  .main { padding: 16px; }
  .topbar {
    margin-bottom: 16px;
    align-items: flex-start;
  }
  h1 { font-size: 28px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid, .settings-grid, .dashboard-hero, .dashboard-grid, .insight-strip { grid-template-columns: 1fr; }
  .toolbar {
    grid-template-columns: 1fr;
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 10px 0;
    background: var(--bg);
  }
  .export-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .export-actions .icon-text {
    justify-content: center;
  }
  .chart-panel canvas { height: 220px; }
  .lock-panel { grid-template-columns: 1fr; }
  .lock-copy { min-height: 280px; }
}

@media (max-width: 560px) {
  body { overflow-x: hidden; }
  .main { padding: 14px 12px; }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .topbar .icon-text span { display: none; }
  h1 { font-size: 26px; }
  .dashboard-hero { gap: 10px; }
  .quick-entry {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  .quick-row { grid-template-columns: 1fr; }
  .quick-row .primary { width: 100%; }
  .quick-suggestions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .quick-suggestions button { min-height: 40px; }
  .metrics { grid-template-columns: 1fr; }
  .metric {
    min-height: 96px;
    padding: 16px;
  }
  .metric strong { font-size: 24px; }
  .insight-card { min-height: 78px; }
  .panel { padding: 14px; }
  .chart-panel canvas { height: 190px; }
  .transaction-summary { grid-template-columns: 1fr; }
  .tx-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 14px;
  }
  .tx-desc { white-space: normal; }
  .tx-side { min-width: 94px; }
  .tx-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
  .tx-actions .square {
    width: 44px;
    height: 44px;
  }
  .edit-grid { grid-template-columns: 1fr; }
  .lock-screen { padding: 10px; }
  .lock-panel {
    min-height: auto;
    max-height: calc(100dvh - 20px);
    overflow: auto;
  }
  .lock-copy {
    min-height: 250px;
    padding: 22px;
  }
  .lock-form { padding: 22px; }
  .lock-copy h2 { font-size: 36px; }
  .lock-preview { grid-template-columns: 1fr; }
  input, select, .primary, .icon-text { min-height: 48px; }
  .modal { padding: 8px; }
  .modal-panel {
    max-height: calc(100dvh - 16px);
    padding: 14px;
  }
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
