:root {
  --navy: #0b2545; --navy2: #13315c; --gold: #f2a900; --blue: #1f6feb;
  --bg: #f4f6fa; --card: #ffffff; --ink: #14213d; --dim: #5b6b84; --line: #dfe5ee;
  --bad: #b42318; --badbg: #fdecea; --ok: #067647; --okbg: #e7f6ee; --warnbg: #fff4d6; --warn: #8a5a00;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.band { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 28px; padding: 14px 24px; border-bottom: 4px solid var(--gold); flex-wrap: wrap; }
.brand .co { font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.brand .sub { font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px; color: #c9d4e6; }
.band nav { display: flex; gap: 4px; flex: 1; }
.band nav a { color: #dbe4f2; padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.band nav a:hover { background: var(--navy2); text-decoration: none; }
.band nav a.on { background: var(--gold); color: var(--navy); }
.status { display: flex; align-items: center; gap: 10px; }
.status form { margin: 0; }
.status .user, .status .data { display: contents; }
.badge { font-size: 12px; color: #c9d4e6; border: 1px solid #36507a; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.live { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; }
button { font: inherit; font-weight: 600; background: var(--navy); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer; }
button:hover { background: var(--navy2); }
a.ghost, button.ghost { text-decoration: none; display: inline-block; border-radius: 6px; cursor: pointer; }
a.ghost, button.ghost { background: transparent; border: 1px solid #5a739b; color: #fff; padding: 5px 12px; font-size: 12px; }

main { padding: 20px 24px 8px; max-width: 1700px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--dim); margin: 26px 0 8px; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 0; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); font-weight: 600; }
input, select { font: inherit; padding: 7px 10px; border: 1px solid #c4cedd; border-radius: 6px; background: #fff; color: var(--ink); min-width: 190px; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }

.combo { position: relative; display: block; }
.combo input { min-width: 320px; width: 100%; }
.combo .menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; min-width: 420px; max-height: 360px; overflow: auto;
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #c4cedd; border-radius: 8px; box-shadow: 0 8px 24px rgba(11, 37, 69, .18);
  text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 14px; color: var(--ink); }
.combo .menu li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 10px; border-radius: 5px; cursor: pointer; }
.combo .menu li:hover, .combo .menu li.on { background: #e8eefb; }
.combo .menu .main { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo .menu .sub { color: var(--dim); font-size: 12px; white-space: nowrap; }
.combo .menu li.none { color: var(--dim); cursor: default; justify-content: center; }
.combo .menu li.none:hover { background: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: #fff; border: 1px solid var(--line); color: var(--ink); padding: 5px 12px; border-radius: 999px; font-weight: 500; font-size: 13px; }
.chip b { margin-left: 4px; }
.chip:hover { text-decoration: none; border-color: var(--blue); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.warn b { color: var(--bad); }
.chip.warn.on b { color: var(--gold); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles.small { grid-template-columns: repeat(auto-fit, minmax(190px, 260px)); }
.tile { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: 8px; padding: 12px 14px; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); font-weight: 600; }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--dim); margin-top: 2px; }
.tile.gold { border-top-color: var(--gold); background: var(--navy); color: #fff; border-color: var(--navy); }
.tile.gold .k, .tile.gold .s { color: #c9d4e6; }
.tile.bad { border-top-color: var(--bad); }
.tile.bad .v { color: var(--bad); }

.tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { background: #eef2f8; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; position: sticky; top: 0; white-space: nowrap; }
.grid tr.grp th { background: var(--navy); color: #fff; text-align: center; border-left: 1px solid #2b4470; position: static; }
.grid .l { text-align: left; }
.grid .b { font-weight: 700; }
.grid tbody tr:hover td { background: #f7f9fd; }
.grid tfoot td { background: #eef2f8; font-weight: 700; border-top: 2px solid var(--navy); border-bottom: 0; }
.grid td.miss { background: var(--badbg); color: var(--bad); font-weight: 600; }
.grid tr.arch td { color: #98a2b3; text-decoration: line-through; }
.grid tr.arch td .f { text-decoration: none; display: inline-block; }
.nowrap { white-space: nowrap; }
.dim { color: var(--dim); font-size: 12px; }
.flags { white-space: nowrap; }
.f { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #eef2f8; color: var(--dim); margin-right: 4px; }
.f.warn { background: var(--badbg); color: var(--bad); }
.s { font-size: 12px; color: var(--dim); }

.ty { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 4px; background: #eef2f8; color: var(--navy); white-space: nowrap; }
.ty-labour, .ty-gutterlabour { background: #e3ecfb; color: #174ea6; }
.ty-material { background: #f3e8ff; color: #6b21a8; }
.ty-dumpster { background: #fde9d9; color: #9a3412; }
.ty-solar { background: var(--warnbg); color: var(--warn); }
.ty-refundincentive { background: #e6e6e6; color: #444; }
.pay { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.pay-paid { background: var(--okbg); color: var(--ok); }
.pay-unpaid { background: var(--badbg); color: var(--bad); }
.pay-scheduled, .pay-partially { background: var(--warnbg); color: var(--warn); }

.jobhead { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: 8px; padding: 16px 18px; display: flex; gap: 32px; flex-wrap: wrap; margin-bottom: 16px; }
.jobno { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--dim); font-weight: 700; }
.cust { font-size: 22px; font-weight: 700; }
.addr { color: var(--dim); }
.jobhead dl { display: grid; grid-template-columns: repeat(4, minmax(120px, auto)); gap: 8px 28px; margin: 0; flex: 1; }
.jobhead dt { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); font-weight: 600; }
.jobhead dd { margin: 0; font-weight: 600; }

.empty { color: var(--dim); text-align: center; padding: 26px; }
.box { background: var(--card); border: 1px dashed #c4cedd; border-radius: 8px; }
.alert { background: var(--badbg); color: var(--bad); padding: 10px 24px; font-weight: 600; border-radius: 0; }
main .alert { border-radius: 8px; margin-bottom: 14px; padding: 10px 14px; }
.note { color: var(--dim); font-size: 12px; margin: 10px 2px; max-width: 1100px; }
footer { color: var(--dim); font-size: 12px; padding: 14px 24px 26px; max-width: 1700px; margin: 0 auto; }
@media (max-width: 900px) { .jobhead dl { grid-template-columns: repeat(2, auto); } }

input.date { min-width: 150px; }
h1 .period { font-size: 13px; font-weight: 500; color: var(--dim); margin-left: 10px; white-space: nowrap; }

.grid tr.credit td { color: var(--bad); }

details.fix summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: 12px; list-style: none; }
details.fix summary::-webkit-details-marker { display: none; }
.fixform { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 6px; padding: 8px; background: #f7f9fd; border: 1px solid var(--line); border-radius: 6px; }
.fixform label { display: flex; flex-direction: column; font-size: 11px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.fixform input { min-width: 0; padding: 5px 8px; font-size: 13px; }
.fixform button { padding: 6px 12px; }
.suggest a { margin-right: 8px; }
/* dense tracker table: smaller type, tighter cells, names on one line */
main.wide { max-width: 1900px; }
.grid.compact { font-size: 13px; }
.grid.compact th, .grid.compact td { padding: 5px 7px; vertical-align: middle; }
.grid.compact th { font-size: 10px; letter-spacing: .5px; }
.grid.compact td.name { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid.compact td.flags .f { font-size: 11px; padding: 1px 6px; }

/* ---------- phones (under 700px): cards instead of the wide table, lead figures first ---------- */
.cards { display: none; }
.filters .more { display: contents; }
.filters .moretoggle { display: none; }
@media (max-width: 699px) {
  main { padding: 12px 12px 8px; }
  /* header on phones: brand + account on one line, a full-width tab bar, then a thin data line */
  .band { display: grid; grid-template-columns: 1fr auto; padding: 10px 12px 0; gap: 0; border-bottom-width: 3px; }
  .brand .co { font-size: 17px; line-height: 1.1; }
  .brand .sub { font-size: 9px; letter-spacing: 1.2px; }
  .band .status { display: contents; }
  .band .status .user { display: flex; align-items: center; gap: 10px; font-size: 12px; justify-self: end; }
  .band .status .user .badge { border: 0; padding: 0; color: #fff; font-weight: 600; font-size: 12px; }
  .band .status .user a.ghost, .band .status .user button.ghost { border: 0; padding: 0; color: #c9d4e6; font-size: 12px; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
  .band nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 10px; border-top: 1px solid #2b4470; }
  .band nav a { padding: 9px 2px 8px; font-size: 12px; text-align: center; border-radius: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .band nav a.on { background: transparent; color: var(--gold); border-bottom-color: var(--gold); }
  .band .status .data { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0 6px; font-size: 11px; color: #c9d4e6; border-top: 1px solid #2b4470; }
  .band .status .data .badge { border: 0; padding: 0; font-size: 11px; }
  .band .status .data button.ghost { padding: 2px 10px; font-size: 11px; }
  h1 { font-size: 18px; margin: 0 0 6px; }
  h1 .period { display: block; margin: 2px 0 0; }
  .toolbar { gap: 8px; margin-bottom: 8px; }
  .filters { width: 100%; gap: 8px; }
  .filters > label { flex: 1 1 40%; min-width: 0; }
  .filters select, .filters input[type=date] { min-width: 0; }
  .filters select, .filters input { width: 100%; }
  .filters .moretoggle { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--navy); color: var(--navy);
    padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-top: 2px; }
  .filters .moretoggle .chev { width: 7px; height: 7px; border-right: 2px solid var(--navy); border-bottom: 2px solid var(--navy); transform: rotate(45deg); margin-top: -3px; }
  .filters .moretoggle.open .chev { transform: rotate(-135deg); margin-top: 3px; }
  .filters .more { display: none; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 2px; }
  .filters .more.open { display: block; }
  .filters .more label { margin-bottom: 8px; }
  .filters .more button { margin-bottom: 8px; }
  .chips { gap: 6px; margin-bottom: 10px; }
  .chip { padding: 4px 10px; font-size: 12px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .tile { padding: 8px 10px; }
  .tile .v { font-size: 18px; }
  .tile .s { font-size: 11px; }
  .tile.gold { order: -2; grid-column: span 2; }
  .tile.m1 { order: -1; }
  .tablewrap, main.wide .tablewrap { display: none; }
  .cards { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .card { border-bottom: 1px solid var(--line); color: var(--ink); }
  .card:last-child { border-bottom: 0; }
  .card .row { display: grid; grid-template-columns: 1fr auto auto 14px; gap: 10px; align-items: center; padding: 8px 10px 8px 12px; cursor: pointer; }
  .card.head { display: grid; grid-template-columns: 1fr auto auto 14px; gap: 10px; background: #eef2f8; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; padding: 5px 10px 5px 12px; }
  .card.open .row { background: #f7f9fd; }
  .card .left { min-width: 0; }
  .card .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card .meta { font-size: 11px; color: var(--dim); margin-top: 1px; }
  .card .meta .num { color: var(--blue); font-weight: 700; }
  .card .fl { margin-top: 3px; }
  .card .fl .f { font-size: 10px; padding: 0 6px; margin-right: 3px; }
  .card .mid { text-align: right; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.35; }
  .card .mid .cost { color: var(--dim); }
  .card .mid .cost::before { content: "− "; }
  .card .right { text-align: right; min-width: 72px; font-variant-numeric: tabular-nums; line-height: 1.15; }
  .card .right .gpv { font-size: 14px; font-weight: 600; color: var(--ok); }
  .card .right .gpp { font-size: 11px; font-weight: 500; color: var(--ok); }
  .card .right.neg .gpv, .card .right.neg .gpp { color: var(--bad); }
  .card .chev { width: 7px; height: 7px; border-right: 2px solid #9aa8bd; border-bottom: 2px solid #9aa8bd; transform: rotate(45deg); margin: 0 auto 3px; transition: transform .15s; }
  .card.open .chev { transform: rotate(-135deg); margin: 3px auto 0; }
  .card .detail { display: none; padding: 4px 12px 10px; background: #f7f9fd; border-top: 1px dashed var(--line); }
  .card.open .detail { display: block; }
  .card .detail dl { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; margin: 6px 0 0; }
  .card .detail dt { font-size: 9px; text-transform: uppercase; letter-spacing: .7px; color: var(--dim); font-weight: 600; }
  .card .detail dd { margin: 0; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .card .detail .miss dd { color: var(--bad); }
  .card .detail .src { font-size: 10px; color: var(--dim); margin-top: 1px; }
  .card .detail .links { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; }
  .card .detail .links .dim { color: var(--dim); }
  .note { font-size: 12px; }
}
