:root {
  --chrome: #232a33;      /* graphite chrome */
  --chrome-2: #2d3641;
  --canvas: #f1f2f4;      /* working surface */
  --paper: #ffffff;
  --ink: #1b222b;
  --ink-2: #5a6672;
  --line: #d7dbe0;
  --accent: #f5b914;      /* lockout yellow — primary action + bid total only */
  --accent-ink: #221a00;
  --good: #1e7f4f;
  --bad: #b3352c;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Barlow', system-ui, sans-serif;
  background: var(--canvas); color: var(--ink);
  font-size: 14.5px; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.hidden { display: none !important; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--chrome); }
.login-card { background: var(--paper); border-radius: var(--radius); padding: 34px 38px; width: 320px; border-top: 6px solid var(--accent); }
.login-mark { font-weight: 700; letter-spacing: .14em; font-size: 18px; }
.login-card p { color: var(--ink-2); margin: 4px 0 20px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card button { width: 100%; }
.login-err { color: var(--bad); margin-top: 10px; min-height: 1em; }

/* shell */
.shell { display: flex; flex-direction: column; height: 100vh; }
.topbar { background: var(--chrome); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 18px; height: 50px; flex: none; }
.mark { font-weight: 700; letter-spacing: .14em; border-left: 4px solid var(--accent); padding-left: 10px; }
.crumb { color: #aeb8c2; }
.right { margin-left: auto; }
.body { display: flex; flex: 1; min-height: 0; }
.rail { width: 150px; background: var(--chrome-2); padding: 14px 0; flex: none; }
.rail a { display: block; color: #c4cdd6; text-decoration: none; padding: 9px 18px; font-weight: 500; border-left: 3px solid transparent; }
.rail a:hover { color: #fff; }
.rail a.active { color: #fff; border-left-color: var(--accent); background: rgba(255,255,255,.05); }
main { flex: 1; overflow: auto; padding: 22px 26px; }

/* controls */
input, select, textarea {
  font: inherit; color: inherit; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .rail a:focus-visible {
  outline: 2px solid var(--chrome); outline-offset: 1px;
}
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.96); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: #c4cdd6; }
.btn-ghost:hover { color: #fff; border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 3px 9px; font-size: 13px; }

/* layout helpers */
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; }
.page-head .sub { color: var(--ink-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card { margin-top: 16px; }
.card-pad { padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 3px; }
.field input, .field select, .field textarea { width: 100%; }

/* tables */
table { border-collapse: collapse; width: 100%; }
th { font-family: 'Barlow Semi Condensed', 'Barlow', sans-serif; font-weight: 600; font-size: 13px;
  color: var(--ink-2); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--chrome); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #f7f8f9; }
.num, th.num { text-align: right; }
td input.cell { width: 76px; text-align: right; padding: 4px 6px; }
td input.cell-wide { width: 120px; padding: 4px 6px; }
.muted { color: var(--ink-2); }
.rowlink { cursor: pointer; }
.status { font-weight: 600; }
.status.Won { color: var(--good); }
.status.Lost { color: var(--bad); }
.status.Submitted { color: #8a6d00; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--chrome); margin-bottom: 16px; }
.tabs button { font: inherit; font-weight: 600; border: none; background: none; padding: 9px 16px; cursor: pointer; color: var(--ink-2); }
.tabs button.active { color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }

/* takeoff picker */
.picker { position: relative; }
.picker input { width: 380px; }
.picker-list { position: absolute; z-index: 10; top: 100%; left: 0; width: 460px; max-height: 320px; overflow: auto;
  background: var(--paper); border: 1px solid var(--chrome); border-radius: var(--radius); box-shadow: 0 8px 20px rgba(20,26,33,.18); }
.picker-list div { padding: 7px 12px; cursor: pointer; display: flex; gap: 8px; }
.picker-list div:hover { background: #f2ecd6; }
.picker-list .tag { font-size: 12px; font-weight: 600; color: var(--ink-2); width: 34px; flex: none; }

/* summary recap */
.recap { max-width: 640px; }
.recap-line { display: flex; justify-content: space-between; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.recap-line.section { font-weight: 600; background: #f7f8f9; }
.recap-line.indent { padding-left: 34px; color: var(--ink-2); }
.recap-total { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 20px; }
.recap-check { padding: 10px 18px; color: var(--ink-2); display: flex; gap: 24px; }

/* plan viewer */
.plan-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-toolbar .spacer { flex: 1; }
.toolset { display: inline-flex; gap: 4px; }
.plan-stage { position: relative; overflow: auto; height: 68vh; background: #dfe2e6;
  border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; }
.plan-stage canvas { position: absolute; top: 0; left: 0; }
#ovC { z-index: 2; }
#sheetTotals { margin-top: 12px; }
label.btn input[type=file] { display: none; }

.empty { padding: 40px; text-align: center; color: var(--ink-2); }
.notice { background: #fdf6df; border: 1px solid #ecd68a; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; color: #5c4a00; }

@media (max-width: 800px) {
  .rail { width: 54px; }
  .rail a { padding: 9px 8px; font-size: 11px; text-align: center; }
  main { padding: 14px; }
  .picker input, .picker-list { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
