:root {
  --ink: #14213d;
  --ink-2: #2b3a55;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #eef2f6;
  --bg: #f5f7fa;
  --card: #ffffff;
  --accent: #0f766e;
  --accent-2: #0d9488;
  --accent-soft: #e6f4f2;
  --green: #16a34a;
  --green-soft: #e8f6ec;
  --blue: #0284c7;
  --blue-soft: #e0f2fe;
  --amber: #b45309;
  --amber-dot: #eab308;
  --amber-soft: #fef3e2;
  --red: #dc2626;
  --red-soft: #fdecea;
  --slate: #334155;
  --grey: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 1px 1px rgba(20, 33, 61, .04);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink-2); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--ink); margin: 0; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 40px; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #cbd5e1; 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 10px 18px; color: #fff; font-weight: 700; font-size: 15.5px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #1f3157; display: grid; place-items: center; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: #8fa3c4; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cbd5e1; font-weight: 500; }
.nav a:hover { background: #1c2c4f; text-decoration: none; color: #fff; }
.nav a.active { background: #22365f; color: #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; background: #f59e0b; color: #1f2937; border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 0 7px; line-height: 19px; }
.nav-sep { height: 1px; background: #24365b; margin: 10px 8px; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #24365b; font-size: 12.5px; }
.side-foot b { color: #fff; display: block; font-weight: 600; }
.side-foot button { background: none; border: 0; color: #8fd3c9; padding: 0; cursor: pointer; margin-top: 6px; }
.main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: none; }

.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); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; white-space: nowrap; box-shadow: var(--shadow); }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ok { color: var(--green); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.ghost { box-shadow: none; background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #eef2f6; }
.input, select.input, textarea.input { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; min-width: 0; }
.input:focus, .btn:focus-visible { outline: 2px solid #99d5cd; outline-offset: 1px; border-color: var(--accent); }
textarea.input { width: 100%; min-height: 70px; resize: vertical; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.seg button { border: 0; background: none; padding: 6px 11px; cursor: pointer; border-right: 1px solid var(--line); font-weight: 500; color: var(--ink-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.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(--line-2); }
.section { margin-top: 22px; }
.section > h2 { margin-bottom: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
button.stat { text-align: left; cursor: pointer; font: inherit; }
button.stat.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------- status ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.s-working { --c: var(--green); --cs: var(--green-soft); }
.s-idle, .s-prompt { --c: var(--amber-dot); --cs: var(--amber-soft); }
.s-away { --c: var(--red); --cs: var(--red-soft); }
.s-break { --c: var(--blue); --cs: var(--blue-soft); }
.s-checked_out { --c: var(--grey); --cs: #f1f5f9; }
.s-closed, .s-offline { --c: var(--slate); --cs: #e2e8f0; }
.s-not_in { --c: #cbd5e1; --cs: #f8fafc; }
.pill { background: var(--cs); color: var(--ink-2); }
.pill .dot, .dot.s { background: var(--c); }
.s-working .dot { box-shadow: 0 0 0 3px rgba(22, 163, 74, .16); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #f1f5f9; color: var(--ink-2); white-space: nowrap; }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--red-soft); color: var(--red); }
.chip.good { background: var(--green-soft); color: var(--green); }
.chip.info { background: var(--blue-soft); color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.bar { height: 7px; background: #eef2f6; border-radius: 99px; overflow: hidden; position: relative; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.full i { background: var(--green); }
.bar.over i { background: linear-gradient(90deg, var(--green) var(--split), #65a30d var(--split)); }

/* ---------- live board ---------- */
.team-block { margin-top: 20px; }
.team-block > h3 { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; margin-bottom: 8px; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.person { padding: 14px 15px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, box-shadow .15s; color: inherit; }
.person:hover { border-color: #b8c4d4; box-shadow: 0 3px 10px rgba(20, 33, 61, .07); text-decoration: none; }
.person-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.person-name { font-weight: 650; color: var(--ink); }
.person-sub { color: var(--muted); font-size: 12.5px; }
.person-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; gap: 8px; }
.person-meta b { color: var(--ink); font-weight: 650; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f8fafc; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--ink); }
table.t td.r, table.t th.r { text-align: right; }
table.t tfoot td { font-weight: 650; background: #fafbfc; border-top: 1px solid var(--line); }
.cell-name b { color: var(--ink); font-weight: 600; display: block; }
.cell-name span { color: var(--muted); font-size: 12.5px; }
.worked-cell { min-width: 150px; }
.worked-cell .bar { margin-top: 5px; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }

/* ---------- timeline ---------- */
.tl { position: relative; height: 30px; background: repeating-linear-gradient(90deg, #f1f5f9 0, #f1f5f9 1px, transparent 1px, transparent calc(100% / 9)); background-color: #fafbfc; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.tl.mini { height: 14px; border-radius: 4px; }
.tl .seg-i { position: absolute; top: 0; bottom: 0; min-width: 2px; }
.tl .k-work { background: #22c55e; }
.tl .k-work.corr { background: repeating-linear-gradient(45deg, #22c55e, #22c55e 4px, #86efac 4px, #86efac 8px); }
.tl .k-break { background: #38bdf8; }
.tl .k-away { background: #ef4444; }
.tl .idle-mark { position: absolute; top: 0; height: 6px; background: var(--amber-dot); }
.tl .now-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.tl-scale { position: relative; height: 18px; font-size: 11px; color: var(--muted); margin-top: 3px; }
.tl-scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 9px; border-radius: 2px; display: inline-block; }

.day-row { display: grid; grid-template-columns: 130px 1fr 180px; gap: 16px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.day-row:hover { background: #f8fafc; }
.day-row.sel { background: var(--accent-soft); }
.day-row:last-child { border-bottom: 0; }
.day-row .d b { display: block; color: var(--ink); }
.day-row .w { text-align: right; }
.day-row .w b { color: var(--ink); }
.day-row.off { color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 550; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.list li:last-child { border-bottom: 0; }
.list .when { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 128px; }

/* ---------- forms / modal ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 23, 42, .25); font-size: 13.5px; max-width: 360px; }
.toast.error { background: #991b1b; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #1f3157 0, var(--ink) 55%); }
.login { width: min(380px, 100%); background: #fff; border-radius: 14px; padding: 28px 28px 24px; box-shadow: 0 30px 60px rgba(0, 0, 0, .3); }
.login .brand { color: var(--ink); padding: 0 0 18px; }
.login .brand small { color: var(--muted); }
.login .brand-mark { background: var(--ink); }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login .btn { width: 100%; padding: 10px; }

/* ---------- download page ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 40px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.rules .card b { color: var(--ink); display: block; margin-bottom: 4px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .4); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
  .main { padding: 18px 14px 50px; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .day-row { grid-template-columns: 96px 1fr; }
  .day-row .w { grid-column: 1 / -1; text-align: left; }
}

table.t td.num, table.t td .num { white-space: nowrap; }
.cell-name { min-width: 150px; }
.page-head > div:first-child { flex: 1 1 260px; }
.toolbar { min-width: 0; justify-content: flex-end; }
table.t.compact th, table.t.compact td { padding-left: 9px; padding-right: 9px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.btn svg { width: 18px; height: 18px; flex: none; }
