/* DENO app.css — 通用樣式(載入順序:tokens.css → app.css)
   結構:base / 元件(btn input card badge chip notice list stat)/ 外殼(topbar nav view)
         / toast modal / 班表格子(.cell*)/ 預假日曆(.cal)/ 工具類 */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- typography helpers ---------- */
.title { font-size: 20px; font-weight: 700; color: var(--ink); }
.subtitle { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.ink-2 { color: var(--ink-2); }

/* ---------- layout helpers ---------- */
.page { padding: 16px 14px 24px; max-width: 1080px; margin: 0 auto; }
.page--narrow { max-width: 560px; }
.page__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.page__head .title { margin-right: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--sm { gap: 8px; }
.stack--lg { gap: 20px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--center { justify-content: center; }
.grid { display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card--flat { box-shadow: none; }
.card--tight { padding: 12px; }
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card__title { font-size: 15px; font-weight: 700; margin-right: auto; }

/* ---------- button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1.2;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .08s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--surface-3); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.95); }
.btn--outline-danger { background: transparent; border-color: var(--danger); color: var(--danger-ink); }
.btn--sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn--lg { min-height: 48px; padding: 10px 22px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; border-color: transparent; background: transparent; }
.btn--icon:hover { background: var(--surface-3); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--icon svg { width: 20px; height: 20px; }

/* ---------- input ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field__hint { font-size: 12.5px; color: var(--muted); }
.field__error { font-size: 12.5px; color: var(--danger-ink); }
.input, .select, .textarea {
  width: 100%; min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input::placeholder { color: var(--muted); }
.input--code { font-family: var(--mono); letter-spacing: 4px; text-transform: uppercase; font-size: 20px; text-align: center; min-height: 52px; }
.select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.textarea { min-height: 96px; resize: vertical; }
.input--sm, .select--sm { min-height: 34px; padding: 4px 10px; font-size: 13.5px; }
.select--sm { padding-right: 28px; }

/* ---------- badge / chip / pill ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2); border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge--collecting { background: var(--warn-soft); color: var(--warn-ink); }
.badge--scheduling { background: var(--info-soft); color: var(--info-ink); }
.badge--published { background: var(--ok-soft); color: var(--ok-ink); }
.badge--gray { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.badge--danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge--plain::before { display: none; }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px; padding: 0 7px;
  border-radius: 6px; border: 1px solid transparent;
  font-family: var(--mono); font-weight: 700; font-size: 12.5px; letter-spacing: .3px; line-height: 1;
  white-space: nowrap;
}
.chip--d { background: var(--shift-d-bg); color: var(--shift-d-ink); border-color: var(--shift-d-line); }
.chip--e { background: var(--shift-e-bg); color: var(--shift-e-ink); border-color: var(--shift-e-line); }
.chip--n { background: var(--shift-n-bg); color: var(--shift-n-ink); border-color: var(--shift-n-line); }
.chip--off { background: var(--shift-off-bg); color: var(--shift-off-ink); border-color: var(--shift-off-line); }
.chip--offreg { background: var(--shift-offreg-bg); color: var(--shift-offreg-ink); border-color: var(--shift-offreg-line); }
.chip--unknown { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.chip--lg { height: 28px; min-width: 32px; font-size: 14px; }

.pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.pill--ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill--warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill--danger { background: var(--danger-soft); color: var(--danger-ink); }
.pill--info { background: var(--info-soft); color: var(--info-ink); }

/* ---------- notice / empty ---------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 14px; line-height: 1.55;
}
.notice__icon { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.notice__body { flex: 1; min-width: 0; }
.notice__title { font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.notice--info { background: var(--info-soft); border-color: transparent; color: var(--info-ink); }
.notice--info .notice__title { color: var(--info-ink); }
.notice--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn-ink); }
.notice--warn .notice__title { color: var(--warn-ink); }
.notice--ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-ink); }
.notice--ok .notice__title { color: var(--ok-ink); }
.notice--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger-ink); }
.notice--danger .notice__title { color: var(--danger-ink); }

.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 14px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2);
}
.empty__icon { width: 44px; height: 44px; margin: 0 auto 10px; opacity: .55; }
.empty__title { font-weight: 700; color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---------- list (roster / units) ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list__item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 52px;
  border-bottom: 1px solid var(--line);
  background: transparent; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; color: var(--ink);
  transition: background .12s ease;
}
.list__item:last-child { border-bottom: 0; }
button.list__item:hover:not(:disabled) { background: var(--surface-2); }
.list__item:disabled { cursor: not-allowed; }
.list__item--claimed { color: var(--muted); background: var(--surface-2); }
.list__item--claimed .list__name { text-decoration: line-through; text-decoration-color: var(--line-strong); }
.list__item--active { background: var(--accent-soft); }
.list__main { flex: 1; min-width: 0; }
.list__name { font-weight: 600; font-size: 15px; }
.list__sub { font-size: 12.5px; color: var(--muted); }
.list__aside { flex: none; font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

/* ---------- stats tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat__k { font-size: 11.5px; letter-spacing: 1px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat__v { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.stat__v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.stat--d { border-color: var(--shift-d-line); }
.stat--e { border-color: var(--shift-e-line); }
.stat--n { border-color: var(--shift-n-line); }
.stat--off { border-color: var(--shift-off-line); }

/* ---------- avatar ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--brand-mist); color: var(--brand-teal);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; overflow: hidden; border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 64px; height: 64px; font-size: 22px; }

/* ---------- month nav ---------- */
.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.month-nav__label { min-width: 96px; text-align: center; font-weight: 700; font-family: var(--mono); font-size: 15px; letter-spacing: .5px; }
.month-nav .btn--icon { width: 34px; height: 34px; }

/* ---------- legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); align-items: center; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 22px; height: 18px; border-radius: 4px; border: 1px solid var(--line); position: relative; display: inline-block; }
.legend__swatch.cal__day { aspect-ratio: auto; min-height: 0; width: 22px; height: 18px; font-size: 10px; }
.legend__swatch.cal__day--wish::after { font-size: 9px; right: 3px; bottom: 1px; }
.legend__swatch.cal__day--approved::after { width: 6px; height: 6px; right: 2px; top: 2px; }

/* ---------- segmented control(本月 / 上月)---------- */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 3px; gap: 2px; }
.seg__btn {
  border: 0; background: transparent; color: var(--ink-2);
  border-radius: 999px; padding: 4px 12px; min-height: 30px;
  font-size: 13px; font-weight: 600; line-height: 1.2;
  display: inline-flex; flex-direction: column; align-items: center; gap: 0;
  transition: background .15s ease, color .15s ease;
}
.seg__btn .seg__sub { font-size: 10.5px; font-weight: 500; color: var(--muted); font-family: var(--mono); letter-spacing: .3px; }
.seg__btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.seg__btn.is-active .seg__sub { color: var(--primary); }

/* ---------- 「我」分頁 ---------- */
.me-head { display: flex; align-items: center; gap: 14px; }
.me-head__body { flex: 1; min-width: 0; }
.me-head .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat--primary { background: var(--accent-soft); }
.stat--primary .stat__k::after { content: "主"; font-size: 10px; background: var(--accent); color: var(--on-accent); border-radius: 4px; padding: 0 4px; letter-spacing: 0; }

/* ---------- 班表 meta 列 ---------- */
.sched-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); align-items: center; }
.sched-meta b { font-weight: 600; color: var(--ink); }
.sched-badge:empty { display: none; }
.nav__emoji { font-size: 20px; line-height: 1; }

/* =====================================================================
   外殼(shell):topbar / nav / view
   ===================================================================== */
:root { --topbar-h: 52px; --tabbar-h: 60px; --sidenav-w: 208px; }
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-sizing: content-box;
}
.brand { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand__logo { width: 28px; height: 28px; flex: none; }
.brand__name { font-weight: 800; letter-spacing: 2px; font-size: 15px; color: var(--brand-teal); }
:root[data-theme="dark"] .brand__name { color: var(--primary); }
.brand__sep { color: var(--line-strong); font-weight: 300; }
.brand__title { font-weight: 600; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar__right { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.unit-switch { max-width: 180px; min-height: 34px; padding: 4px 28px 4px 10px; font-size: 13px; border-radius: 999px; }
.topbar .avatar { width: 32px; height: 32px; font-size: 13px; cursor: pointer; }
.topbar .avatar:hover { box-shadow: 0 0 0 3px var(--accent-soft); }

.nav { display: flex; }
.nav__item {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-weight: 600; font-size: 12px;
  text-decoration: none; border-radius: var(--radius-sm);
  transition: color .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.nav__item:hover { text-decoration: none; color: var(--ink); }
.nav__item svg { width: 22px; height: 22px; flex: none; }
.nav__item.is-active { color: var(--primary); }
.view { flex: 1; min-width: 0; width: 100%; }
.view > .page { animation: view-in .18s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* mobile:底部 tab bar */
@media (max-width: 640px) {
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
    justify-content: space-around;
  }
  .nav__item { flex: 1; flex-direction: column; gap: 2px; padding: 4px 2px; }
  .nav__item.is-active { background: transparent; }
  .nav__item.is-active svg { transform: translateY(-1px); }
  .view { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
  .brand__title { max-width: 34vw; }
  .unit-switch { max-width: 120px; }
}
/* desktop:左側欄 */
@media (min-width: 641px) {
  .shell__body { display: flex; flex: 1; align-items: stretch; }
  .nav {
    flex-direction: column; gap: 4px;
    width: var(--sidenav-w); flex: none;
    padding: 14px 10px;
    border-right: 1px solid var(--line);
    background: var(--surface);
    position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
    align-self: flex-start;
  }
  .nav__item { justify-content: flex-start; padding: 10px 12px; font-size: 14px; }
  .nav__item.is-active { background: var(--accent-soft); color: var(--primary); }
  .nav__item:hover:not(.is-active) { background: var(--surface-2); }
  .page { padding: 22px 24px 40px; }
}

/* ---------- splash / loading ---------- */
.splash { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); text-align: center; padding: 24px; }
.splash .brand__logo { width: 56px; height: 56px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 12px 0; }

/* =====================================================================
   toast
   ===================================================================== */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(92vw, 420px); pointer-events: none;
}
@media (max-width: 640px) { .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--brand-charcoal); color: #fff;
  font-size: 14px; font-weight: 500; line-height: 1.45;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  max-width: 100%;
  animation: toast-in .22s cubic-bezier(.2,.8,.2,1) both;
}
:root[data-theme="dark"] .toast { background: #E6ECF2; color: #151A21; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--brand-mist); }
.toast--ok::before { background: var(--accent); }
.toast--warn::before { background: var(--warn); }
.toast--error::before { background: var(--brand-coral); }
.toast.is-leaving { animation: toast-out .18s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }

/* =====================================================================
   modal
   ===================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 30, 36, .48);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
  animation: fade-in .18s ease both;
}
@media (min-width: 641px) { .modal-backdrop { align-items: center; } }
.modal {
  width: min(100%, 460px); max-height: 86vh; max-height: 86dvh;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: modal-in .22s cubic-bezier(.2,.8,.2,1) both;
}
.modal__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.modal__title { font-size: 16px; font-weight: 700; margin-right: auto; }
.modal__body { padding: 8px 16px 14px; overflow: auto; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.modal__body p { margin: 0 0 8px; }
.modal__body p:last-child { margin-bottom: 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 16px; border-top: 1px solid var(--line); }
@media (max-width: 640px) { .modal__actions .btn { flex: 1; } }
.modal-backdrop.is-closing { animation: fade-out .16s ease both; }
.modal-backdrop.is-closing .modal { animation: modal-out .16s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes modal-out { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }
body.has-modal { overflow: hidden; }

/* change list inside modal */
.change-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.change-list__item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line); flex-wrap: wrap; }
.change-list__arrow { color: var(--muted); }
.change-list__time { margin-left: auto; font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* =====================================================================
   班表(schedule table)
   ===================================================================== */
.sched-wrap {
  overflow: auto;
  max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px);
  min-height: 200px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.sched { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
/* 注意:td 不在這裡設 background,否則 (0,1,1) 會壓過 .cell--d 等 (0,1,0) 的班別色 */
.sched th, .sched td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; }
.sched th { background: var(--surface); }
.sched thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.sched th.day-head { min-width: 34px; width: 34px; height: 40px; text-align: center; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sched th.day-head .d { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.sched th.day-head .w { display: block; font-size: 10.5px; color: var(--muted); }
.sched th.day-head.col--weekend .w { color: var(--danger-ink); }
.sched .name-col { position: sticky; left: 0; z-index: 2; min-width: 96px; max-width: 132px; text-align: left; padding: 0 8px; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.sched thead th.name-col { z-index: 4; background: var(--surface-2); }
.sched .name-col .nm { display: block; font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched .name-col .name-inner { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.sched .name-col .name-inner .chip { min-width: 22px; height: 18px; font-size: 11px; padding: 0 5px; }
.sched .name-col .name-inner .nm { flex: 1; min-width: 0; }
.sched .name-col .me-tag { font-size: 10px; background: var(--accent); color: var(--on-accent); border-radius: 4px; padding: 0 4px; font-weight: 700; flex: none; }
.sched th.col--weekend, .sched td.cell--empty.col--weekend { background: var(--weekend-bg); }
.sched th.col--today { box-shadow: inset 0 -3px 0 var(--today-ring); }
.sched th.col--today .d { color: var(--accent); }
/* 自己那列:名字欄反白 + 上下 2px 強調線(用 border,不用 box-shadow,避免蓋掉 .cell--override / .cell--today 的框) */
.sched .row--me .name-col { background: var(--accent-soft); box-shadow: 1px 0 0 var(--accent), inset 3px 0 0 var(--accent); }
.sched .row--me th, .sched .row--me td { border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.sched .row--me td.cell { height: 38px; }
.sched tfoot td { background: var(--surface-2); color: var(--muted); font-size: 11.5px; text-align: center; height: 26px; }

/* 格子 */
.cell {
  position: relative;
  min-width: 34px; width: 34px; height: 36px;
  text-align: center; vertical-align: middle;
  font-family: var(--mono); font-weight: 700; font-size: 12.5px; letter-spacing: .2px;
  color: var(--ink-2); background: var(--shift-empty-bg);
  user-select: none;
}
.cell--d { background: var(--shift-d-bg); color: var(--shift-d-ink); }
.cell--e { background: var(--shift-e-bg); color: var(--shift-e-ink); }
.cell--n { background: var(--shift-n-bg); color: var(--shift-n-ink); }
.cell--off { background: var(--shift-off-bg); color: var(--shift-off-ink); font-family: var(--font); font-size: 12px; }
.cell--offreg { background: var(--shift-offreg-bg); color: var(--shift-offreg-ink); font-family: var(--font); font-size: 12px; }
.cell--empty { background: var(--shift-empty-bg); color: var(--line-strong); }
.cell--implicit { opacity: .78; }
.cell--override::after { content: ""; position: absolute; inset: 0; background: var(--override-stripe); pointer-events: none; }
.cell--override { box-shadow: inset 0 0 0 2px var(--brand-coral); }
.cell--locked::before { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--lock-dot); z-index: 1; }
.cell--changed { outline: 2px solid var(--warn); outline-offset: -2px; cursor: pointer; }
.cell--changed::after { content: ""; position: absolute; left: 3px; bottom: 3px; width: 0; height: 0; border-style: solid; border-width: 5px 0 0 5px; border-color: transparent transparent transparent var(--warn); }
.cell--changed.cell--override::after { background: var(--override-stripe); border: 0; inset: 0; width: auto; height: auto; }
.cell--today { box-shadow: inset 0 0 0 2px var(--today-ring); }
.cell--override.cell--today { box-shadow: inset 0 0 0 2px var(--brand-coral), inset 0 0 0 4px var(--today-ring); }
.cell--wish { box-shadow: inset 0 0 0 2px var(--accent); }
.cell--selected { box-shadow: inset 0 0 0 2px var(--primary); z-index: 1; }
.cell--red { box-shadow: inset 0 0 0 2px var(--danger); }
.cell--yellow { box-shadow: inset 0 0 0 2px var(--warn); }
.cell--muted { color: var(--muted); }
.cell > span { position: relative; z-index: 1; }

/* 圖例用的迷你格 */
.legend__swatch.cell { min-width: 22px; width: 22px; height: 18px; font-size: 10px; }

/* =====================================================================
   預假日曆(leave calendar)
   ===================================================================== */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__head { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 2px 0; }
.cal__head--weekend { color: var(--danger-ink); }
.cal__day {
  position: relative;
  aspect-ratio: 1 / 1; min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
  -webkit-tap-highlight-color: transparent;
}
.cal__day--blank { border-color: transparent; background: transparent; pointer-events: none; }
.cal__day--weekend { background: var(--weekend-bg); }
.cal__day--today { box-shadow: inset 0 0 0 2px var(--today-ring); }
.cal__day--wish { background: var(--shift-off-bg); color: var(--shift-off-ink); border-color: var(--shift-off-line); }
.cal__day--wish::after { content: "休"; position: absolute; right: 4px; bottom: 2px; font-size: 10px; font-weight: 700; opacity: .8; }
.cal__day--approved { background: var(--accent-soft); color: var(--ok-ink); border-color: var(--accent); }
.cal__day--approved::after { content: ""; position: absolute; right: 4px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.cal__day--approved .cal__lock { position: absolute; right: 3px; bottom: 3px; width: 11px; height: 11px; }
.cal__day--pending { opacity: .55; }
.cal__day--readonly { cursor: default; }
button.cal__day:not(:disabled):not(.cal__day--readonly):hover { border-color: var(--accent); }
button.cal__day:not(:disabled):active { transform: scale(.96); }
.cal__day:disabled { cursor: not-allowed; opacity: .55; }
@media (min-width: 641px) { .cal { gap: 8px; } .cal__day { min-height: 52px; font-size: 16px; } }

.leave-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13.5px; color: var(--ink-2); }
.leave-meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.leave-meta .pill { font-variant-numeric: tabular-nums; }

/* =====================================================================
   簡表(一般 table)
   ===================================================================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-3); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.icon-inline { width: 16px; height: 16px; vertical-align: -3px; }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }
:root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
.pending-illus { width: 80px; height: 80px; margin: 0 auto 8px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .toast, .toast.is-leaving, .modal, .modal-backdrop, .modal-backdrop.is-closing, .modal-backdrop.is-closing .modal, .view > .page { animation: none !important; }
  .spinner { animation: spin 1.5s linear infinite !important; }
}

/* ---------- print(成員端偶爾截圖/列印) ---------- */
@media print {
  .topbar, .nav, .toasts, .modal-backdrop { display: none !important; }
  .view { padding: 0 !important; }
  .sched-wrap { max-height: none; overflow: visible; border: 0; }
}
