:root { --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb; --bg: #f6f7f5; --panel: #fff; --accent: #1d4ed8; --accent-ink: #fff; --danger: #b91c1c; --ok: #166534; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
code { background: #eef0f3; padding: 1px 4px; border-radius: 3px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; color: var(--ink); font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 10px; border-radius: 6px; color: var(--ink); }
.topbar nav a.active, .topbar nav a:hover { background: #eef2ff; color: var(--accent); text-decoration: none; }
.topbar .user { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.container { max-width: 1500px; margin: 0 auto; padding: 20px 24px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.card h2 { margin-top: 0; }
.cols { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.cols > table { flex: 1 1 320px; }
.banner { background: #fff7d6; border: 1px solid #f2d36b; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.flash-info { background: #eef2ff; border-color: #c7d2fe; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.flash-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #e5e7eb; }
.tag-open { background: #fef3c7; color: #92400e; }
.tag-finalized { background: #dcfce7; color: var(--ok); }

.btn { display: inline-block; padding: 6px 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; line-height: 1.3; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

table.grid { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { background: #f1f3f5; font-weight: 600; white-space: nowrap; }
table.grid tfoot th { background: #f8fafc; }
table.grid caption { text-align: left; font-weight: 600; padding: 6px 0; }
table.grid.compact th, table.grid.compact td { padding: 4px 8px; font-size: 13px; }
table.grid.narrow { width: auto; min-width: 360px; }
table.grid tr.excluded td { opacity: 0.45; }
table.grid tr.muted td { color: var(--muted); }
.num, td.num, th.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table.payroll input.num { width: 86px; }
input, select, textarea { font: inherit; padding: 5px 7px; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; }
input.num { text-align: right; }
input[readonly] { background: #f8fafc; color: var(--muted); }
input[type=checkbox] { width: 16px; height: 16px; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 12px 16px 16px; margin: 0 0 14px; }
.form legend { font-weight: 600; padding: 0 6px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; margin-top: 18px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 10px; }
.form.narrow { max-width: 520px; }
.form.narrow label { margin-bottom: 10px; }
.form textarea { width: 100%; }
.filters label { display: inline-flex; gap: 6px; align-items: center; }
.login-box { max-width: 380px; margin: 60px auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login-box label { display: block; margin-bottom: 12px; }
.login-box input { width: 100%; }
ol.rules li { margin-bottom: 14px; }
ol.rules li { line-height: 1.7; font-size: 15px; }
ol.rules .where { display: block; color: var(--muted); font-size: 13px; }

/* Pay stubs */
.print-page { background: #e5e7eb; }
.print-bar { display: flex; gap: 12px; align-items: center; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.stub { position: relative; width: 8.5in; min-height: 5.5in; margin: 16px auto; padding: 0.5in 0.55in; background: #fff; color: #000; font-size: 11.5px; line-height: 1.35; box-shadow: 0 1px 4px rgba(0,0,0,.12); page-break-after: always; }
.stub:last-child { page-break-after: auto; }
.draft-mark { position: absolute; top: 0.2in; right: 0.4in; color: #b91c1c; border: 2px solid #b91c1c; padding: 2px 8px; font-weight: 700; letter-spacing: 1px; }
.stub-company { margin-bottom: 0.35in; }
.stub-company-name { font-weight: 700; font-size: 13px; }
.stub-employee-addr { margin: 0 0 0.3in 0.1in; }
table.stub-meta { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
table.stub-meta td, table.stub-meta th { padding: 3px 4px; text-align: left; }
table.stub-meta.bordered th { border-bottom: 1px solid #000; font-weight: 600; }
table.stub-meta .stub-title { font-weight: 700; font-size: 13px; }
table.stub-meta .right { text-align: right; }
.stub-cols { display: flex; gap: 14px; align-items: flex-start; }
table.stub-table { border-collapse: collapse; width: 100%; margin: 10px 0 4px; }
table.stub-table.earnings { flex: 3; }
table.stub-table.sick { flex: 2; }
table.stub-table th { text-align: left; border-bottom: 1px solid #000; padding: 3px 4px; font-weight: 600; }
table.stub-table td { padding: 2px 4px; }
table.stub-table tr.total td { border-top: 1px solid #000; font-weight: 600; }
table.stub-table.netpay { margin-top: 14px; border-top: 2px solid #000; }
table.stub-table.netpay th { border: 0; font-size: 12.5px; padding-top: 6px; }
table.stub-table th.num, table.stub-table td.num { text-align: right; }
.stub-footer { margin-top: 0.5in; border-top: 1px solid #000; padding-top: 4px; font-size: 10.5px; text-align: center; }

@media print {
  .no-print { display: none !important; }
  body, .print-page { background: #fff; }
  .stub { margin: 0; box-shadow: none; width: auto; min-height: auto; padding: 0.3in 0.2in; }
  @page { size: letter; margin: 0.4in; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .container { padding: 12px; }
  .stub { width: auto; padding: 16px; }
  .stub-cols { flex-direction: column; }
}

/* payroll grid tweaks */
table.payroll td:nth-child(2) { white-space: nowrap; }
table.payroll th, table.payroll td { padding: 5px 6px; }

