/* ============================================================
   homeUI — halftone / technical-blueprint aesthetic
   ============================================================ */

:root {
  color-scheme: dark;

  /* surfaces */
  --page:        #1c1c1a;
  --page-deep:   #161614;
  --grid-line:   rgba(233, 229, 219, 0.035);

  --cream:       #e9e5db;
  --cream-deep:  #ded9cc;
  --orange:      #ef4e23;
  --orange-deep: #d8431b;
  --dark-card:   #26262230;

  /* ink */
  --ink:         #17170f;
  --ink-soft:    rgba(23, 23, 15, 0.70);
  --ink-faint:   rgba(23, 23, 15, 0.52);
  --ink-line:    rgba(23, 23, 15, 0.16);

  /* text on the dark page */
  --text:        #e9e5db;
  --text-dim:    #8b8b81;

  --critical:    #a32b16;

  /* texture */
  --dot:         rgba(23, 23, 15, 0.20);
  --dot-size:    4px;
  --tick:        rgba(23, 23, 15, 0.42);
  --wash:        rgba(23, 23, 15, 0.18);

  --radius:      5px;

  --font-display: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

[hidden] { display: none !important; }

/* ---- Background grid ---- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 132px 132px;
}

/* ---- Micro label (mono, uppercase, tracked out) ---- */
.section-label,
.card-num,
.chip,
.field-label,
.affix,
.bills-table thead th,
.meter-pct {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 400;
}

/* ---- Left rail ---- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 68px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
  padding: 1rem 0 1.1rem;
  background: var(--page-deep);
  border-right: 1px solid rgba(233, 229, 219, 0.08);
}

.side-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(233, 229, 219, 0.06);
}

.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--orange);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.side-link {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
}

.side-link:hover { color: var(--text); background: rgba(233, 229, 219, 0.07); }

.side-link.is-active {
  color: var(--orange);
  background: rgba(239, 78, 35, 0.13);
}

.side-link--foot { margin-top: auto; }

/* ---- App shell ---- */
.app { padding-left: 68px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 2rem;
  background: var(--page);
  border-bottom: 1px solid rgba(233, 229, 219, 0.08);
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.chip {
  color: var(--text-dim);
  border: 1px solid rgba(233, 229, 219, 0.14);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  white-space: nowrap;
}

.chip.is-stale { opacity: 0.6; }

main {
  position: relative;
  z-index: 1;
  padding: 0.25rem 2rem 4rem;
}

/* ---- Dashboard grid ---- */
.dash {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  column-gap: 1.5rem;
  align-items: start;
}

.dash-cell {
  min-width: 0;
  scroll-margin-top: 92px;
}

.dash-cell--bills { grid-column: 1 / -1; }

.dash-cell .section-head { margin: 1.3rem 0 0.7rem; }

.setup-wrap { max-width: 760px; }

/* ---- Section head:  ◇ LABEL ┈┈┈┈┈┈┈ ---- */
.section-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 2.4rem 0 0.85rem;
}

.diamond {
  color: var(--text-dim);
  font-size: 0.6rem;
  line-height: 1;
}

.section-label { color: var(--text-dim); }

.section-rule {
  flex: 1;
  height: 1px;
  background-image: repeating-linear-gradient(
    to right,
    var(--text-dim) 0 2px,
    transparent 2px 7px
  );
  opacity: 0.45;
}

/* ---- Card ---- */
.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
}

/* the halftone dot field */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--dot) 0.85px, transparent 0.9px);
  background-size: var(--dot-size) var(--dot-size);
}

.card > * { position: relative; z-index: 1; }

.card--cream { background: var(--cream); color: var(--ink); }

/* the accent card runs cream-on-orange: re-point the ink tokens and every
   rule inside it follows, rather than overriding each one */
.card--accent {
  background: var(--orange);
  --dot:       rgba(23, 23, 15, 0.20);
  --ink:       var(--cream);
  --ink-soft:  rgba(233, 229, 219, 0.82);
  --ink-faint: rgba(233, 229, 219, 0.58);
  --ink-line:  rgba(233, 229, 219, 0.26);
  --tick:      rgba(233, 229, 219, 0.58);
  --wash:      rgba(233, 229, 219, 0.26);
  color: var(--ink);
}

.card-body {
  position: relative;
  padding: 1.15rem 1.35rem 1.35rem;
}

/* corner ticks — 4 L-brackets, two from the body, two from .ticks */
.card-body::before,
.card-body::after,
.ticks::before,
.ticks::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  border-style: solid;
  border-color: var(--tick);
  pointer-events: none;
}

.card-body::before { top: 7px; left: 7px;     border-width: 1px 0 0 1px; }
.card-body::after  { bottom: 7px; right: 7px; border-width: 0 1px 1px 0; }

.ticks { position: absolute; inset: 0; pointer-events: none; }
.ticks::before { top: 7px; right: 7px;    border-width: 1px 1px 0 0; }
.ticks::after  { bottom: 7px; left: 7px;  border-width: 0 0 1px 1px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.card-num { color: var(--ink-faint); }

.card-sub {
  margin: 0.15rem 0 1.1rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.card-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.35rem 0.85rem;
  border-top: 1.5px solid var(--page);
}

.card-foot p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  max-width: 46ch;
}

.foot-dots {
  color: var(--ink-faint);
  line-height: 1;
  letter-spacing: 0.1em;
}

/* ---- Hero ---- */
.hero .card-body { padding-bottom: 1.15rem; }

.hero-figure {
  margin: 0.6rem 0 0;
  font-family: var(--font-display);
  font-size: 3.4rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.hero-figure.is-placeholder { color: var(--ink-faint); }

/* ---- Meter ---- */
.meter { margin-top: 1.35rem; }

.meter-track {
  height: 6px;
  border-radius: 999px;
  background: var(--wash);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--ink);
  transition: width 300ms cubic-bezier(0.23, 1, 0.32, 1);
}

.meter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.6rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
}

.status-icon { flex: none; }

.meter-pct { color: var(--ink-soft); }

/* ---- KPI row ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.stat .card-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-bottom: 1.15rem;
}

/* same treatment as .card-head h2, one step down in size */
.stat-label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  text-transform: none;
  color: var(--ink);
}

.stat-value {
  margin-top: 0.45rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.stat-foot {
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.stat-value.is-critical,
.stat-foot.is-critical { color: var(--critical); }

/* ---- Schedule ---- */
.month-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.9rem 0 1rem;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--ink-line);
  color: var(--ink-soft);
  width: 22px;
  height: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.nav-btn:hover { background: rgba(23, 23, 15, 0.07); color: var(--ink); }

.month-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  min-width: 13ch;
  text-align: center;
}

.month-summary {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sched-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.sched-row {
  display: grid;
  grid-template-columns: 22px 62px 1fr auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--ink-line);
}

.sched-row:last-child { border-bottom: none; }

.paid-toggle {
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink-faint);
  border-radius: 4px;
  background: transparent;
  color: var(--cream);
  font-size: 0.7rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.paid-toggle:hover { border-color: var(--ink); }

.is-paid .paid-toggle {
  background: var(--ink);
  border-color: var(--ink);
}

.sched-date {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.sched-name {
  font-size: 0.88rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sched-status {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--ink-line);
  color: var(--ink-soft);
  white-space: nowrap;
}

.is-overdue .sched-status {
  color: var(--critical);
  border-color: rgba(163, 43, 22, 0.4);
  background: rgba(163, 43, 22, 0.08);
}

.is-today .sched-status {
  color: var(--ink);
  border-color: var(--ink);
}

.is-paid .sched-status {
  color: var(--ink-faint);
  border-color: transparent;
}

.sched-amount {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* a paid row recedes — the eye should land on what's still owed */
.is-paid .sched-name,
.is-paid .sched-date,
.is-paid .sched-amount { color: var(--ink-faint); }

.is-paid .sched-name { text-decoration: line-through; }

.due-input {
  width: 62px;
  padding: 0.25rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: rgba(23, 23, 15, 0.05);
  color: var(--ink-soft);
}

.due-input:hover { border-color: var(--ink-line); }
.due-input:focus { color: var(--ink); }

.input-affix--day { flex: 0 0 118px; }

/* ---- Bar chart ---- */
.chart {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(70px, 130px) 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  cursor: default;
}

.bar-row:hover { background: rgba(23, 23, 15, 0.05); }

.bar-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  border-left: 1px solid var(--ink-faint);
  padding-left: 2px;
  min-height: 16px;
  display: flex;
  align-items: center;
}

.bar-fill {
  height: 16px;
  min-width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--orange);
  transition: width 300ms cubic-bezier(0.23, 1, 0.32, 1);
}

.bar-value {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-state {
  margin: 0;
  padding: 1.75rem 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* ---- Forms ---- */
form { display: flex; flex-direction: column; gap: 1.1rem; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field-label { color: var(--ink-soft); }

input, select {
  font-family: var(--font-display);
  font-size: 0.92rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--ink-line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
}

input::placeholder { color: var(--ink-faint); }

input:focus-visible,
select:focus-visible,
button:focus-visible,
.bar-row:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.input-affix {
  display: flex;
  align-items: center;
  border: 1px solid var(--ink-line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.input-affix .affix {
  padding: 0 0.35rem 0 0.7rem;
  color: var(--ink-faint);
}

.input-affix input {
  border: none;
  background: transparent;
  padding-left: 0.15rem;
}

.input-affix input:focus-visible { outline: none; }
.input-affix:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }

.form-actions { display: flex; gap: 0.6rem; }

button {
  font-family: var(--font-display);
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  border-radius: 5px;
}

.primary-btn {
  background: var(--ink);
  color: var(--cream);
  font-weight: 500;
  padding: 0.55rem 1.15rem;
}

.primary-btn:hover { background: #000; }

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(233, 229, 219, 0.18);
  color: var(--text);
  padding: 0.42rem 0.85rem;
}

.ghost-btn:hover { background: rgba(233, 229, 219, 0.07); }

.ghost-btn--ink {
  border-color: var(--ink-line);
  color: var(--ink-soft);
}

.ghost-btn--ink:hover { background: rgba(23, 23, 15, 0.06); }

/* ---- Bills form & table ---- */
.bill-form {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.3rem;
}

.bill-form > input[type="text"] { flex: 2 1 0; }
.bill-form > .input-affix { flex: 1 1 0; }
.bill-form > button { flex: none; }

.table-wrap { overflow-x: auto; }

.bills-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.bills-table th,
.bills-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--ink-line);
  white-space: nowrap;
}

.bills-table thead th {
  color: var(--ink-faint);
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 0.5rem;
}

.bills-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bills-table tbody tr:hover { background: rgba(23, 23, 15, 0.04); }

.bills-table tfoot th,
.bills-table tfoot td {
  border-bottom: none;
  border-top: 1px solid var(--ink-faint);
  font-weight: 600;
  padding-top: 0.7rem;
}

.bill-swatch {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--orange);
  margin-right: 0.55rem;
  vertical-align: 1px;
}

.remove-btn {
  background: transparent;
  color: var(--ink-soft);
  padding: 0.15rem 0.45rem;
  font-size: 0.85rem;
  line-height: 1;
}

.remove-btn:hover { color: var(--critical); background: rgba(23, 23, 15, 0.06); }

.table-empty {
  color: var(--ink-faint);
  text-align: center;
  padding: 1.5rem 0.5rem;
}

/* ---- Tooltip ---- */
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--page-deep);
  color: var(--text);
  border: 1px solid rgba(233, 229, 219, 0.16);
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  font-size: 0.78rem;
  min-width: 178px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.tooltip-title {
  font-weight: 600;
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  color: var(--text-dim);
}

.tooltip-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ---- Responsive ---- */
@media (max-width: 1150px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash-cell--bills { grid-column: 1; }
}

@media (max-width: 620px) {
  .sidebar { width: 54px; gap: 1.1rem; }
  .app { padding-left: 54px; }
  .side-link { width: 34px; height: 34px; }
  main { padding: 0.25rem 1rem 3rem; }
  .topbar { padding: 0.9rem 1rem; }
  .page-title { font-size: 1.2rem; }
  .kpi-row { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .bill-form { flex-wrap: wrap; }
  .bill-form > input[type="text"] { flex: 1 1 100%; }
  .hero-figure { font-size: 2.5rem; }
}
