* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1a1d21; --muted: #6b7280;
  --brand: #1e3a5f; --brand-2: #2d5a8e; --accent: #e8a33d;
  --ok: #1a7f37; --warn: #b45309; --bad: #b91c1c; --line: #e2e4e8;
}
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand-2); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--brand) 0%, #0f1f33 100%); }
.login-box { background: var(--panel); padding: 36px; border-radius: 12px; width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box .sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }

/* shell */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #dbe4ef; padding: 18px 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .logo { font-weight: 700; font-size: 17px; color: #fff; padding: 0 18px 14px; letter-spacing: .3px; }
.sidebar .logo span { color: var(--accent); }
.sidebar nav { flex: 1; }
.sidebar nav a { display: block; padding: 9px 18px; color: #c3cfdd; font-size: 13.5px; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--accent); }
.sidebar nav .sect { padding: 14px 18px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #7d92aa; }
.sidebar .whoami { padding: 12px 18px; font-size: 12.5px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar .whoami b { color: #fff; display: block; }
.sidebar .whoami button { background: none; border: none; color: #9fb2c8; padding: 2px 0; font-size: 12px; }
.sidebar .whoami button:hover { color: #fff; }

.main { padding: 22px 28px; max-width: 1300px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; margin-right: auto; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.btn { background: var(--brand-2); color: #fff; border: none; border-radius: 7px; padding: 8px 14px; font-size: 13.5px; }
.btn:hover { background: var(--brand); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--brand-2); color: var(--brand-2); }
.btn.danger { background: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(45,90,142,.25); border-color: var(--brand-2); }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.field { margin-bottom: 12px; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 9px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f0f4f9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.available, .badge.confirmed, .badge.paid, .badge.reconciled { background: #dcf2e3; color: var(--ok); }
.badge.out, .badge.open { background: #fdeeda; color: var(--warn); }
.badge.maintenance, .badge.quote { background: #e3e9f5; color: var(--brand-2); }
.badge.missing, .badge.cancelled, .badge.void, .badge.overdue { background: #fbe1e1; color: var(--bad); }
.badge.retired, .badge.closed, .badge.returned { background: #e8e8ea; color: var(--muted); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 200; }
.toast.err { background: var(--bad); }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,33,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 100%; max-width: 640px; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.modal h3 { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* scan screen */
.scan-input { font-size: 20px; padding: 14px; text-align: center; letter-spacing: .05em; }
.scan-toggle { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.scan-toggle button { flex: 1; padding: 12px; border: none; background: #fff; font-weight: 700; font-size: 15px; color: var(--muted); }
.scan-toggle button.on-out { background: var(--warn); color: #fff; }
.scan-toggle button.on-in { background: var(--ok); color: #fff; }
.scan-feedback { padding: 14px; border-radius: 9px; font-weight: 600; text-align: center; margin: 10px 0; }
.scan-feedback.ok { background: #dcf2e3; color: var(--ok); }
.scan-feedback.err { background: #fbe1e1; color: var(--bad); }
.manifest-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.manifest-item .dot { width: 12px; height: 12px; border-radius: 50%; background: #d2d6dc; flex-shrink: 0; }
.manifest-item.st-out .dot { background: var(--warn); }
.manifest-item.st-in .dot { background: var(--ok); }
.manifest-item .nm { flex: 1; }
#camWrap { position: fixed; inset: 0; background: #000; z-index: 300; display: flex; flex-direction: column; }
#camWrap video { flex: 1; object-fit: cover; width: 100%; }
#camWrap .cam-bar { padding: 14px; display: flex; gap: 10px; background: #111; }
.sig-pad { border: 2px dashed var(--line); border-radius: 10px; touch-action: none; width: 100%; background: #fff; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.photo-grid a { display: block; }
.photo-grid img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* mobile */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; height: auto; bottom: 0; top: auto; left: 0; right: 0; z-index: 90;
    flex-direction: row; align-items: center; padding: 0; overflow-x: auto; }
  .sidebar .logo, .sidebar .sect, .sidebar .whoami { display: none; }
  .sidebar nav { display: flex; flex: 1; }
  .sidebar nav a { padding: 12px 13px; border-left: none; border-top: 3px solid transparent; white-space: nowrap; }
  .sidebar nav a.active { border-left: none; border-top-color: var(--accent); }
  .main { padding: 14px 12px 78px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 17px; }
}

/* shop board */
.board { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.board-legend { display: flex; gap: 18px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }
.board-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.board-legend .dot-out { background: var(--warn); } .board-legend .dot-in { background: var(--ok); }
.board-legend .dot-quote { background: #b9c3d4; }
.bd-day { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 180px; }
.bd-day.today { outline: 3px solid var(--accent); }
.bd-dayhead { font-weight: 700; font-size: 12.5px; letter-spacing: .06em; display: flex; gap: 6px; align-items: baseline; border-bottom: 2px solid var(--line); padding-bottom: 5px; margin-bottom: 7px; }
.bd-dayhead span { color: var(--muted); font-weight: 500; }
.bd-count { margin-left: auto; background: var(--brand); color: #fff; border-radius: 10px; padding: 0 8px; font-size: 11px; }
.bd-card { border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; font-size: 12.5px; cursor: pointer; border-left: 4px solid; }
.bd-card.out { background: #fdf1e2; border-left-color: var(--warn); }
.bd-card.in { background: #e4f4ea; border-left-color: var(--ok); }
.bd-card.tentative { opacity: .65; border-left-style: dashed; }
.bd-card:hover { filter: brightness(.96); }
.bd-kind { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: var(--muted); }
.bd-job { color: #3d4756; }
.bd-meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* TV mode: fills screen, big type for across-the-shop reading */
body.tv .sidebar, body.tv .board-legend { display: none; }
body.tv .shell { grid-template-columns: 1fr; }
body.tv .main { max-width: none; padding: 18px 22px; }
body.tv { background: #10141b; }
body.tv .page-head h2 { color: #fff; font-size: 30px; }
body.tv .bd-day { background: #1a2029; border-color: #2a3342; min-height: 70vh; }
body.tv .bd-dayhead { color: #fff; font-size: 19px; border-color: #2a3342; }
body.tv .bd-card { font-size: 17px; padding: 12px; }
body.tv .bd-kind { font-size: 13px; }
body.tv .bd-job { color: #c6cedb; }
body.tv .bd-card.out { background: #3d2c14; } body.tv .bd-card.in { background: #14331f; }
body.tv .bd-card b { color: #fff; }
body.tv #bdRange { color: #8ea0b8; font-size: 18px; }
@media (max-width: 760px) { .board { grid-template-columns: 1fr 1fr; } }

/* QuikActivity-style calendar grid */
.cal-grid { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: #eef1f5; border-bottom: 2px solid var(--line); }
.cal-head div { padding: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-align: center; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-week:last-child { border-bottom: none; }
.cal-day { border-right: 1px solid var(--line); min-height: 108px; padding: 5px; }
.cal-day:last-child { border-right: none; }
.cal-day.today { background: #fdf7e8; }
.cal-date { font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; margin-bottom: 4px; }
.cal-day.today .cal-date { color: var(--accent); font-weight: 800; }
.cal-pill { border-radius: 12px; padding: 3px 9px; font-size: 11.5px; font-weight: 700; text-align: center; margin-bottom: 4px; cursor: pointer; color: #fff; }
.cal-pill:hover { filter: brightness(.92); }
.pill-out { background: #35c3dd; color: #073d47; }
.pill-in { background: #e23b3b; }
.pill-pick { background: #8ee05e; color: #1d4708; }
.pill-quote { background: #b9c3d4; color: #333c49; }

body.tv .cal-grid { background: #1a2029; border-color: #2a3342; }
body.tv .cal-head { background: #10141b; border-color: #2a3342; }
body.tv .cal-head div { color: #8ea0b8; font-size: 16px; }
body.tv .cal-week { border-color: #2a3342; }
body.tv .cal-day { border-color: #2a3342; min-height: 15vh; }
body.tv .cal-day.today { background: #26221a; }
body.tv .cal-date { color: #8ea0b8; font-size: 16px; }
body.tv .cal-pill { font-size: 16px; padding: 6px 10px; }
body.tv .board-legend { display: flex; color: #8ea0b8; font-size: 15px; }

/* typeahead result list */
.type-list { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); width: 100%; max-height: 420px; overflow-y: auto; }
.type-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.type-row:hover { background: #f0f4f9; }
.type-nm { flex: 1; min-width: 0; }
.type-pr { white-space: nowrap; font-weight: 600; }
tr.kit-child td { background: #fafbfc; color: #4a5462; }
