/* Madix Time — white, dark text, restrained orange accents. */
:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --line: #e2e3e6;
  --text: #16181d;
  --muted: #555b66;           /* 7.1:1 on white */
  --accent: #c2410c;          /* orange, 5.2:1 on white; white text on it 5.2:1 */
  --accent-strong: #9a3412;
  --accent-soft: #fff4ec;
  --ok: #15803d;  --ok-soft: #ecfdf3;
  --warn: #a15c07; --warn-soft: #fff8e6;
  --bad: #b42318;  --bad-soft: #fef1f0;
  --info: #1d4ed8; --info-soft: #eff4ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: .25rem 0 .75rem; }
a { color: var(--accent-strong); }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  display: flex; align-items: center; gap: .75rem; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.topbar .who { color: var(--muted); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { max-width: 640px; margin: 0 auto; padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 1180px; padding-bottom: 3rem; }

.demo-banner { background: #111827; color: #fff; text-align: center; font-weight: 700; padding: .35rem; font-size: .85rem; letter-spacing: .04em; }
.net-banner { background: var(--bad); color: #fff; padding: .6rem 1rem; text-align: center; font-weight: 600; }

/* bottom tab bar (employee) — thumb reachable */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; padding: .7rem .25rem .8rem; font: inherit; font-size: .9rem; font-weight: 600;
  color: var(--muted); min-height: 56px; cursor: pointer; border-top: 3px solid transparent;
}
.tabbar button[aria-selected="true"] { color: var(--accent-strong); border-top-color: var(--accent); }
.tabbar .badge { margin-left: .25rem; }

/* admin tabs */
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 0 1rem; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: .7rem .8rem; font: inherit; font-weight: 600;
  color: var(--muted); white-space: nowrap; cursor: pointer; min-height: 48px;
}
.tabs button[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* ---------- components ---------- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.flat { box-shadow: none; background: var(--surface); }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat { background: var(--surface); border-radius: 12px; padding: .75rem .9rem; }
.stat .label { font-size: .85rem; color: var(--muted); }
.stat .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.confirmed .value { color: var(--ok); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* status */
.status-card { text-align: center; padding: 1.25rem 1rem; }
.status-label { display: inline-flex; align-items: center; gap: .5rem; font-size: 1.6rem; font-weight: 800; }
.dot { width: .8rem; height: .8rem; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.s-working .dot, .chip.s-working .dot { background: var(--ok); }
.s-on_break .dot, .chip.s-on_break .dot { background: var(--warn); }
.s-working .status-label { color: var(--ok); }
.s-on_break .status-label { color: var(--warn); }
.s-clocked_out .status-label { color: var(--text); }
.status-since { color: var(--muted); margin-top: .25rem; }
.big-clock { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: .4rem 0 0; }

.chip { display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px; padding: .15rem .6rem; font-size: .82rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.chip.s-working { background: var(--ok-soft); color: var(--ok); }
.chip.s-on_break { background: var(--warn-soft); color: var(--warn); }
.chip.s-clocked_out { background: var(--surface); color: var(--muted); }
.chip.approved { background: var(--ok-soft); color: var(--ok); }
.chip.completed, .chip.pending { background: var(--info-soft); color: var(--info); }
.chip.in_progress { background: var(--warn-soft); color: var(--warn); }
.chip.incomplete, .chip.flag, .chip.rejected { background: var(--bad-soft); color: var(--bad); }
.chip.void, .chip.cancelled { background: var(--surface); color: var(--muted); text-decoration: line-through; }
.chip.edited { background: var(--accent-soft); color: var(--accent-strong); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--accent); color: #fff; font-size: .78rem; line-height: 1.4em; text-align: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--bad); border-color: #f1c1bc; }
.btn.small { min-height: 38px; padding: .35rem .75rem; font-size: .9rem; border-radius: 10px; }
.btn.link { border: 0; background: none; color: var(--accent-strong); padding: .3rem .2rem; min-height: 38px; text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.punch-area { display: grid; gap: .8rem; margin: 1rem 0; }
.punch {
  width: 100%; min-height: 76px; border-radius: 18px; border: 2px solid transparent;
  font: inherit; font-size: 1.35rem; font-weight: 800; letter-spacing: .01em; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.punch.in { background: var(--accent); color: #fff; }
.punch.out { background: #1f2937; color: #fff; }
.punch.brk { background: var(--bg); color: var(--text); border-color: var(--text); }
.punch:active:not([disabled]) { transform: scale(.985); }
.punch[disabled] { opacity: .55; cursor: progress; }

/* confirmation / alerts */
.notice { border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.notice.ok { background: var(--ok-soft); border-color: #a6e3bd; color: #0f5d2c; }
.notice.warn { background: var(--warn-soft); border-color: #f5d48e; color: #6b3d03; }
.notice.bad { background: var(--bad-soft); border-color: #f5b5ae; color: #8a1a12; }
.notice.info { background: var(--info-soft); border-color: #bcd0fb; color: #173d99; }
.notice strong { display: block; font-size: 1.05rem; }
.confirm-banner { font-size: 1.1rem; }
.confirm-banner .tick { font-size: 1.4rem; font-weight: 900; margin-right: .35rem; }

#toast-region { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; padding: 0 1rem; }
.toast { background: #111827; color: #fff; border-radius: 12px; padding: .75rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 520px; font-weight: 600; pointer-events: auto; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }

/* forms */
label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-size: .88rem; color: var(--muted); font-weight: 400; margin-top: .2rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: .55rem .75rem; font: inherit; color: var(--text);
  border: 1px solid #b9bcc4; border-radius: 10px; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(194, 65, 12, .35); border-color: var(--accent); }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.checkbox input { width: 22px; height: 22px; accent-color: var(--accent); }
.err { color: var(--bad); font-weight: 600; font-size: .92rem; margin-top: .3rem; }

/* sheets / dialogs */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 1.2rem 1rem calc(1.2rem + env(safe-area-inset-bottom));
}
@media (min-width: 760px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; max-width: 760px; }
}
.sheet h2 { margin-bottom: .75rem; }
.sheet .actions { display: grid; gap: .6rem; margin-top: 1rem; }
@media (min-width: 760px) { .sheet .actions { display: flex; justify-content: flex-end; } }

/* lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: .8rem 0; }
.list > li:last-child { border-bottom: 0; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-weight: 700; }
.shift-line { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; padding: .4rem 0; }
.shift-line .times { font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fcfcfd; }
tr.void td { color: var(--muted); text-decoration: line-through; }
tfoot td { font-weight: 700; background: var(--surface); }
.people { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.person { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.person .name { font-weight: 800; font-size: 1.1rem; }
.linkbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; word-break: break-all; background: var(--surface); padding: .6rem; border-radius: 8px; border: 1px dashed var(--line); }
.week-nav { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.week-nav .title { text-align: center; font-weight: 700; }
.audit-change { font-size: .9rem; }
.audit-change del { color: var(--bad); }
.audit-change ins { color: var(--ok); text-decoration: none; font-weight: 700; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.spinner { display: inline-block; width: 1.1em; height: 1.1em; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(0,0,0,.15); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .punch:active:not([disabled]) { transform: none; } }

.auth-box { max-width: 420px; margin: 8vh auto 2rem; padding: 0 1rem; }
.auth-box .brand { font-size: 2rem; text-align: center; margin-bottom: .25rem; }
.auth-box .sub { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.spacer { flex: 1; }
details > summary { list-style: none; margin: .5rem 0; }
details > summary::-webkit-details-marker { display: none; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.card h3, section > h3 { margin-top: 1.25rem; }
.card h2 + .grid, .card .row + .grid { margin-top: .5rem; }
.shift-line .num, .day-head .num { white-space: nowrap; }
