/* ==========================================================================
   Дежурный календарь v2 — стили (светлая / тёмная тема)
   ========================================================================== */
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f3f2ed;
  --surface-3: #ebe9e2;
  --border: #e3e1d9;
  --border-strong: #d2cfc4;
  --text: #19191d;
  --muted: #6e6d74;
  --faint: #a3a1a8;
  --accent: #3d4fd6;
  --accent-ink: #ffffff;
  --accent-soft: #e9ebfb;
  --danger: #d33f33;
  --danger-soft: #fbeceb;
  --ok: #188a4c;
  --ok-soft: #e7f5ec;
  --warn: #a8640a;
  --warn-soft: #fdf3e2;
  --work: #3d4fd6;
  --off: #e48ab9;
  --shadow: 0 1px 2px rgba(25, 25, 29, .04), 0 2px 8px rgba(25, 25, 29, .04);
  --shadow-lg: 0 18px 50px -12px rgba(25, 25, 29, .28), 0 2px 6px rgba(25, 25, 29, .06);
  --r: 18px;
  --r-sm: 11px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d0e11;
  --surface: #16171b;
  --surface-2: #1c1d22;
  --surface-3: #24262c;
  --border: #26282e;
  --border-strong: #35373f;
  --text: #ecebef;
  --muted: #9b9aa4;
  --faint: #62616b;
  --accent: #8d99ff;
  --accent-ink: #0d0e11;
  --accent-soft: #1f2242;
  --danger: #f2766b;
  --danger-soft: #2c1715;
  --ok: #5fd08f;
  --ok-soft: #12261a;
  --warn: #f1b45a;
  --warn-soft: #2a2010;
  --work: #8d99ff;
  --off: #e48ab9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7), 0 0 0 1px var(--border);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  background: var(--bg); color: var(--text);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0 !important; }
.inline { display: inline; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-in { max-width: 1200px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -.015em; font-size: 1.02rem; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5px; width: 22px; height: 22px; flex: none; }
.brand-mark i { border-radius: 3.5px; background: var(--accent); }
.brand-mark i:nth-child(2) { background: #ef4444; }
.brand-mark i:nth-child(3) { background: #22c55e; }
.brand-mark i:nth-child(4) { background: #f472b6; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 10px; font-weight: 500; font-size: .92rem; color: var(--muted); transition: background .15s, color .15s; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.nav a.nav-admin.on { color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="light"] .i-moon, :root:not([data-theme]) .i-moon { display: none; }

/* ---------------- layout ---------------- */
.wrap { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 22px 20px 40px; }
.foot { text-align: center; color: var(--faint); font-size: .8rem; padding: 0 0 26px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 2px 18px; flex-wrap: wrap; }
.h2 { font-size: 1.06rem; font-weight: 700; letter-spacing: -.01em; margin: 28px 2px 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-2 > .form-card { margin-bottom: 0; }
.grid-2 + .form-card, .form-card + .form-card { margin-top: 16px; }

/* ---------------- buttons ---------------- */
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--r-sm); padding: 8px 15px; font-weight: 600; font-size: .9rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
}
.btn:hover, .icon-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.icon-btn { width: 38px; height: 38px; padding: 0; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- flash ---------------- */
.flash { padding: 11px 15px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: .9rem; border: 1px solid; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.flash-info, .flash-message { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

/* ---------------- subnav (admin) ---------------- */
.subnav { display: flex; gap: 4px; margin: -4px 0 18px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; text-decoration: none; padding: 8px 14px; border-radius: 10px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.subnav a:hover { color: var(--text); }
.subnav a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ================= month view ================= */
.month-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.cal-card { padding: 22px 22px 16px; }
.cal-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-title { margin: 0; font-size: 2.1rem; line-height: 1.05; font-weight: 800; letter-spacing: -.035em; }
.cal-title span { color: var(--faint); font-weight: 600; }
.cal-sub { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.go-form input[type=date] { height: 38px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-sm); padding: 0 10px; font-size: .86rem; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; user-select: none; -webkit-user-select: none; }
.cal-wd { text-align: left; padding: 0 4px 4px; font-size: .74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cal-wd.we { color: var(--danger); opacity: .75; }

.day {
  position: relative; aspect-ratio: 1 / .9; min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  padding: 8px 9px; border-radius: 13px; border: 1px solid var(--border);
  background: var(--surface-2); background-origin: border-box; background-clip: border-box;
  text-align: left; cursor: pointer; overflow: hidden;
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s, filter .15s;
}
.day:hover { transform: translateY(-1px); box-shadow: var(--shadow); filter: brightness(1.04); }
.day:not(.filled):hover { border-color: var(--border-strong); }
.day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.day.filled { border: 0; padding: 9px 10px; }
.day-num { font-weight: 700; font-size: 1rem; line-height: 1; white-space: nowrap; }
.day.we:not(.filled) .day-num { color: var(--danger); }
.day.hol:not(.filled) { background: color-mix(in srgb, var(--danger) 8%, var(--surface-2)); }
.day.short .day-num::after { content: "сокр."; margin-left: 5px; font-size: .6rem; font-weight: 700; opacity: .7; vertical-align: 2px; }
.day.short:not(.filled) .day-num::after { color: var(--warn); opacity: 1; }

/* подписи статусов */
.lab { font-size: .68rem; font-weight: 600; line-height: 1.15; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lab:empty { display: none; }
.lab2 { display: none; }
/* два статуса: каждая подпись в своём треугольнике */
.day.split .lab1, .day.split .lab2 { position: absolute; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .64rem; line-height: 1.12; }
.day.split .lab1 { left: 10px; top: 29px; max-width: 62%; color: var(--t1); }
.day.split .lab2 { right: 10px; bottom: 9px; max-width: 70%; text-align: right; color: var(--t2); }
.day.split .lab2:empty { display: none; }

.day-note { position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.day.split .day-note { background: var(--t2); }
.day:not(.filled) .day-note { background: var(--accent); }

/* дни соседних месяцев: нейтральная клетка + тонкая полоска цвета статуса */
.day.out, .day.out.filled {
  background: linear-gradient(to right, var(--c1, transparent) 50%, var(--c2, var(--c1, transparent)) 50%) left bottom / 100% 4px no-repeat, color-mix(in srgb, var(--surface-2) 60%, transparent) !important;
  color: var(--faint) !important; border: 1px solid var(--border) !important; padding: 8px 9px !important;
}
.day.out .lab, .day.out .day-note { display: none; }
.day.out .day-num { color: var(--faint) !important; font-weight: 600; }
.day.out .day-num::after { display: none; }
.day.out:hover { filter: none; }

/* прошедшие дни — бледнее; при наведении цвет возвращается */
.day.past:not(.out)::before { content: ""; position: absolute; inset: 0; background: var(--surface); opacity: .6; pointer-events: none; transition: opacity .15s; }
.day.past:not(.out) > * { position: relative; z-index: 1; }
.day.past:not(.out) .day-num, .day.past:not(.out) .lab { opacity: .75; }
.day.past.split .lab1, .day.past.split .lab2 { position: absolute; }
.day.past:not(.out):not(.filled) .day-num { color: var(--faint); }
.day.past:not(.out):hover::before, .day.past.sel::before { opacity: 0; }
.day.past:not(.out):hover .day-num, .day.past:not(.out):hover .lab { opacity: 1; }
.md.past { position: relative; }
.md.past::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--surface); opacity: .6; }
.day.today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.day.today .day-num::after { content: "сегодня"; margin-left: 6px; font-size: .6rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .8; vertical-align: 2px; color: inherit; }
.day.sel { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.day.flash-cell { animation: pulse 1.6s ease 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 6px var(--accent); } }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 16px 2px 2px; margin-top: 12px; border-top: 1px solid var(--border); }
.legend-page { border: 0; justify-content: center; margin-top: 18px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--muted); font-weight: 500; }
.legend-item i { width: 12px; height: 12px; border-radius: 4px; }
.legend-item small { font-size: .7rem; color: var(--faint); }
.legend-hint { margin-left: auto; font-size: .78rem; color: var(--faint); }

/* ---------------- sidebar ---------------- */
.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }
.side-card { padding: 18px; }
.eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.side-title { font-weight: 700; font-size: .98rem; margin-bottom: 12px; letter-spacing: -.01em; }
.today-card { background: var(--surface); position: relative; overflow: hidden; }
.today-main { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.today-main .pill { font-size: 1rem; padding: 7px 14px; }
.muted-big { font-size: 1.15rem; font-weight: 600; color: var(--muted); }
.today-note { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: .88rem; }
.today-meta { margin-top: 14px; display: grid; gap: 8px; border-top: 1px dashed var(--border); padding-top: 12px; }
.today-meta div { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; }
.today-meta span { color: var(--muted); }
.today-meta b { font-weight: 600; text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: .82rem; font-weight: 650; color: #fff; white-space: nowrap; }
.upcoming { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.upcoming li { display: grid; grid-template-columns: 6px 1fr auto; grid-template-rows: auto auto; column-gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.upcoming li:last-child { border-bottom: 0; }
.up-bar { grid-row: 1 / 3; display: flex; flex-direction: column; border-radius: 4px; overflow: hidden; }
.up-bar i { flex: 1; }
.up-what { font-weight: 600; font-size: .9rem; }
.up-when { grid-column: 3; grid-row: 1; font-size: .86rem; font-weight: 600; text-align: right; }
.up-in { grid-column: 2 / 4; grid-row: 2; font-size: .78rem; color: var(--muted); }

.stack { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; margin-bottom: 12px; }
.stack i { min-width: 3px; }
.tally { list-style: none; margin: 0; padding: 0; }
.tally li { display: grid; grid-template-columns: 10px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 7px 0; }
.tally li i { width: 10px; height: 10px; border-radius: 3px; grid-row: 1 / 3; }
.tally .t-name { font-size: .9rem; font-weight: 500; }
.tally .t-sub { grid-column: 2; font-size: .74rem; color: var(--muted); }
.tally .t-sub:empty { display: none; }
.tally b { grid-column: 3; grid-row: 1 / 3; font-size: 1.25rem; font-weight: 750; letter-spacing: -.02em; }
.tally li.zero { opacity: .42; }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.mini-grid div { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; }
.mini-grid b { font-size: 1.15rem; font-weight: 750; }
.mini-grid span { font-size: .7rem; color: var(--muted); line-height: 1.2; }
.norm { margin-top: 12px; font-size: .78rem; color: var(--muted); line-height: 1.4; }
.norm b { color: var(--text); }
.side-link { display: inline-block; margin-top: 14px; font-size: .86rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.side-link:hover { text-decoration: underline; }

/* ---------------- popover ---------------- */
.pop {
  position: fixed; z-index: 200; width: 300px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 16px; animation: popin .14s ease-out;
}
.pop-edit { width: 340px; }
@keyframes popin { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.pop.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100%; max-width: none; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 82vh; overflow-y: auto; animation: sheetin .2s ease-out; }
@keyframes sheetin { from { transform: translateY(40%); opacity: .4; } }
.pop-x { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 9px; background: var(--surface-2); cursor: pointer; font-size: 1.1rem; color: var(--muted); }
.pop-date { font-weight: 750; font-size: 1.1rem; letter-spacing: -.01em; }
.pop-wd { color: var(--muted); font-size: .84rem; margin-bottom: 12px; }
.pop-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-hol { margin-top: 10px; font-size: .84rem; font-weight: 600; color: var(--danger); }
.pop-note { margin-top: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: .9rem; white-space: pre-wrap; }
.pop-cap { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 7px; }
.pop-cap small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
.pop-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 11px 5px 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.pchip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.pchip.none { padding: 5px 11px; color: var(--muted); }
.pchip.on { background: var(--c, var(--text)); border-color: var(--c, var(--text)); color: #fff; }
.pchip.on i { background: #fff; }
.pchip.none.on { background: var(--text); color: var(--surface); }
.pop textarea { width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; resize: vertical; font-size: .9rem; }
.pop-actions { display: flex; justify-content: space-between; margin-top: 14px; gap: 8px; }

/* ---------------- editor brushbar ---------------- */
.brushbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; padding: 10px; margin: -4px 0 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; }
.brush-group { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.brush-cap { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 4px 0 2px; }
.brush { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 11px 5px 8px; font-size: .82rem; font-weight: 600; cursor: pointer; transition: all .12s; }
.brush i { width: 11px; height: 11px; border-radius: 50%; background: var(--c); }
.brush:hover { border-color: var(--border-strong); }
.brush.on { background: var(--c, var(--text)); border-color: var(--c, var(--text)); color: #fff; box-shadow: 0 2px 10px -2px var(--c, rgba(0,0,0,.3)); }
.brush.on i { background: #fff; }
.brush[data-brush=""].on { color: var(--surface); }
.brush-erase.on { --c: var(--muted); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .82rem; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--text); color: var(--surface); }
.save-state { font-size: .78rem; color: var(--muted); min-width: 90px; }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--danger); }
.cal.painting .day { cursor: crosshair; touch-action: none; }
.day.painted { transform: scale(.94); }

/* ---------------- share ---------------- */
.share-modal { position: fixed; inset: 0; z-index: 300; background: rgba(10, 10, 14, .55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: popin .15s ease-out; }
.share-box { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 18px; box-shadow: var(--shadow-lg); }
.share-title { font-weight: 750; font-size: 1.05rem; margin-bottom: 12px; }
.share-seg { align-self: flex-start; margin-bottom: 12px; }
.share-seg button { padding: 6px 14px; }
.share-box { width: min(560px, 100%); }
.share-box:has(.share-img.pc) { width: min(920px, 100%); }
.share-img { overflow: auto; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); min-height: 0; flex: 1; }
.share-img img { display: block; width: 100%; height: auto; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.share-actions .btn { flex: 1; }
.share-hint { margin-top: 10px; }

/* ================= year ================= */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mini-month { padding: 14px 14px 12px; text-decoration: none; transition: transform .1s, box-shadow .15s, border-color .15s; }
.mini-month:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.mini-month.current { border-color: var(--text); }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-weight: 700; }
.mini-head small { font-weight: 500; color: var(--muted); font-size: .76rem; }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mwd { font-size: .62rem; color: var(--faint); text-align: center; font-weight: 600; }
.md { aspect-ratio: 1; display: grid; place-items: center; font-size: .66rem; font-weight: 600; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.md.filled { font-weight: 700; }
.md.blank { background: transparent; }
.md.we:not(.filled) { color: var(--danger); }
.md.today { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--text); }

/* ================= stats ================= */
.period-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 13px; font-size: .84rem; font-weight: 600; text-decoration: none; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.range-form { display: flex; align-items: center; gap: 6px; }
.range-form input { height: 34px; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 0 8px; font-size: .84rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi[style*="--c"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.kpi-num { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; }
.kpi-lbl { color: var(--muted); font-size: .84rem; font-weight: 500; margin-top: 3px; }
.kpi-sub { font-size: .78rem; color: var(--faint); margin-top: 6px; }
.kpi-hero { background: var(--text); color: var(--surface); border-color: var(--text); grid-column: span 2; }
.kpi-hero .kpi-num { font-size: 2.8rem; }
.kpi-hero .kpi-lbl, .kpi-hero .kpi-sub { color: color-mix(in srgb, var(--surface) 70%, transparent); }
.delta { font-weight: 700; font-size: .78rem; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--danger-soft); color: var(--danger); }
.kpi-hero .delta { background: color-mix(in srgb, var(--surface) 15%, transparent); color: var(--surface); }

.status-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.scard { padding: 16px; position: relative; overflow: hidden; }
.scard::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--c); opacity: .12; }
.scard.zero { opacity: .5; }
.scard-top { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: .92rem; }
.scard-top i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.kind { margin-left: auto; font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.scard-num { font-size: 2.3rem; font-weight: 800; letter-spacing: -.04em; margin: 8px 0 0; line-height: 1.1; color: var(--c); }
.scard-sub { font-size: .8rem; color: var(--muted); }
.scard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: .76rem; color: var(--faint); }

.chart-card { padding: 18px 20px; margin-top: 16px; }
.bars { display: grid; grid-template-columns: repeat(var(--n), minmax(22px, 1fr)); gap: 8px; height: 220px; align-items: end; overflow-x: auto; }
.bar-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; text-decoration: none; min-width: 22px; }
.bar-val { font-size: .7rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.bar { width: 100%; max-width: 44px; display: flex; flex-direction: column-reverse; border-radius: 7px 7px 3px 3px; overflow: hidden; gap: 1.5px; min-height: 2px; transition: filter .15s; }
.bar i { min-height: 2px; }
.bar-col:hover .bar { filter: brightness(1.08) saturate(1.1); }
.bar-lbl { font-size: .68rem; color: var(--muted); margin-top: 7px; white-space: nowrap; }

.stats-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.donut-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; border-radius: 50%; position: relative; flex: none; }
.donut-hole { position: absolute; inset: 26px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-hole b { font-size: 1.8rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.donut-hole span { font-size: .7rem; color: var(--muted); max-width: 80px; line-height: 1.2; margin-top: 3px; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; display: grid; gap: 7px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend b { margin-left: auto; font-weight: 700; }

.wd-bars { display: grid; gap: 9px; }
.wd-row { display: grid; grid-template-columns: 26px 1fr 56px; align-items: center; gap: 10px; }
.wd-lbl { font-size: .8rem; font-weight: 600; color: var(--muted); }
.wd-lbl.we { color: var(--danger); }
.wd-track { display: flex; height: 16px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.wd-work { background: var(--work); }
.wd-off { background: var(--off); }
.wd-num { font-size: .84rem; font-weight: 700; text-align: right; }
.wd-num small { color: var(--faint); font-weight: 500; }
.wd-legend { display: flex; gap: 16px; margin-top: 12px; font-size: .78rem; color: var(--muted); }
.wd-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.records { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.record { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.record b { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; }
.record span { color: var(--muted); font-size: .84rem; }

.table-card { padding: 18px 20px; margin-top: 16px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: center; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl-left th, .tbl-left td { text-align: left; }
.tbl td a { text-decoration: none; font-weight: 600; }
.tbl td a:hover { color: var(--accent); }
.tbl td.nil { color: var(--faint); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tfoot td { font-weight: 800; border-bottom: 0; border-top: 2px solid var(--border-strong); }
.tbl .dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; }

/* ================= forms (admin) ================= */
.form-card { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 14px 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-grid .field { margin-bottom: 0; }
.field > span, .field-cap { font-size: .76rem; font-weight: 650; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 9px 11px; font-size: .92rem; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { border: 0; padding: 0; background: none; cursor: pointer; }
.color-full { width: 100%; height: 40px; border-radius: 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; margin: 10px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-size: .82rem; }

.switch { display: flex; align-items: center; gap: 12px; margin: 14px 0; font-size: .92rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 40px; height: 23px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; flex: none; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* bulk */
.mode-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 16px 0 4px; }
.mode-tab input { position: absolute; opacity: 0; }
.mode-tab span { display: flex; flex-direction: column; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 13px; cursor: pointer; transition: all .12s; }
.mode-tab b { font-size: .92rem; }
.mode-tab small { color: var(--muted); font-size: .78rem; }
.mode-tab input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.mode-tab input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.pattern-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin: 6px 0 12px; }
.pattern { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.step { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 4px 4px 4px 9px; }
.step-n { font-size: .7rem; font-weight: 800; color: var(--faint); min-width: 12px; }
.step select { border: 0; padding: 5px 4px; background: transparent; }
.step select:focus { box-shadow: none; }
.step .x { border: 0; background: var(--surface-2); border-radius: 8px; width: 26px; height: 26px; cursor: pointer; color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.wd-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.wd-pick label { cursor: pointer; }
.wd-pick input { position: absolute; opacity: 0; }
.wd-pick span { display: inline-grid; place-items: center; width: 44px; height: 38px; border-radius: 10px; border: 1px solid var(--border); font-weight: 650; font-size: .86rem; }
.wd-pick input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* statuses */
.status-list { display: grid; gap: 8px; margin-top: 16px; }
.status-row { display: grid; grid-template-columns: auto auto minmax(150px, 1fr) 130px auto 82px auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.status-row.archived { opacity: .6; background: var(--surface-2); }
.sr-order { display: flex; flex-direction: column; gap: 2px; }
.mini { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; width: 24px; height: 18px; font-size: .55rem; cursor: pointer; color: var(--muted); padding: 0; }
.mini:disabled { opacity: .3; cursor: default; }
.swatch-input { width: 38px; height: 38px; border-radius: 11px; background: var(--c); position: relative; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch-input input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.sr-name { width: 100%; font-weight: 600; }
.sr-meta { font-size: .74rem; color: var(--muted); margin-top: 4px; }
.sr-pair { margin: 0; font-size: .84rem; white-space: nowrap; }
.sr-hours { display: flex; align-items: center; gap: 5px; font-size: .84rem; color: var(--muted); }
.sr-hours input { width: 60px; padding: 7px 8px; }
.sr-preview { display: none; }
.sr-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.del { position: relative; }
.del summary { list-style: none; }
.del summary::-webkit-details-marker { display: none; }
.del-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; padding: 14px; width: 250px; display: grid; gap: 8px; box-shadow: var(--shadow-lg); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 8px; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); transition: transform .1s; }
.swatches button:hover { transform: scale(1.12); }

/* log */
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.tag-login_fail, .tag-restore { background: var(--danger-soft); color: var(--danger); }
.tag-login { background: var(--ok-soft); color: var(--ok); }
.tag-bulk, .tag-import, .tag-migrate { background: var(--accent-soft); color: var(--accent); }
.log td { font-size: .84rem; vertical-align: top; }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 14px; }

/* login */
.login { max-width: 380px; margin: 9vh auto 0; padding: 30px; text-align: center; }
.login h1 { font-size: 1.4rem; margin: 14px 0 4px; letter-spacing: -.02em; }
.login form { text-align: left; margin-top: 20px; }
.login-mark { width: 40px; height: 40px; margin: 0 auto; gap: 4px; }
.login-mark i { border-radius: 6px; }

/* ================= responsive ================= */
@media (max-width: 1020px) {
  .month-layout { grid-template-columns: 1fr; }
  .side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .status-row { grid-template-columns: auto auto 1fr; }
  .status-row > select, .sr-pair, .sr-hours { grid-column: span 1; }
  .sr-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .stats-two { grid-template-columns: 1fr; }
  .kpi-hero { grid-column: 1 / -1; }
  .lab { display: none !important; }
  .legend-hint { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar-in { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand-name { max-width: 52vw; }
  .nav { order: 3; width: 100%; margin: 0; justify-content: space-between; }
  .nav a { flex: 1; text-align: center; padding: 7px 6px; font-size: .86rem; }
  .icon-btn { width: 34px; height: 34px; }
  .wrap { padding: 14px 10px 30px; }
  .cal-card { padding: 14px 10px 10px; border-radius: 16px; }
  .cal-title { font-size: 1.6rem; }
  .cal-head { margin-bottom: 12px; }
  .cal-nav { width: 100%; }
  .go-form { margin-left: auto; }
  .share-txt { display: none; }
  #shareBtn { width: 34px; height: 34px; padding: 0; }
  .go-form input[type=date] { width: 132px; height: 34px; }
  .cal { gap: 3px; }
  .cal-wd { font-size: .64rem; text-align: center; padding: 0 0 2px; }
  .day { aspect-ratio: 1; padding: 5px; border-radius: 9px; align-items: center; justify-content: center; }
  .day-num { font-size: .9rem; }
  .day.today .day-num::after { display: none; }
  .day.short .day-num::after { content: ""; display: block; width: 4px; height: 4px; border-radius: 50%; background: currentColor; margin: 3px auto 0; }
  .day.short:not(.filled) .day-num::after { background: var(--warn); }
  .day-note { top: 4px; right: 4px; width: 5px; height: 5px; }
  .brushbar { padding: 8px; }
  .brush { padding: 4px 9px 4px 7px; font-size: .78rem; }
  .side { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 13px 14px; }
  .kpi-num { font-size: 1.6rem; }
  .kpi-hero .kpi-num { font-size: 2.2rem; }
  .status-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .scard { padding: 13px; }
  .scard-num { font-size: 1.8rem; }
  .scard-foot span { display: none; }
  .period-bar { padding: 8px; }
  .range-form { width: 100%; }
  .range-form input { flex: 1; min-width: 0; }
  .bars { height: 170px; gap: 4px; }
  .donut { width: 140px; height: 140px; margin: 0 auto; }
  .donut-hole { inset: 22px; }
  .year-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mini-month { padding: 10px 8px; }
  .md { font-size: .55rem; border-radius: 4px; }
  .mini-cal { gap: 2px; }
  .mini-head { font-size: .86rem; }
  .mini-head small { display: none; }
  .form-card { padding: 16px; }
  .status-row { grid-template-columns: auto 1fr; }
  .sr-order { display: none; }
  .status-row > select, .sr-pair, .sr-hours { grid-column: auto; }
  .page-head .cal-title { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
