:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #1c2530;
  --muted: #5f6c7b;
  --accent: #1f5fa8;
  --accent-soft: #e8f0fb;
  --ready: #1d7a46; --ready-bg: #e3f5ea;
  --unresolved: #b42323; --unresolved-bg: #fbe5e5;
  --review: #9a5b00; --review-bg: #fff1d6;
  --hold: #5b3fb0; --hold-bg: #ece6fb;
  --excluded: #6b7480; --excluded-bg: #eceff2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Header */
.topbar { background: #14304f; color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; margin-right: auto; }
.brand strong { font-size: 16px; letter-spacing: 0.2px; }
.brand span { font-size: 11.5px; opacity: 0.75; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { color: #d7e2ef; text-decoration: none; padding: 7px 12px; border-radius: 6px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav a.active { background: rgba(255,255,255,0.18); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #d7e2ef; }
.userbox button { background: transparent; border: 1px solid rgba(255,255,255,0.35); color: #fff; }

.banner { background: #fff4d6; color: #6b4b00; border-bottom: 1px solid #f0d9a0; padding: 8px 20px; font-size: 13px; }
.banner.info { background: #e8f0fb; color: #1f3d66; border-color: #c9dbf3; }
.banner .inner { max-width: 1280px; margin: 0 auto; }

main { max-width: 1280px; margin: 0 auto; padding: 18px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { margin: 2px 0 0; }

/* Week picker */
.weekpick { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 6px; }
.weekpick .range { font-weight: 600; min-width: 170px; text-align: center; }
.weekpick input[type=date] { border: none; font: inherit; color: var(--muted); width: 130px; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card h2 { display: flex; align-items: center; gap: 10px; }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi-tile .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-tile .value.warn { color: var(--review); }
.kpi-tile .value.bad { color: var(--unresolved); }
.kpi-tile .value.good { color: var(--ready); }
.kpi-tile .value.compact { font-size: 17px; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted); background: #f8fafc; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #f7f9fc; }
tr.clickable { cursor: pointer; }
tr.selected { background: var(--accent-soft) !important; }
td.actions { white-space: nowrap; }
tfoot td { font-weight: 600; background: #f8fafc; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap; }
.badge.READY { color: var(--ready); background: var(--ready-bg); }
.badge.UNRESOLVED { color: var(--unresolved); background: var(--unresolved-bg); }
.badge.REVIEW { color: var(--review); background: var(--review-bg); }
.badge.HOLD { color: var(--hold); background: var(--hold-bg); }
.badge.EXCLUDED { color: var(--excluded); background: var(--excluded-bg); }
.badge.neutral { color: var(--muted); background: var(--excluded-bg); }
.badge.union { color: #1f5fa8; background: var(--accent-soft); }
.badge.FINAL { color: #fff; background: var(--ready); }

/* Buttons & forms */
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 6px; cursor: pointer; line-height: 1.3; }
button:hover, .btn:hover { background: #f1f4f8; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #17508f; }
button.danger { color: var(--unresolved); border-color: #e9b9b9; }
button.small, .btn.small { padding: 3px 8px; font-size: 12.5px; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: #fff; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #9dbdf0; outline-offset: 1px; }
input[type=number] { width: 90px; }
input[type=checkbox] { width: auto; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.field > input, label.field > select { color: var(--text); }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; }

/* Drop zone */
.dropzone { border: 2px dashed #b9c6d6; border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: #fbfcfe; transition: background 0.15s, border-color 0.15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { display: none; }

/* Detail panel */
.panel { position: fixed; top: 0; right: 0; height: 100%; width: min(480px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(16,24,40,0.12); padding: 18px 20px; overflow-y: auto; z-index: 50; }
.panel h2 { margin-bottom: 2px; }
.panel .close { position: absolute; top: 12px; right: 12px; }
.punch-list { list-style: none; margin: 0; padding: 0; }
.punch-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dotted var(--border); }
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,0.35); z-index: 40; }
.modal { position: fixed; top: 8vh; left: 50%; transform: translateX(-50%); width: min(560px, 94vw); max-height: 84vh; overflow-y: auto; background: var(--surface); border-radius: 10px; box-shadow: 0 20px 50px rgba(16,24,40,0.3); padding: 20px 22px; z-index: 60; }

/* Timesheets */
.timesheet { page-break-inside: avoid; break-inside: avoid; margin-bottom: 18px; }
.timesheet .ts-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--text); padding-bottom: 4px; margin-bottom: 6px; }
.timesheet .ts-head strong { font-size: 15px; }
.timesheet table { font-size: 13px; }
.timesheet th { background: #fff; position: static; }
.timesheet td.num, .timesheet th.num { width: 62px; }
.ts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); gap: 16px; }
@media (max-width: 640px) { .ts-grid { grid-template-columns: 1fr; } }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: 12px; box-shadow: 0 12px 40px rgba(16,24,40,0.18); padding: 26px 28px; }
.login-card h1 { margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.error { color: var(--unresolved); font-size: 13px; }

/* Toasts */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1c2530; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13.5px; animation: fade 0.2s ease-out; }
.toast.error { background: var(--unresolved); }
.toast.success { background: var(--ready); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { background: var(--excluded-bg); border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.pill button { border: none; background: transparent; padding: 0 2px; color: var(--muted); font-size: 13px; }
.pill button:hover { color: var(--unresolved); background: transparent; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.status-dot.READY { background: var(--ready); } .status-dot.UNRESOLVED { background: var(--unresolved); }
.status-dot.REVIEW { background: var(--review); } .status-dot.HOLD { background: var(--hold); } .status-dot.EXCLUDED { background: var(--excluded); }
.day-cells span { display: inline-block; width: 18px; height: 18px; border-radius: 4px; text-align: center; font-size: 11px; line-height: 18px; margin-right: 2px; background: var(--excluded-bg); color: var(--muted); }
.day-cells span.READY { background: var(--ready-bg); color: var(--ready); }
.day-cells span.UNRESOLVED { background: var(--unresolved-bg); color: var(--unresolved); }
.day-cells span.REVIEW { background: var(--review-bg); color: var(--review); }
.day-cells span.HOLD { background: var(--hold-bg); color: var(--hold); }
.day-cells span.PTO { background: var(--accent-soft); color: var(--accent); }

@media print {
  .topbar, .banner, .toolbar, .page-head .weekpick, .no-print, #toasts, .panel, .overlay { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  .ts-grid { display: block; }
  .timesheet { border: 1px solid #999; padding: 10px 12px; margin: 0 0 14px; }
  th, td { padding: 4px 6px; }
}
