:root {
  /* Hyngstrom Racing colors (from hyngstromracing.com) */
  --navy: #14284b;
  --orange: #f26b21;
  --orange-dark: #d4561a;
  --blue: #1d4f9c;

  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5b6675;
  --line: #e4e0d6;
  --brand: var(--navy);
  --brand-ink: #ffffff;
  --pos: var(--blue);
  --neg: #b3261e;
  --cap: #a8480f;
  --inc-bar: #3b6fc4;
  --exp-bar: var(--orange);
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { background: #efece4; padding: 0 4px; border-radius: 4px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* top bar */
.topbar { background: var(--brand); color: var(--brand-ink); border-bottom: 4px solid var(--orange); }
.topbar .wrap { display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand span { font-weight: 400; color: #ff8a3d; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #d3dbea; padding: 6px 10px; border-radius: 6px; }
.topbar nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.topbar nav a.on { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 -2px 0 var(--orange); }

main.wrap { padding-top: 24px; padding-bottom: 24px; }
.foot { color: var(--muted); font-size: .85rem; padding-bottom: 32px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 .muted { font-weight: 400; }
.page-head p { margin: 4px 0 0; }
.buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline { display: inline-flex; gap: 6px; align-items: center; }

/* buttons & inputs */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: #c9cec7; }
.btn.primary { background: var(--orange-dark); border-color: var(--orange-dark); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--orange); border-color: var(--orange); }
.btn.danger { color: var(--neg); border-color: #e7c3bc; }
button.link { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd4cd; border-radius: 8px;
  background: #fff; color: var(--ink); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f9b88f; border-color: var(--orange); }

/* flashes */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: #e6eef9; color: var(--navy); }
.flash.error { background: #fbe9e6; color: #8a2a1e; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: inherit; }
a.card:hover { text-decoration: none; border-color: #c9cec7; }
.card .label { color: var(--muted); font-size: .85rem; }
.card .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .hint { color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data.compact td { padding: 7px 4px; }
table.data tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
table.data tr.grand td { font-weight: 700; font-size: 1.1rem; border-top: 3px double var(--ink); }
.report h2 { margin-top: 22px; }
.report h2:first-child { margin-top: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.actions a { margin-left: 8px; }
.pre { white-space: pre-line; }
.empty { color: var(--muted); text-align: center; padding: 24px !important; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.ref { color: var(--muted); font-size: .8rem; }
.warn { color: var(--neg); }
.notes { background: var(--panel); border-left: 3px solid var(--orange); padding: 8px 12px; white-space: pre-line; }

/* month bars */
table.months { width: 100%; border-collapse: collapse; }
table.months th { text-align: left; color: var(--muted); font-size: .8rem; font-weight: 600; padding: 4px 6px; }
table.months td { padding: 4px 6px; width: 38%; }
table.months td:first-child { width: 8%; color: var(--muted); }
table.months td.num { width: 16%; }
.barcell { position: relative; height: 22px; display: flex; align-items: center; }
.barcell .bar { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 4px; opacity: .3; }
.barcell span { position: relative; font-size: .85rem; padding-left: 6px; font-variant-numeric: tabular-nums; }
.bar.inc { background: var(--inc-bar); }
.bar.exp { background: var(--exp-bar); }
.hbar { display: block; margin-bottom: 10px; color: inherit; }
.hbar:hover { text-decoration: none; }
.hbar-label { display: flex; justify-content: space-between; font-size: .9rem; }
.hbar-label span:last-child { font-variant-numeric: tabular-nums; }
.hbar-track { background: #f1eee7; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.hbar-track .bar { height: 100%; border-radius: 4px; }

/* badges */
.badge { display: inline-block; font-size: .7rem; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: #efece4; color: var(--muted); vertical-align: 1px; }
.badge.income { background: #e3ecf9; color: var(--pos); }
.badge.expense { background: #f9e4e2; color: var(--neg); }
.badge.capital { background: #fdeadf; color: var(--cap); }
.badge.yes { background: #e3ecf9; color: var(--pos); }
.badge.warn { background: #f9e4e2; color: var(--neg); }
.status { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #efece4; color: var(--muted); vertical-align: middle; }
.status.s-active { background: #e3ecf9; color: var(--pos); }
.status.s-layup { background: #fdeadf; color: var(--cap); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 220px; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; }
.totals-line { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 10px; color: var(--muted); font-size: .9rem; }
.totals-line b { font-variant-numeric: tabular-nums; }

/* forms */
.form { max-width: 760px; display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; flex: 1; }
.form label input, .form label select, .form label textarea { font-weight: 400; width: 100%; }
.form small { font-weight: 400; color: var(--muted); }
.form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.form .row > label { min-width: 200px; }
label.check { flex-direction: row !important; align-items: center; gap: 6px !important; font-weight: 400 !important; display: inline-flex !important; }
label.check input { width: auto !important; }
label.check.big { font-weight: 600 !important; }
.danger-zone { max-width: 760px; text-align: right; }

/* categories */
.cat-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cat-row .rename { flex: 1; }
.cat-row input { width: 100%; border-color: transparent; padding: 5px 8px; }
.cat-row input:hover { border-color: #cfd4cd; }
.cat-row.inactive input { color: var(--muted); text-decoration: line-through; }

@media (max-width: 640px) {
  .topbar .wrap { padding-top: 10px; padding-bottom: 6px; gap: 8px; justify-content: space-between; }
  .topbar nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topbar nav a { white-space: nowrap; }
  .topbar .btn.primary { padding: 6px 12px; }
  .card .value { font-size: 1.35rem; }
  .filters input[type=search] { min-width: 0; flex: 1; }
}
@media print {
  .topbar, .foot, .noprint, .flash { display: none; }
  body { background: #fff; }
  .panel { border: 0; padding: 0; }
}
