:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2430;
  --muted: #5d6878;
  --border: #dde1e7;
  --accent: #1f5fbf;
  --accent-soft: #e6eefb;
  --accent-text: #ffffff;
  --ok: #16794a;
  --ok-bg: #e5f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --err: #b42318;
  --err-bg: #fdeceb;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --surface-2: #232b35;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --border: #2f3946;
    --accent: #5b9cf5;
    --accent-soft: #1c2c44;
    --accent-text: #0d1117;
    --ok: #5fd39a;
    --ok-bg: #163527;
    --warn: #f2c15b;
    --warn-bg: #3a2f14;
    --err: #ff8a80;
    --err-bg: #3d1c1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12.5px; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { font-weight: 700; font-size: 16px; }
.company-pick select { min-width: 240px; font-weight: 600; }
.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.tabs button { background: none; border: none; color: var(--muted); font-weight: 600; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); }

main { padding-top: 18px; padding-bottom: 60px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.spacer { flex: 1; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; min-height: 34px;
}
textarea { min-height: 60px; resize: vertical; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { min-height: auto; width: 16px; height: 16px; }

button, .button {
  font: inherit; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 7px; padding: 6px 14px; min-height: 34px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--err); border-color: var(--err); }
button.link { background: none; border: none; color: var(--accent); padding: 4px 6px; min-height: auto; }
button:disabled { opacity: .45; cursor: not-allowed; }
.button.disabled { opacity: .45; pointer-events: none; }

.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.badge.final { background: var(--ok-bg); color: var(--ok); }
.flag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--warn-bg); color: var(--warn); margin-left: 6px; }
.flag.manual { background: var(--accent-soft); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 9px 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
tfoot th, tfoot td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.selected td { background: var(--accent-soft) !important; }
tr.inactive td { color: var(--muted); }

.layout-runs { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.layout-runs > * { min-width: 0; }
.run-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.run-list button { width: 100%; justify-content: space-between; background: transparent; color: var(--text); border-color: transparent; font-weight: 500; }
.run-list button.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.editor { border: 2px solid var(--accent); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.item-row { display: grid; grid-template-columns: 1fr 130px 28px; gap: 8px; align-items: center; margin-bottom: 6px; }
.stat-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 110px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13.5px; }
.stat-row .auto { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.result-box .line { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.result-box .line.big { font-weight: 700; font-size: 15px; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }

.notice { border-radius: 8px; padding: 9px 12px; margin-bottom: 10px; font-size: 13.5px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.err { background: var(--err-bg); color: var(--err); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

.layout-sharing { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.layout-sharing > * { min-width: 0; }
.layout-sharing td input.money { width: 70px; min-height: 30px; padding: 4px 7px; }
.layout-sharing td select.rest-pick { width: auto; min-height: 30px; padding: 4px 6px; }
.range-table th.sticky, .range-table td.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.range-table tr.clickable:hover td.sticky { background: var(--surface-2); }
.range-table th.day-col { text-align: center; font-size: 11px; padding: 4px 3px; min-width: 34px; }
.range-table th.day-col .dow { font-weight: 400; font-size: 10px; }
.range-table th.weekend { color: var(--accent); }
.range-table td.day-cell { text-align: center; padding: 4px 3px; font-variant-numeric: tabular-nums; border-left: 1px solid var(--border); }
.rc-work { font-weight: 650; } .rc-zero { color: var(--muted); } .rc-blank { background: var(--surface-2); }
.rc-f { background: var(--surface-2); color: var(--muted); } .rc-m { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.rc-mc { background: var(--warn-bg); color: var(--warn); font-weight: 650; }
.button.small, button.small { padding: 3px 8px; min-height: 0; font-size: 12px; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.subtabs button { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 600; }
.subtabs button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.bar { height: 10px; border-radius: 5px; background: var(--accent); opacity: .75; min-width: 2px; }
.rank { display: inline-block; min-width: 26px; text-align: center; font-weight: 700; }
tr.podium .rank { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 1px 6px; }
.up { color: var(--ok); font-weight: 700; } .down { color: var(--err); font-weight: 700; }
table.deductions td input.money { width: 90px; min-height: 30px; padding: 4px 7px; }
strong.neg { color: var(--err); }
.lang-toggle { background: transparent; color: var(--accent); border: 1px solid var(--border); padding: 5px 10px; min-height: 0; font-size: 13px; }
.day-sheet { margin-top: 14px; }
.day-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 600px; }
.day-grid .dow { font-size: 11.5px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.day { border: 1px solid var(--border); border-radius: 6px; padding: 4px 2px; min-height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.day.empty { border: none; }
.day .dd { font-size: 11px; color: var(--muted); }
.day .dv { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.day-m { background: var(--accent-soft); } .day-m .dv { color: var(--accent); }
.day-f { background: var(--surface-2); } .day-f .dv { color: var(--muted); }
.day-mc { background: var(--warn-bg); } .day-mc .dv { color: var(--warn); }
.day-zero .dv { color: var(--muted); font-weight: 400; }
.day-blank .dv { color: var(--border); }
.tier-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 28px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12.5px; }
.tier-row input, .layout-sharing aside input, .layout-sharing aside select { min-width: 0; width: 100%; }
table.compact th, table.compact td { padding: 5px 7px; font-size: 13px; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; max-width: 90vw;
}
.toast.err { background: var(--err); color: #fff; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

@media (max-width: 860px) {
  .layout-runs { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .layout-sharing { grid-template-columns: 1fr; }
  .tabs { margin-left: 0; }
  .company-pick select { min-width: 0; width: 100%; }
  .company-pick { flex: 1 1 100%; }
}

/* sign-in and invite pages */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px 24px; }
.auth-card h1 { font-size: 20px; margin: 4px 0 14px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card button { justify-content: center; margin-top: 4px; }
.auth-brand { font-weight: 700; color: var(--accent); font-size: 14px; }
.auth-card { position: relative; }
.auth-lang { position: absolute; top: 14px; right: 14px; }

/* app chrome added with accounts */
.banner { background: var(--warn-bg); color: var(--warn); text-align: center; padding: 8px 16px; font-size: 13.5px; font-weight: 600; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; font-weight: 600; font-size: 13.5px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-width: 220px; z-index: 20; display: grid; gap: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.user-menu .menu button { justify-content: flex-start; }
.link-box { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.link-box input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* Payroll variance */
td.notes { white-space: normal; min-width: 260px; font-size: 12.5px; color: var(--muted); }
td.notes.warn-text { color: var(--warn); }
#variance .card-head input[type=month] { width: auto; }
td.missing { color: var(--warn); font-weight: 600; }
.form-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 16px; }
.form-link { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
th.group { background: var(--surface-2); text-align: left; font-size: 12px; text-transform: none; }

/* HR letters: a preview of the letter as it will print */
.letter-paper { background: #fff; color: #1c2430; border: 1px solid var(--border); border-radius: 6px; padding: 16px 18px; font-size: 13px; line-height: 1.55; max-height: 520px; overflow: auto; }
.letter-paper .letter-meta { color: #5d6878; font-size: 12px; margin-bottom: 10px; }
.letter-paper .letter-to { margin-bottom: 10px; }
.letter-paper .letter-title { font-weight: 700; text-decoration: underline; margin-bottom: 10px; }
.letter-paper .letter-body { white-space: pre-wrap; }
.letter-paper mark { background: #fdf3dc; color: #8a5a00; border-radius: 3px; padding: 0 2px; }

/* Dashboard */
.dash-title { font-size: 18px; margin: 2px 0 12px; }
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.dash > * { min-width: 0; }
@media (max-width: 900px) { .dash { grid-template-columns: 1fr; } }
ul.todo, ul.plain-list { list-style: none; margin: 0; padding: 0; }
ul.todo li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
ul.todo li:first-child { border-top: 0; }
.todo-mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
ul.todo li.warn .todo-mark { background: var(--warn-bg); color: var(--warn); }
.todo-text { flex: 1; font-size: 13.5px; }
ul.plain-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
ul.plain-list li:first-child { border-top: 0; }
ul.plain-list .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.date-chip { font-size: 12px; font-weight: 650; background: var(--surface-2); border-radius: 6px; padding: 2px 7px; min-width: 52px; text-align: center; }
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .base { stroke: var(--muted); stroke-width: 1; }
svg.chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg.chart .tick.year { font-size: 10px; }
svg.chart .cap { font-size: 11.5px; font-weight: 650; fill: var(--text); }
svg.chart .bar { fill: var(--accent); }
svg.chart .bar.partial { opacity: 0.45; }
svg.chart .bar.hover { opacity: 0.8; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit:focus { outline: none; }
svg.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 1.5; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 7px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; z-index: 2; }
.chart-tip .tip-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); }
