/* Prop Tracking — single hand-written stylesheet. Light theme, mobile-first.
   Styling mirrors the Daily Report Card (font, palette, surfaces, shadows). */

@font-face {
  font-family: 'Inter Variable';
  src: url('fonts/InterVariable.woff2') format('woff2-variations'),
       url('fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --border: #e5e7eb;
  --border-strong: #cbd1d9;
  --text: #15171c;
  --muted: #6b7280;
  --accent: #1f6feb;
  --accent-weak: #e8f0fe;
  --pos: #15803d;
  --pos-weak: #dcfce7;
  --neg: #dc2626;
  --neg-weak: #fdecec;
  --warn: #f97316;
  --shadow: 0 1px 2px rgba(15,17,28,0.04), 0 1px 1px rgba(15,17,28,0.03);
  --radius: 10px;
  --sans: 'Google Sans', 'Inter Variable', 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding-bottom: 72px; /* room for bottom tab bar on mobile */
}
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; }
.brand-mark .bar { width: 4px; border-radius: 1px; }
.brand-mark .b1 { height: 8px;  background: var(--neg); }
.brand-mark .b2 { height: 13px; background: var(--warn); }
.brand-mark .b3 { height: 18px; background: var(--pos); }
.navtabs { display: none; gap: 4px; margin-left: 8px; }
.navtabs a {
  padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.navtabs a:hover { background: var(--bg); text-decoration: none; }
.navtabs a.active { color: var(--text); background: var(--accent-weak); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.whoami { font-size: 13px; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* ---------- bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-around;
  height: 60px; padding: 4px 8px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; text-align: center; color: var(--muted); font-size: 12px; font-weight: 500;
  padding: 8px 0; border-radius: 8px;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--accent); }
.tabbar a.add {
  flex: 0 0 auto; width: 44px; height: 44px; line-height: 40px; font-size: 26px;
  color: #fff; background: var(--accent); border-radius: 50%; margin-top: -14px;
  box-shadow: 0 4px 10px rgba(31,111,235,.35);
}
.tabbar a.add:hover { text-decoration: none; }

/* ---------- layout ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 16px; }
.page.dashboard { max-width: 920px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.footer {
  max-width: 920px; margin: 24px auto 0; padding: 16px;
  display: flex; flex-wrap: wrap; justify-content: center; text-align: center;
  gap: 6px 16px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border);
}

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

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger, .btn-sm {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 8px; padding: 11px 16px; border: 1px solid transparent; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { text-decoration: none; filter: brightness(1.05); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { text-decoration: none; background: var(--bg); }
.btn-danger { background: var(--neg-weak); color: var(--neg); }
.btn-sm { padding: 7px 12px; font-size: 14px; background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-link { color: var(--accent); font-weight: 500; }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.stack > label, .form-main > label { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.or-new { margin-top: 6px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; min-height: 0; margin: 0; }
.check.inline { display: inline-flex; margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.form-actions .btn-primary, .form-actions .btn-secondary { flex: 1; min-width: 140px; }
.danger-form { margin-top: 24px; }

/* segmented type control */
.seg { border: 0; padding: 0; margin: 0 0 14px; }
.seg legend { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { flex-basis: 100%; }
.seg-opt { position: relative; margin: 0; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-opt span {
  display: inline-block; padding: 9px 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px;
}
.seg-opt input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.fx-line { margin: -6px 0 14px; font-size: 13px; }
.flag-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.flag-row input[type=date] { width: auto; margin-top: 0; }
.more summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-bottom: 12px; }
.payout-chain label { margin-bottom: 10px; }

/* row-edit (firms/methods) */
.row-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.row-edit input { margin-top: 0; }
.ed-name { flex: 2 1 140px; }
.ed-split { flex: 0 1 90px; }
.ed-notes { flex: 3 1 160px; }
.ed-name.static { padding: 8px 0; }
.is-archived { opacity: .55; }

/* ---------- auth ---------- */
.auth { max-width: 380px; margin: 48px auto; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.auth h1 { margin-bottom: 4px; }
.error { background: var(--neg-weak); color: var(--neg); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash { background: var(--pos-weak); color: var(--pos); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }

/* ---------- lists ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters select, .filters input { width: auto; flex: 1 1 120px; margin-top: 0; }
.month-head { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; font-weight: 600; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { margin-bottom: 8px; }
.rowlink {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; color: var(--text);
  box-shadow: var(--shadow);
}
.rowlink:hover { text-decoration: none; background: var(--surface-2); }
.row-main { display: flex; align-items: center; gap: 8px; }
.row-date { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); flex: 0 0 auto; }
.row-title { font-weight: 600; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; font-size: 14px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.chip.ok { background: var(--pos-weak); color: var(--pos); border-color: transparent; }
.chip.bad { background: var(--neg-weak); color: var(--neg); border-color: transparent; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-top: 1px solid var(--border); }

/* ---------- dashboard ---------- */
.hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 16px; text-align: center; margin-bottom: 16px; box-shadow: var(--shadow);
}
.hero.pos { background: var(--pos-weak); border-color: transparent; }
.hero.neg { background: var(--neg-weak); border-color: transparent; }
.hero-label { font-size: 12px; letter-spacing: .08em; color: var(--muted); }
.hero-num { font-variant-numeric: tabular-nums; font-size: 40px; font-weight: 700; line-height: 1.1; margin: 4px 0; }
.hero.pos .hero-num { color: var(--pos); }
.hero.neg .hero-num { color: var(--neg); }
.hero-sub { font-variant-numeric: tabular-nums; font-size: 18px; color: var(--muted); }
.hero-meta, .hero-foot { font-size: 13px; color: var(--muted); margin-top: 6px; }

.stat-grid, .stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat-k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-v { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; margin: 2px 0; }
.stat-s, .stat-d { font-size: 12px; color: var(--muted); }
.stat-unit { font-size: 13px; font-weight: 400; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.data, table.metrics { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.metrics th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data td, table.metrics td { padding: 8px; border-bottom: 1px solid var(--border); }
table .num, table.data th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
table tr:last-child td { border-bottom: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.typechip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 14px; }

.months { display: flex; flex-direction: column; gap: 8px; }
.mrow, .bar-row { display: grid; grid-template-columns: 56px 1fr 72px; align-items: center; gap: 10px; }
.mlabel, .bar-label { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mbars { display: flex; flex-direction: column; gap: 3px; }
.mbars .bar, .bar-track { height: 9px; border-radius: 4px; }
.bar-track { position: relative; background: var(--bg); display: flex; flex-direction: column; gap: 3px; height: auto; }
.bar { height: 9px; border-radius: 4px; min-width: 2px; }
.bar.spend { background: var(--neg); }
.bar.payout { background: var(--pos); }
.mnet, .bar-net { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: middle; }
.dot.spend { background: var(--neg); }
.dot.payout { background: var(--pos); }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-month { font-weight: 600; min-width: 7.5em; text-align: center; }
.nav-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 20px; line-height: 1;
}
.nav-arrow:hover { background: var(--surface-2); text-decoration: none; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1 / 1; position: relative; border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  overflow: hidden; padding: 2px;
}
a.cal-cell:hover { text-decoration: none; filter: brightness(0.97); }
.cal-cell.out { background: transparent; pointer-events: none; }
.cal-cell.none { background: var(--surface-2); }
.cal-cell.pos { background: var(--pos-weak); }
.cal-cell.neg { background: var(--neg-weak); }
.cal-cell.flat { background: var(--surface-2); }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day { position: absolute; top: 3px; left: 5px; font-size: 11px; font-weight: 600; color: var(--muted); }
.cal-amt { font-size: 13px; font-weight: 700; margin-top: 8px; }
.cal-cell.pos .cal-amt { color: var(--pos); }
.cal-cell.neg .cal-amt { color: var(--neg); }
.cal-meta { display: flex; gap: 5px; font-size: 9px; font-variant-numeric: tabular-nums; opacity: .8; }
.cal-meta .cal-sp { color: var(--neg); }
.cal-meta .cal-py { color: var(--pos); }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.cal-legend .legend-label { font-weight: 600; }
.cal-legend .sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: middle; }
.cal-legend .sw.pos { background: var(--pos-weak); }
.cal-legend .sw.neg { background: var(--neg-weak); }
.cal-legend .sw.none { background: var(--surface-2); }
.cal-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.cal-summary strong { font-size: 18px; }
.cal-pop {
  position: absolute; z-index: 50; min-width: 168px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(15,17,28,.16); padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.cal-pop-title { font-size: 12px; color: var(--muted); padding: 4px 8px 2px; }
.cal-pop a { display: block; padding: 9px 10px; border-radius: 6px; color: var(--text); font-size: 14px; }
.cal-pop a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- desktop ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .navtabs { display: flex; }
  .tabbar { display: none; }
  .stat-grid, .stats { grid-template-columns: repeat(3, 1fr); }
  .tables { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .tables .card:first-child { grid-column: 1 / -1; }
}
