/* Ledger Emerald — shell + components. Mobile-first, iOS-PWA-aware. */

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

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  font-size: var(--fs-body);
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Fixed app shell: 100dvh is unreliable on iOS PWA cold start */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  overscroll-behavior-y: none;
}

header.topbar {
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 12px;
  display: flex; align-items: center; justify-content: space-between;
}
header.topbar h1 { font-size: var(--fs-h3); font-weight: 700; letter-spacing: -0.01em; }

main#view {
  flex: 1; overflow-y: auto;
  padding: 4px var(--gutter) 24px;
  -webkit-overflow-scrolling: touch;
}

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 12px;
}

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 14px 16px; }
.tile.wide { grid-column: 1 / -1; }
.tile .label {
  font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 6px;
}
.tile .value { font-size: var(--fs-hero); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.tile .sub { margin-top: 6px; font-size: var(--fs-sec); color: var(--text-2); }

.money { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum"; }

.delta { display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-sec); font-weight: 600; border-radius: 999px; padding: 2px 8px; }
.delta.up   { color: var(--danger);  background: color-mix(in srgb, var(--danger) 12%, transparent); }
.delta.down { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }

/* ---- chips ---- */
.chip { display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sec); font-weight: 600;
  padding: 4px 10px; border-radius: var(--r-chip); }
.chip.business { color: var(--business); background: var(--business-soft); }
.chip.personal { color: var(--personal); background: var(--personal-soft); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---- buttons + inputs ---- */
.btn {
  display: block; width: 100%; text-align: center;
  font: inherit; font-weight: 600;
  background: var(--primary); color: var(--on-primary);
  border: 0; border-radius: var(--r-input);
  padding: 14px; cursor: pointer;
}
.btn.secondary { background: var(--surface-2); color: var(--text-1); }
.btn:active { filter: brightness(0.93); }

input, select, textarea {
  font: inherit; color: var(--text-1);
  width: 100%; padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary); outline-offset: -1px;
}
label { display: block; font-size: var(--fs-sec); font-weight: 600;
  color: var(--text-2); margin: 14px 0 6px; }

/* segmented entity toggle */
.segment { display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--surface-2); border-radius: var(--r-input); padding: 4px; }
.segment button { font: inherit; font-weight: 600; border: 0; background: transparent;
  color: var(--text-2); padding: 10px; border-radius: 9px; cursor: pointer; }
.segment button.active.business { background: var(--business); color: var(--on-primary); }
.segment button.active.personal { background: var(--personal); color: #fff; }

/* ---- list rows ---- */
.row { display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .thumb { width: 44px; height: 44px; border-radius: 10px;
  background: var(--surface-2); object-fit: cover; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: var(--fs-sec); color: var(--text-3); }
.row .amt { font-weight: 700; }

/* ---- bottom tab bar ---- */
nav.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: end;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
}
nav.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--text-3);
  font-size: 10px; font-weight: 600; padding: 4px 0;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
nav.tabbar a.active { color: var(--primary); }
nav.tabbar a svg { width: 24px; height: 24px; }

/* raised center scan button */
nav.tabbar a.scan {
  transform: translateY(-14px);
}
nav.tabbar a.scan .disc {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 45%, transparent);
}
nav.tabbar a.scan .disc svg { width: 26px; height: 26px; }

/* ---- utility ---- */
.muted { color: var(--text-3); font-size: var(--fs-sec); }
.center { text-align: center; }
h2.section { font-size: var(--fs-sec); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3); margin: 20px 0 10px; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%,
    color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px; color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }
