/* ===========================================================================
   CustomOps — Component library
   =========================================================================== */

/* ============================ BUTTONS ==================================== */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--text);
  --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-4); flex-shrink: 0;
  height: 34px; padding: 0 var(--s-6);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd); border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: var(--fw-med); white-space: nowrap;
  letter-spacing: -0.005em;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  position: relative; user-select: none;
}
.btn:hover  { background: var(--surface-4); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-disabled { opacity: .42; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn.primary {
  --btn-bg: var(--brand); --btn-fg: var(--brand-ink); --btn-bd: var(--brand);
  box-shadow: 0 1px 0 rgba(255,255,255,.14) inset, 0 2px 8px var(--brand-glow);
  font-weight: var(--fw-semi);
}
.btn.primary:hover {
  --btn-bg: var(--brand-hi); --btn-bd: var(--brand-hi);
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 16px var(--brand-glow);
}

.btn.ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-2); }
.btn.ghost:hover { --btn-bg: var(--surface-3); color: var(--text); border-color: transparent; }

.btn.outline { --btn-bg: transparent; --btn-bd: var(--line-strong); }
.btn.outline:hover { --btn-bg: var(--surface-3); }

.btn.danger  { --btn-bg: var(--c-red); --btn-fg:#fff; --btn-bd: var(--c-red); font-weight: var(--fw-semi); }
.btn.danger:hover { filter: brightness(1.1); }
.btn.success { --btn-bg: var(--c-green); --btn-fg:#04140A; --btn-bd: var(--c-green); font-weight: var(--fw-semi); }
.btn.success:hover { filter: brightness(1.08); }

.btn.sm { height: 27px; padding: 0 var(--s-5); font-size: var(--fs-sm); border-radius: var(--r-sm); gap: var(--s-3); }
.btn.sm svg { width: 13px; height: 13px; }
.btn.lg { height: 42px; padding: 0 var(--s-8); font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn.lg svg { width: 17px; height: 17px; }
.btn.xl { height: 50px; padding: 0 var(--s-10); font-size: var(--fs-lg); border-radius: var(--r-lg); font-weight: var(--fw-semi); }
.btn.block { width: 100%; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 27px; }
.btn.icon.lg { width: 42px; }
.btn.pill { border-radius: var(--r-pill); }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn.active { background: var(--surface-4); color: var(--text); border-color: var(--line-strong); z-index: 1; }

/* Segmented control */
.seg {
  display: inline-flex; background: var(--surface-inset); padding: 3px;
  border-radius: var(--r-md); border: 1px solid var(--line-soft); gap: 2px;
}
.seg button {
  height: 27px; padding: 0 var(--s-6); border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: var(--fw-med); color: var(--text-3);
  transition: all var(--dur-fast) var(--ease); white-space: nowrap;
  display: inline-flex; align-items: center; gap: var(--s-3);
}
.seg button svg { width: 13px; height: 13px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

/* ============================ CARDS ====================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.card.pad   { padding: var(--pad-card); }
.card.hover { transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.card.hover:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.glass { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(14px); }
.card.accent::before {
  content:''; position:absolute; inset:0 auto 0 0; width:3px;
  background: var(--brand); border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.card-head {
  display: flex; align-items: center; gap: var(--s-6);
  padding: var(--s-6) var(--pad-card);
  border-bottom: 1px solid var(--line-soft); min-height: 50px;
}
.card-head h3, .card-head h4 { letter-spacing: -0.012em; }
.card-body { padding: var(--pad-card); }
.card-foot {
  padding: var(--s-5) var(--pad-card); border-top: 1px solid var(--line-soft);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* Stat tile */
.stat {
  padding: var(--s-7) var(--s-8); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); position: relative; overflow: hidden;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.stat .stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing:.1em; font-weight: var(--fw-bold); color: var(--text-3); }
.stat .stat-val   { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing:-.03em; line-height:1.05; margin-top: var(--s-4); }
.stat .stat-sub   { font-size: var(--fs-sm); color: var(--text-3); margin-top: var(--s-3); }
.stat .stat-ico   {
  position:absolute; top: var(--s-6); right: var(--s-6); width: 32px; height: 32px;
  border-radius: var(--r-md); display:grid; place-items:center; opacity:.9;
}
.stat .stat-ico svg { width:16px; height:16px; }
.stat .spark { position:absolute; inset: auto 0 0 0; height: 34px; opacity:.5; pointer-events:none; }

.delta { display:inline-flex; align-items:center; gap:3px; font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.delta svg { width:12px; height:12px; }
.delta.up   { color: var(--c-green); }
.delta.down { color: var(--c-red); }
.delta.flat { color: var(--text-3); }

/* ============================ BADGES ===================================== */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-3);
  height: 20px; padding: 0 var(--s-4);
  border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: var(--fw-semi);
  letter-spacing: .01em; white-space: nowrap; flex-shrink: 0;
  background: var(--tint-slate); color: var(--c-slate);
  border: 1px solid transparent;
}
.badge svg { width: 11px; height: 11px; }
.badge.lg { height: 24px; padding: 0 var(--s-5); font-size: var(--fs-sm); }
.badge.pill { border-radius: var(--r-pill); }
.badge.solid { color: #fff; }
.badge.outline { background: transparent; border-color: currentColor; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge.blue  { background: var(--tint-blue);  color: var(--c-blue); }
.badge.cyan  { background: var(--tint-cyan);  color: var(--c-cyan); }
.badge.teal  { background: var(--tint-teal);  color: var(--c-teal); }
.badge.green { background: var(--tint-green); color: var(--c-green); }
.badge.lime  { background: var(--tint-lime);  color: var(--c-lime); }
.badge.amber { background: var(--tint-amber); color: var(--c-amber); }
.badge.orange{ background: var(--tint-orange);color: var(--c-orange); }
.badge.red   { background: var(--tint-red);   color: var(--c-red); }
.badge.violet{ background: var(--tint-violet);color: var(--c-violet); }
.badge.pink  { background: var(--tint-pink);  color: var(--c-pink); }
.badge.indigo{ background: var(--tint-indigo);color: var(--c-indigo); }
.badge.slate { background: var(--tint-slate); color: var(--c-slate); }
.badge.brand { background: var(--brand-wash); color: var(--brand); }

.chip {
  display:inline-flex; align-items:center; gap: var(--s-3); height: 24px;
  padding: 0 var(--s-5); border-radius: var(--r-pill); background: var(--surface-3);
  border: 1px solid var(--line); font-size: var(--fs-sm); color: var(--text-2);
}
.chip button { display:grid; place-items:center; width:14px; height:14px; border-radius:50%; color: var(--text-3); }
.chip button:hover { background: var(--surface-4); color: var(--text); }

/* Priority flag */
.prio { width: 3px; border-radius: var(--r-pill); align-self: stretch; min-height: 16px; background: var(--c-slate); }
.prio.p1 { background: var(--brand); box-shadow: 0 0 8px var(--brand-glow); }
.prio.p2 { background: var(--c-orange); }
.prio.p3 { background: var(--c-blue); }
.prio.p4 { background: var(--c-slate); }

/* ============================ AVATARS ==================================== */
.av {
  --av-size: 30px;
  width: var(--av-size); height: var(--av-size); border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: calc(var(--av-size) * .38); font-weight: var(--fw-bold);
  letter-spacing: -.02em; color: #fff; position: relative;
  background: linear-gradient(140deg, hsl(var(--av-h,220) 62% 52%), hsl(var(--av-h,220) 58% 38%));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.13);
  user-select: none;
}
.av.xs { --av-size: 20px; } .av.sm { --av-size: 24px; }
.av.md { --av-size: 34px; } .av.lg { --av-size: 44px; } .av.xl { --av-size: 60px; }
.av.sq { border-radius: var(--r-md); }
.av .pres {
  position:absolute; right:-1px; bottom:-1px; width: 32%; height: 32%;
  min-width: 8px; min-height: 8px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--c-slate);
}
.av .pres.on   { background: var(--c-green); }
.av .pres.away { background: var(--c-amber); }
.av .pres.busy { background: var(--brand); }
.av-stack { display: flex; }
.av-stack .av { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.av-stack .av:first-child { margin-left: 0; }

/* ============================ TABLES ===================================== */
.tbl-wrap { overflow: auto; border-radius: var(--r-lg); }
table.tbl { width: 100%; font-size: var(--fs-md); }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); text-align: left;
  padding: var(--s-5) var(--s-6); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: .09em; font-weight: var(--fw-bold);
  color: var(--text-3); white-space: nowrap; border-bottom: 1px solid var(--line);
  user-select: none;
}
table.tbl thead th.sortable { cursor: pointer; }
table.tbl thead th.sortable:hover { color: var(--text); }
table.tbl thead th .sort-ind { display:inline-block; margin-left: 4px; opacity:.55; font-size:9px; }
table.tbl tbody td {
  padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; height: var(--row-h);
}
table.tbl tbody tr { transition: background var(--dur-fast) var(--ease); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.sel { background: var(--brand-wash); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl.zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.tight, table.tbl th.tight { width: 1%; white-space: nowrap; }
table.tbl .row-act { opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
table.tbl tr:hover .row-act { opacity: 1; }

/* ============================ FORMS ====================================== */
.field { display: flex; flex-direction: column; gap: var(--s-4); }
.field > label, .lbl {
  font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--text-2);
  display: flex; align-items: center; gap: var(--s-3);
}
.field .hint { font-size: var(--fs-sm); color: var(--text-3); }
.field .err  { font-size: var(--fs-sm); color: var(--c-red); }
.req::after { content:'*'; color: var(--brand); margin-left: 2px; }

.inp, .sel, .ta {
  width: 100%; height: 36px; padding: 0 var(--s-6);
  background: var(--surface-inset); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: var(--fs-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.inp::placeholder, .ta::placeholder { color: var(--text-4); }
.inp:hover, .sel:hover, .ta:hover { border-color: var(--line-strong); }
.inp:focus, .sel:focus, .ta:focus { border-color: var(--brand); box-shadow: var(--ring); background: var(--surface); }
.inp[readonly] { color: var(--text-2); background: var(--surface-2); }
.inp.invalid, .sel.invalid { border-color: var(--c-red); }
.ta { height: auto; min-height: 84px; padding: var(--s-5) var(--s-6); resize: vertical; line-height: var(--lh-normal); }
.sel {
  appearance: none; padding-right: var(--s-10); cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237C8AA5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right var(--s-5) center;
}
.sel option { background: var(--surface-2); color: var(--text); }
.inp.sm, .sel.sm { height: 30px; font-size: var(--fs-sm); }
.inp.lg, .sel.lg { height: 44px; font-size: var(--fs-base); border-radius: var(--r-lg); }

.inp-icon { position: relative; }
.inp-icon > svg:first-child {
  position: absolute; left: var(--s-5); top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none;
}
.inp-icon .inp { padding-left: var(--s-11); }
.inp-icon .clear-x {
  position:absolute; right: var(--s-4); top:50%; transform: translateY(-50%);
  width:20px; height:20px; display:grid; place-items:center; border-radius:50%;
  color: var(--text-3);
}
.inp-icon .clear-x:hover { background: var(--surface-3); color: var(--text); }

.check, .radio {
  appearance: none; width: 16px; height: 16px; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); background: var(--surface-inset);
  border-radius: var(--r-xs); cursor: pointer; position: relative;
  transition: all var(--dur-fast) var(--ease);
}
.radio { border-radius: 50%; }
.check:hover, .radio:hover { border-color: var(--brand); }
.check:checked, .radio:checked { background: var(--brand); border-color: var(--brand); }
.check:checked::after {
  content:''; position:absolute; left:4.5px; top:1px; width:4px; height:8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(43deg);
}
.radio:checked::after {
  content:''; position:absolute; inset:3.5px; border-radius:50%; background:#fff;
}
.check-row { display:flex; align-items:center; gap: var(--s-5); cursor:pointer; user-select:none; }

.switch {
  appearance:none; width: 34px; height: 19px; border-radius: var(--r-pill);
  background: var(--surface-4); position: relative; cursor: pointer; flex-shrink:0;
  transition: background var(--dur) var(--ease); border: 1px solid var(--line);
}
.switch::after {
  content:''; position:absolute; top:1.5px; left:2px; width:14px; height:14px;
  border-radius:50%; background:#fff; transition: transform var(--dur) var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.switch:checked { background: var(--brand); border-color: var(--brand); }
.switch:checked::after { transform: translateX(15px); }

.range { -webkit-appearance:none; appearance:none; width:100%; height:4px; border-radius:var(--r-pill); background: var(--surface-4); }
.range::-webkit-slider-thumb {
  -webkit-appearance:none; width:16px; height:16px; border-radius:50%;
  background: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); cursor:pointer;
}

.input-addon { display:flex; align-items:stretch; }
.input-addon .addon {
  display:grid; place-items:center; padding: 0 var(--s-5); font-size: var(--fs-sm);
  color: var(--text-3); background: var(--surface-3); border:1px solid var(--line);
  border-right:0; border-radius: var(--r-md) 0 0 var(--r-md); white-space:nowrap;
}
.input-addon .inp { border-radius: 0 var(--r-md) var(--r-md) 0; }

/* ============================ TABS ======================================= */
.tabs { display: flex; gap: var(--s-2); border-bottom: 1px solid var(--line); position: relative; overflow-x:auto; }
.tabs button {
  padding: var(--s-5) var(--s-6); font-size: var(--fs-md); font-weight: var(--fw-med);
  color: var(--text-3); position: relative; white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
  display: inline-flex; align-items: center; gap: var(--s-4);
}
.tabs button svg { width: 14px; height: 14px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); font-weight: var(--fw-semi); }
.tabs button.active::after {
  content:''; position:absolute; left: var(--s-4); right: var(--s-4); bottom:-1px; height:2px;
  background: var(--brand); border-radius: var(--r-pill) var(--r-pill) 0 0;
}
.tabs .count {
  min-width: 18px; height: 17px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-3);
  font-size: var(--fs-2xs); font-weight: var(--fw-bold); display:grid; place-items:center;
}
.tabs button.active .count { background: var(--brand-wash); color: var(--brand); }

.pills { display:flex; gap: var(--s-3); flex-wrap: wrap; }
.pills button {
  height: 28px; padding: 0 var(--s-6); border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-med);
  display:inline-flex; align-items:center; gap: var(--s-3);
  transition: all var(--dur-fast) var(--ease);
}
.pills button:hover { border-color: var(--line-strong); color: var(--text); }
.pills button.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ============================ PROGRESS =================================== */
.bar { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.bar > i { display:block; height:100%; background: var(--brand); border-radius: var(--r-pill);
           transition: width var(--dur-slow) var(--ease-out); }
.bar.sm { height: 4px; } .bar.lg { height: 9px; }
.bar.green > i { background: var(--c-green); }
.bar.amber > i { background: var(--c-amber); }
.bar.blue  > i { background: var(--c-blue); }
.bar.red   > i { background: var(--c-red); }
.bar.multi { display:flex; }
.bar.multi > i { border-radius: 0; }

.meter-ring { transform: rotate(-90deg); }
.meter-ring circle { fill: none; stroke-linecap: round; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }

/* ============================ EMPTY / STATES ============================= */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s-13) var(--s-9); text-align: center; gap: var(--s-5);
}
.empty .icon-wrap {
  width: 54px; height: 54px; border-radius: var(--r-xl); display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3); margin-bottom: var(--s-2);
}
.empty .icon-wrap svg { width: 24px; height: 24px; }
.empty h4 { font-size: var(--fs-lg); }
.empty p { color: var(--text-3); font-size: var(--fs-md); max-width: 380px; }

/* ============================ MODAL / DRAWER ============================= */
.scrim {
  position: fixed; inset: 0; background: var(--overlay);
  backdrop-filter: blur(3px); z-index: var(--z-modal);
  animation: fadeIn var(--dur) var(--ease) both;
}
.modal {
  position: fixed; z-index: calc(var(--z-modal) + 1);
  left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; overflow: hidden;
  animation: popIn var(--dur) var(--ease-out) both;
}
.modal.w-sm { width: min(420px, calc(100vw - 32px)); }
.modal.w-lg { width: min(760px, calc(100vw - 32px)); }
.modal.w-xl { width: min(1060px, calc(100vw - 32px)); }
.modal-head {
  display: flex; align-items: center; gap: var(--s-6);
  padding: var(--s-7) var(--s-8); border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.modal-body { padding: var(--s-8); overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; gap: var(--s-5); justify-content: flex-end;
  padding: var(--s-6) var(--s-8); border-top: 1px solid var(--line-soft);
  background: var(--surface-2); flex-shrink: 0;
}

.drawer {
  /* Must clear the shared .scrim (--z-modal), which both modals and drawers
     mount behind. At --z-drawer the blurred scrim painted over the drawer and
     the whole panel was invisible. */
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-modal) + 1);
  width: min(680px, 100vw); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column;
  animation: slideL var(--dur-slow) var(--ease-out) both;
}
.drawer.wide { width: min(940px, 100vw); }
.drawer-head { padding: var(--s-7) var(--s-8); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.drawer-body { flex: 1; overflow-y: auto; }
.drawer-foot {
  padding: var(--s-6) var(--s-8); border-top: 1px solid var(--line);
  background: var(--surface-2); flex-shrink: 0; display: flex; gap: var(--s-5); align-items:center;
}

/* ============================ MENU / POPOVER ============================= */
.menu {
  position: fixed; z-index: var(--z-tip);
  min-width: 196px; padding: var(--s-3); max-height: 70vh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  animation: popIn var(--dur-fast) var(--ease-out) both;
}
.menu button, .menu a {
  display: flex; align-items: center; gap: var(--s-5); width: 100%;
  padding: var(--s-4) var(--s-5); border-radius: var(--r-sm);
  font-size: var(--fs-md); color: var(--text-2); text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.menu button:hover, .menu a:hover { background: var(--surface-3); color: var(--text); }
.menu button svg, .menu a svg { width: 14px; height: 14px; opacity:.8; flex-shrink:0; }
.menu .sep { height:1px; background: var(--line-soft); margin: var(--s-3) calc(var(--s-3) * -1); }
.menu .head { padding: var(--s-4) var(--s-5) var(--s-3); font-size: var(--fs-2xs); text-transform: uppercase;
              letter-spacing: .1em; font-weight: var(--fw-bold); color: var(--text-4); }
.menu button.danger { color: var(--c-red); }
.menu button.danger:hover { background: var(--tint-red); }
.menu .kbd { margin-left: auto; }

.kbd {
  display:inline-grid; place-items:center; min-width: 18px; height: 18px; padding: 0 5px;
  font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semi);
  color: var(--text-3); background: var(--surface-3); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: var(--r-xs);
}

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; z-index: var(--z-tip);
  bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%) translateY(3px);
  padding: 4px var(--s-5); background: var(--surface-4); color: var(--text);
  border: 1px solid var(--line-strong);
  font-size: var(--fs-xs); font-weight: var(--fw-med); white-space: nowrap;
  border-radius: var(--r-sm); box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip-pos="right"]::after { bottom:auto; top:50%; left: calc(100% + 8px); transform: translateY(-50%) translateX(-3px); }
[data-tip-pos="right"]:hover::after { transform: translateY(-50%) translateX(0); }
[data-tip-pos="bottom"]::after { bottom:auto; top: calc(100% + 7px); transform: translateX(-50%) translateY(-3px); }
[data-tip-pos="bottom"]:hover::after { transform: translateX(-50%) translateY(0); }

/* ============================ TOASTS ===================================== */
#toasts {
  position: fixed; bottom: var(--s-8); right: var(--s-8); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-5); align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s-5);
  min-width: 290px; max-width: 400px; padding: var(--s-6) var(--s-7);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: riseIn var(--dur) var(--ease-out) both; position: relative; overflow: hidden;
}
.toast.out { animation: fadeIn var(--dur) var(--ease) reverse both; }
.toast .t-ico { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast .t-title { font-size: var(--fs-md); font-weight: var(--fw-semi); }
.toast .t-msg { font-size: var(--fs-sm); color: var(--text-3); margin-top: 2px; }
.toast::before { content:''; position:absolute; inset:0 auto 0 0; width:3px; background: var(--c-slate); }
.toast.success::before { background: var(--c-green); } .toast.success .t-ico { color: var(--c-green); }
.toast.error::before   { background: var(--c-red); }   .toast.error .t-ico   { color: var(--c-red); }
.toast.warn::before    { background: var(--c-amber); } .toast.warn .t-ico    { color: var(--c-amber); }
.toast.info::before    { background: var(--c-blue); }  .toast.info .t-ico    { color: var(--c-blue); }
.toast.brand::before   { background: var(--brand); }   .toast.brand .t-ico   { color: var(--brand); }

/* ============================ TIMELINE =================================== */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: var(--s-6); padding-bottom: var(--s-7); position: relative; }
.tl-item::before {
  content:''; position: absolute; left: 12px; top: 27px; bottom: 0; width: 1.5px;
  background: var(--line);
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 25px; height: 25px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  display: grid; place-items: center; background: var(--surface-3);
  border: 1px solid var(--line); color: var(--text-3);
}
.tl-dot svg { width: 12px; height: 12px; }
.tl-body { flex: 1; min-width: 0; padding-top: 2px; }

/* ============================ CALLOUTS =================================== */
.callout {
  display: flex; gap: var(--s-6); padding: var(--s-6) var(--s-7);
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2); font-size: var(--fs-md);
}
.callout svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.callout.warn   { background: var(--tint-amber); border-color: color-mix(in srgb, var(--c-amber) 34%, transparent); }
.callout.warn svg { color: var(--c-amber); }
.callout.danger { background: var(--tint-red); border-color: color-mix(in srgb, var(--c-red) 34%, transparent); }
.callout.danger svg { color: var(--c-red); }
.callout.info   { background: var(--tint-blue); border-color: color-mix(in srgb, var(--c-blue) 34%, transparent); }
.callout.info svg { color: var(--c-blue); }
.callout.success{ background: var(--tint-green); border-color: color-mix(in srgb, var(--c-green) 34%, transparent); }
.callout.success svg { color: var(--c-green); }
.callout.brand  { background: var(--brand-wash); border-color: var(--brand-wash-2); }
.callout.brand svg { color: var(--brand); }

/* ============================ MISC ======================================= */
.kv { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: var(--s-5) var(--s-6); font-size: var(--fs-md); }
.kv dt { color: var(--text-3); }
.kv dd { color: var(--text); font-weight: var(--fw-med); min-width: 0; }

.tag-strip { display:flex; gap: var(--s-3); flex-wrap: wrap; }

/* Axis tick labels are centred on their position, so the first and last hang
   half outside the lane. Clip rather than let them widen the page. */
.tick-lane { overflow: hidden; }

/* Meta rows: each fact stays whole, the row wraps between facts. */
.meta-item { flex-shrink: 0; max-width: 100%; }
.meta-item > svg { width: 14px; height: 14px; flex-shrink: 0; }

.hl { background: var(--brand-wash-2); color: var(--text); border-radius: 2px; padding: 0 1px; }

.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg);
  padding: var(--s-9); text-align: center; color: var(--text-3);
  transition: all var(--dur) var(--ease); background: var(--surface-inset);
}
.dropzone.over { border-color: var(--brand); background: var(--brand-wash); color: var(--text); }

.ph-img {
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--text-4); overflow: hidden; position: relative;
}

.sig-pad {
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  touch-action: none; cursor: crosshair; width: 100%; display: block;
}

.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--c-green);
  position: relative; flex-shrink: 0;
}
.live-dot::after {
  content:''; position:absolute; inset:0; border-radius:50%; background: var(--c-green);
  animation: ping 2s cubic-bezier(0,0,.2,1) infinite;
}
