/* =========================================================
   Design system
   ========================================================= */
:root {
  /* Surfaces */
  --bg:         #0a0b0f;
  --surface:    #12141b;
  --surface-2:  #1a1d26;
  --surface-3:  #232732;
  --border:     #262b37;
  --border-2:   #30364456;

  /* Text */
  --text:       #edf0f5;
  --text-dim:   #c2c8d3;
  --muted:      #7a8396;

  /* Brand */
  --accent:     #ff385c;           /* Airbnb coral */
  --accent-2:   #ff6a85;
  --accent-soft: rgba(255,56,92,.12);

  /* Semantic */
  --pos:        #2ecc71;
  --pos-soft:   rgba(46,204,113,.14);
  --neg:        #ff5c6c;
  --neg-soft:   rgba(255,92,108,.14);
  --warn:       #ffb74d;
  --warn-soft:  rgba(255,183,77,.14);
  --info:       #5aa7ff;
  --info-soft:  rgba(90,167,255,.14);
  --violet:     #a78bfa;
  --violet-soft: rgba(167,139,250,.14);

  /* Radii & shadow */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 6px 24px rgba(0,0,0,.25);

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* =========================================================
   Reset-ish
   ========================================================= */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 800px at 80% -10%, rgba(255,56,92,.08), transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: .02em; }
p  { margin: 0; }
em { font-style: normal; }

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

main { max-width: 1180px; margin: 28px auto 64px; padding: 0 24px; }

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  background: linear-gradient(to bottom, rgba(18,20,27,.85), rgba(18,20,27,.7));
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-size: 16px; box-shadow: 0 4px 14px rgba(255,56,92,.35);
}
.brand-mark.lg { width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub  { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  padding: 8px 14px; border-radius: 999px; color: var(--text-dim);
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tab.active {
  background: var(--accent-soft); color: var(--accent);
}
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; font-size: 15px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--accent); }

/* =========================================================
   Page head
   ========================================================= */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px;
  margin-bottom: 22px;
}
.eyebrow {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px;
}
.page-head p { max-width: 640px; margin-top: 8px; color: var(--muted); }
.month-nav { display: flex; gap: 8px; }

/* =========================================================
   Cards & sections
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}

/* Chart canvases: constrain height so they don't stretch to fill page */
.chart-wrap { position: relative; height: 280px; width: 100%; }
.chart-wrap.sm { height: 200px; }
.card > canvas { max-height: 280px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.two-col > .card { margin-bottom: 0; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* =========================================================
   KPI grid
   ========================================================= */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px;
}
.kpi-grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 920px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.kpi::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%);
}
.kpi-label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 10px;
}
.kpi-value {
  font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 8px;
  line-height: 1.1; font-variant-numeric: tabular-nums;
}
.kpi-foot { font-size: 12px; color: var(--text-dim); }
.kpi-foot .muted { color: var(--muted); }

.kpi-earned  { box-shadow: var(--shadow), inset 3px 0 0 var(--pos); }
.kpi-spent   { box-shadow: var(--shadow), inset 3px 0 0 var(--neg); }
.kpi-net     { box-shadow: var(--shadow), inset 3px 0 0 var(--info); }
.kpi-burn    { box-shadow: var(--shadow), inset 3px 0 0 var(--warn); }
.kpi-annual  { box-shadow: var(--shadow), inset 3px 0 0 var(--violet); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* =========================================================
   Progress bar
   ========================================================= */
.progress {
  height: 6px; background: var(--surface-2); border-radius: 999px; margin: 10px 0 6px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--info), var(--pos));
  border-radius: 999px; transition: width .35s ease;
}

/* =========================================================
   Forms
   ========================================================= */
.tx-form { display: flex; flex-direction: column; gap: 14px; }
.form-head { margin-bottom: 4px; }
.form-head h2 { display: block; margin-bottom: 4px; font-size: 16px; }

.field { display: block; }
.field > span {
  display: block; font-size: 12px; letter-spacing: .04em; color: var(--muted);
  margin-bottom: 6px; font-weight: 500;
}
.field em.muted { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 4px; }
.field input, .tx-form input, .login-card input {
  width: 100%; padding: 11px 13px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); font: inherit; transition: border-color .15s, background .15s;
}
.field input:focus, .tx-form input:focus, .login-card input:focus {
  outline: none; border-color: var(--accent); background: var(--surface-3);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

/* Kind picker */
.kind-picker {
  border: none; padding: 0; margin: 4px 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.pill {
  position: relative; cursor: pointer; user-select: none;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--r); padding: 12px 14px;
  transition: border-color .15s, background .15s, transform .15s;
  display: block;
}
.pill:hover { border-color: var(--border-2); transform: translateY(-1px); }
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill-title { display: block; font-weight: 600; font-size: 14px; }
.pill-sub   { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .02em; }

.pill-invest:has(input:checked)  { border-color: var(--violet); background: var(--violet-soft); }
.pill-invest:has(input:checked) .pill-title { color: var(--violet); }
.pill-cost:has(input:checked)    { border-color: var(--warn); background: var(--warn-soft); }
.pill-cost:has(input:checked) .pill-title   { color: var(--warn); }
.pill-income:has(input:checked)  { border-color: var(--pos); background: var(--pos-soft); }
.pill-income:has(input:checked) .pill-title { color: var(--pos); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: 500 14px/1 var(--font); cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: white;
  box-shadow: 0 4px 14px rgba(255,56,92,.28);
}
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-3); text-decoration: none; }
.btn.full { width: 100%; }

.link {
  background: none; border: none; color: var(--info); cursor: pointer;
  padding: 0; font: inherit; text-decoration: none;
}
.link:hover { text-decoration: underline; }
.link.danger { color: var(--neg); }
.link.small  { font-size: 12px; }

.inline { display: inline; }

/* =========================================================
   Tables & lists
   ========================================================= */
.ledger { width: 100%; border-collapse: collapse; }
.ledger th, .ledger td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 14px; text-align: left; vertical-align: top;
}
.ledger th {
  color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
.ledger tr:last-child td { border-bottom: none; }
.ledger tr:hover td { background: rgba(255,255,255,.015); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.muted { color: var(--muted); }

.line-list { list-style: none; padding: 0; margin: 0; }
.line-list li {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.line-list li:last-child { border-bottom: none; }
.line-main strong { display: block; font-weight: 600; }
.line-side { text-align: right; }
.line-side .num { font-weight: 600; font-size: 15px; }

/* Tags */
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.tag-income      { background: var(--pos-soft); color: var(--pos); }
.tag-running_cost, .tag-cost { background: var(--warn-soft); color: var(--warn); }
.tag-investment  { background: var(--violet-soft); color: var(--violet); }
.tag-fixed       { background: var(--warn-soft); color: var(--warn); }
.tag-muted       { background: var(--surface-3); color: var(--muted); }
.tag-splitwise   { background: rgba(31,177,124,.12); color: #1fb17c; border: 1px solid rgba(31,177,124,.3); }
.tag-splitwise:hover { filter: brightness(1.1); text-decoration: none; }

/* Inline kind reclassification dropdown */
.kind-form { margin: 0; }
.kind-select {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 22px 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8396' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: filter .12s, border-color .12s;
}
.kind-select:hover { filter: brightness(1.1); }
.kind-select-income       { background-color: var(--pos-soft);    color: var(--pos);    border-color: rgba(46,204,113,.3); }
.kind-select-running_cost { background-color: var(--warn-soft);   color: var(--warn);   border-color: rgba(255,183,77,.3); }
.kind-select-investment   { background-color: var(--violet-soft); color: var(--violet); border-color: rgba(167,139,250,.3); }

/* =========================================================
   Inventory
   ========================================================= */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.inv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .15s;
}
.inv-card:hover { border-color: var(--border-2); }
.inv-low {
  border-color: rgba(255,92,108,.4);
  background: linear-gradient(180deg, rgba(255,92,108,.04), var(--surface) 60%);
}
.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.inv-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.inv-badge {
  background: var(--neg-soft);
  color: var(--neg);
  border: 1px solid rgba(255,92,108,.3);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.inv-note {
  margin-top: -6px;
}

.inv-counts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 6px;
}
.inv-count {
  text-align: center;
  padding: 4px 2px;
}
.inv-count-num {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.inv-count-label {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.inv-count-avail   .inv-count-num { color: var(--pos); }
.inv-count-clean   .inv-count-num { color: var(--warn); }
.inv-count-retired .inv-count-num { color: var(--neg); }
.inv-count-total   .inv-count-num { color: var(--text-dim); }

.inv-move {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 6px;
}
.inv-count-input,
.inv-kind-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  -webkit-appearance: none;
  appearance: none;
}
.inv-kind-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8396' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}
.inv-count-input:focus,
.inv-kind-select:focus { outline: none; border-color: var(--accent); }
.inv-go {
  padding: 8px 14px;
  font-size: 13px;
}

.inv-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

@media (max-width: 480px) {
  .inv-grid { grid-template-columns: 1fr; }
  .inv-counts { grid-template-columns: repeat(2, 1fr); }
  .inv-move { grid-template-columns: 56px 1fr; }
  .inv-go { grid-column: 1 / -1; }
}

/* =========================================================
   Cohost holdings + method tags
   ========================================================= */
/* =========================================================
   Cohost holdings — collapsible cards with expanded settlement view
   ========================================================= */
.holdings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.holding-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--r);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.holding-card:hover:not([open]) { border-color: var(--border-2); }
.holding-card[open] {
  /* Expanded card spans the entire row — gives the form room to breathe */
  grid-column: 1 / -1;
  border-color: var(--accent);
  background: var(--surface);
  cursor: default;
  padding: 22px 24px;
}
.holding-card.holding-zero { opacity: 0.75; border-left-color: var(--muted); }

.holding-summary {
  list-style: none;
  cursor: pointer;
  display: block;
  position: relative;
  padding-right: 24px;
}
.holding-summary::-webkit-details-marker { display: none; }
.holding-summary::after {
  content: '▸';
  position: absolute;
  top: 0; right: 0;
  color: var(--muted);
  font-size: 14px;
  transition: transform .15s;
}
.holding-card[open] .holding-summary::after { transform: rotate(90deg); color: var(--accent); }

.holding-name {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.holding-total {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
  line-height: 1.1;
}
.holding-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.holding-breakdown { margin-top: 10px; font-size: 12px; }

/* ---- Expanded section: two-column layout (settlements | form) ---- */
.holding-expand {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 28px;
}
.holding-expand > .ledger-list,
.holding-expand > .empty { margin-bottom: 0; }

@media (max-width: 800px) {
  .holding-expand { grid-template-columns: 1fr; gap: 18px; }
}

/* ---- Settlement ledger list (left column) ---- */
.ledger-list {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}
.ledger-head {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}
.ledger-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ledger-row:last-child { border-bottom: none; padding-bottom: 2px; }
.ledger-kind { font-weight: 600; font-size: 13px; }
.ledger-side { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.ledger-side .num { font-size: 14px; font-weight: 600; }

/* ---- Settlement form (right column) ---- */
.settlement-form {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px 18px;
  margin: 0;
}
.settlement-title { font-size: 14px; font-weight: 600; margin: 0; }
.settlement-kinds {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.settlement-kinds .pill { padding: 10px 12px; min-height: 56px; display: flex; flex-direction: column; justify-content: center; }
.settlement-kinds .pill-title { font-size: 13px; font-weight: 600; white-space: nowrap; }
.settlement-kinds .pill-sub { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.3; }

/* Category field reveals only when "Expense paid" is selected.
   Implemented via :has() — supported in all modern browsers. */
.settlement-form .field-category {
  display: none;
}
.settlement-form:has(input[name="kind"][value="expense_paid"]:checked) .field-category {
  display: block;
}

@media (max-width: 560px) {
  .holding-card[open] { padding: 18px 16px; }
  .settlement-form { padding: 14px; }
  .settlement-kinds { grid-template-columns: 1fr; }
  .settlement-kinds .pill { min-height: 0; padding: 10px 14px; }
  .settlement-kinds .pill-sub { white-space: normal; }
}

.method-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-dim);
}
.method-cash         { background: rgba(46,204,113,.14); color: var(--pos); }
.method-upi          { background: rgba(90,167,255,.14); color: var(--info); }
.method-banktransfer { background: rgba(167,139,250,.14); color: var(--violet); }
.method-card         { background: rgba(255,183,77,.14); color: var(--warn); }
.method-other        { background: var(--surface-3); color: var(--muted); }

.payment-route {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.payment-route strong { color: var(--text-dim); font-weight: 600; }

/* Add-on services: commission pill + totals row */
.commission-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.commission-pill.pos { background: var(--pos-soft); color: var(--pos); }
.commission-pill.neg { background: var(--neg-soft); color: var(--neg); }

.addon-totals td {
  border-top: 1px solid var(--border) !important;
  background: var(--surface-2);
  font-weight: 600;
}

/* =========================================================
   Notes
   ========================================================= */
.section-head {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 8px 4px 12px;
}
.notes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: border-color .15s, background .15s;
}
.note-card:hover { border-color: var(--border-2); }
.note-pinned {
  background: linear-gradient(180deg, rgba(255,183,77,.06), var(--surface) 60%);
  border-color: rgba(255,183,77,.3);
}
.note-pinned::before {
  content: '📌';
  position: absolute;
  top: 12px; right: 12px;
  font-size: 14px;
  opacity: .8;
}
.note-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  padding-right: 28px; /* room for pin icon */
  color: var(--text);
}
.note-body {
  font-size: 14px;
  color: var(--text-dim);
  white-space: pre-wrap;       /* preserve user's line breaks */
  word-wrap: break-word;
  line-height: 1.55;
}
.note-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: auto; /* push to bottom in flex container */
}
.note-actions { display: flex; gap: 12px; }

/* Inputs added for notes form */
.tx-form textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  font: inherit;
  resize: vertical;
  min-height: 90px;
  transition: border-color .15s, background .15s;
}
.tx-form textarea:focus { outline: none; border-color: var(--accent); background: var(--surface-3); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.hint-list {
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 18px;
  margin: 8px 0 14px;
  line-height: 1.7;
}
.hint-list li { margin-bottom: 2px; }

@media (max-width: 560px) {
  .notes-list { grid-template-columns: 1fr; gap: 10px; }
  .note-card { padding: 14px 16px; }
  .note-title { font-size: 14px; }
  .note-body { font-size: 13px; }
}

/* Sync banner */
.sync-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  flex-wrap: wrap;
}
.sync-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sync-flash {
  font-size: 13px;
  font-weight: 600;
}
@media (max-width: 560px) {
  .sync-banner { gap: 10px; padding: 12px 14px; }
  .sync-info { font-size: 12px; }
}

/* Chips (filters) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); font-size: 13px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { text-decoration: none; color: var(--text); border-color: var(--border-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: white; }

/* Empty states */
.empty {
  text-align: center; padding: 32px 16px; color: var(--muted); font-size: 14px;
  background: var(--surface-2); border-radius: var(--r); border: 1px dashed var(--border);
}
.empty a { color: var(--accent); }

/* =========================================================
   Login
   ========================================================= */
.login-wrap { display: grid; place-items: center; min-height: 72vh; }
.login-card {
  width: 360px; max-width: 92vw; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.login-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.login-brand h1 { font-size: 22px; }
.login-brand p { font-size: 13px; }

.error {
  background: var(--neg-soft); color: var(--neg);
  border: 1px solid rgba(255,92,108,.35);
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px;
}

/* =========================================================
   KPI grid - 3-column variant for calendar stats
   ========================================================= */
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .kpi-grid-3 { grid-template-columns: 1fr; } }

/* =========================================================
   Calendar grid
   ========================================================= */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
}
.cal-head {
  text-align: center;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 0 6px;
  font-weight: 600;
}
.cal-cell {
  background: var(--surface);
  border-radius: 8px;
  min-height: 92px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  transition: background .12s;
}
.cal-cell.cal-out { background: transparent; opacity: .35; }
.cal-cell.cal-today { box-shadow: inset 0 0 0 2px var(--accent); }

.cal-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 6px;
  text-decoration: none;
  align-self: flex-start;
  transition: background .12s, color .12s;
}
.cal-num:hover { background: var(--surface-3); color: var(--accent); text-decoration: none; }
.cal-cell.cal-today .cal-num { background: var(--accent); color: white; }

.cal-bars { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-bar {
  display: block;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  transition: filter .12s;
}
.cal-bar:hover { filter: brightness(1.15); text-decoration: none; }
.cal-bar-paid       { background: var(--pos-soft); color: var(--pos); border-left: 3px solid var(--pos); }
.cal-bar-partial    { background: var(--warn-soft); color: var(--warn); border-left: 3px solid var(--warn); }
.cal-bar-past       { background: var(--surface-3); color: var(--muted); border-left: 3px solid var(--muted); }
.cal-bar-cancelled  { background: var(--surface-3); color: var(--muted); border-left: 3px solid var(--muted); text-decoration: line-through; }
.cal-bar-ota        { background: var(--info-soft); color: var(--info); border-left: 3px solid var(--info); cursor: default; }

.cal-overflow {
  font-size: 10px;
  color: var(--muted);
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: 4px;
  align-self: flex-start;
}

.cal-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cal-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.cal-swatch-paid       { background: var(--pos); }
.cal-swatch-partial    { background: var(--warn); }
.cal-swatch-past       { background: var(--muted); }
.cal-swatch-cancelled  { background: var(--surface-3); border: 1px solid var(--border); }
.cal-swatch-ota        { background: var(--info); }

/* =========================================================
   Calendar sync panel
   ========================================================= */
.sync-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 760px) { .sync-grid { grid-template-columns: 1fr; } }
.sync-col h3 { margin: 0 0 6px; font-size: 14px; }
.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.input.mono { font-family: var(--mono); font-size: 12px; }
.copy-row { display: flex; gap: 8px; margin: 8px 0; }
.copy-row .input { flex: 1; }
.mono { font-family: var(--mono); }
.xsmall { font-size: 11px; }
.right { text-align: right; }

.feed-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.feed-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.feed-table td { padding: 8px; border-bottom: 1px solid var(--border-2); vertical-align: top; }
.feed-add { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.feed-add .input[name="name"] { flex: 0 0 120px; }
.feed-add .input[name="url"] { flex: 1; min-width: 200px; }

/* Small status badge (distinct from the .pill radio cards in .kind-picker). */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-ok  { background: var(--pos-soft); color: var(--pos); }
.badge-bad { background: var(--neg-soft); color: var(--neg); }

/* =========================================================
   Booking-detail page bits
   ========================================================= */
.status-pill {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: .01em;
}
.status-paid       { background: var(--pos-soft); color: var(--pos); }
.status-partial    { background: var(--warn-soft); color: var(--warn); }
.status-past       { background: var(--surface-3); color: var(--muted); }
.status-cancelled  { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }

.form-divider {
  border-top: 1px dashed var(--border);
  margin-top: 8px;
  padding-top: 14px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.form-divider em { text-transform: none; letter-spacing: 0; font-weight: 400; }

.field select {
  width: 100%; padding: 11px 13px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); font: inherit; transition: border-color .15s, background .15s;
}
.field select:focus { outline: none; border-color: var(--accent); background: var(--surface-3); }

.details-toggle {
  cursor: pointer; user-select: none;
  font-weight: 600; font-size: 14px;
  color: var(--text-dim);
  padding: 4px 0;
}
.details-toggle:hover { color: var(--accent); }

.danger-zone { border: 1px solid rgba(255,92,108,.25); }
.danger-zone .card-head h2 { color: var(--neg); }
.danger-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.danger-row:last-child { border-bottom: none; }
.btn-danger {
  background: var(--neg); color: white;
}
.btn-danger:hover { filter: brightness(1.08); }

/* Calendar mobile tweaks */
@media (max-width: 720px) {
  .cal-cell { min-height: 70px; padding: 4px; }
  .cal-num { width: 20px; height: 20px; font-size: 11px; }
  .cal-bar { font-size: 10px; padding: 2px 5px; border-left-width: 2px; }
  .cal-head { font-size: 10px; padding: 6px 0 4px; }
}
@media (max-width: 480px) {
  .cal-grid { gap: 2px; padding: 2px; }
  .cal-cell { min-height: 56px; padding: 3px; }
  .cal-num { width: 18px; height: 18px; font-size: 10px; }
  /* Collapse bars to dots — guest name hidden, just show colored marker */
  .cal-bar {
    font-size: 0;
    padding: 0;
    height: 6px;
    border-left: none;
    border-radius: 999px;
  }
  .cal-bar-paid       { background: var(--pos); }
  .cal-bar-partial    { background: var(--warn); }
  .cal-bar-past       { background: var(--muted); }
  .cal-bar-cancelled  { background: var(--surface-3); }
  .cal-overflow { font-size: 9px; padding: 1px 4px; }
  .cal-legend { gap: 10px; font-size: 10px; }
}

/* =========================================================
   Tables that overflow horizontally — wrap in this div
   to get a clean horizontal-scroll experience on mobile.
   ========================================================= */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Bleed slightly into card padding so the scroll cue is visible */
  margin: 0 -6px;
  padding: 0 6px;
}
.table-scroll .ledger { min-width: 520px; }
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }

/* =========================================================
   MOBILE / TABLET BREAKPOINTS
   ========================================================= */

/* Tablet & below */
@media (max-width: 860px) {
  main { margin: 18px auto 48px; padding: 0 16px; }
  h1 { font-size: 22px; }
  .card { padding: 18px; margin-bottom: 16px; border-radius: 14px; }
  .card-head { margin-bottom: 12px; }
  .page-head { margin-bottom: 16px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 24px; }
  .kpi-label { margin-bottom: 8px; }

  /* Topbar: brand + scrollable tabs + logout fit on one row */
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
  .brand-name { font-size: 14px; }
  .brand-sub { display: none; }

  .tabs {
    margin-left: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: calc(100vw - 160px); /* leave room for brand + logout */
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; padding: 6px 12px; font-size: 13px; }

  .month-nav .btn { padding: 8px 12px; font-size: 13px; }
}

/* Phones */
@media (max-width: 560px) {
  main { padding: 0 12px; }
  h1 { font-size: 20px; }
  .eyebrow { font-size: 10px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }

  .card { padding: 16px; border-radius: 12px; }
  .card-head { flex-wrap: wrap; row-gap: 4px; }

  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-foot { font-size: 11px; }

  /* Forms become single-column */
  .row { grid-template-columns: 1fr; gap: 10px; }
  .kind-picker { grid-template-columns: 1fr; gap: 6px; }
  .pill { padding: 12px 14px; }
  .pill-title { font-size: 14px; }

  /* Form inputs slightly more padded for touch */
  .field input, .login-card input { padding: 12px 14px; font-size: 16px; /* prevents iOS zoom-on-focus */ }

  /* Filter chips wrap nicely */
  .chips { gap: 6px; }
  .chip { padding: 6px 12px; font-size: 12px; }

  /* Line list (income/fixed-cost rows) — keep amount on its own visual line if needed */
  .line-list li { gap: 8px; padding: 10px 0; }
  .line-side .num { font-size: 14px; }

  /* Login card: full width with a little breathing room */
  .login-card { width: 100%; padding: 24px; }
  .login-brand h1 { font-size: 20px; }

  /* Charts: shorter so they don't dominate small screens */
  .chart-wrap { height: 240px; }
  .chart-wrap.sm { height: 180px; }
}

/* Very narrow phones (<= 380px) */
@media (max-width: 380px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .tabs { max-width: calc(100vw - 130px); }
  .brand-name { font-size: 13px; }
  .icon-btn { width: 32px; height: 32px; }
  .kpi-value { font-size: 20px; }
  h1 { font-size: 18px; }
}

/* Multi-tenant: property switcher + topbar actions */
.prop-switch { margin-left: 14px; }
.prop-select {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--r-sm); padding: 6px 10px; font: inherit;
  max-width: 200px;
}
.prop-select:focus { outline: none; border-color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .icon-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* ----- Mobile topbar: brand + actions on top row, tabs scroll horizontally ----- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-sub { display: none; }
  .topbar-actions { margin-left: auto; }
  .prop-switch { margin-left: 8px; }
  .prop-select { max-width: 44vw; padding: 6px 8px; }
  .tabs {
    order: 5; width: 100%; margin-left: 0;
    overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 7px 12px; font-size: 13px; }
  /* Wide tables scroll instead of overflowing the card */
  .feed-table { display: block; overflow-x: auto; white-space: nowrap; }
  /* Settings sub-nav buttons wrap */
  .page-head .month-nav { flex-wrap: wrap; }
}

/* Per-person holdings: link to the full ledger from the card */
.holding-link { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--accent); }
.holding-link:hover { text-decoration: underline; }
