/* ==========================================================================
   HAJIRI DESIGN SYSTEM — Components
   Layer 2 of 3. Depends on theme.css tokens.

   Every dialog in Hajiri lives here: the browser's alert/confirm/prompt and
   the native validation bubble are never used.
   ========================================================================== */

/* ==========================================================  OVERLAY  === */
.h-overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: rgba(7, 35, 26, 0.42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) ease;
}
.h-overlay.show { opacity: 1; pointer-events: auto; }
body.h-locked { overflow: hidden; }

/* ============================================================  MODAL  === */
.h-modal {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: 20px;
  pointer-events: none;
}
.h-modal.show { pointer-events: auto; }
.h-modal-card {
  width: 100%; max-width: 460px; max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--e4);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: scale(.96) translateY(8px);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.h-modal.show .h-modal-card { opacity: 1; transform: none; }
.h-modal-card.md { max-width: 560px; }
.h-modal-card.lg { max-width: 720px; }

.h-modal-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 22px 22px 0;
}
.h-modal-head .h-modal-titles { flex: 1; min-width: 0; padding-top: 2px; }
.h-modal-head h3 {
  font-size: 17px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.02em; line-height: 1.35;
}
.h-modal-head p { font-size: 13.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.55; }
.h-modal-close {
  flex: 0 0 auto; width: 30px; height: 30px; margin: -4px -4px 0 0;
  border-radius: var(--r-sm); display: grid; place-items: center; color: var(--ink-4);
  transition: background var(--t-fast), color var(--t-fast);
}
.h-modal-close:hover { background: var(--surface-2); color: var(--ink); }

.h-modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.h-modal-body:empty { display: none; }
.h-modal-head + .h-modal-foot { margin-top: 22px; }

.h-modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--line); background: var(--surface-2);
  flex-wrap: wrap;
}
.h-modal-foot.spread { justify-content: space-between; }
.h-modal-foot .grow { flex: 1; }

/* ===========================================================  DRAWER  === */
.h-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-drawer);
  width: 100%; max-width: 560px;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--e4);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease-in-out);
  pointer-events: none;
}
.h-drawer.show { transform: none; pointer-events: auto; }
.h-drawer.sm { max-width: 440px; }
.h-drawer.lg { max-width: 720px; }
.h-drawer.xl { max-width: 920px; }

.h-drawer-head {
  flex: 0 0 auto; display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.h-drawer-head .h-drawer-titles { flex: 1; min-width: 0; }
.h-drawer-head h3 {
  font-size: 17px; font-weight: 750; color: var(--ink);
  letter-spacing: -0.02em; line-height: 1.35;
}
.h-drawer-head p { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.h-drawer-close {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--ink-4);
  transition: background var(--t-fast), color var(--t-fast);
}
.h-drawer-close:hover { background: var(--surface-2); color: var(--ink); }

.h-drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 22px 24px; overscroll-behavior: contain; }
.h-drawer-body.flush { padding: 0; }
.h-drawer-foot {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface-2);
  flex-wrap: wrap;
}
.h-drawer-foot.end { justify-content: flex-end; }
.h-drawer-foot.spread { justify-content: space-between; }

@media (max-width: 640px) {
  .h-drawer, .h-drawer.sm, .h-drawer.lg, .h-drawer.xl {
    max-width: none; top: auto; height: 92vh;
    border-left: none; border-top: 1px solid var(--line);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    transform: translateY(100%);
  }
  .h-drawer.show { transform: none; }
  .h-drawer-head { border-radius: var(--r-2xl) var(--r-2xl) 0 0; }
}

/* ============================================================  TOAST  === */
.toast-stack {
  position: fixed; z-index: var(--z-toast);
  top: 16px; right: 16px; width: min(380px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--ink-4);
  border-radius: var(--r-md); box-shadow: var(--e3);
  padding: 13px 14px; pointer-events: auto;
  animation: h-toast-in var(--t-slow) var(--ease) both;
}
@keyframes h-toast-in { from { opacity: 0; transform: translateX(24px) scale(.97) } to { opacity: 1; transform: none } }
@keyframes h-toast-out { to { opacity: 0; transform: translateX(24px) scale(.97); max-height: 0; margin-bottom: -10px; padding-top: 0; padding-bottom: 0 } }
.toast.leaving { animation: h-toast-out var(--t-base) var(--ease-in-out) both; }
.toast .toast-ic { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.toast .toast-text { flex: 1; min-width: 0; }
.toast .toast-text b { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink); line-height: 1.4; }
.toast .toast-text span { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.5; }
.toast .toast-x {
  flex: 0 0 auto; width: 24px; height: 24px; margin: -2px -3px 0 0;
  border-radius: var(--r-xs); display: grid; place-items: center; color: var(--ink-4);
  transition: background var(--t-fast), color var(--t-fast);
}
.toast .toast-x:hover { background: var(--surface-2); color: var(--ink); }
.toast.t-ok    { border-left-color: var(--ok) }    .toast.t-ok    .toast-ic { color: var(--ok-d) }
.toast.t-warn  { border-left-color: var(--warn) }  .toast.t-warn  .toast-ic { color: var(--warn-d) }
.toast.t-bad   { border-left-color: var(--bad) }   .toast.t-bad   .toast-ic { color: var(--bad-d) }
.toast.t-info  { border-left-color: var(--info) }  .toast.t-info  .toast-ic { color: var(--info-d) }
.toast.t-brand { border-left-color: var(--brand) } .toast.t-brand .toast-ic { color: var(--brand-d) }

@media (max-width: 560px) {
  .toast-stack { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; }
  @keyframes h-toast-in { from { opacity: 0; transform: translateY(24px) scale(.97) } to { opacity: 1; transform: none } }
}

/* =============================================================  TABS  === */
.h-tabs {
  display: flex; align-items: center; gap: 2px;
  border-bottom: 1px solid var(--line); margin-bottom: 20px;
  overflow-x: auto; scrollbar-width: none;
}
.h-tabs::-webkit-scrollbar { display: none; }
.h-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.h-tab:hover { color: var(--ink); text-decoration: none; }
.h-tab.on { color: var(--brand-d); border-bottom-color: var(--brand); }
.h-tab .ic { width: 16px; height: 16px; }
.h-tab .cnt {
  min-width: 19px; text-align: center; padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--ink-3); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.h-tab.on .cnt { background: var(--brand-t); color: var(--brand-d); }
.h-tabs.pill { border-bottom: none; gap: 6px; }
.h-tabs.pill .h-tab {
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 7px 14px; margin: 0;
  background: var(--surface);
}
.h-tabs.pill .h-tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.h-tabs.pill .h-tab.on .cnt { background: rgba(255,255,255,.22); color: #fff; }

.tab-panel { display: none; }
.tab-panel.on { display: block; animation: h-fade var(--t-base) ease both; }

/* =========================================================  DROPDOWN  === */
.h-dd { position: relative; display: inline-flex; }
.h-dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  min-width: 194px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--e3);
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.h-dd.open .h-dd-menu { opacity: 1; transform: none; pointer-events: auto; }
.h-dd-menu.left { right: auto; left: 0; }
.h-dd-menu.up { top: auto; bottom: calc(100% + 6px); transform: translateY(6px) scale(.98); }
.h-dd-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.h-dd-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.h-dd-item .ic { width: 16px; height: 16px; color: var(--ink-3); flex: 0 0 auto; }
.h-dd-item:hover .ic { color: var(--ink-2); }
.h-dd-item.danger { color: var(--bad-d); } .h-dd-item.danger .ic { color: var(--bad-d); }
.h-dd-item.danger:hover { background: var(--bad-t); color: var(--bad-d); }
.h-dd-item.on { background: var(--brand-t); color: var(--brand-d); font-weight: 650; }
.h-dd-item[disabled], .h-dd-item.disabled { opacity: .45; pointer-events: none; }
.h-dd-sep { height: 1px; background: var(--line); margin: 5px 0; }
.h-dd-label {
  padding: 7px 10px 5px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4);
}
.h-dd-form { margin: 0; }
.h-dd-form button { width: 100%; }

/* ==========================================================  TOOLTIP  === */
.h-tip { position: relative; display: inline-flex; }
.h-tip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 550;
  padding: 5px 9px; border-radius: var(--r-sm); white-space: nowrap;
  opacity: 0; pointer-events: none; z-index: 55;
  transition: opacity var(--t-fast) ease, transform var(--t-fast) var(--ease);
  box-shadow: var(--e2);
}
.h-tip:hover::after, .h-tip:focus-visible::after { opacity: 1; transform: translateX(-50%); }
.h-tip.down::after { bottom: auto; top: calc(100% + 7px); transform: translateX(-50%) translateY(-3px); }
.h-tip.down:hover::after { transform: translateX(-50%); }
.h-tip.left::after { left: auto; right: 0; transform: translateY(3px); }
.h-tip.left:hover::after, .h-tip.left:focus-visible::after { transform: none; }

/* ======================================================  EMPTY STATE  === */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 52px 28px; gap: 4px;
}
.empty .empty-ic {
  width: 60px; height: 60px; border-radius: var(--r-xl); margin-bottom: 14px;
  background: var(--surface-2); color: var(--ink-4);
  display: grid; place-items: center;
}
.empty .empty-ic .ic { width: 28px; height: 28px; stroke-width: 1.5; }
.empty .empty-ic.t-brand { background: var(--brand-50); color: var(--brand-400) }
.empty .empty-ic.t-ok    { background: var(--ok-t);     color: var(--ok-d) }
.empty .empty-ic.t-warn  { background: var(--warn-t);   color: var(--warn-d) }
.empty h4 { font-size: 15.5px; font-weight: 700; color: var(--ink); letter-spacing: -0.015em; }
.empty p { font-size: 13.5px; color: var(--ink-3); max-width: 42ch; line-height: 1.6; margin-top: 4px; }
.empty .empty-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.empty.sm { padding: 34px 20px; }
.empty.sm .empty-ic { width: 46px; height: 46px; border-radius: var(--r-md); margin-bottom: 10px; }
.empty.sm .empty-ic .ic { width: 22px; height: 22px; }
.empty.sm h4 { font-size: 14px; }
.empty.sm p { font-size: 13px; }
td .empty { padding: 40px 20px; }

/* =========================================================  SKELETON  === */
.sk {
  display: block; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 420px 100%;
  animation: h-shimmer 1.3s linear infinite;
}
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-line:last-child { margin-bottom: 0; }
.sk-line.w-90 { width: 90% } .sk-line.w-75 { width: 75% }
.sk-line.w-60 { width: 60% } .sk-line.w-40 { width: 40% } .sk-line.w-25 { width: 25% }
.sk-title { height: 18px; width: 45%; margin-bottom: 12px; }
.sk-circle { border-radius: 50%; width: 36px; height: 36px; }
.sk-box { height: 84px; border-radius: var(--r-md); }
.sk-kpi { height: 104px; border-radius: var(--r-lg); }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.sk-row:last-child { border-bottom: none; }
.sk-row .sk-line { margin: 0; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid currentColor; border-right-color: transparent;
  opacity: .7; animation: h-spin .7s linear infinite;
}
.spinner.lg { width: 26px; height: 26px; border-width: 2.5px; }
.btn.is-loading { pointer-events: none; opacity: .75; }

/* =========================================================  PROGRESS  === */
.prog { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.prog > span {
  display: block; height: 100%; border-radius: inherit; background: var(--brand);
  transition: width var(--t-slow) var(--ease);
}
.prog.sm { height: 4px; }
.prog.lg { height: 9px; }
.prog.ok > span   { background: var(--ok) }
.prog.warn > span { background: var(--warn) }
.prog.bad > span  { background: var(--bad) }

.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset 700ms var(--ease); }
.ring .ring-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 17px; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums;
}

/* =========================================================  TIMELINE  === */
/* Horizontal — the attendance day strip (check-in → break → check-out) */
.tl-h { display: flex; align-items: stretch; gap: 0; width: 100%; }
.tl-h-step { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; position: relative; }
.tl-h-step .tl-track { display: flex; align-items: center; height: 22px; }
.tl-h-step .tl-node {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; z-index: 1;
  background: var(--surface); border: 2.5px solid var(--line-3);
}
.tl-h-step .tl-bar { flex: 1; height: 2px; background: var(--line); }
.tl-h-step:last-child { flex: 0 0 auto; }
.tl-h-step:last-child .tl-bar { display: none; }
.tl-h-step.done .tl-node { border-color: var(--ok); background: var(--ok); }
.tl-h-step.done .tl-bar { background: var(--ok); }
.tl-h-step.live .tl-node { border-color: var(--ok); background: var(--surface); animation: h-ring 2s ease-out infinite; }
.tl-h-step.live .tl-bar { background: linear-gradient(90deg, var(--ok), var(--line)); }
.tl-h-step.skip .tl-node { border-color: var(--line-3); background: var(--surface-3); }
.tl-h-step .tl-meta { padding-right: 12px; min-width: 0; }
.tl-h-step .tl-meta b {
  display: block; font-size: 13.5px; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.tl-h-step .tl-meta span {
  display: block; font-size: 11.5px; color: var(--ink-4); font-weight: 550;
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px;
}
.tl-h-step.pending .tl-meta b { color: var(--ink-4); font-weight: 500; }

/* Vertical — duty history */
.tl-v { position: relative; padding-left: 26px; }
.tl-v::before {
  content: ''; position: absolute; left: 6.5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-v-item { position: relative; padding-bottom: 20px; }
.tl-v-item:last-child { padding-bottom: 0; }
.tl-v-item::before {
  content: ''; position: absolute; left: -26px; top: 4px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--line-3); z-index: 1;
}
.tl-v-item.ok::before   { border-color: var(--ok) }
.tl-v-item.warn::before { border-color: var(--warn) }
.tl-v-item.bad::before  { border-color: var(--bad) }
.tl-v-item.brand::before{ border-color: var(--brand) }
.tl-v-item .tl-when {
  font-size: 11.5px; font-weight: 650; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.05em; font-variant-numeric: tabular-nums;
}
.tl-v-item .tl-what { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.tl-v-item .tl-note { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.5; }

/* =========================================================  CALENDAR  === */
.cal { user-select: none; }
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.cal-head b { font-size: 14px; font-weight: 700; color: var(--ink); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow {
  text-align: center; font-size: 10.5px; font-weight: 700; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.06em; padding-bottom: 6px;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid transparent;
  font-variant-numeric: tabular-nums; position: relative;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.cal-day.blank { background: none; }
.cal-day.today { border-color: var(--brand); color: var(--brand-d); font-weight: 750; }
.cal-day .cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-3); }
.cal-day.s-present  { background: var(--ok-t);   color: var(--ok-d) }
.cal-day.s-present  .cal-dot { background: var(--ok) }
.cal-day.s-absent   { background: var(--bad-t);  color: var(--bad-d) }
.cal-day.s-absent   .cal-dot { background: var(--bad) }
.cal-day.s-leave    { background: var(--warn-t); color: var(--warn-d) }
.cal-day.s-leave    .cal-dot { background: var(--warn) }
.cal-day.s-holiday  { background: var(--info-t); color: var(--info-d) }
.cal-day.s-holiday  .cal-dot { background: var(--info) }
.cal-day.s-half     { background: var(--warn-t); color: var(--warn-d) }
.cal-day.s-half     .cal-dot { background: linear-gradient(90deg, var(--ok) 50%, var(--warn) 50%) }
.cal-day.s-off      { background: var(--surface-2); color: var(--ink-4) }
.cal-day.s-off      .cal-dot { background: transparent }
a.cal-day:hover, button.cal-day:hover { border-color: var(--line-3); text-decoration: none; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.cal-legend i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }

/* ============================================================  STEPS  === */
.steps { display: flex; align-items: center; gap: 0; }
.step { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.step:last-child { flex: 0 0 auto; }
.step .step-n {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-4); border: 1.5px solid var(--line-2);
}
.step .step-t { font-size: 13px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.step .step-bar { flex: 1; height: 2px; background: var(--line); margin: 0 10px; min-width: 16px; }
.step.done .step-n { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done .step-t { color: var(--ink-2); }
.step.done .step-bar { background: var(--ok); }
.step.on .step-n { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.on .step-t { color: var(--brand-d); font-weight: 700; }

/* ======================================================  DATA VISUAL  === */
.chart-box { position: relative; width: 100%; }
.chart-box.h-200 { height: 200px } .chart-box.h-240 { height: 240px }
.chart-box.h-280 { height: 280px } .chart-box.h-320 { height: 320px }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-hole { position: relative; width: 168px; height: 168px; flex: 0 0 auto; }

/* =========================================================  TOOLBAR  === */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px 18px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); margin-bottom: 22px; flex-wrap: wrap;
}
.toolbar form { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-label { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.toolbar .spacer { flex: 1; }
.toolbar .btn { height: 36px; padding: 0 14px; font-size: 13px; }

/* ========================================================  TIMELINE  === */
.tl-view { display: none; }
.tl-view.active { display: block; }
/* One knob for the name column: the axis below pads itself by the same amount,
   so the two can never drift apart. Narrowed at 560px. */
:root { --tl-who-w: 220px; }

.tl-row {
  display: flex; align-items: center; gap: 16px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.tl-row:last-child { border-bottom: none; }
/* One knob for the name column: the axis below pads itself by the same amount,
   so the two can never drift apart. Narrowed at 560px. */
.tl-who { width: var(--tl-who-w); flex: 0 0 auto; }
.tl-who b { display: block; font-size: 14px; font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-who span { display: block; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track {
  flex: 1; min-width: 0; height: 36px; background: var(--surface-3);
  border-radius: var(--r-sm); position: relative;
}
.tl-bar {
  position: absolute; top: 4px; bottom: 4px; background: var(--ok);
  border-radius: var(--r-sm); transition: width var(--t-fast);
}
.tl-bar.pending { background: var(--warn); }
.tl-bar.absent { background: var(--bad); }
.tl-axis {
  display: flex; justify-content: space-between; font-size: 11px;
  color: var(--ink-4); font-weight: 600; padding: 4px 18px 0 calc(var(--tl-who-w) + 34px);
}


/* ========================================================  SETTINGS  === */
.settings-layout { display: flex; gap: 48px; align-items: flex-start; }
.settings-nav { flex: 0 0 220px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 24px; }
.settings-nav button, .settings-nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; 
  border-radius: var(--r-md); color: var(--ink-3); font-weight: 500; 
  text-decoration: none; border: none; background: transparent; cursor: pointer; text-align: left; transition: var(--t-fast);
}
.settings-nav button:hover, .settings-nav a:hover { background: var(--surface-2); color: var(--ink); }
.settings-nav button.active, .settings-nav a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.settings-nav .ic { color: var(--ink-4); }
.settings-nav .active .ic { color: var(--ink); }

.settings-content { flex: 1; min-width: 0; max-width: 640px; }
.settings-section { display: none; animation: fade-in var(--t-fast); }
.settings-section.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Toggle Switch */
.toggle-switch {
  position: relative; display: inline-block; width: 44px; height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--line-2); transition: .4s; border-radius: 24px;
}
.toggle-slider:before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: white; transition: .4s; border-radius: 50%; box-shadow: var(--e1);
}
input:checked + .toggle-slider { background-color: var(--brand); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

/* The donut is drawn by the browser, not a charting library. Three segments
   never needed 200 KB of JavaScript over a CDN, and the site's CSP refuses
   third-party script anyway. Each slice is an angle set inline by the template;
   --ring is the thickness of the band. */
.donut-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(
    var(--ok) 0turn var(--seg-1),
    var(--bad) var(--seg-1) var(--seg-2),
    var(--warn) var(--seg-2) var(--seg-3),
    var(--line-2) var(--seg-3) 1turn
  );
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent calc(50% - var(--ring)), #000 calc(50% - var(--ring) + 1px));
          mask-image: radial-gradient(circle at 50% 50%, transparent calc(50% - var(--ring)), #000 calc(50% - var(--ring) + 1px));
  --ring: 23px;
  transform: rotate(-90deg);
}
@media (prefers-reduced-motion: no-preference) {
  .donut-ring { animation: h-donut var(--t-slow) var(--ease) both; }
}
@keyframes h-donut { 
  from { opacity: 0; transform: rotate(-90deg) scale(.94) } 
  to { opacity: 1; transform: rotate(-90deg) scale(1) } 
}
.donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  pointer-events: none;
}
.donut-center b { font-size: 26px; font-weight: 750; color: var(--ink); letter-spacing: -0.03em; line-height: 1.1; }
.donut-center span { display: block; font-size: 11px; color: var(--ink-4); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-top: 2px; }
.legend { display: grid; gap: 10px; flex: 1; min-width: 150px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-row i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.legend-row span { color: var(--ink-2); flex: 1; }
.legend-row b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Sparkline bars — attendance trend without a chart library */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 68px; }
.spark-bar {
  flex: 1; min-width: 3px; border-radius: 3px 3px 0 0;
  background: var(--brand-200); min-height: 3px;
  transition: background var(--t-fast), height var(--t-slow) var(--ease);
}
.spark-bar.hi { background: var(--brand); }
.spark-bar.lo { background: var(--bad-t); }
.spark-labels {
  display: flex; gap: 4px; margin-top: 7px;
  font-size: 10.5px; color: var(--ink-4); font-weight: 600; text-align: center;
}
.spark-labels span { flex: 1; min-width: 3px; }

/* ============================================================  MAP  ==== */
.map-card {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
  min-height: 280px;
}
.map-canvas {
  position: absolute; inset: 0;
  background-color: #EAF0EC;
  background-image:
    linear-gradient(rgba(21,122,78,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21,122,78,.055) 1px, transparent 1px),
    linear-gradient(rgba(21,122,78,.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21,122,78,.1) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px, 110px 110px, 110px 110px;
}
.map-fence {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--brand-t);
  border: 2px dashed var(--brand-300);
  display: grid; place-items: center;
  transition: width var(--t-slow) var(--ease), height var(--t-slow) var(--ease);
}
.map-fence::after {
  content: ''; position: absolute; inset: 22%; border-radius: 50%;
  background: rgba(21,122,78,.07);
}
.map-pin {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -100%);
  color: var(--brand-d); z-index: 2; filter: drop-shadow(0 3px 5px rgba(7,35,26,.25));
}
.map-pin .ic { width: 34px; height: 34px; fill: var(--surface); }
.map-badge {
  position: absolute; z-index: 3; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border: 1px solid var(--line); box-shadow: var(--e2);
  font-size: 12.5px; font-weight: 650; color: var(--ink-2);
}
.map-badge.tl { top: 12px; left: 12px } .map-badge.tr { top: 12px; right: 12px }
.map-badge.bl { bottom: 12px; left: 12px } .map-badge.br { bottom: 12px; right: 12px }
.map-foot {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap;
}

/* ==========================================================  DETAILS  === */
.detail-list { display: grid; gap: 0; }
.detail-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; }
.detail-row > dt, .detail-row .k { font-size: 13px; color: var(--ink-3); flex: 0 0 auto; }
.detail-row > dd, .detail-row .v {
  font-size: 13.5px; font-weight: 600; color: var(--ink); text-align: right; min-width: 0;
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px 20px; }
.detail-item .k {
  display: block; font-size: 11px; font-weight: 650; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px;
}
.detail-item .v { font-size: 14px; font-weight: 600; color: var(--ink); }

/* Stat strip inside drawers */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.stat-strip > div {
  padding: 13px 14px; border-right: 1px solid var(--line); background: var(--surface);
  text-align: center;
}
.stat-strip > div:last-child { border-right: none; }
.stat-strip b {
  display: block; font-size: 19px; font-weight: 750; color: var(--ink);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.stat-strip span {
  display: block; font-size: 11px; color: var(--ink-4); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px;
}
.stat-strip .ok b { color: var(--ok-d) } .stat-strip .bad b { color: var(--bad-d) }
.stat-strip .warn b { color: var(--warn-d) } .stat-strip .brand b { color: var(--brand-d) }

/* ==================================================  SETTINGS LAYOUT  === */
.set-layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: 24px; align-items: start; }
.set-nav {
  position: sticky; top: calc(var(--topbar-h) + 20px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 8px;
}
.set-nav-group + .set-nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.set-nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-4); padding: 4px 10px 6px;
}
.set-nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--r-sm); font-size: 13.5px; font-weight: 550; color: var(--ink-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.set-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.set-nav a.on { background: var(--brand-t); color: var(--brand-d); font-weight: 650; }
.set-nav a .ic { width: 16px; height: 16px; }
@media (max-width: 1024px) {
  .set-layout { grid-template-columns: 1fr; }
  .set-nav { position: static; display: flex; gap: 4px; overflow-x: auto; padding: 6px; }
  .set-nav-group { display: flex; gap: 4px; }
  .set-nav-group + .set-nav-group { margin: 0; padding: 0 0 0 10px; border-top: none; border-left: 1px solid var(--line); }
  .set-nav-label { display: none; }
  .set-nav a { white-space: nowrap; }
}

/* ==============================================  FILTER / TOOLBAR BAR == */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.toolbar form { display: contents; }
.toolbar .tb-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .tb-label { font-size: 12px; font-weight: 650; color: var(--ink-3); }
.toolbar select, .toolbar input[type=month], .toolbar input[type=date], .toolbar input[type=text] {
  height: 36px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); font-size: 13.5px; color: var(--ink); min-width: 120px;
}
.toolbar select { padding-right: 32px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2363756D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.toolbar select:focus, .toolbar input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}

/* Filter chips */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { background: var(--surface-2); border-color: var(--line-3); color: var(--ink); text-decoration: none; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .cnt { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 700; }

/* ==========================================================  BANNERS  === */
.notice-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); margin-bottom: 18px;
}
.notice-card .notice-body { flex: 1; min-width: 0; }
.notice-card h4 { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.notice-card p { font-size: 13px; color: var(--ink-3); margin-top: 3px; line-height: 1.55; }
.notice-card .notice-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.notice-card.brand { background: var(--brand-50); border-color: var(--brand-200); }
.notice-card.warn  { background: var(--warn-t);  border-color: var(--warn-line); }
.notice-card.bad   { background: var(--bad-t);   border-color: var(--bad-line); }

/* =========================================================  PAGINATION = */
.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span {
  min-width: 32px; height: 32px; padding: 0 9px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  border: 1px solid transparent; transition: background var(--t-fast), border-color var(--t-fast);
  font-variant-numeric: tabular-nums;
}
.pager a:hover { background: var(--surface); border-color: var(--line-2); text-decoration: none; }
.pager .on { background: var(--brand); color: #fff; }
.pager .off { color: var(--ink-4); pointer-events: none; }

/* =======================================================  NARROW SCREENS ==
   Rules that only bite below the tablet breakpoint. The page shell itself is
   handled in theme.css; these are the components whose fixed widths were sized
   for a desktop column and would otherwise push the layout sideways on a phone.
   ========================================================================== */
@media (max-width: 900px) {
  /* Stacked, the sticky side nav would pin itself over the panel it controls. */
  .settings-layout { flex-direction: column; gap: 20px; }
  .settings-nav {
    position: static; flex: none; width: 100%;
    flex-direction: row; overflow-x: auto; gap: 4px;
    padding-bottom: 4px; scrollbar-width: none;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav button, .settings-nav a { white-space: nowrap; padding: 9px 12px; }
  .settings-content { max-width: none; }

  /* The timeline is a fixed-width name column beside a flexible track. On a
     phone the 220px column leaves the track too narrow to read, so shrink it —
     .tl-axis follows automatically through the shared token. */
  :root { --tl-who-w: 116px; }
  .tl-row { padding: 12px 14px; gap: 12px; }
  .tl-axis { padding: 4px 14px 0 calc(var(--tl-who-w) + 26px); }

  /* Horizontal scrollers rather than wrapped blobs. */
  .toolbar { padding: 12px 14px; }
  .toolbar select, .toolbar input[type=month], .toolbar input[type=date], .toolbar input[type=text] {
    min-width: 0; flex: 1 1 130px;
  }

  /* Touch targets: 32px is a mouse size. */
  .pager a, .pager span { min-width: 38px; height: 38px; }
  .chip { padding: 8px 13px; }
}

@media (max-width: 560px) {
  :root { --tl-who-w: 96px; }
  /* The bars stay legible but the row tightens further. */
  .tl-row { gap: 10px; }
  .tl-track { height: 30px; }
  .h-modal { padding: 12px; }
  .h-modal-card { max-height: calc(100vh - 24px); }
  .h-drawer, .h-drawer.sm, .h-drawer.lg, .h-drawer.xl { height: 96vh; }
}
