/* Sama Time. Native CSS, light/dark via variables.
   Shape rule: controls 8px, cards/dialogs 12px, shift pills 6px, status chips full-pill. */

/* Brand palette:
   Love Myself #8b0018 | Early Bird #ffd0d7 | Baby #ffe9ec | Make Me Blush #e68686
   Clean Girl #f7f2f0 | Mystic #2e2e2e | White #ffffff
   Semantic states (ok / warn / err) keep their own hues so "published" never reads as "error". */
:root {
  --bg: #f7f2f0;            /* Clean Girl */
  --surface: #ffffff;       /* White */
  --surface-2: #f7f2f0;     /* Clean Girl */
  --border: #efe2e0;
  --border-strong: #e0cdca;
  --text: #2e2e2e;          /* Mystic */
  --muted: #6e6462;
  --accent: #8b0018;        /* Love Myself */
  --accent-hover: #70000f;
  --accent-ink: #ffffff;
  --accent-soft: #ffe9ec;   /* Baby */
  --accent-mid: #ffd0d7;    /* Early Bird */
  --blush: #e68686;         /* Make Me Blush */
  --ok: #2f7a4d;
  --ok-soft: #e4f3ea;
  --warn: #9a5b07;
  --warn-soft: #fdf1dc;
  --err: #c62828;
  --err-soft: #fde8e8;
  --we: #f7f2f0;
  --hol: #ffe9ec;
  --today: #8b0018;
  --shadow: 0 1px 2px rgb(46 46 46 / .05), 0 8px 24px rgb(139 0 24 / .07);
  --r-ctl: 8px;
  --r-card: 12px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
/* Dark: Mystic surfaces, Clean Girl text, Make Me Blush as accent (Love Myself is too dark to read on Mystic). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #232222; --surface: #2e2e2e; --surface-2: #363434; --border: #403c3c; --border-strong: #544e4e;
    --text: #f7f2f0; --muted: #b9aeac; --accent: #e68686; --accent-hover: #f0a3a3; --accent-ink: #2e2e2e; --accent-soft: #4a262b;
    --accent-mid: #5e2a31; --blush: #e68686; --ok: #7fcc9b; --ok-soft: #233a2c; --warn: #f0b45e; --warn-soft: #3a2d17;
    --err: #ff8a80; --err-soft: #4a2424; --we: #2a2828; --hol: #3d2a2d; --today: #e68686;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #232222; --surface: #2e2e2e; --surface-2: #363434; --border: #403c3c; --border-strong: #544e4e;
  --text: #f7f2f0; --muted: #b9aeac; --accent: #e68686; --accent-hover: #f0a3a3; --accent-ink: #2e2e2e; --accent-soft: #4a262b;
  --accent-mid: #5e2a31; --blush: #e68686; --ok: #7fcc9b; --ok-soft: #233a2c; --warn: #f0b45e; --warn-soft: #3a2d17;
  --err: #ff8a80; --err-soft: #4a2424; --we: #2a2828; --hol: #3d2a2d; --today: #e68686;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ic { flex: none; vertical-align: -3px; }
[hidden] { display: none !important; }

/* ---------------------------------- buttons ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff8f7; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-text { color: var(--err); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; height: 42px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 34px; height: 34px; padding: 0 6px;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--muted); cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.link-btn:hover { color: var(--text); }

/* ----------------------------------- forms ----------------------------------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline > span { font-weight: 500; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-ctl); height: 36px; padding: 0 10px; width: 100%; min-width: 0;
}
input[type=color] { padding: 3px; height: 36px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 85%, transparent); }
.hint { color: var(--muted); font-size: 12px; }
.form-error { color: var(--err); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check.end { align-self: end; height: 36px; }
.row2, .row3 { display: grid; gap: 12px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: repeat(3, 1fr); }
.span2 { grid-column: span 2; }
.stack { display: grid; gap: 14px; }
.select-wrap {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 0 0 10px; border: 1px solid var(--border-strong);
  border-radius: var(--r-ctl); background: var(--surface); color: var(--muted);
}
.select-wrap select { border: 0; height: 34px; background: transparent; color: var(--text); padding-left: 2px; width: auto; }
.select-wrap select:focus { outline: none; }
.search { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); background: var(--surface); color: var(--muted); }
.search input { border: 0; height: 32px; padding: 0; background: transparent; width: 200px; }
.search input:focus { outline: none; }

/* ----------------------------------- shell ----------------------------------- */
.boot { min-height: 100dvh; }
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px; padding: 18px 12px;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 2px 8px; text-decoration: none !important; }
/* Logo has a white background: sits flush on white surfaces, reads as an app tile on dark ones. */
.brand-logo { width: 46px; height: 46px; flex: none; border-radius: 12px; background: #ffffff; object-fit: contain; }
.brand-logo.sm { width: 28px; height: 28px; border-radius: 8px; }
.login .brand-logo { width: 52px; height: 52px; }
:root[data-theme="dark"] .brand-logo { padding: 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { padding: 2px; } }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r-ctl); color: var(--muted);
  font-weight: 550; text-decoration: none !important; border: 0; background: none; font: inherit; cursor: pointer; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-count { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.quick { display: flex; gap: 4px; padding: 0 4px; }
.lang-code { font-size: 11px; font-weight: 700; }
.me {
  display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.me:hover { border-color: var(--border-strong); }
.me-text { display: grid; min-width: 0; flex: 1; }
.me-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.main-wrap { min-width: 0; }
.mobile-bar { display: none; }
main { outline: none; }
.page { padding: 24px 28px 48px; max-width: 1600px; display: grid; gap: 16px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav h1 { min-width: 190px; text-align: center; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: var(--r-ctl); }
.segmented button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 550; height: 30px; padding: 0 12px; border-radius: 6px; cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px; padding: 6px; display: grid;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow);
}
.menu button { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; border-radius: 6px; cursor: pointer; }
.menu button:hover:not(:disabled) { background: var(--surface-2); }
.menu button:disabled { opacity: .45; cursor: not-allowed; }

/* ----------------------------------- status ----------------------------------- */
.status-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 13px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 0; font-family: inherit; white-space: nowrap;
}
button.status { cursor: pointer; }
.status-ok { background: var(--ok-soft); color: var(--ok); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-err { background: var(--err-soft); color: var(--err); }
.status-draft { background: var(--warn-soft); color: var(--warn); }
.status-lock { background: var(--surface-2); color: var(--text); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.count.err { background: var(--err-soft); color: var(--err); }
.count.warn { background: var(--warn-soft); color: var(--warn); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700;
  background: color-mix(in srgb, var(--c, var(--muted)) 16%, var(--surface)); color: color-mix(in srgb, var(--c, var(--muted)) 75%, var(--text));
}
.tag.warn { --c: var(--warn); }
.diff { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.diff.ok { background: var(--ok-soft); color: var(--ok); }
.diff.over { background: var(--warn-soft); color: var(--warn); }
.diff.under { background: var(--surface-2); color: var(--muted); }
.bad-text { color: var(--err); font-weight: 600; }

/* ---------------------------------- palette ---------------------------------- */
.palette {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card);
}
.palette .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--r-ctl);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.chip:hover { border-color: var(--border-strong); }
.chip:active { transform: scale(.98); }
.chip.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
.shift-chip b, .abs-chip b {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 5px;
  background: var(--c); color: #fff; font-size: 12px;
}
.abs-chip b { background: repeating-linear-gradient(135deg, var(--c) 0 5px, color-mix(in srgb, var(--c) 70%, #000) 5px 7px); }
.chip span { color: var(--muted); font-size: 12px; }
.chip.on span { color: var(--text); }
.brush-hint { margin-left: 6px; }

/* ----------------------------------- grid ----------------------------------- */
.grid-wrap {
  overflow: auto; max-height: calc(100dvh - 260px); min-height: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card);
}
.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
.grid thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); height: 46px; font-weight: 600; }
.grid .corner { left: 0; z-index: 5; text-align: left; padding: 0 12px; min-width: 210px; color: var(--muted); font-size: 12px; }
.grid th.day { min-width: 38px; text-align: center; color: var(--muted); }
.grid.wide th.day, .grid-wrap.wide .grid th.day { min-width: 124px; }
.grid th.day .wd { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.grid th.day .dn { display: block; font-size: 14px; color: var(--text); }
.grid th.day.today .dn { color: var(--accent-ink); background: var(--today); border-radius: 999px; width: 24px; height: 24px; line-height: 24px; margin: 0 auto; }
.grid th.we, .grid td.we { background: var(--we); }
.grid th.hol, .grid td.hol { background: var(--hol); }
.grid tbody th.emp {
  position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 8px 12px; min-width: 210px; max-width: 240px; font-weight: 400;
}
.emp-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-meta { color: var(--muted); font-size: 11px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.warn-ic { color: var(--err); display: inline-flex; }
.cell { height: 46px; }
.cell.today { box-shadow: inset 2px 0 0 var(--today), inset -2px 0 0 var(--today); }
.cell.issue .cell-btn { box-shadow: inset 0 0 0 2px var(--err); }
.cell-btn {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 46px; padding: 3px; border: 0; background: transparent;
  cursor: pointer; font: inherit; color: inherit;
}
.cell-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cell-btn:disabled { cursor: default; }
.cell-btn.saving { opacity: .45; }
.pill {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%;
  min-width: 28px; border-radius: 6px; padding: 0 4px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); color: color-mix(in srgb, var(--c) 65%, var(--text));
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.pill b { font-size: 12px; line-height: 1.1; }
.pill small { font-size: 11px; line-height: 1.2; color: var(--text); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pill.abs {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 22%, var(--surface)) 0 6px, color-mix(in srgb, var(--c) 10%, var(--surface)) 6px 12px);
}
.pill.custom { border-style: dashed; }
.note-dot { position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.grid tfoot th, .grid tfoot td { position: sticky; background: var(--surface-2); height: 28px; font-size: 11px; color: var(--muted); text-align: center; }
.grid tfoot tr:nth-child(1) > * { bottom: 56px; }
.grid tfoot tr:nth-child(2) > * { bottom: 28px; }
.grid tfoot tr:nth-child(3) > * { bottom: 0; }
.grid tfoot th { left: 0; z-index: 4; text-align: left; padding: 0 12px; font-weight: 600; }

/* --------------------------------- popover --------------------------------- */
.popover {
  position: fixed; z-index: 50; width: 360px; max-height: calc(100dvh - 24px); overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px; display: grid; gap: 14px;
  animation: pop .18s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.pop-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pop-sec { display: grid; gap: 8px; }
.pop-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chip-grid .chip { justify-content: flex-start; height: 36px; }
.chip-grid .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-sec.custom { border-top: 1px solid var(--border); padding-top: 12px; }
.pop-actions { display: flex; justify-content: space-between; align-items: center; }

/* --------------------------------- details --------------------------------- */
.details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.details-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.details-toggle { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; padding: 4px 0; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.page > .tabs { padding: 0; }
.tab-body { padding: 16px; display: grid; gap: 14px; }
.table-scroll { overflow-x: auto; }
table.mini { border-collapse: collapse; font-size: 12px; width: 100%; }
table.mini th, table.mini td { border: 1px solid var(--border); padding: 4px 6px; text-align: center; min-width: 26px; }
table.mini thead th { background: var(--surface-2); color: var(--muted); font-weight: 600; }
table.mini thead th.we { background: var(--we); color: var(--text); }
table.mini tbody th { text-align: left; font-weight: 500; white-space: nowrap; padding-right: 12px; }
table.mini td.zero { color: color-mix(in srgb, var(--muted) 50%, transparent); }
table.mini tr.sum th, table.mini tr.sum td { background: var(--surface-2); font-weight: 700; }
table.mini tr.group th { background: transparent; border-left: 0; border-right: 0; text-align: left; padding-top: 14px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table.mini td.tot { font-weight: 700; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data caption { text-align: left; font-weight: 600; padding: 4px 0 10px; }
.card table.data caption { padding: 14px 16px 6px; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data tr.inactive td { opacity: .55; }
table.data tr.after-pub td { background: color-mix(in srgb, var(--warn-soft) 60%, transparent); }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--surface-2); }
.callout.info { color: var(--text); }
.callout.info .ic { color: var(--accent); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.err { background: var(--err-soft); color: var(--err); }
.callout code { word-break: break-all; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 8px; }
.rule { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--r-ctl); border: 1px solid var(--border); }
.rule > div { flex: 1; }
.rule.good > .ic { color: var(--ok); }
.rule.bad { border-color: color-mix(in srgb, var(--err) 40%, var(--border)); background: var(--err-soft); }
.rule.bad > .ic { color: var(--err); }
.rule-n { font-size: 20px; font-weight: 700; }
.rule.good .rule-n { color: var(--muted); }
.rule.bad .rule-n { color: var(--err); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.two-col h3 { margin-bottom: 8px; }
.versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.versions li { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-ctl); justify-items: start; }
.hash { font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------------------------- cards ---------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.form-card { display: grid; gap: 14px; max-width: 860px; }
.form-card h2:not(:first-child) { margin-top: 10px; }
.pad { padding: 10px 16px 0; }
.settings-body { display: grid; gap: 10px; }
.members { border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 10px 12px; margin: 14px 0 0; }
.members legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.member-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; max-height: 320px; overflow: auto; }
.member-list li { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; border-radius: 6px; }
.member-list li:hover { background: var(--surface-2); }
.order-btns { display: inline-flex; }
.facts { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.facts li { display: flex; gap: 8px; align-items: center; color: var(--muted); }

/* leave balance */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 26px; line-height: 1.1; font-weight: 700; }
.stat small { color: var(--muted); font-size: 12px; }
.stat.accent { background: var(--accent-soft); border-color: var(--accent-mid); }
.stat.accent strong { color: var(--accent); }
@media (max-width: 960px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.leave-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.actions-cell { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------- empty ---------------------------------- */
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h2 { color: var(--text); }
.empty.slim { padding: 28px 12px; }
.empty.error .ic { color: var(--err); }
.skeleton-table { display: grid; gap: 10px; padding: 8px 0; }
.sk-row { display: grid; grid-template-columns: 2fr repeat(auto-fit, minmax(40px, 1fr)); gap: 10px; }
.sk { height: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sh 1.4s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------------------------------- dialog ---------------------------------- */
dialog.modal {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.modal-wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal[open] { animation: pop .2s var(--ease); }
dialog::backdrop { background: rgb(46 46 46 / .5); }
.modal-form { display: grid; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; }
.modal-body { padding: 8px 18px 16px; display: grid; gap: 12px; max-height: 70dvh; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-foot .form-error { margin-right: auto; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--r-ctl); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow); font-weight: 550; animation: pop .2s var(--ease); transition: opacity .25s, transform .25s;
}
.toast-error { background: var(--err); color: #fff8f7; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------------------------------- login ---------------------------------- */
.login { display: grid; grid-template-columns: minmax(360px, 480px) 1fr; min-height: 100dvh; }
.login-panel { display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 48px 56px; background: var(--surface); }
.login-panel h1 { font-size: 28px; margin-top: 24px; }
.login-aside {
  display: flex; align-items: center; justify-content: center; padding: 48px;
  background:
    radial-gradient(900px 520px at 105% -5%, rgb(230 134 134 / .35), transparent 60%),
    linear-gradient(160deg, #8b0018, #5c0011 55%, #2e2e2e);
}
.aside-logo { display: inline-flex; padding: 22px; border-radius: 36px; background: #ffffff; box-shadow: 0 24px 60px rgb(46 0 8 / .4); }
.aside-logo img { width: 160px; height: 160px; display: block; }

/* -------------------------------- my schedule -------------------------------- */
.my-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.my-head > div:first-child { flex: 1; }
.my-stats { display: flex; gap: 12px; color: var(--muted); font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-h { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; text-align: center; }
.cal-d { min-height: 74px; border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 6px; display: grid; gap: 4px; align-content: start; }
.cal-d.blank { border: 0; }
.cal-d.we { background: var(--we); }
.cal-d.hol { background: var(--hol); }
.cal-d.today { border-color: var(--today); box-shadow: inset 0 0 0 1px var(--today); }
.cal-n { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-d .pill { height: auto; padding: 4px; }

/* ------------------------------- inspection doc ------------------------------- */
.bare { padding: 16px; }
.report-toolbar { display: flex; align-items: center; gap: 10px; max-width: 1400px; margin: 0 auto 12px; }
.grow { flex: 1; }
.report {
  position: relative; max-width: 1400px; margin: 0 auto; background: #ffffff; color: #2e2e2e; padding: 28px 32px;
  border-radius: var(--r-card); border: 1px solid var(--border); font-size: 12px; overflow-x: auto;
}
.report h2 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.watermark {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 120px; font-weight: 800; color: rgb(139 0 24 / .07); transform: rotate(-18deg);
}
.r-head { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #8b0018; padding-bottom: 10px; }
.r-logo { width: 64px; height: 64px; object-fit: contain; flex: none; }
.r-company { font-size: 15px; font-weight: 700; }
.r-right { text-align: right; margin-left: auto; }
.r-title { text-align: center; font-size: 20px; margin-top: 16px; letter-spacing: .06em; }
.r-sub { text-align: center; font-size: 14px; font-weight: 600; }
.r-note { text-align: center; color: #6e6462; margin: 4px 0 12px; }
.r-grid { border-collapse: collapse; width: 100%; font-size: 10.5px; }
.r-grid th, .r-grid td { border: 1px solid #d8c7c4; padding: 3px 2px; text-align: center; }
.r-grid th { background: #f7f2f0; }
.r-grid .we { background: #f3ebe8; }
.r-grid .hol { background: #ffe9ec; }
.r-grid .r-emp { text-align: left; padding: 3px 6px; min-width: 150px; }
.r-grid .wd { font-weight: 500; font-size: 9px; }
.r-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.r-legend { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.r-legend th, .r-legend td { border: 1px solid #e6d8d5; padding: 3px 6px; text-align: left; }
.r-legend th { background: #f7f2f0; }
.r-legend .sign { width: 160px; }
.r-issues { margin: 0; padding-left: 18px; }
.r-sign { display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; margin-top: 30px; }
.r-gen { margin-top: 18px; color: #6e6462; }
.report .hash { color: #6e6462; }

/* --------------------------------- responsive --------------------------------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
  .page { padding: 16px 14px 40px; }
  .month-nav h1 { min-width: 0; font-size: 18px; }
  .two-col, .r-cols, .row3, .row2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .login { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-panel { padding: 32px 22px; }
  .grid-wrap { max-height: none; }
  .popover { left: 12px !important; right: 12px; width: auto; top: auto !important; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ----------------------------------- print ----------------------------------- */
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  body { background: #fff; }
  .no-print, .sidebar, .mobile-bar, #toasts { display: none !important; }
  .bare { padding: 0; }
  .report { border: 0; padding: 0; max-width: none; border-radius: 0; overflow: visible; }
  .r-grid { font-size: 8.5px; }
  .r-grid tr, .r-legend tr { break-inside: avoid; }
  .r-ack, .r-sign { break-inside: avoid; }
}
