/* Front desk calendar UI — tokens straight from the design spec doc. No bare hex below §2. */

:root {
  /* 2.1 backgrounds */
  --bg-app:        #F7F7F5;
  --bg-surface:    #FFFFFF;
  --bg-subtle:     #FAFAF9;
  --bg-hover:      #F2F2F0;
  --bg-active:     #ECECEA;
  --bg-closed:     repeating-linear-gradient(-45deg, #FAFAF9, #FAFAF9 6px, #F2F2F0 6px, #F2F2F0 7px);

  /* 2.2 borders */
  --border-default: #E4E4E1;
  --border-strong:  #CFCFCB;
  --border-grid-h:  #EFEFED;
  --border-grid-hr: #E4E4E1;
  --border-grid-v:  #E4E4E1;

  /* 2.3 text */
  --text-primary:   #1A1A18;
  --text-secondary: #55554F;
  --text-tertiary:  #8B8B84;
  --text-disabled:  #B8B8B2;
  --text-inverse:   #FFFFFF;

  /* 2.4 brand + status */
  --brand:          #0F6B5C;
  --brand-hover:    #0C5A4D;
  --brand-soft:     #E3F0ED;
  --status-danger:  #D64545;
  --status-danger-soft: #FBEAEA;
  --status-warn:    #D97706;
  --status-warn-soft:   #FDF3E3;
  --status-ok:      #16A34A;
  --status-ok-soft:     #E8F6EC;
  --status-info:    #2563EB;
  --status-info-soft:   #E8EFFC;
  --ai-accent:      #7C5CBF;
  --ai-accent-soft: #F0EBF9;
  --now-line:       #E11D48;

  /* 2.5 appointment type palette */
  --apt-exam-bar: #3B82C4; --apt-exam-fill: #EBF2F9; --apt-exam-text: #1E4E7A;
  --apt-hyg-bar:  #14957F; --apt-hyg-fill:  #E7F4F2; --apt-hyg-text:  #0B5A4D;
  --apt-rest-bar: #6366D1; --apt-rest-fill: #EEEFFA; --apt-rest-text: #3B3D8F;
  --apt-endo-bar: #E08A3C; --apt-endo-fill: #FBF1E7; --apt-endo-text: #8A5320;
  --apt-surg-bar: #C2557E; --apt-surg-fill: #F8EBF1; --apt-surg-text: #7A2F4E;
  --apt-pros-bar: #A8843C; --apt-pros-fill: #F6F1E5; --apt-pros-text: #6B5422;
  --apt-emrg-bar: #D64545; --apt-emrg-fill: #FBEAEA; --apt-emrg-text: #8F2626;
  --apt-misc-bar: #8B8B84; --apt-misc-fill: #F1F1EF; --apt-misc-text: #4A4A45;

  /* 2.6 provider dots */
  --dr-1: #0EA5A5; --dr-2: #B4592B; --dr-3: #5B78C7;
  --dr-4: #4E9950; --dr-5: #B0568F; --dr-6: #737373;

  /* 2.7 type + spacing + radius + shadow */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei",
             "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px; --fs-20: 20px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-full: 9999px;
  --shadow-card:  0 1px 2px rgba(26,26,24,.06);
  --shadow-raise: 0 1px 3px rgba(26,26,24,.08), 0 4px 12px rgba(26,26,24,.08);
  --shadow-pop:   0 0 0 1px var(--border-default),
                  0 4px 8px rgba(26,26,24,.06),
                  0 12px 32px rgba(26,26,24,.12);

  /* grid geometry (single source shared with JS via getComputedStyle) */
  --slot-h: 22px;
  --axis-w: 64px;
  --head-h: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-13);
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-app);
  min-width: 1280px;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; color: var(--text-primary); }
[hidden] { display: none !important; }

#app { display: grid; grid-template-rows: 56px 1fr; height: 100vh; overflow: hidden; }

/* ---------- topbar ---------- */

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: var(--sp-3); }
#clinic-name { font-size: var(--fs-14); font-weight: 600; color: var(--text-secondary); }
#date-title { font-size: var(--fs-20); font-weight: 700; white-space: nowrap; }
.seg {
  display: inline-flex; border: 1px solid var(--border-default);
  border-radius: var(--r-md); overflow: hidden; background: var(--bg-surface);
}
.seg-btn {
  padding: 4px 10px; font-size: var(--fs-13); color: var(--text-secondary);
  border-radius: 0;
}
.seg .seg-btn + .seg-btn { border-left: 1px solid var(--border-default); }
.seg-btn:hover { background: var(--bg-hover); }
.seg-btn.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
#panel-toggle { border: 1px solid var(--border-default); border-radius: var(--r-md); padding: 4px 8px; display: inline-flex; color: var(--text-tertiary); }
#panel-toggle:hover { background: var(--bg-hover); }
#date-pick {
  border: 1px solid var(--border-default); border-radius: var(--r-md);
  padding: 3px 6px; font-size: var(--fs-12); color: var(--text-secondary); background: var(--bg-surface);
}
#chair-filter {
  border: 1px solid var(--border-default); border-radius: var(--r-md);
  padding: 3px 6px; font-size: var(--fs-12); background: var(--bg-surface); color: var(--text-secondary);
}

#legend { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-12); color: var(--text-tertiary); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dr-dot { width: 8px; height: 8px; border-radius: var(--r-full); flex: none; }

#conn { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-tertiary); }
.conn-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--text-disabled); }
.conn-dot.is-ok { background: var(--status-ok); }
.conn-dot.is-warn { background: var(--status-warn); animation: breathe 1s ease-in-out infinite; }
.conn-dot.is-down { background: var(--status-danger); }
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- main layout ---------- */

#main { display: flex; min-height: 0; overflow: hidden; }
#cal-scroll { flex: 1; overflow: auto; background: var(--bg-surface); border-right: 1px solid var(--border-default); }
#cal-inner { min-width: calc(64px + 4 * 200px); }

#col-heads {
  display: flex; position: sticky; top: 0; z-index: 20;
  height: var(--head-h);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
}
.axis-spacer { width: var(--axis-w); flex: none; border-right: 1px solid var(--border-grid-v); }
#head-cols { flex: 1; display: grid; }
.col-head {
  border-right: 1px solid var(--border-grid-v);
  padding: 5px 10px 4px;
  min-width: 0; overflow: hidden;
  position: relative;
}
.col-head:last-child { border-right: none; }
.col-head .ch-name { font-size: var(--fs-14); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-head .ch-sub { font-size: var(--fs-12); color: var(--text-tertiary); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.col-head.is-today { background: var(--brand-soft); }
.col-head.is-alert::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 4px;
  border-radius: var(--r-sm) var(--r-sm) 0 0; background: var(--brand);
  animation: breathe 1s ease-in-out 4;
}

#cal-body { display: flex; position: relative; }
#time-axis {
  width: var(--axis-w); flex: none; position: relative;
  background: var(--bg-subtle); border-right: 1px solid var(--border-grid-v);
}
.axis-label {
  position: absolute; right: 8px; transform: translateY(-6px);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-11); color: var(--text-tertiary);
}
#calendar-grid { flex: 1; display: grid; position: relative; }
.cal-col {
  position: relative; min-width: 200px;
  border-right: 1px solid var(--border-grid-v);
  background-image:
    repeating-linear-gradient(to bottom, var(--border-grid-hr) 0 1px, transparent 1px 88px),
    repeating-linear-gradient(to bottom, var(--border-grid-h) 0 1px, transparent 1px 22px);
}
.cal-col:last-child { border-right: none; }

.closed-zone { position: absolute; left: 0; right: 0; background: var(--bg-closed); z-index: 1; }
.blockout-zone {
  position: absolute; left: 0; right: 0; background: var(--bg-closed); z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-11); color: var(--text-disabled); letter-spacing: .04em;
  overflow: hidden; pointer-events: none;
}
.conflict-zone { position: absolute; left: 0; right: 0; background: var(--status-danger-soft); z-index: 2; }

#now-line {
  position: absolute; height: 0; border-top: 2px solid var(--now-line);
  z-index: 15; pointer-events: none;
}
#now-line::before {
  content: ""; position: absolute; left: -4px; top: -5px;
  width: 8px; height: 8px; border-radius: var(--r-full); background: var(--now-line);
}

/* ---------- event card (§4.3) ---------- */

.event {
  position: absolute;
  border-radius: var(--r-md);
  background: var(--apt-misc-fill);
  border-left: 3px solid var(--apt-misc-bar);
  box-shadow: var(--shadow-card);
  padding: 3px 8px;
  overflow: hidden;
  cursor: pointer;
  color: var(--apt-misc-text);
  z-index: 5;
  transition: box-shadow .12s ease, transform .12s ease, top .3s, left .3s, height .3s;
}
.event:hover, .event.is-linked {
  box-shadow: var(--shadow-raise);
  transform: translateY(-1px);
  z-index: 10;
}
.event.is-linked { outline: 2px solid var(--brand); outline-offset: -1px; }
.ev-row1 { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; }
.ev-name {
  flex: 1; min-width: 0; font-size: var(--fs-13); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev-marks { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.ev-row2 { font-size: var(--fs-12); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-row2 .t { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ev-note { font-size: var(--fs-12); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event.is-tiny .ev-row2, .event.is-tiny .ev-note { display: none; }
.event.is-tiny { padding-top: 1px; padding-bottom: 1px; }

/* type palettes */
.event.t-exam { background: var(--apt-exam-fill); border-left-color: var(--apt-exam-bar); color: var(--apt-exam-text); }
.event.t-hyg  { background: var(--apt-hyg-fill);  border-left-color: var(--apt-hyg-bar);  color: var(--apt-hyg-text); }
.event.t-rest { background: var(--apt-rest-fill); border-left-color: var(--apt-rest-bar); color: var(--apt-rest-text); }
.event.t-endo { background: var(--apt-endo-fill); border-left-color: var(--apt-endo-bar); color: var(--apt-endo-text); }
.event.t-surg { background: var(--apt-surg-fill); border-left-color: var(--apt-surg-bar); color: var(--apt-surg-text); }
.event.t-pros { background: var(--apt-pros-fill); border-left-color: var(--apt-pros-bar); color: var(--apt-pros-text); }
.event.t-emrg { background: var(--apt-emrg-fill); border-left-color: var(--apt-emrg-bar); color: var(--apt-emrg-text); }
.event.t-misc { background: var(--apt-misc-fill); border-left-color: var(--apt-misc-bar); color: var(--apt-misc-text); }

/* §5.1 states */
.event.is-unconfirmed { border: 1.5px dashed var(--status-warn); border-left: 3px solid; }
.event.t-exam.is-unconfirmed { border-left-color: var(--apt-exam-bar); }
.event.t-hyg.is-unconfirmed  { border-left-color: var(--apt-hyg-bar); }
.event.t-rest.is-unconfirmed { border-left-color: var(--apt-rest-bar); }
.event.t-endo.is-unconfirmed { border-left-color: var(--apt-endo-bar); }
.event.t-surg.is-unconfirmed { border-left-color: var(--apt-surg-bar); }
.event.t-pros.is-unconfirmed { border-left-color: var(--apt-pros-bar); }
.event.t-emrg.is-unconfirmed { border-left-color: var(--apt-emrg-bar); }
.event.t-misc.is-unconfirmed { border-left-color: var(--apt-misc-bar); }
.unconf-corner {
  position: absolute; top: 3px; right: 3px; width: 10px; height: 10px;
  border-radius: var(--r-full); background: var(--status-warn);
  box-shadow: 0 0 0 1.5px var(--bg-surface);
}
.event.is-unconfirmed .ev-row1 { padding-right: 10px; }
.event.is-past { opacity: .55; border-left-color: var(--apt-misc-bar) !important; }
.event.is-conflict { outline: 2px solid var(--status-danger); outline-offset: -2px; }

.ai-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; flex: none;
  font-size: var(--fs-11); color: var(--ai-accent);
  background: var(--ai-accent-soft); border-radius: var(--r-sm);
}

/* §7.3 enter animations */
@keyframes apt-enter {
  0%   { opacity: 0; transform: scale(.92); }
  60%  { opacity: 1; transform: scale(1.02); }
  100% { transform: scale(1); }
}
@keyframes apt-flash {
  0%, 100% { box-shadow: var(--shadow-card); }
  30%      { box-shadow: 0 0 0 4px var(--flash-color, var(--brand-soft)), var(--shadow-raise); }
}
.event.is-new { animation: apt-enter .28s cubic-bezier(.2,.9,.3,1.2), apt-flash 1.6s ease .3s 2; }
.event.is-new-ai { --flash-color: var(--ai-accent-soft); }
.event.is-remote-flash { animation: apt-flash 1.6s ease 1; --flash-color: var(--status-info-soft); }
.event.is-leaving { opacity: 0; transform: scale(.95); transition: opacity .2s, transform .2s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  16%,50%,83% { transform: translateX(-3px); }
  33%,66% { transform: translateX(3px); }
}
.is-shake { animation: shake .3s linear; }
@media (prefers-reduced-motion: reduce) {
  .event.is-new, .event.is-remote-flash { animation: none; background-color: var(--flash-color, var(--brand-soft)); transition: background-color 2s; }
  .is-shake { animation: none; }
  .event, .wl-body, #worklists { transition: none !important; }
}

/* ---------- worklists panel (§6) ---------- */

#worklists {
  width: 336px; flex: none; background: var(--bg-app);
  overflow-y: auto; overflow-x: hidden;
  transition: width .2s ease;
}
#worklists.is-collapsed { width: 0; }
.wl-section + .wl-section { margin-top: var(--sp-2); }
.wl-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 12px 6px; cursor: pointer; user-select: none;
  background: var(--bg-subtle); position: sticky; top: 0; z-index: 3;
}
.wl-title {
  font-size: var(--fs-12); font-weight: 600; color: var(--text-tertiary);
  letter-spacing: .04em;
}
.wl-pill {
  min-width: 18px; padding: 0 5px; text-align: center;
  font-size: var(--fs-11); line-height: 16px; border-radius: var(--r-full);
  background: var(--bg-active); color: var(--text-tertiary);
}
.wl-pill.is-hot-warn { background: var(--status-warn); color: var(--text-inverse); }
.wl-pill.is-hot-ai { background: var(--ai-accent); color: var(--text-inverse); }
.wl-pill.is-hot-info { background: var(--status-info); color: var(--text-inverse); }
.wl-pill.is-hot-danger { background: var(--status-danger); color: var(--text-inverse); }
.tc-dot-danger { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--status-danger); }
.wl-caret { margin-left: auto; font-size: var(--fs-11); color: var(--text-tertiary); }
.wl-section.is-collapsed .wl-body { display: none; }
.wl-empty { padding: 4px 14px 10px; font-size: var(--fs-12); color: var(--text-disabled); }

.task-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: 8px 10px;
  margin: 0 12px 8px;
  box-shadow: var(--shadow-card);
  transition: border-color .12s, box-shadow .12s, opacity .25s, transform .25s;
}
.task-card:hover, .task-card.is-linked { border-color: var(--border-strong); box-shadow: var(--shadow-raise); }
.task-card.is-done { opacity: 0; transform: translateX(8px); }
.tc-row1 { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.tc-badge { flex: none; display: inline-flex; align-items: center; }
.tc-dot-warn { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--status-warn); }
.tc-name { font-size: var(--fs-13); font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-when { font-size: var(--fs-12); font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-tertiary); flex: none; }
.tc-when.is-overdue { color: var(--status-danger); }
.tc-row2 { font-size: var(--fs-12); color: var(--text-secondary); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-row3 { display: flex; gap: 6px; margin-top: 6px; }

.btn {
  height: 24px; padding: 0 8px; font-size: var(--fs-12);
  border-radius: var(--r-sm); border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.btn-brand { background: var(--brand); color: var(--text-inverse); }
.btn-brand:hover { background: var(--brand-hover); }
.btn-brand-line { border-color: var(--brand); color: var(--brand); background: var(--bg-surface); }
.btn-brand-line:hover { background: var(--brand-soft); }
.btn-ok-line { border-color: var(--status-ok); color: var(--status-ok); background: var(--bg-surface); }
.btn-ok-line:hover { background: var(--status-ok-soft); }
.btn-gray { background: var(--bg-hover); color: var(--text-secondary); }
.btn-gray:hover { background: var(--bg-active); }
.btn-gray.btn-danger-hover:hover { background: var(--status-danger-soft); color: var(--status-danger); }
.btn-danger-text { color: var(--status-danger); background: none; }
.btn-danger-text:hover { background: var(--status-danger-soft); }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- popover (§7.2) ---------- */

#popover {
  position: fixed; z-index: 100; width: 320px;
  background: var(--bg-surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: pop-in .12s ease;
  max-height: 80vh; overflow-y: auto;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.po-pad { padding: var(--sp-4); }
.po-title { font-size: var(--fs-16); font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); }
.po-phone { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-secondary); text-decoration: none; }
.po-phone:hover { color: var(--brand); text-decoration: underline; }
.po-rows { margin-top: var(--sp-3); display: grid; gap: 6px; font-size: var(--fs-13); color: var(--text-secondary); }
.po-row { display: flex; gap: var(--sp-2); align-items: center; }
.po-row .k { color: var(--text-tertiary); font-size: var(--fs-12); width: 40px; flex: none; }
.po-row .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.po-status-pill { font-size: var(--fs-11); padding: 1px 7px; border-radius: var(--r-full); }
.po-status-pill.is-ok { background: var(--status-ok-soft); color: var(--status-ok); }
.po-status-pill.is-warn { background: var(--status-warn-soft); color: var(--status-warn); }
.po-ai-line { display: flex; gap: 6px; align-items: center; font-size: var(--fs-12); color: var(--ai-accent); }
.po-note { font-size: var(--fs-12); color: var(--text-tertiary); background: var(--bg-subtle); border-radius: var(--r-sm); padding: 6px 8px; }
.po-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-top: 1px solid var(--border-default);
  padding: var(--sp-3) var(--sp-4);
}
.po-close {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); border-radius: var(--r-sm);
}
.po-close:hover { background: var(--bg-hover); }
.po-sec-label { font-size: var(--fs-12); font-weight: 600; color: var(--text-tertiary); letter-spacing: .04em; margin: var(--sp-3) 0 var(--sp-1); }

.slot-list { display: grid; gap: 4px; max-height: 300px; overflow-y: auto; }
.slot-item {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2);
  padding: 5px 8px; border: 1px solid var(--border-default); border-radius: var(--r-sm);
  font-size: var(--fs-12); text-align: left; width: 100%;
}
.slot-item:hover { background: var(--brand-soft); border-color: var(--brand); }
.slot-item .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-primary); }
.slot-item .sub { color: var(--text-tertiary); }

/* quick create form */
.qc-field { margin-top: var(--sp-2); }
.qc-field label { display: block; font-size: var(--fs-12); color: var(--text-tertiary); margin-bottom: 2px; }
.qc-field input, .qc-field select {
  width: 100%; padding: 5px 8px; font-size: var(--fs-13);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--bg-surface);
}
.qc-field input:focus, .qc-field select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.qc-results { position: relative; }
.qc-drop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5;
  background: var(--bg-surface); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  max-height: 180px; overflow-y: auto;
}
.qc-opt { display: block; width: 100%; text-align: left; padding: 6px 10px; font-size: var(--fs-13); }
.qc-opt:hover { background: var(--bg-hover); }
.qc-opt .sub { font-size: var(--fs-11); color: var(--text-tertiary); font-family: var(--font-mono); }
.qc-selected { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand); border-radius: var(--r-full); padding: 2px 10px; font-size: var(--fs-13); font-weight: 600; }
.qc-time-row { display: flex; gap: 6px; }
.qc-time-row input { flex: 1; }
.qc-err { margin-top: var(--sp-2); font-size: var(--fs-12); color: var(--status-danger); background: var(--status-danger-soft); border-radius: var(--r-sm); padding: 6px 8px; }

.hist-item { display: flex; gap: var(--sp-2); font-size: var(--fs-12); color: var(--text-secondary); padding: 3px 0; }
.hist-item .mono { font-family: var(--font-mono); color: var(--text-tertiary); flex: none; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; z-index: 120; max-width: 260px;
  background: var(--bg-surface); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  padding: 6px 10px; font-size: var(--fs-12); color: var(--text-secondary);
  pointer-events: none;
}
#tooltip .mono { font-family: var(--font-mono); }

/* ---------- toast ---------- */
#toast-wrap { position: fixed; top: 64px; right: 16px; z-index: 200; display: grid; gap: 8px; }
.toast {
  background: var(--status-danger-soft); color: var(--status-danger);
  border-radius: var(--r-md); box-shadow: var(--shadow-raise);
  padding: 8px 12px; font-size: var(--fs-13); max-width: 360px;
}
.toast.is-ok { background: var(--status-ok-soft); color: var(--status-ok); }

/* ---------- login ---------- */
#login {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-app);
}
#login-card {
  width: 360px; background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--r-lg); box-shadow: var(--shadow-raise); padding: var(--sp-8);
  display: grid; gap: var(--sp-3);
}
#login-card h2 { font-size: var(--fs-20); font-weight: 700; }
.login-sub { font-size: var(--fs-12); color: var(--text-tertiary); }
#login-token {
  padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-family: var(--font-mono); font-size: var(--fs-13);
}
#login-token:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
#login-btn {
  padding: 8px 0; background: var(--brand); color: var(--text-inverse);
  border-radius: var(--r-md); font-weight: 600;
}
#login-btn:hover { background: var(--brand-hover); }
.login-err { font-size: var(--fs-12); color: var(--status-danger); background: var(--status-danger-soft); border-radius: var(--r-sm); padding: 6px 8px; }
