/* CA Hub base: reset, typography, controls and the shared components every view uses.
   Only tokens from tokens.css appear here. Layout of the app itself is in shell.css. */

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
#app { height: var(--app-h, 100%); }   /* --app-h: the visible height on phones (main.js), so the keyboard never covers the composer */
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font: 700 var(--fs-large)/var(--lh-large) var(--font-display); letter-spacing: var(--track-hero); }
h2 { font: 700 var(--fs-title2)/var(--lh-title2) var(--font-display); letter-spacing: var(--track-title); }
h3 { font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 600; letter-spacing: var(--track-title); }
h4 { font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 600; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
::selection { background: color-mix(in srgb, var(--tint) 26%, transparent); }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--fill) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--fill); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--fill-hover); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- small utilities */
.num, .mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); font-size: .94em; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: var(--fs-sm); line-height: var(--lh-sm); }
.grow { flex: 1 1 0; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.clickable { cursor: pointer; }
.show-mobile { display: none !important; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}

/* ---- icons */
.icon { flex: none; display: block; }

/* ---- buttons: macOS push buttons with a pointer (7px corners, 28px tall), larger on phones.
   Gray by default; one filled (.primary) button per view. Hover and press are a veil of the label colour. */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  height: var(--ctl-h); padding: 0 12px; border-radius: var(--radius-ctl);
  background: var(--fill-2); color: var(--text); font-size: var(--fs-md); font-weight: 500; line-height: 1; white-space: nowrap;
  letter-spacing: -.006em; text-decoration: none; user-select: none; -webkit-user-select: none;
  transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t) var(--ease);
}
.btn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: currentColor; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.btn:hover { text-decoration: none; }
.btn:hover::after { opacity: .05; }
.btn:active::after { opacity: .10; }
.btn:active { transform: scale(.97); }
.btn:focus-visible { border-radius: var(--radius-ctl); }
.btn.primary { background: var(--accent); color: var(--accent-text); box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .18); }
.btn.primary::after { background: #000; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:hover::after { opacity: 0; }
.btn.primary:active::after { opacity: .12; }
.btn.ghost { background: transparent; color: var(--link); padding: 0 8px; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 var(--hair) var(--hairline-strong); }
.btn.danger.solid { background: var(--danger-fill); color: #fff; box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .16); }
.btn.active { background: var(--accent-soft); color: var(--link); }
.btn.sm { height: var(--ctl-h-sm); padding: 0 8px; gap: 4px; font-size: var(--fs-sm); border-radius: calc(var(--radius-ctl) - 2px); }
.btn.lg { height: var(--ctl-h-lg); padding: 0 18px; gap: 8px; font-size: var(--fs-headline); font-weight: 600; border-radius: calc(var(--radius-ctl) + 1px); letter-spacing: -.01em; }
.btn.block { display: flex; width: 100%; }
.btn.tinted { background: var(--accent-soft); color: var(--link); }
.btn.ghost.danger { color: var(--danger); box-shadow: none; }
/* (after the variants above: a button that paints its own edge would otherwise lose the focus ring) */
.btn.primary:focus-visible, .btn.danger:focus-visible { box-shadow: var(--ring); }
.btn[aria-busy="true"] { pointer-events: none; }
.btn .spinner { width: 14px; height: 14px; border-width: 1.5px; }
.btn:disabled, .btn[disabled] { opacity: .4; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative;
  width: var(--ctl-h); height: var(--ctl-h); border-radius: var(--radius-ctl); color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--fill-3); color: var(--text); text-decoration: none; }
.icon-btn:active { transform: scale(.94); background: var(--fill-2); }
.icon-btn:focus-visible { border-radius: var(--radius-ctl); }
.icon-btn.active { background: var(--fill-2); color: var(--link); }
.icon-btn.accent { color: var(--link); }
.icon-btn:disabled { opacity: .4; pointer-events: none; }
.icon-btn.loading { pointer-events: none; }   /* (`.loading`, the block placeholder below, leaves buttons alone) */
.icon-btn.loading .icon { animation: spin .7s linear infinite; }
/* a press answers at once; only the release fades */
.btn:active, .icon-btn:active, button.list-row:active, a.list-row:active, .pick-item:active { transition-duration: 0s; }
/* touch: the visible shape stays small, the hit area grows to 44pt; and nothing keeps a hover look after a tap */
@media (hover: none) {
  .icon-btn::after { content: ""; position: absolute; inset: -6px; }
  .btn:hover::after { opacity: 0; }
  .btn:active::after { opacity: .10; }
  .btn.primary:hover { background: var(--accent); }
  .icon-btn:hover { background: none; color: var(--text-2); }
  .icon-btn:active { background: var(--fill-2); }
  .seg > :not(.active):hover, .tabs > :not(.active):hover { background: none; }
  button.list-row:hover, a.list-row:hover, .table tbody tr:hover, .pick-item:hover { background: none; }
}

/* ---- text fields: a quiet well with a hairline edge; the accent only appears on focus */
.input, .select, textarea.input {
  display: block; width: 100%; height: var(--field-h); padding: 0 10px; border: 0; border-radius: var(--radius-ctl);
  background: var(--bg-sunken); box-shadow: inset 0 0 0 var(--hair) var(--hairline-strong); color: var(--text); font-size: var(--fs-body);
  transition: box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
  -webkit-appearance: none; appearance: none;
}
textarea.input { height: auto; min-height: 64px; padding: 7px 10px; line-height: var(--lh-body); resize: vertical; }
.input::placeholder, textarea::placeholder { color: var(--text-4); }
.input:focus, .select:focus, textarea.input:focus { background: var(--bg-elev); box-shadow: var(--ring); border-radius: var(--radius-ctl); }
.input:disabled, .select:disabled { opacity: .55; }
.input.sm, .select.sm { height: var(--ctl-h); padding: 0 8px; font-size: var(--fs-md); }
.select {
  padding-right: 26px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 5l3-3 3 3M2 9l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.select.sm { padding-right: 24px; }
.select option { background: var(--bg-elev); color: var(--text); }
@media (max-width: 767px) {
  /* 16px or more: iOS zooms the page when a smaller field is focused */
  .input, .select, textarea.input { padding: 0 12px; font-size: 16px; }
  .input.sm, .select.sm { font-size: 16px; }
}
/* a button in one row with a field is as tall as the field */
.row > .input:not(.sm) ~ .btn:not(.sm), .row > .btn:not(.sm):has(~ .input:not(.sm)) { height: var(--field-h); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .field-l { font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.field .hint, .hint { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-3); }
.hint.warn-text { color: var(--warn); }
.field.invalid .input { box-shadow: inset 0 0 0 1px var(--danger); }
.field.invalid .hint { color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--tint); flex: none; }

/* switch: <label class="switch"><input type="checkbox"><i></i></label> */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 28px; background: var(--fill); transition: background var(--t); }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .28); transition: transform var(--t) var(--ease); }
.switch input:checked + i { background: var(--ok-fill); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: var(--ring); }

/* ---- segmented control: a track with a raised thumb; hairline dividers between unselected segments */
.seg, .tabs {
  display: inline-flex; align-items: stretch; flex: none; max-width: 100%; height: var(--ctl-h); padding: 2px;
  border-radius: calc(var(--radius-ctl) + 1px); background: var(--fill-2); overflow-x: auto; scrollbar-width: none; isolation: isolate;
}
.seg::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.seg > button, .tabs > button, .seg > a {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 1 0 auto;
  padding: 0 10px; border-radius: calc(var(--radius-ctl) - 1px);
  font-size: var(--fs-md); font-weight: 500; line-height: 1; color: var(--text); white-space: nowrap; text-decoration: none;
  transition: background-color var(--t-base) var(--ease-snappy), color var(--t);
}
.seg > * + *::before, .tabs > * + *::before { content: ""; position: absolute; left: 0; top: 26%; bottom: 26%; width: 1px; background: var(--hairline-strong); opacity: .6; transition: opacity var(--t); }
.seg > .active::before, .seg > .active + *::before, .tabs > .active::before, .tabs > .active + *::before { opacity: 0; }
.seg > .active, .tabs > .active { background: var(--thumb); box-shadow: var(--shadow-thumb); }
.seg > :not(.active):hover, .tabs > :not(.active):hover { background: var(--fill-3); text-decoration: none; }
.seg > :focus-visible, .tabs > :focus-visible { border-radius: calc(var(--radius-ctl) - 1px); }
/* the thumb slides: core.js (initSegThumbs) inserts .seg-thumb and positions it; without it .active is painted */
.seg, .tabs { position: relative; }
.seg-thumb { position: absolute; z-index: -1; top: 2px; bottom: 2px; left: 0; width: var(--tw); transform: translateX(var(--tx)); border-radius: calc(var(--radius-ctl) - 1px); background: var(--thumb); box-shadow: var(--shadow-thumb); pointer-events: none; transition: transform var(--t-base) var(--ease-snappy), width var(--t-base) var(--ease-snappy); }
.seg-thumb.no-anim { transition: none; }
.has-thumb > .active { background: none; box-shadow: none; }
.seg-thumb::before { content: none; }
/* keyboard focus: an inset ring (the track clips an outer one), with no divider on either side of it */
.seg > :focus-visible, .tabs > :focus-visible { box-shadow: inset 0 0 0 2px var(--tint); }
.seg > :focus-visible::before, .seg > :focus-visible + *::before, .tabs > :focus-visible::before, .tabs > :focus-visible + *::before { opacity: 0; }
.seg > :not(.active):active, .tabs > :not(.active):active { opacity: .6; }
.seg > .active .muted, .seg > .active .num, .tabs > .active .muted { color: inherit; opacity: .75; }
.seg.block { display: flex; width: 100%; }
.tabs { margin-bottom: 18px; }
.tabs .badge, .seg .badge { min-width: 0; height: auto; padding: 0; background: none; color: var(--text-2); font: inherit; font-weight: 400; }
.tabs .badge.danger, .tabs .badge:not(.muted) { color: var(--danger); }
.seg .muted, .tabs .muted { font-weight: 400; color: var(--text-2); }

/* ---- status: chips, count badge, dots */
.chip {
  display: inline-flex; align-items: center; gap: 4px; flex: none; height: 20px; padding: 0 8px; border-radius: var(--pill);
  background: var(--fill-2); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; line-height: 1; letter-spacing: -.003em;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn, .chip.held { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--info-soft); color: var(--link); }
.chip.muted { background: var(--fill-2); color: var(--text-2); }
/* a change figure on its own: "+0.96%" on a soft ground, squarer than a chip */
.delta { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; background: var(--fill-2); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1; }
.delta.pos { background: var(--pos-soft); color: var(--pos); }
.delta.neg { background: var(--neg-soft); color: var(--neg); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger-fill); color: #fff; font-size: 11px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.badge.muted { background: var(--text-4); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-4); flex: none; }
.dot.ok { background: var(--ok-fill); } .dot.warn { background: var(--warn-fill); } .dot.danger { background: var(--danger-fill); } .dot.info { background: var(--tint); }
/* (after .dot, which would otherwise turn the unread dot grey) */
.badge.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; background: var(--danger-fill); }
.badge.dot.muted { background: var(--text-4); }

/* ---- surfaces: a card is a white tile with a hairline edge and a very soft shadow */
.card { background: var(--bg-elev); border-radius: var(--radius-lg); padding: 18px; min-width: 0; box-shadow: var(--shadow-card); --ring-bg: var(--bg-elev); }
.card:focus-visible { box-shadow: var(--ring); border-radius: var(--radius-lg); }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-h h2, .card-h h3 { flex: 1; min-width: 0; font: 600 var(--fs-headline)/var(--lh-headline) var(--font); letter-spacing: -.01em; }
.card-sub { color: var(--text-3); font-size: var(--fs-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-h { padding: 16px 18px 0; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 18px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 18px; }
@media (max-width: 767px) {
  .card { padding: 16px; }
  .card.flush > .card-h { padding: 16px 16px 0; }
  .card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 16px; }
  .card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 16px; }
}

/* figures: a small label, then the number — the number is the loudest thing in the tile */
.kpi { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-l { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.kpi-v { font: 600 var(--fs-title1)/1.2 var(--font-display); letter-spacing: var(--track-title); font-variant-numeric: tabular-nums; }
.kpi-s { font-size: var(--fs-sm); color: var(--text-2); }
/* the unit after a figure: smaller and quieter than the number it follows */
.unit { font-size: .58em; font-weight: 600; color: var(--text-3); margin-left: 1px; letter-spacing: 0; }
/* a value that just changed washes once (v-tick in core.js); P&L in the colour of its direction */
[data-tick] { animation: tick var(--t-tick) ease-out; border-radius: 6px; }
[data-tick="up"] { animation-name: tick-up; }
[data-tick="down"] { animation-name: tick-down; }
@keyframes tick { 0%, 22% { background-color: var(--fill-2); } 100% { background-color: transparent; } }
@keyframes tick-up { 0%, 22% { background-color: var(--pos-soft); } 100% { background-color: transparent; } }
@keyframes tick-down { 0%, 22% { background-color: var(--neg-soft); } 100% { background-color: transparent; } }
/* whatever scrolls fades at the edge that hides more: .fade-r / .fade-l sideways (set by the view that owns the
   scroller), .has-more downwards (set by v-scrolled while the scroller is not at its end) */
.fade-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
.fade-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 24px); mask-image: linear-gradient(90deg, transparent, #000 24px); }
.fade-l.fade-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.fade-b { -webkit-mask-image: linear-gradient(#000 calc(100% - 24px), transparent); mask-image: linear-gradient(#000 calc(100% - 24px), transparent); }
.fade-r.fade-b {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent), linear-gradient(#000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent), linear-gradient(#000 calc(100% - 24px), transparent);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}

/* grouped list (settings, pickers): label on the leading side, value or control on the trailing side */
.list-h { margin: 28px 0 8px; padding: 0 16px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); letter-spacing: .01em; }
.list-h:first-child { margin-top: 0; }
.list { background: var(--bg-elev); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--row-h); padding: 8px 16px; position: relative;
  text-align: left; font-size: var(--fs-body); color: var(--text);
}
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: var(--hair); background: var(--hairline); }
.list-row > label:not(.switch), .list-row .list-l { flex: none; min-width: 96px; color: var(--text); }
.list-row .list-v { margin-left: auto; color: var(--text-3); text-align: right; min-width: 0; }
.list-row .input { background: transparent; text-align: right; padding: 0 6px; margin-right: -6px; height: 28px; box-shadow: none; border-radius: 6px; }
.list-row .input:hover { background: var(--fill-3); }
.list-row .input:focus { background: var(--accent-soft); box-shadow: none; }
.list-row:focus-visible, .pick-item:focus-visible, .pick-item:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--tint); }
.table tr.clickable:focus-visible { outline: 2px solid var(--tint); outline-offset: -2px; box-shadow: none; }
button.list-row, a.list-row { cursor: pointer; transition: background var(--t-fast); }
button.list-row:hover, a.list-row:hover { background: var(--bg-hover); text-decoration: none; }
button.list-row:active, a.list-row:active { background: var(--bg-active); }
.list-row.accent { color: var(--link); }
.list-row.danger { color: var(--danger); justify-content: center; }
.list-row.stacked { display: block; padding: 16px; }
.list-row .chev { color: var(--text-4); margin-left: 2px; flex: none; }
.list-f { margin: 8px 0 0; padding: 0 16px; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-3); }

/* ---- tables: small grey header, 44px rows, hairlines between rows, numbers right-aligned */
.table-wrap { overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); line-height: var(--lh-body); }
.table th, .table td { padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: var(--hair) solid var(--hairline); }
.table th { position: sticky; top: 0; z-index: 1; padding-top: 7px; padding-bottom: 7px; background: var(--bg-elev); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; letter-spacing: .005em; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom-color: transparent; }
.table tbody tr { transition: background-color var(--t-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tr.clickable { cursor: pointer; }
.table tr.selected, .table tr.selected:hover { background: var(--selection); }
.table.compact { font-size: var(--fs-md); }
.table.compact th, .table.compact td { padding: 6px 10px; }

/* ---- feedback */
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fill); border-top-color: var(--text-3); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading:where(:not(.icon-btn, .btn)) { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--text-3); font-size: var(--fs-md); }
.skeleton { background: linear-gradient(90deg, var(--fill-3), var(--fill-2), var(--fill-3)); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: var(--radius); box-shadow: none; }
.card.skeleton { border-radius: var(--radius-lg); }
i.skeleton { display: block; flex: none; }   /* a placeholder is a block in its final shape, never inline text */
.skeleton.line { height: 12px; border-radius: 4px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 56px 24px; text-align: center; color: var(--text-3); font-size: var(--fs-md); line-height: var(--lh-md); }
.empty-ico { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: 6px; border-radius: 50%; background: var(--fill-2); color: var(--text-3); }
.empty-t { font-size: var(--fs-headline); font-weight: 600; color: var(--text); }
.empty .btn { margin-top: 10px; }
.empty { text-wrap: balance; }
.empty.compact { padding: 20px 12px; gap: 2px; }
.empty.compact .empty-ico { display: none; }

/* ---- avatars: the colour arrives as --av; people are circles, groups rounded squares */
.avatar {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%;
  background: color-mix(in srgb, var(--av, #8e8e93) 16%, var(--bg-elev)); color: color-mix(in srgb, var(--av, #8e8e93) 82%, #000);
  font-weight: 600; letter-spacing: -.01em; user-select: none; line-height: 1;
}
:root[data-theme="dark"] .avatar { background: color-mix(in srgb, var(--av, #8e8e93) 30%, #1c1c1e); color: color-mix(in srgb, var(--av, #8e8e93) 55%, #fff); }
.avatar.group { border-radius: 28%; }
.avatar.bot { border-radius: 28%; }
.online-dot { position: absolute; right: -1px; bottom: -1px; width: 28%; height: 28%; min-width: 9px; min-height: 9px; max-width: 12px; max-height: 12px; border-radius: 50%; background: var(--ok-fill); box-shadow: 0 0 0 2px var(--dot-ring, var(--bg-elev)); }

/* ---- menus and popovers (material) */
.menu {
  position: absolute; z-index: 60; min-width: 190px; padding: 5px; border-radius: var(--radius-lg);
  background: var(--material-pop); -webkit-backdrop-filter: var(--blur-thick); backdrop-filter: var(--blur-thick);
  box-shadow: var(--shadow-pop); animation: pop var(--t) var(--ease-snappy); transform-origin: top right;
}
.menu > button, .menu > a {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 28px; padding: 0 9px; border-radius: 6px;
  font-size: var(--fs-md); color: var(--text); text-align: left; white-space: nowrap;
}
.menu > button:hover, .menu > a:hover { background: var(--accent); color: #fff; text-decoration: none; }
.menu > button.danger { color: var(--danger); }
.menu > button.danger:hover { background: var(--danger-fill); color: #fff; }
.menu hr { border: 0; height: var(--hair); margin: 5px 9px; background: var(--hairline); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu.up { transform-origin: bottom left; animation-name: pop-up; }
@keyframes pop-up { from { opacity: 0; transform: scale(.96) translateY(4px); } to { opacity: 1; transform: none; } }
.menu.leaving { opacity: 0; transition: opacity var(--t-out); pointer-events: none; }
.menu > button:focus-visible, .menu > a:focus-visible { background: var(--accent); color: #fff; box-shadow: none; }
@media (max-width: 767px) { .menu { border-radius: 14px; min-width: 220px; } .menu > button, .menu > a { min-height: 44px; padding: 0 12px; font-size: var(--fs-body); border-radius: 9px; } }

/* ---- sheets (modal dialogs): centred card with a pointer, bottom sheet on phones */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--overlay); animation: fade var(--t) ease;
}
.modal {
  display: flex; flex-direction: column; max-width: 100%; max-height: min(86vh, 860px); border-radius: var(--radius-xl);
  background: var(--bg-elev); box-shadow: var(--shadow-sheet); animation: sheet-in var(--t-base) var(--ease-snappy); overflow: hidden;
}
.modal-h { display: flex; align-items: center; gap: 12px; padding: 16px 16px 10px 20px; font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 600; letter-spacing: -.01em; }
.modal-h > span { flex: 1; min-width: 0; }
.modal-h .icon-btn { width: 24px; height: 24px; border-radius: 50%; background: var(--fill-2); color: var(--text-2); }
.modal-b { padding: 4px 20px 20px; overflow: auto; flex: 1; overscroll-behavior: contain; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal-grab { display: none; }
/* leaving: the dimmer fades, the card settles away (the <modal> component wraps itself in <transition name="sheet">) */
.sheet-leave-active { transition: opacity 160ms ease; }
.sheet-leave-to { opacity: 0; }
.sheet-leave-active .modal { transition: transform 200ms var(--ease-sheet); transform: translateY(8px) scale(.98); }
.modal-mask ~ .modal-mask { background: rgba(0, 0, 0, .12); }   /* a dialog over a dialog dims only a little more */
/* hairlines above and below the body appear only when it actually scrolls */
.modal.is-scroll .modal-h { box-shadow: inset 0 calc(-1 * var(--hair)) 0 var(--hairline); }
.modal.is-scroll .modal-f { box-shadow: inset 0 var(--hair) 0 var(--hairline); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 767px) {
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal { width: 100% !important; max-height: calc(100dvh - 44px - var(--safe-t)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: sheet-up var(--t-slow) var(--ease-sheet); padding-bottom: var(--safe-b); }
  .modal-grab { display: block; width: 36px; height: 5px; margin: 7px auto 0; border-radius: 3px; background: var(--fill); flex: none; }
  .sheet-leave-active .modal { transition-duration: 280ms; transform: translateY(100%); }
  .modal-h { padding: 10px 14px 10px 16px; font-size: var(--fs-headline); }
  .modal-h .icon-btn { width: 30px; height: 30px; }
  .modal-b { padding: 4px 16px 16px; }
  .modal-f { padding: 10px 16px 14px; }
  .modal-f .btn { flex: 1; height: var(--ctl-h-lg); font-size: var(--fs-headline); font-weight: 600; border-radius: 12px; }
}

/* ---- toasts: a banner at the top, like a notification */
.toasts { position: fixed; top: calc(14px + var(--safe-t)); left: 50%; z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
@media (min-width: 768px) { .toasts { left: calc(var(--side-w) + (100vw - var(--side-w)) / 2); top: calc(var(--bar-h) + 10px); } }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 9px 14px 9px 12px; border-radius: 18px; pointer-events: auto; text-align: left;
  background: var(--material-pop); -webkit-backdrop-filter: var(--blur-thick); backdrop-filter: var(--blur-thick); box-shadow: var(--shadow-pop);
  font-size: var(--fs-md); font-weight: 500; color: var(--text); animation: toast-in var(--t-slow) var(--ease-snappy);
}
.toast > .icon { flex: none; color: var(--link); }
.toast.ok > .icon { color: var(--ok); }
.toast.danger > .icon { color: var(--danger); }
.toast a { color: var(--link); margin-left: 4px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---- pickers inside dialogs */
.pick-list { max-height: 280px; overflow: auto; border-radius: var(--radius); background: var(--bg-sunken); box-shadow: inset 0 0 0 var(--hair) var(--hairline); padding: 4px; }
.pick-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: var(--fs-body); }
.pick-item:hover { background: var(--bg-hover); }
.pick-item.active { background: var(--selection); }
.pick-item input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.pick-item input[type="checkbox"]:checked { background: var(--tint) center / 12px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.4 2.4 4.6-5'/%3E%3C/svg%3E"); box-shadow: none; }
.pick-list.has-more { -webkit-mask-image: linear-gradient(#000 calc(100% - 20px), transparent); mask-image: linear-gradient(#000 calc(100% - 20px), transparent); }
@media (max-width: 767px) { .pick-list { max-height: 40vh; } }

/* ---- image viewer */
.lightbox { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: rgba(0, 0, 0, .94); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); color: #fff; animation: fade var(--t) ease; }
.lightbox-top { display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-t)) 14px 10px; font-size: var(--fs-md); background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.lightbox-top .icon-btn { color: #fff; width: 36px; height: 36px; }
.lightbox-top .icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.lightbox-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 0 12px calc(16px + var(--safe-b)); }
.lightbox-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; cursor: zoom-in; animation: lb-in var(--t-base) var(--ease-snappy); }
@keyframes lb-in { from { opacity: 0; transform: scale(.96); } }
.lightbox-body.zoomed { align-items: flex-start; justify-content: flex-start; }
.lightbox-body.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox-nav { position: absolute; top: 50%; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-top: -22px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 26px; line-height: 1; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .26); }
.lightbox-nav.prev { left: 14px; } .lightbox-nav.next { right: 14px; }
@media (max-width: 767px) { .lightbox { background: #000; } }

/* ---- charts */
.echart { width: 100%; min-width: 0; }
.echart svg text { font-variant-numeric: tabular-nums; }
/* ECharts tooltip content built by core.js tipHtml(): a title and rows of swatch · label · value */
.tip-t { font-weight: 600; margin-bottom: 4px; }
.tip-r { display: grid; grid-template-columns: 8px 1fr auto; gap: 8px; align-items: center; color: var(--text-2); font-size: var(--fs-sm); }
.tip-r b { color: var(--text); font-variant-numeric: tabular-nums; }
.tip-r i { width: 8px; height: 8px; border-radius: 2px; }

/* ---- boot */
.boot { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-3); font-size: var(--fs-md); gap: 10px; }

/* reduced motion means gentler, not none: no movement, short fades of opacity and colour */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-property: opacity, color, background-color, box-shadow !important; transition-duration: 120ms !important; }
}
