@font-face { font-family: "Geist"; src: url("../fonts/Geist-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist"; src: url("../fonts/Geist-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("../fonts/GeistMono-500.ttf") format("truetype"); font-weight: 500; font-display: swap; }

:root {
  --bg: #070708;
  --surface: #111113;
  --surface-2: #18181b;
  --line: #26262a;
  --text: #f4f3ef;
  --muted: #9a9aa2;
  --ember: #ff5b22;
  --ember-soft: rgba(255, 91, 34, 0.14);
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Geist", system-ui, sans-serif;
}
a { color: var(--text); text-decoration-color: var(--ember); text-underline-offset: 3px; }
a:hover { color: var(--ember); }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.mono, .label { font-family: "Geist Mono", ui-monospace, monospace; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.small { font-size: 13px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar .inner { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { height: 22px; display: block; }
.brand span { font-family: "Geist Mono", monospace; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.nav a:hover, .nav a.on { color: var(--text); background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who form { margin: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 64px; }
.narrow { max-width: 460px; margin: 8vh auto; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--muted); font-size: 14px; }
.messages .success { border-color: var(--good); background: var(--good-soft); }
.messages .error { border-color: var(--bad); background: var(--bad-soft); }
.messages .warning { border-color: var(--warn); background: var(--warn-soft); }

/* Layout bits */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card, .grid + .card, .grid + .grid { margin-top: 16px; }
.card > h2:first-child { margin-bottom: 14px; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > h2 { padding: 16px 20px 0; }
.stat .value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.callout { border: 1px solid var(--ember); background: var(--ember-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; }
.callout p:last-child { margin: 0; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 20px; margin: 0; }
dl.facts dt { font-family: "Geist Mono", monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
dl.facts dd { margin: 2px 0 0; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-family: "Geist Mono", monospace; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
tr[id] { scroll-margin-top: 90px; }
tr:target td { background: var(--ember-soft); }
.row-line { padding: 8px 0; border-bottom: 1px solid var(--line); }
.row-line:last-of-type { border-bottom: 0; }
.row-line form { display: inline; margin: 0 0 0 6px; }
td form { margin: 0; }

/* Pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); }
.pill.active, .pill.paid, .pill.locked, .pill.ok { color: var(--good); background: var(--good-soft); border-color: transparent; }
.pill.review, .pill.scheduled, .pill.due { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.invited, .pill.onboarding, .pill.promised, .pill.draft { color: var(--ember); background: var(--ember-soft); border-color: transparent; }
.pill.exited, .pill.forfeited, .pill.cancelled { color: var(--muted); }

/* Buttons */
.btn, button { display: inline-flex; align-items: center; gap: 6px; justify-content: center; font: inherit; font-size: 14px; font-weight: 600; line-height: 1; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover, button:hover { border-color: var(--muted); color: var(--text); }
.btn.primary, button.primary { background: var(--ember); border-color: var(--ember); color: #0a0a0b; }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
.btn.danger, button.danger { color: var(--bad); }
.btn.small, button.small { padding: 6px 10px; font-size: 13px; }
.btn.link, button.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); font-weight: 400; }
.btn.block, button.block { width: 100%; padding: 13px; }
.btn.google { background: var(--text); color: #0a0a0b; border-color: var(--text); }

/* Forms */
form > div, .field { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=month], input[type=number], input[type=tel], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ember); outline-offset: -1px; border-color: transparent; }
input[type=file] { font-size: 14px; color: var(--muted); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ember); vertical-align: middle; margin-right: 6px; }
.helptext { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--bad); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.form-grid > div { margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }
.inline-form input.days { width: 72px; text-align: right; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 4px; margin: 0 0 18px; }
legend { padding: 0 6px; font-weight: 600; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details[open] summary { margin-bottom: 12px; }

.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.empty { color: var(--muted); padding: 20px; text-align: center; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .wrap { padding: 0 16px; }
  .topbar .inner { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .hide-sm { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
}

/* Calendar (employee attendance) */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-h { font-family: "Geist Mono", monospace; font-size: 11px; color: var(--muted); text-align: center; }
.cal-d { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 64px; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-d span { font-weight: 600; font-size: 13px; }
.cal-d small { font-size: 11px; color: var(--muted); line-height: 1.2; }
.cal-d.off, .cal-d.future { background: transparent; }
.cal-d.holiday { border-color: var(--warn); }
.cal-d.absent, .cal-d.unpaid, .cal-d.half_unpaid { border-color: var(--bad); }
.cal-d.leave, .cal-d.half_leave { border-color: var(--good); }
.cal-d.wfh small, .cal-d.present:not(.default) small { color: var(--text); }
.cal-d.today { outline: 2px solid var(--ember); }

/* Attendance grid (HR) */
.grid-table th.c, .grid-table td.c { padding: 6px 2px; text-align: center; min-width: 26px; font-size: 12px; }
.att.off { background: rgba(255, 255, 255, 0.02); }
.att.default { color: var(--muted); }
.att.holiday { color: var(--warn); }
.att.absent, .att.unpaid, .att.half_unpaid { color: var(--bad); font-weight: 600; }
.att.leave, .att.half_leave { color: var(--good); font-weight: 600; }
.att.wfh { color: var(--ember); }
@media (max-width: 640px) { .cal { gap: 3px; } .cal-d { min-height: 48px; padding: 4px; } .cal-d small { display: none; } }
.grid-table td:first-child { white-space: nowrap; }

/* Email threads */
.mail { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.mail.out { background: var(--surface-2); }
.mail-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.mail-body { white-space: normal; word-break: break-word; }
textarea.mono { font-family: "Geist Mono", monospace; font-size: 12px; }
.checks > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 0; }
.readonly-banner { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 16px; font-size: 13px; }
body.readonly main a.btn[href$="/edit/"], body.readonly main a.btn[href*="/new/"], body.readonly main a.btn[href$="/add/"], body.readonly main a.btn[href*="/admin/"] { display: none; }
body.readonly main form[method="post"] button, body.readonly main form[method="post"] [type="submit"] { display: none !important; }
