/* RENK CL Attendance — design tokens + components. Light and dark themes. */
:root {
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ecebe5;
  --surface-3: #e2e0d8;
  --text: #1b1c19;
  --text-2: #4a4b45;
  --muted: #6e6f67;
  --border: #dbd9d0;
  --border-strong: #c3c1b6;

  --accent: #0f6e5a;
  --accent-hover: #0b5a49;
  --accent-soft: #dcefe8;
  --on-accent: #ffffff;

  --under: #b4361a;
  --under-soft: #fbe5dd;
  --ok: #1b7a3d;
  --ok-soft: #dff2e3;
  --over: #2457c5;
  --over-soft: #e1e9fb;
  --warn: #946200;
  --warn-soft: #fbf0d4;

  --shift-a: #0f766e;
  --shift-b: #c2680a;
  --shift-c: #4f46c8;
  --shift-g: #be3a74;

  --bar-track: #e7e5de;
  --shadow: 0 1px 2px rgb(30 28 20 / 0.06), 0 4px 16px rgb(30 28 20 / 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311;
    --surface: #1b1c1a;
    --surface-2: #242522;
    --surface-3: #2e2f2b;
    --text: #ecebe5;
    --text-2: #c6c5bd;
    --muted: #9a998f;
    --border: #33342f;
    --border-strong: #46473f;
    --accent: #3cbf98;
    --accent-hover: #5ad2ae;
    --accent-soft: #173a30;
    --on-accent: #08130f;
    --under: #ff7f5c;
    --under-soft: #3d1f17;
    --ok: #57d07f;
    --ok-soft: #173322;
    --over: #82a8ff;
    --over-soft: #1c2742;
    --warn: #f0bd4f;
    --warn-soft: #3a2e12;
    --shift-a: #2dc5b4;
    --shift-b: #f2a43a;
    --shift-c: #9b95ff;
    --shift-g: #f07bb0;
    --bar-track: #2b2c28;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121311;
  --surface: #1b1c1a;
  --surface-2: #242522;
  --surface-3: #2e2f2b;
  --text: #ecebe5;
  --text-2: #c6c5bd;
  --muted: #9a998f;
  --border: #33342f;
  --border-strong: #46473f;
  --accent: #3cbf98;
  --accent-hover: #5ad2ae;
  --accent-soft: #173a30;
  --on-accent: #08130f;
  --under: #ff7f5c;
  --under-soft: #3d1f17;
  --ok: #57d07f;
  --ok-soft: #173322;
  --over: #82a8ff;
  --over-soft: #1c2742;
  --warn: #f0bd4f;
  --warn-soft: #3a2e12;
  --shift-a: #2dc5b4;
  --shift-b: #f2a43a;
  --shift-c: #9b95ff;
  --shift-g: #f07bb0;
  --bar-track: #2b2c28;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  font-feature-settings: "tnum" 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hide { display: none !important; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.brand b { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 6px; }
.who { padding: 0 8px; font-size: 13px; }
.who b { display: block; }
.role-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.main { min-width: 0; padding: 22px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--under); border-color: color-mix(in srgb, var(--under) 45%, var(--border)); }
.btn.danger:hover { background: var(--under-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 16px; }
.btn svg { width: 16px; height: 16px; }

.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  min-width: 0; width: 100%;
}
textarea.input { height: auto; padding: 8px 10px; }
.input:focus, .btn:focus-visible, .seg button:focus-visible, .nav a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 34px; cursor: pointer; font-weight: 600; color: var(--text-2); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.seg button small { font-weight: 400; opacity: 0.8; margin-left: 4px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-32 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

.context-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.context-bar .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.context-bar .input[type="date"] { width: 160px; }
.clock { font-family: var(--mono); font-weight: 600; font-size: 15px; }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin-bottom: 18px; }
.kpis.card > div { padding: 14px 18px; border-right: 1px solid var(--border); }
.kpis.card > div:last-child { border-right: 0; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.kpi-sub { font-size: 13px; color: var(--muted); }
.kpi-value.under { color: var(--under); }
.kpi-value.over { color: var(--over); }
.kpi-value.ok { color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; background: var(--surface); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tbody tr.clickable { cursor: pointer; }
tr.sub td { font-size: 14px; }
tr.sub td:first-child { padding-left: 34px; color: var(--text-2); }
tr.parent td:first-child { font-weight: 600; }
tfoot td { font-weight: 650; border-bottom: 0; border-top: 1px solid var(--border-strong); }
.scroll-y { max-height: 560px; overflow: auto; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.under { color: var(--under); background: var(--under-soft); }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.over { color: var(--over); background: var(--over-soft); }
.pill.none { color: var(--muted); background: var(--surface-2); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
.shift-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

/* attainment bar: fill = present, tick = required */
.meter { position: relative; height: 8px; background: var(--bar-track); border-radius: 4px; min-width: 80px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--muted); }
.meter.under > i { background: var(--under); }
.meter.ok > i { background: var(--ok); }
.meter.over > i { background: var(--over); }
.meter > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 1px; }

/* ---------- punch screen ---------- */
.punch-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.punch-box { padding: 22px; }
.punch-form { display: flex; gap: 10px; }
.punch-input {
  flex: 1; min-width: 0; height: 68px; padding: 0 18px;
  font: 600 34px/1 var(--mono); letter-spacing: 0.08em;
  border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); color: var(--text);
}
.punch-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.punch-input::placeholder { color: var(--muted); opacity: 0.6; letter-spacing: 0.02em; font-weight: 500; font-size: 22px; }
.punch-hint { margin-top: 10px; color: var(--muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.punch-hint label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.result { margin-top: 18px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.result-banner { padding: 12px 18px; font-weight: 650; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.result-banner svg { width: 22px; height: 22px; flex: none; }
.result.ok .result-banner { background: var(--ok-soft); color: var(--ok); }
.result.dup .result-banner { background: var(--warn-soft); color: var(--warn); }
.result.bad .result-banner { background: var(--under-soft); color: var(--under); }
.result.info .result-banner { background: var(--surface-2); color: var(--text); }
.result-body { padding: 16px 18px; background: var(--surface); }
.person { display: flex; gap: 16px; align-items: flex-start; }
.avatar { width: 56px; height: 56px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 20px; color: var(--text-2); flex: none; }
.person-name { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.person-card { font-family: var(--mono); color: var(--muted); font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 18px; margin-top: 16px; }
.facts div span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.facts div b { font-weight: 600; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.shift-count { display: flex; align-items: baseline; gap: 10px; }
.shift-count .big { font-size: 44px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.recent-list { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.recent-list li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--border); }
.recent-list li:last-child { border-bottom: 0; }
.recent-list .t { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.recent-list .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-list .d { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--border-strong); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 50; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.5; box-shadow: var(--shadow); white-space: nowrap;
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 11px 12px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgb(10 10 8 / 0.45); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--under); font-size: 13px; margin-top: 10px; }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-weight: 500; }
.toast.err { background: var(--under); color: #fff; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(400px, 100%); padding: 28px; }
.auth-card .brand { padding: 0 0 20px; }
.auth-card form { display: grid; gap: 14px; }

.theme-btn { justify-content: flex-start; width: 100%; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .punch-layout, .grid-2, .grid-32 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .seg button small { display: none; }
  .seg button { padding: 0 14px; }
  .punch-box { padding: 14px; }
  .punch-form .btn.lg { padding: 0 14px; }
  .context-bar .input[type="date"] { width: 150px; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); gap: 4px; }
  .brand { padding: 0 8px 0 0; }
  .brand span, .brand b { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; }
  .who { display: none; }
  .theme-btn { width: auto; }
  .theme-btn span { display: none; }
  .main { padding: 16px 16px 60px; }
  .punch-input { height: 58px; font-size: 26px; }
  .form-grid { grid-template-columns: 1fr; }
  .kpis.card > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .meter { min-width: 70px; }
}
@media print {
  .side, .context-bar .btn, .no-print { display: none !important; }
  .shell { display: block; }
}
