/* Hub components.
   base.css is Lakeside Code's app.css, copied verbatim — it owns the tokens,
   the glass material and the chrome. This file adds only what the hub needs on
   top, and never redefines a token. */

/* ── Chrome ───────────────────────────────────────────────────────── */

.bar-nav { display: flex; gap: 4px; }
.bar-nav-item {
  padding: 7px 13px; border-radius: var(--r-pill);
  color: var(--text-secondary); font-size: 13px; font-weight: var(--fw-medium);
  letter-spacing: -.01em; transition: var(--t-control);
}
.bar-nav-item:hover { color: var(--text); background: var(--control); }
.bar-nav-item.selected { background: var(--inverted); color: var(--inverted-text); }

/* The phone bottom bar. Glass over the content that scrolls under it, resting
   on the home indicator. base.css owns the recipe; this opts in, exactly the
   way .app-bar does, and takes the chrome tint. */
.tab-bar {
  position: fixed; z-index: var(--z-bar); right: 0; bottom: 0; left: 0;
  display: none; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  border-top: 1px solid var(--glass-edge);
  --mat-tint: var(--glass-tint-chrome);
  --mat-solid: var(--glass-solid-chrome);
  background-color: var(--mat-solid);
  background-image: var(--glass-sheen);
  box-shadow: var(--glass-spec);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tab-bar {
    background-color: var(--mat-tint);
    -webkit-backdrop-filter: blur(var(--glass-blur-regular)) saturate(var(--glass-sat)) brightness(var(--glass-lift));
    backdrop-filter: blur(var(--glass-blur-regular)) saturate(var(--glass-sat)) brightness(var(--glass-lift));
    transform: translateZ(0);
    will-change: backdrop-filter;
  }
}
.tab {
  display: flex; min-height: var(--tap-min); flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  border-radius: var(--r-md); color: var(--text-tertiary);
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: .02em;
  transition: color var(--dur-2) var(--ease-standard);
}
.tab svg { width: 22px; height: 22px; }
.tab.selected { color: var(--accent); }

@media (max-width: 720px) {
  .tab-bar { display: grid; }
  .bar-nav { display: none; }
  /* Content must clear the bar, or the last row is unreachable. */
  .hub-page { padding-bottom: calc(96px + var(--safe-bottom)); }
}

.hub-page { width: min(var(--shell-w), calc(100% - 40px)); margin: 28px auto 120px; }
body.bare .hub-page { margin-top: 0; }

/* ── Page furniture ───────────────────────────────────────────────── */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-6); margin-bottom: var(--sp-8); }
.page-head h1 { margin: 0; font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: var(--tr-display); line-height: var(--lh-tight); }
.page-head p { margin: var(--sp-3) 0 0; color: var(--text-secondary); font-size: var(--fs-base); }

.month-nav { display: flex; align-items: center; gap: var(--sp-4); margin-top: var(--sp-4); }
.month-label { color: var(--text-secondary); font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
/* The forward arrow is a link, and a link cannot be :disabled — so the future
   month is made inert rather than hidden, which would move the controls. */
.circle-button.is-disabled { pointer-events: none; opacity: .35; }

/* The month label is a jump menu dressed as text. */
.month-select {
  padding: 4px 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-secondary);
  font-size: var(--fs-base); font-family: var(--font); font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.month-select:hover { background: var(--control); color: var(--text); }
.month-select:focus { outline: 0; background: var(--control); }

.search-row { display: flex; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.search-row input {
  min-width: 0; flex: 1; min-height: var(--tap-min); padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--control); color: var(--text); font-size: 16px;
}
.search-row input:focus { border-color: var(--focus); outline: 0; }

.card {
  padding: var(--sp-7); border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--elev-1);
}
.sub-heading { margin: 0 0 var(--sp-5); font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.summary-heading {
  font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: var(--tr-normal); cursor: pointer;
}
.summary-heading::marker { color: var(--text-tertiary); }

/* An entry row that opens into its own edit form. No modal, no second page,
   and the row keeps its place in the list while you edit it. */
.row-edit > summary { cursor: pointer; list-style: none; }
.row-edit > summary::-webkit-details-marker { display: none; }
.row-edit > summary:hover { background: color-mix(in srgb, var(--control) 40%, transparent); }
.row-edit[open] > summary { border-bottom: 0; }
.row-edit[open] { border-bottom: 1px solid var(--line); }
.row-edit > form { padding: 0 var(--sp-2) var(--sp-7); }
.card + .card { margin-top: var(--sp-6); }
.card > h2 {
  margin: 0 0 var(--sp-6); font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: var(--tr-normal);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); margin-bottom: var(--sp-6); }
.card-head h2 { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: var(--tr-normal); }

.grid-2 { display: grid; gap: var(--sp-6); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* KPI row. .metric comes from base.css; this only lays them out and gives the
   numbers a money treatment. */
.kpis { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: var(--sp-8); }
.kpi {
  padding: var(--sp-6); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.kpi span { display: block; color: var(--text-tertiary); font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: var(--tr-caps); text-transform: uppercase; }
.kpi strong {
  display: block; margin-top: var(--sp-3);
  font-size: var(--fs-xl); font-weight: var(--fw-medium); letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.kpi small { display: block; margin-top: var(--sp-2); color: var(--text-tertiary); font-size: var(--fs-sm); }

/* Money only. Nothing else on the page earns a colour. */
.pos { color: var(--success); }
.neg { color: var(--danger); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* ── Forms ────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: var(--sp-3); }
.field > label { color: var(--text-secondary); font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: var(--tr-caps); text-transform: uppercase; }
.field input, .field select, .field textarea {
  min-height: var(--tap-min); padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--control); color: var(--text);
  /* 16px, not the 15px body size: below 16px iOS zooms the page on focus and
     never zooms back out. */
  font-size: 16px; transition: var(--t-control);
}
.field textarea { min-height: 96px; padding-top: 11px; resize: vertical; line-height: var(--lh-snug); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--focus); background: var(--control-hover); }
.field-row { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.form-actions { display: flex; align-items: center; gap: var(--sp-5); margin-top: var(--sp-6); }

.button {
  display: inline-flex; min-height: var(--tap-min); align-items: center; justify-content: center; gap: var(--sp-4);
  padding: 0 var(--sp-7); border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--control); color: var(--text);
  font-size: var(--fs-base); font-weight: var(--fw-semibold); letter-spacing: var(--tr-normal);
  transition: var(--t-control), transform var(--dur-2) var(--ease-standard);
}
.button:hover { background: var(--control-hover); }
.button:active { transform: scale(.97); }
.button.primary { border-color: transparent; background: var(--inverted); color: var(--inverted-text); }
.button.accent { border-color: transparent; background: var(--accent); color: #000; }
.button.quiet { border-color: transparent; background: transparent; color: var(--text-secondary); }
.button:disabled { cursor: wait; opacity: .5; }

/* ── Lists ────────────────────────────────────────────────────────── */

.row-list { display: flex; flex-direction: column; }
.row {
  display: grid; gap: var(--sp-5); align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 60px; padding: var(--sp-5) var(--sp-2);
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
/* Rows that carry a trailing action button get a third column for it. */
.row:has(> .button) { grid-template-columns: minmax(0, 1fr) auto auto; }
.row-main { min-width: 0; }
.row-title { overflow: hidden; font-size: var(--fs-md); font-weight: var(--fw-medium); letter-spacing: var(--tr-normal); text-overflow: ellipsis; white-space: nowrap; }
.row-meta { margin-top: 2px; color: var(--text-tertiary); font-size: var(--fs-sm); }
.row-amount { font-size: var(--fs-md); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--control); color: var(--text-secondary);
  font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--tr-caps); text-transform: uppercase;
}
.overdue-tag { background: var(--danger-soft); color: var(--danger); }
/* Tag chips that filter, so they need a tap target and an on state. */
.tag.chip { padding: 6px 12px; font-size: var(--fs-xs); transition: var(--t-control); }
.tag.chip:hover { background: var(--control-hover); color: var(--text); }
.tag.chip.on { background: var(--inverted); color: var(--inverted-text); }

/* Every list's empty state, one voice. */
.empty-list {
  margin: var(--sp-5) 0; padding: var(--sp-7);
  border: 1px dashed var(--line); border-radius: var(--r-md);
  color: var(--text-tertiary); font-size: var(--fs-base); text-align: center;
}
.empty-list a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }

/* ── Charts ───────────────────────────────────────────────────────── */

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
.chart .line {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
  /* The card is wider than the 720-unit viewBox on a desktop, so without this
     the line thickens as the window grows. */
  vector-effect: non-scaling-stroke;
}
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .bar { fill: var(--control-hover); }
.chart .dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.chart text { fill: var(--text-tertiary); font-size: 10px; font-family: var(--font); }

/* Ranked bars. HTML rather than SVG: the label column then wraps and truncates
   like any other text, which SVG will not do. */
.bars { display: flex; flex-direction: column; gap: var(--sp-4); }
.bar-row { display: grid; gap: var(--sp-5); align-items: center; grid-template-columns: minmax(84px, 132px) minmax(0, 1fr) auto; }
.bar-label { overflow: hidden; color: var(--text-secondary); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: var(--r-pill); background: var(--control); }
.bar-fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--accent); opacity: .8; }
.bar-value { color: var(--text-secondary); font-size: var(--fs-sm); }

/* ── Today ────────────────────────────────────────────────────────── */

.today-habits { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.today-habit {
  display: flex; min-height: var(--tap-min); align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--control); color: var(--text-secondary);
  font-size: var(--fs-base); font-weight: var(--fw-medium); text-align: left;
  transition: var(--t-control), transform var(--dur-1) var(--ease-standard);
}
.today-habit:active { transform: scale(.97); }
.today-habit.on { border-color: transparent; background: var(--accent); color: #000; }
.today-habit-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-habit-streak { flex: 0 0 auto; font-variant-numeric: tabular-nums; opacity: .6; }
.kpi small a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }

/* ── Habits ───────────────────────────────────────────────────────── */

.habit-row + .habit-row { margin-top: var(--sp-7); padding-top: var(--sp-7); border-top: 1px solid var(--line); }
.habit-head { display: flex; align-items: baseline; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.habit-head .row-meta { margin-left: auto; }
.habit-menu > summary {
  display: inline-flex; min-width: 32px; min-height: 28px; align-items: center; justify-content: center;
  border-radius: var(--r-sm); color: var(--text-tertiary); cursor: pointer; list-style: none;
  font-size: var(--fs-md); letter-spacing: .1em;
}
.habit-menu > summary::-webkit-details-marker { display: none; }
.habit-menu > summary:hover { background: var(--control); color: var(--text); }
.habit-menu[open] > form { margin-top: var(--sp-5); }
.habit-name {
  padding: 0; border: 0; background: transparent; color: var(--text);
  font-size: var(--fs-md); font-weight: var(--fw-medium); letter-spacing: var(--tr-normal);
}
.habit-name:hover { color: var(--accent); }
/* auto-fill, not a fixed count: the grid then keeps square cells at any width
   and simply wraps to more rows on a phone. */
.habit-grid { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(18px, 1fr)); }
.habit-grid .cell {
  aspect-ratio: 1; padding: 0; border: 1px solid var(--line);
  border-radius: var(--r-xs); background: var(--control);
  transition: background var(--dur-1) var(--ease-standard), transform var(--dur-1) var(--ease-standard);
}
.habit-grid .cell:hover { border-color: var(--line-strong); }
.habit-grid .cell:active { transform: scale(.9); }
/* --habit-c is set per row when the habit has its own colour. */
.habit-grid .cell.on { border-color: transparent; background: var(--habit-c, var(--accent)); }
.habit-name:hover { color: var(--habit-c, var(--accent)); }

/* ── Fitness ──────────────────────────────────────────────────────── */

.set-list { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); }
.set-pill {
  padding: 3px 9px; border-radius: var(--r-pill); background: var(--control);
  color: var(--text-secondary); font-size: var(--fs-xs); font-variant-numeric: tabular-nums;
}
a.set-pill { transition: var(--t-control); }
a.set-pill:hover { background: var(--control-hover); color: var(--text); }

/* ── Notes ────────────────────────────────────────────────────────── */

.note { padding: var(--sp-6) var(--sp-2); border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-5); }
.note-title { font-size: var(--fs-md); font-weight: var(--fw-medium); letter-spacing: var(--tr-normal); }
.note-body { margin: var(--sp-4) 0 0; color: var(--text-secondary); font-size: var(--fs-base); line-height: var(--lh-prose); white-space: pre-wrap; }
.todo { display: grid; gap: var(--sp-5); align-items: center; grid-template-columns: auto minmax(0, 1fr) auto; min-height: var(--tap-min); padding: var(--sp-3) var(--sp-2); border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: 0; }
.todo-check {
  width: 22px; height: 22px; padding: 0; border: 1.5px solid var(--line-strong);
  border-radius: var(--r-circle); background: transparent; color: transparent;
  font-size: 12px; line-height: 1;
}
.todo-check.on { border-color: transparent; background: var(--accent); color: #000; }
.todo.done .todo-text { color: var(--text-tertiary); text-decoration: line-through; }

/* Journal entries reuse the details/summary edit pattern from money rows. */
.row-edit > summary.note { cursor: pointer; list-style: none; }
.row-edit > summary.note::-webkit-details-marker { display: none; }
.note.pinned .note-title { color: var(--accent); }
.pinned-note .note-body { margin-top: 0; }

/* ── Categories ───────────────────────────────────────────────────── */

.category-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.category-row {
  display: grid; gap: var(--sp-4); align-items: center;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  padding: var(--sp-2) 0;
}
.category-row input[type="color"] {
  width: 34px; height: 34px; padding: 2px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--control); cursor: pointer;
}
.category-row input[type="text"] {
  min-height: 38px; padding: 6px 11px; border: 1px solid transparent;
  border-radius: var(--r-md); background: transparent; color: var(--text); font-size: var(--fs-base);
}
.category-row input[type="text"]:hover { border-color: var(--line); }
.category-row input[type="text"]:focus { border-color: var(--focus); outline: 0; background: var(--control); }

/* ── Import mapping ───────────────────────────────────────────────── */

.map-row { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.map-field {
  display: flex; flex-direction: column; gap: var(--sp-2);
  color: var(--text-tertiary); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  letter-spacing: var(--tr-caps); text-transform: uppercase;
}
.map-field select {
  min-height: 38px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--control); color: var(--text); font-size: var(--fs-sm);
}

/* ── Today sparkline ──────────────────────────────────────────────── */

.spark {
  display: flex; height: 26px; align-items: flex-end; gap: 3px; margin-top: var(--sp-3);
}
.spark i {
  flex: 1; min-height: 2px; border-radius: 2px 2px 0 0;
  background: var(--accent); opacity: .55;
}
.spark i:last-child { opacity: 1; }

/* ── Login ────────────────────────────────────────────────────────── */

.login-shell {
  display: flex; min-height: 100vh; flex-direction: column;
  align-items: center; justify-content: center; padding: var(--sp-8);
}
.login-card { width: min(380px, 100%); padding: var(--sp-9) var(--sp-8); }
.login-card h1 { margin: 0 0 var(--sp-3); font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: var(--tr-tight); }
.login-card p.sub { margin: 0 0 var(--sp-8); color: var(--text-tertiary); font-size: var(--fs-base); }
.login-card .field + .field { margin-top: var(--sp-6); }
.login-card .button { width: 100%; margin-top: var(--sp-7); }
.form-error {
  margin-top: var(--sp-6); padding: var(--sp-5); border: 1px solid var(--danger-edge); border-radius: var(--r-md);
  background: var(--danger-soft); color: var(--danger); font-size: var(--fs-base);
}

/* ── Reduced transparency / motion ────────────────────────────────── */

@media (prefers-reduced-transparency: reduce) {
  .tab-bar, .app-bar {
    -webkit-backdrop-filter: none; backdrop-filter: none;
    background-color: var(--glass-solid-chrome);
  }
  .card, .kpi { background: var(--surface-solid); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
