:root {
  --bg: #0f172a;
  --bg2: #111c33;
  --panel: #16213b;
  --panel2: #1c2a4a;
  --line: #24365c;
  --text: #e5ecf6;
  --muted: #8ea0bf;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--info); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
p.sub { margin: 0 0 18px; color: var(--muted); }
code { font-family: var(--mono); background: var(--bg2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
[hidden] { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel); }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .badge { margin-left: auto; }
.side .foot { margin-top: auto; padding: 10px; color: var(--muted); font-size: 12px; }
.side .foot .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--bad); }
.side .foot .dot.on { background: var(--ok); }
.main { padding: 26px 30px 60px; max-width: 1400px; }
.topbar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* cards */
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card.section { margin-bottom: 18px; }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat .h { color: var(--muted); font-size: 12px; }
.stat.ok .v { color: var(--ok); } .stat.warn .v { color: var(--warn); } .stat.bad .v { color: var(--bad); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: rgba(255,255,255,.02); }
.tbl .mono { font-family: var(--mono); font-size: 12.5px; }
.tbl .r { text-align: right; }
.tbl .muted { color: var(--muted); }
.wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.pill.working { background: rgba(34,197,94,.15); color: var(--ok); }
.pill.away { background: rgba(245,158,11,.15); color: var(--warn); }
.pill.off { background: rgba(142,160,191,.15); color: var(--muted); }
.pill.late { background: rgba(239,68,68,.15); color: var(--bad); }
.pill.info { background: rgba(56,189,248,.15); color: var(--info); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }

/* forms */
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--text); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); border-color: rgba(239,68,68,.4); }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.field .hint { color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.in { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; outline: none; }
.in:focus { border-color: var(--accent); }
textarea.in { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form .full { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.switch input { width: 18px; height: 18px; }
.note { border-left: 3px solid var(--info); background: rgba(56,189,248,.08); padding: 10px 12px; border-radius: 6px; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.note.warn { border-color: var(--warn); background: rgba(245,158,11,.08); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.msg-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--bg2); }
.msg-item .head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.msg-item .vars { color: var(--muted); font-size: 12px; }
.msg-item .vars code { cursor: pointer; }
.preview { white-space: pre-wrap; background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; padding: 10px; font-size: 13px; margin-top: 8px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.ev { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.ev.work_start { background: var(--ok); } .ev.work_end { background: var(--muted); } .ev.break_start { background: var(--warn); } .ev.break_end { background: var(--info); } .ev.late { background: var(--bad); } .ev.reminder { background: #a855f7; } .ev.auto_close { background: #64748b; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .side .foot { display: none; } .main { padding: 18px 14px 40px; } }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; }
.auth h1 { margin-bottom: 4px; }
.auth .form { grid-template-columns: 1fr; }
.err { color: var(--bad); font-size: 13px; }

/* toast */
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 380px; z-index: 50; }
.toast.ok { border-color: var(--ok); } .toast.bad { border-color: var(--bad); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 460px; }
.modal h3 { margin-bottom: 10px; }
.modal .actions { justify-content: flex-end; margin-top: 16px; }
