/* ─── BetaData Shared Foundation ────────────────────────────────────────────
   Tokens, reset, base, nav, and theme toggle.
   FOUC prevention script belongs inline in each template's <head> — not here.
   Page-specific component styles stay in each template's own <style> block.
──────────────────────────────────────────────────────────────────────────── */

/* ── TOKENS — dark default ── */
:root {
  --bg:       #0c0c0b;
  --surface:  #141413;
  --surface2: #1c1c1a;
  --surface3: #242422;
  --border:   #2e2e2c;
  --border2:  #3e3e3c;
  --text:     #eae9e6;
  --muted:    #8a8881;
  --dim:      #56554f;
  --accent:   #eae9e6;
  --green:    #22c55e;
  --violet:   #818cf8;
  --orange:   #f97316;
  --red:      #ef4444;
  --blue:     #3b82f6;
  --purple:   #8b5cf6;
  --teal:     #2dd4bf;
  --amber:    #fbbf24;
  --nav-h:    52px;
  --radius:   8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow:    none;
  --shadow-md: none;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

/* ── Light theme ── */
:root[data-theme="light"] {
  --bg:       #f7f6f3;
  --surface:  #ffffff;
  --surface2: #f0efe9;
  --surface3: #e8e7e0;
  --border:   #d9d8d1;
  --border2:  #cac9c2;
  --text:     #1a1917;
  --muted:    #6b6863;
  --dim:      #a09e98;
  --accent:   #1a1917;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
}

/* ── Auto: follow system preference ── */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg:       #f7f6f3;
    --surface:  #ffffff;
    --surface2: #f0efe9;
    --surface3: #e8e7e0;
    --border:   #d9d8d1;
    --border2:  #cac9c2;
    --text:     #1a1917;
    --muted:    #6b6863;
    --dim:      #a09e98;
    --accent:   #1a1917;
    --shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  }
}

/* ── Entity & property tag colors — state entities OH/TX/VA/MI ─────────
   Entity tag (.ent-{state}) = filled "anchor" chip.
   Property tag (.prop-pill.e-{state}, .prop-tag.e-{state}) = same hue,
   transparent fill, faint border — tinted sibling of the entity tag.
   Hue families: OH=teal 189°, TX=rose 340°, VA=indigo 225°, MI=slate 215°.
   Light/auto themes override the tokens below; rule bodies are written
   once and consume the tokens.
   ──────────────────────────────────────────────────────────────────── */
:root {
  --ent-oh-fg:  hsl(189 70% 80%); --ent-oh-bg:  hsl(189 55% 22%); --ent-oh-bd:  hsl(189 55% 32%);
  --prop-oh-fg: hsl(189 30% 62%); --prop-oh-bd: hsl(189 25% 28%);
  --ent-tx-fg:  hsl(340 70% 86%); --ent-tx-bg:  hsl(340 45% 26%); --ent-tx-bd:  hsl(340 45% 36%);
  --prop-tx-fg: hsl(340 32% 70%); --prop-tx-bd: hsl(340 25% 30%);
  --ent-va-fg:  hsl(225 70% 82%); --ent-va-bg:  hsl(225 50% 28%); --ent-va-bd:  hsl(225 50% 38%);
  --prop-va-fg: hsl(225 32% 68%); --prop-va-bd: hsl(225 25% 30%);
  --ent-mi-fg:  hsl(215 22% 80%); --ent-mi-bg:  hsl(215 14% 26%); --ent-mi-bd:  hsl(215 14% 36%);
  --prop-mi-fg: hsl(215 10% 64%); --prop-mi-bd: hsl(215 8% 30%);
}
:root[data-theme="light"] {
  --ent-oh-fg:  hsl(189 60% 28%); --ent-oh-bg:  hsl(189 55% 90%); --ent-oh-bd:  hsl(189 45% 78%);
  --prop-oh-fg: hsl(189 35% 38%); --prop-oh-bd: hsl(189 30% 80%);
  --ent-tx-fg:  hsl(340 55% 38%); --ent-tx-bg:  hsl(340 60% 94%); --ent-tx-bd:  hsl(340 50% 84%);
  --prop-tx-fg: hsl(340 38% 50%); --prop-tx-bd: hsl(340 35% 84%);
  --ent-va-fg:  hsl(225 55% 40%); --ent-va-bg:  hsl(225 70% 94%); --ent-va-bd:  hsl(225 55% 84%);
  --prop-va-fg: hsl(225 40% 52%); --prop-va-bd: hsl(225 40% 84%);
  --ent-mi-fg:  hsl(215 22% 32%); --ent-mi-bg:  hsl(215 18% 90%); --ent-mi-bd:  hsl(215 14% 78%);
  --prop-mi-fg: hsl(215 14% 46%); --prop-mi-bd: hsl(215 12% 82%);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --ent-oh-fg:  hsl(189 60% 28%); --ent-oh-bg:  hsl(189 55% 90%); --ent-oh-bd:  hsl(189 45% 78%);
    --prop-oh-fg: hsl(189 35% 38%); --prop-oh-bd: hsl(189 30% 80%);
    --ent-tx-fg:  hsl(340 55% 38%); --ent-tx-bg:  hsl(340 60% 94%); --ent-tx-bd:  hsl(340 50% 84%);
    --prop-tx-fg: hsl(340 38% 50%); --prop-tx-bd: hsl(340 35% 84%);
    --ent-va-fg:  hsl(225 55% 40%); --ent-va-bg:  hsl(225 70% 94%); --ent-va-bd:  hsl(225 55% 84%);
    --prop-va-fg: hsl(225 40% 52%); --prop-va-bd: hsl(225 40% 84%);
    --ent-mi-fg:  hsl(215 22% 32%); --ent-mi-bg:  hsl(215 18% 90%); --ent-mi-bd:  hsl(215 14% 78%);
    --prop-mi-fg: hsl(215 14% 46%); --prop-mi-bd: hsl(215 12% 82%);
  }
}
/* Entity-tag rule bodies (sizing/padding stays with each template's
   .ent-* base — these rules only set color/bg/border). */
.ent-oh { color: var(--ent-oh-fg); background: var(--ent-oh-bg); border: 1px solid var(--ent-oh-bd); }
.ent-tx { color: var(--ent-tx-fg); background: var(--ent-tx-bg); border: 1px solid var(--ent-tx-bd); }
.ent-va { color: var(--ent-va-fg); background: var(--ent-va-bg); border: 1px solid var(--ent-va-bd); }
.ent-mi { color: var(--ent-mi-fg); background: var(--ent-mi-bg); border: 1px solid var(--ent-mi-bd); }
/* Property-pill / property-tag rule bodies. Override only color/bg/border
   — the base .prop-pill / .prop-tag class supplies size, padding, radius. */
.prop-pill.e-oh, .prop-tag.e-oh { color: var(--prop-oh-fg); background: transparent; border-color: var(--prop-oh-bd); }
.prop-pill.e-tx, .prop-tag.e-tx { color: var(--prop-tx-fg); background: transparent; border-color: var(--prop-tx-bd); }
.prop-pill.e-va, .prop-tag.e-va { color: var(--prop-va-fg); background: transparent; border-color: var(--prop-va-bd); }
.prop-pill.e-mi, .prop-tag.e-mi { color: var(--prop-mi-fg); background: transparent; border-color: var(--prop-mi-bd); }
/* Property-tag hover (contacts page) lifts toward entity anchor color. */
.prop-tag.e-oh:hover { color: var(--ent-oh-fg); border-color: var(--ent-oh-bd); }
.prop-tag.e-tx:hover { color: var(--ent-tx-fg); border-color: var(--ent-tx-bd); }
.prop-tag.e-va:hover { color: var(--ent-va-fg); border-color: var(--ent-va-bd); }
.prop-tag.e-mi:hover { color: var(--ent-mi-fg); border-color: var(--ent-mi-bd); }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

/* iOS Safari auto-zooms on input focus when font-size < 16px.
   Bump form controls on small screens; desktop sizing untouched.
   Pinch-zoom on images still works. !important is needed because
   several templates set inline font-size on inputs. */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ─── NAV ───────────────────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding-left: 0; padding-right: 0; z-index: 200;
}
.nav-inner {
  max-width: 1500px; margin: 0 auto; width: 100%;
  display: flex; align-items: center; padding: 0 20px; height: 100%;
}
.nav-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: var(--text);
  text-decoration: none; margin-right: 16px; flex-shrink: 0;
}
.nav-brand:hover { color: var(--text); }
.nav-brand-dot {
  width: 20px; height: 20px; background: var(--blue); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.nav-links {
  display: flex; align-items: center; gap: 2px; flex: 1;
}
.nav-link {
  padding: 6px 10px; border-radius: var(--radius-xs);
  color: var(--muted); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: color .12s, background .12s;
  white-space: nowrap; position: relative;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--text); }
.nav-link.active::after {
  content: ''; position: absolute;
  bottom: -1px; left: 10px; right: 10px;
  height: 2px; background: var(--blue); border-radius: 1px;
}
.nav-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; flex-shrink: 0;
}

/* ── Account dropdown ── */
.acct-wrap { position: relative; }
.nav-acct-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); color: #fff; border: none; cursor: pointer;
  font-size: 12px; font-weight: 700; line-height: 1;
  transition: opacity .15s; font-family: var(--font);
}
.nav-acct-btn:hover { opacity: .85; }
.acct-drop {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.28);
  z-index: 300; overflow: hidden;
  opacity: 0; transform: translateY(-6px) scale(.98);
  pointer-events: none; transition: opacity .15s, transform .15s;
}
.acct-drop.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.acct-name-row { padding: 12px 14px 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.acct-div { height: 1px; background: var(--border); }
.acct-theme-row { padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acct-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.theme-btns { display: flex; gap: 3px; }
.theme-btn {
  background: none; border: 1px solid var(--border); cursor: pointer;
  padding: 4px 8px; border-radius: 4px;
  color: var(--muted); font-size: 12px;
  transition: all .12s; line-height: 1; font-family: var(--font);
}
.theme-btn:hover { color: var(--text); }
.theme-btn.active { background: var(--surface2); color: var(--text); border-color: var(--border2); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.acct-item {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; font-size: 13px; color: var(--muted);
  background: none; border: none; cursor: pointer;
  text-decoration: none; transition: color .12s, background .12s;
  font-family: var(--font);
}
.acct-item:hover { color: var(--text); background: var(--surface2); }

/* ── Hamburger (mobile only) ── */
.nav-hamburger {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px; color: var(--text); margin-left: auto; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Mobile dropdown menu ── */
.nav-mobile-menu {
  display: none; position: fixed;
  top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  left: 0; right: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 16px max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 199; flex-direction: column; gap: 2px;
}
.nav-mobile-menu.open { display: flex; }
.nav-mobile-link {
  font-size: 15px; color: var(--muted); padding: 11px 12px;
  border-radius: 8px; text-decoration: none; display: block;
}
.nav-mobile-link:hover, .nav-mobile-link.active { color: var(--text); background: var(--surface2); }
.nav-mobile-divider { height: 1px; background: var(--border); margin: 6px 0; }
.nav-mobile-user { font-size: 13px; color: var(--dim); padding: 6px 12px; }
.nav-mobile-signout {
  font-size: 15px; color: var(--muted); padding: 11px 12px;
  border-radius: 8px; text-decoration: none; display: block;
}
.nav-mobile-theme { display: flex; gap: 6px; padding: 8px 12px; }
.nav-mobile-theme .theme-btn { flex: 1; text-align: center; font-size: 13px; padding: 7px 4px; }

@media (max-width: 600px) {
  .nav-links, .nav-right { display: none; }
  .nav-hamburger { display: flex; align-items: center; }
}

/* ── New-task badge ── */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 0 4px; margin-left: 5px;
  vertical-align: middle; flex-shrink: 0;
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 20px;
  background: var(--bg); overflow: hidden; width: 100%;
}
.login-box {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 32px;
}
.login-logo {
  width: 64px; height: 64px; background: #000;
  border-radius: 12px; padding: 8px;
  margin: 0 auto 24px; display: block;
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; }
.login-title { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 28px; }
.login-box input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
  color: var(--text); font-size: 15px; font-family: var(--font);
  outline: none; margin-bottom: 10px; transition: border-color 0.15s;
}
.login-box input:focus { border-color: var(--border2); }
.login-btn {
  width: 100%; background: var(--accent); color: var(--bg);
  border: none; border-radius: 8px; padding: 13px;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  cursor: pointer; margin-top: 6px; transition: opacity 0.15s;
}
.login-btn:hover { opacity: 0.88; }
.login-error { font-size: 13px; color: var(--red); text-align: center; margin-bottom: 14px; }

/* ── Cash Flow tile — shared between dashboard + property detail ───────────
   Pie on left, Rent + Mort. Payment anchors on right above 4-segment list.
   Stacks pie above info at ≤600px.
────────────────────────────────────────────────────────────────────────── */
:root {
  --cf-escrow:    #4b5566;
  --cf-interest:  #353c4a;
  --cf-principal: #1f6a3d;
  --cf-margin:    #2a8a4f;
}
:root[data-theme="light"] {
  --cf-escrow:    #94a0b1;
  --cf-interest:  #758094;
  --cf-principal: #3fa164;
  --cf-margin:    #2a8a4f;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --cf-escrow:    #94a0b1;
    --cf-interest:  #758094;
    --cf-principal: #3fa164;
    --cf-margin:    #2a8a4f;
  }
}

.cf-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 22px; box-shadow: var(--shadow-md);
  display: grid; grid-template-columns: 156px 1fr; gap: 24px; align-items: center;
}
.cf-card .cf-header {
  grid-column: 1 / -1;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim); margin-bottom: 4px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline;
}
.cf-card .cf-header .cf-meta {
  color: var(--muted); font-weight: 500; letter-spacing: .02em;
  text-transform: none; font-size: 11px;
}
.cf-pie-wrap { position: relative; width: 156px; height: 156px; margin: 0 auto; }
.cf-pie { width: 156px; height: 156px; border-radius: 50%; }
.cf-pie-hole {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 94px; height: 94px; border-radius: 50%;
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.cf-pie-hole .kept-val {
  font-size: 24px; font-weight: 700; color: var(--green);
  line-height: 1; letter-spacing: -.02em;
}
.cf-pie-hole .kept-lbl {
  font-size: 9px; color: var(--dim);
  text-transform: uppercase; letter-spacing: .05em; margin-top: 4px;
}
.cf-info { min-width: 0; }
.cf-anchors {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.cf-anchor-lbl {
  font-size: 10px; color: var(--dim);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px;
}
.cf-anchor-val {
  font-size: 28px; font-weight: 700; letter-spacing: -.025em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cf-anchor-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }
.cf-anchor.rent .cf-anchor-val { color: var(--green); }
.cf-segments { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
.cf-seg-row {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: baseline; gap: 8px; font-size: 12px;
}
.cf-seg-dot { width: 9px; height: 9px; border-radius: 2px; align-self: center; }
.cf-seg-label-col {
  min-width: 0; display: flex; flex-direction: column; line-height: 1.25;
}
.cf-seg-label { color: var(--muted); }
.cf-seg-tag { font-size: 9px; color: var(--dim); font-style: italic; margin-top: 1px; }
.cf-seg-val-col { text-align: right; line-height: 1.25; }
.cf-seg-val { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.cf-seg-pct { font-size: 10px; color: var(--dim); font-weight: 500; margin-top: 1px; }

@media (max-width: 600px) {
  .cf-card { grid-template-columns: 1fr; gap: 14px; padding: 14px 16px; }
  .cf-pie-wrap, .cf-pie { width: 130px; height: 130px; }
  .cf-pie-hole { width: 78px; height: 78px; }
  .cf-pie-hole .kept-val { font-size: 19px; }
  .cf-anchors { gap: 0 16px; }
  .cf-anchor-val { font-size: 22px; }
  .cf-segments { grid-template-columns: 1fr; gap: 6px 0; }
}

/* ── Theme toggle JS ────────────────────────────────────────────────────────
   setTheme() is defined inline in each template; this section is CSS-only.
────────────────────────────────────────────────────────────────────────── */
