/* Marketiism OS components + console/focus shells. Every value comes from tokens.css.
   Naming: .block, .block__part, .block--variant, .is-state. Documented in docs/agents/CONTRACT_UI.md. */

/* ============================================================ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--control-h); padding: 0 var(--s-4); border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: var(--fs-14); font-weight: var(--fw-semibold); line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none; list-style: none; position: relative;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease);
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { background: var(--surface-3); border-color: var(--line-input); color: var(--ink); text-decoration: none; }
.btn:active { background: var(--line); }
.btn--primary { background: var(--brand-btn); border-color: var(--brand-btn); color: var(--brand-btn-ink); }
.btn--primary:hover { background: var(--brand-btn-hover); border-color: var(--brand-btn-hover); color: var(--brand-btn-ink); }
.btn--primary:active { background: var(--brand-btn-hover); }
.btn--danger { color: var(--error); border-color: var(--error-line); }
.btn--danger:hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.btn--danger-solid { background: var(--error); border-color: var(--error); color: var(--ink-inverse); }
.btn--danger-solid:hover { background: var(--error); border-color: var(--error); color: var(--ink-inverse); filter: brightness(0.92); }
.btn--link { border-color: transparent; background: none; color: var(--link); padding: 0 var(--s-2); }
.btn--link:hover { background: none; border-color: transparent; color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }
.btn--ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn--icon { width: var(--control-h); padding: 0; border-color: transparent; background: none; color: var(--ink-2); }
.btn--icon:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn--icon.btn--bordered { border-color: var(--line-strong); background: var(--surface); }
.btn--sm { height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--fs-12); }
.btn--sm.btn--icon { width: var(--control-h-sm); padding: 0; }
.btn--lg { height: var(--control-h-lg); padding: 0 var(--s-5); font-size: var(--fs-16); }
.btn--xl { height: 48px; padding: 0 var(--s-6); font-size: var(--fs-16); }
.btn--full { width: 100%; }
.btn[disabled], .btn.is-disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > .spinner { position: absolute; inset: 0; margin: auto; color: var(--ink-2); }
.btn--primary.is-loading > .spinner { color: var(--brand-btn-ink); }
.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: ui-spin 700ms linear infinite; flex: none; }
.spinner--lg { width: 24px; height: 24px; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ============================================================ Form controls */
.field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.field + .field { margin-top: var(--s-4); }
.form-grid > .field + .field, .grid-form > .field + .field { margin-top: 0; }
.field__label { font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--ink); display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.field__opt { font-weight: var(--fw-regular); font-style: italic; color: var(--muted); font-size: var(--fs-12); }
.field__info { font-weight: var(--fw-semibold); font-size: var(--fs-12); }
.field__desc { font-size: var(--fs-12); color: var(--muted); margin-top: -2px; }
.field__control { margin-top: var(--s-1); }
.field__constraint { font-size: var(--fs-12); color: var(--muted); }
.field__error { display: flex; align-items: flex-start; gap: var(--s-1); font-size: var(--fs-12); color: var(--error); font-weight: var(--fw-medium); }
.field__error .i { margin-top: 1px; }
.field--check { gap: var(--s-1); }

.input, .select, .textarea,
.field__control > input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
.field__control > select, .field__control > textarea {
  width: 100%; height: var(--control-h); padding: 0 var(--s-3);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-input); border-radius: var(--r);
  font-size: var(--fs-14); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.textarea, .field__control > textarea { height: auto; min-height: 88px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: var(--lh); }
.input::placeholder, .textarea::placeholder, .field__control > input::placeholder, .field__control > textarea::placeholder { color: var(--muted); font-style: italic; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus, .select:focus, .textarea:focus,
.field__control > input:focus, .field__control > select:focus, .field__control > textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"],
.field.is-invalid .field__control > input, .field.is-invalid .field__control > select, .field.is-invalid .field__control > textarea { border-color: var(--error); box-shadow: inset 3px 0 0 var(--error); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.input--mono { font-family: var(--mono); font-size: var(--fs-12); }
.input--sm, .select--sm { height: var(--control-h-sm); font-size: var(--fs-12); }
.input--lg, .select--lg { height: var(--control-h-lg); font-size: var(--fs-16); }
.select, .field__control > select { appearance: none; -webkit-appearance: none; padding-right: var(--s-8); cursor: pointer; }
.select-wrap, .field__control:has(> select:not([multiple])) { position: relative; display: block; }
.select-wrap::after, .field__control:has(> select:not([multiple]))::after {
  content: ""; position: absolute; right: var(--s-3); top: 50%; width: 14px; height: 14px; margin-top: -7px; pointer-events: none;
  background: var(--ink-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.select-wrap--inline { display: inline-block; }
.select-wrap--inline > .select { width: auto; }
.select[multiple] { height: auto; padding: var(--s-1); background-image: none; }

.input-group { display: flex; align-items: stretch; width: 100%; border: 1px solid var(--line-input); border-radius: var(--r); background: var(--surface); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.input-group:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.input-group.is-invalid { border-color: var(--error); }
.input-group > .input { border: 0; box-shadow: none; min-width: 0; flex: 1; background: none; }
.input-group > .input:focus { box-shadow: none; }
.input-group__affix { display: inline-flex; align-items: center; gap: var(--s-1); padding: 0 var(--s-3); color: var(--muted); background: var(--surface-2); font-size: var(--fs-14); white-space: nowrap; }
.input-group__affix:first-child { border-right: 1px solid var(--line); border-radius: var(--r) 0 0 var(--r); }
.input-group__affix:last-child { border-left: 1px solid var(--line); border-radius: 0 var(--r) var(--r) 0; }
.input-group--icon > .i { align-self: center; margin-left: var(--s-3); color: var(--muted); }
.input-group--icon > .input { padding-left: var(--s-2); }
.input-group--icon > kbd { align-self: center; margin-right: var(--s-2); }
.input[type="search"]::-webkit-search-cancel-button { display: none; }

.check { display: inline-flex; align-items: flex-start; gap: var(--s-2); cursor: pointer; font-size: var(--fs-14); line-height: 20px; }
.check input, .check__input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; accent-color: var(--link); cursor: pointer; }
.check__text { display: flex; flex-direction: column; }
.check__desc { font-size: var(--fs-12); color: var(--muted); }
.check.is-disabled { color: var(--muted); cursor: not-allowed; }
.choices { border: 0; margin-inline: 0; margin-bottom: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.choices legend { padding: 0; margin-bottom: var(--s-2); font-weight: var(--fw-semibold); }
.choices--inline { flex-direction: row; flex-wrap: wrap; gap: var(--s-4); }
.choices--tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-2); }
.choices--tiles > legend { grid-column: 1 / -1; }
.tile { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); cursor: pointer; transition: border-color var(--t) var(--ease), background var(--t) var(--ease); }
.tile:hover { border-color: var(--line-input); }
.tile:has(input:checked) { border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus); background: var(--surface-sel); }
.tile input { margin-top: 3px; accent-color: var(--link); }
.tile__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile__title { font-weight: var(--fw-semibold); }
.tile__desc { font-size: var(--fs-12); color: var(--muted); }
.tile__meta { margin-left: auto; font-size: var(--fs-12); color: var(--muted); white-space: nowrap; }

.toggle { display: inline-flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; }
.toggle__input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 1px 0 0; position: relative; cursor: pointer;
  width: 34px; height: 20px; border-radius: var(--r-pill); background: var(--line-input); border: 0;
  transition: background var(--t) var(--ease);
}
.toggle__input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: transform var(--t) var(--ease); }
.toggle__input:checked { background: var(--link); }
.toggle__input:checked::before { transform: translateX(14px); }
.toggle__input:disabled { opacity: 0.5; }
.toggle__text { display: flex; flex-direction: column; line-height: 20px; }

/* ============================================================ Segmented control */
.seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg__item { display: inline-flex; align-items: center; gap: var(--s-1); height: 26px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font-size: var(--fs-14); font-weight: var(--fw-semibold); white-space: nowrap; cursor: pointer; text-decoration: none; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.seg__item:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.seg__item.is-on, .seg__item[aria-current="page"], .seg__item[aria-pressed="true"], .seg input:checked + .seg__item { background: var(--chrome); color: var(--chrome-ink); }
.seg__count { font-weight: var(--fw-regular); color: inherit; opacity: 0.75; font-variant-numeric: tabular-nums; }
.seg--sm .seg__item { height: 22px; font-size: var(--fs-12); padding: 0 var(--s-2); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg input:focus-visible + .seg__item { outline: var(--focus-width) solid var(--focus); outline-offset: 1px; }

/* ============================================================ Container (panel) */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel + .panel, .panel + .stats, .stats + .panel { margin-top: var(--s-4); }
.grid-2 > .panel + .panel, .grid-3 > .panel + .panel, .grid-main > .panel + .panel, .grid-detail > .panel + .panel, .grid-4 > .panel + .panel { margin-top: 0; }
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel__titles { min-width: 0; flex: 1; }
.panel__title { font-size: var(--fs-16); font-weight: var(--fw-bold); line-height: var(--lh-snug); display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.panel__count { font-weight: var(--fw-regular); color: var(--muted); font-variant-numeric: tabular-nums; }
.panel__desc { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }
.panel__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.panel__body { padding: var(--s-4) var(--s-5); }
.panel__body--flush { padding: 0; }
.panel__foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.panel--quiet { background: var(--surface-2); }
.panel--attention { border-color: var(--warning-line); }
.panel--headless > .panel__body { padding-top: var(--s-4); }
.panel--rounded-lg { border-radius: var(--r-lg); }

/* ============================================================ Key-value */
.kv { display: grid; gap: var(--s-4) var(--s-6); grid-template-columns: repeat(var(--kv-cols, 1), minmax(0, 1fr)); margin: 0; }
.kv--cols-2 { --kv-cols: 2; } .kv--cols-3 { --kv-cols: 3; } .kv--cols-4 { --kv-cols: 4; }
.kv__item { min-width: 0; }
.kv__item dt { font-size: var(--fs-12); color: var(--muted); font-weight: var(--fw-semibold); }
.kv__item dd { margin: 2px 0 0; color: var(--ink); overflow-wrap: anywhere; }
.kv--rows { grid-template-columns: minmax(0, 1fr); gap: 0; }
.kv--rows .kv__item { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--s-4); padding: var(--s-3) 0; border-top: 1px solid var(--line); align-items: baseline; }
.kv--rows .kv__item:first-child { border-top: 0; padding-top: 0; }
.kv--rows .kv__item dd { margin: 0; }

/* ============================================================ Status, badge, tags */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-14); color: var(--st, var(--stopped)); font-weight: var(--fw-medium); white-space: nowrap; line-height: 20px; vertical-align: middle; }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status__label { color: var(--st, var(--stopped)); }
.status--success { --st: var(--success); }
.status--warning { --st: var(--warning); }
.status--error { --st: var(--error); }
.status--info { --st: var(--info); }
.status--stopped { --st: var(--stopped); }
.status--sm { font-size: var(--fs-12); }
.status--sm .status__dot { width: 6px; height: 6px; }
.status .spinner { width: 10px; height: 10px; border-width: 1.5px; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-12); font-weight: var(--fw-semibold); line-height: 1; white-space: nowrap; background: var(--b-bg, var(--stopped-bg)); color: var(--b-ink, var(--ink-2)); border: 1px solid var(--b-line, var(--stopped-line)); font-variant-numeric: tabular-nums; vertical-align: middle; }
.badge--neutral { --b-bg: var(--stopped-bg); --b-ink: var(--ink-2); --b-line: var(--stopped-line); }
.badge--brand { --b-bg: var(--brand-soft); --b-ink: var(--brand-ink); --b-line: var(--brand-soft); }
.badge--info { --b-bg: var(--info-bg); --b-ink: var(--info); --b-line: var(--info-line); }
.badge--success { --b-bg: var(--success-bg); --b-ink: var(--success); --b-line: var(--success-line); }
.badge--warning { --b-bg: var(--warning-bg); --b-ink: var(--warning); --b-line: var(--warning-line); }
.badge--error { --b-bg: var(--error-bg); --b-ink: var(--error); --b-line: var(--error-line); }
.badge--count { min-width: 20px; justify-content: center; padding: 0 6px; background: var(--brand-btn); color: var(--brand-btn-ink); border-color: var(--brand-btn); }
.badge--square { border-radius: var(--r-sm); }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 var(--s-2); border-radius: var(--r-sm); background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-12); border: 1px solid var(--line); white-space: nowrap; }
a.tag:hover { border-color: var(--line-input); text-decoration: none; color: var(--ink); }
.tag-list { display: inline-flex; gap: var(--s-1); flex-wrap: wrap; vertical-align: middle; }

/* ============================================================ Tabs */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--s-4); }
.tabs__tab { position: relative; display: inline-flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3) var(--s-3); border: 0; background: none; color: var(--ink-2); font-size: var(--fs-14); font-weight: var(--fw-semibold); white-space: nowrap; cursor: pointer; text-decoration: none; }
.tabs__tab:hover { color: var(--link); text-decoration: none; }
.tabs__tab[aria-selected="true"], .tabs__tab[aria-current="page"] { color: var(--link); }
.tabs__tab[aria-selected="true"]::after, .tabs__tab[aria-current="page"]::after { content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -1px; height: 3px; border-radius: 2px 2px 0 0; background: var(--link); }
.tabs__count { font-weight: var(--fw-regular); color: var(--muted); }
.tabs__panel:focus-visible { outline-offset: 4px; }
.panel > .tabs { padding: 0 var(--s-3); margin-bottom: 0; }

/* ============================================================ Breadcrumbs */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-1); font-size: var(--fs-14); color: var(--muted); min-width: 0; }
.crumbs ol { display: contents; }
.crumbs li { display: inline-flex; align-items: center; gap: var(--s-1); min-width: 0; }
.crumbs a { color: var(--link); }
.crumbs .i { color: var(--muted); }
.crumbs [aria-current="page"] { color: var(--muted); }

/* ============================================================ Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head__main { min-width: 0; flex: 1 1 360px; }
.page-head__back { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--fs-14); margin-bottom: var(--s-1); }
.page-head__title { font-size: var(--fs-24); font-weight: var(--fw-bold); letter-spacing: var(--track-tight); line-height: var(--lh-snug); display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.page-head__title .status, .page-head__title .badge { font-size: var(--fs-14); letter-spacing: 0; }
.page-head__info { font-size: var(--fs-14); font-weight: var(--fw-semibold); letter-spacing: 0; }
.page-head__desc { margin-top: var(--s-1); color: var(--muted); max-width: 72ch; }
.page-head__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* ============================================================ Flashbar + inline alert */
.flashbar { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); list-style: none; padding: 0; }
.flash, .alert {
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r); border: 1px solid var(--a-line, var(--info-line)); background: var(--a-bg, var(--info-bg));
  color: var(--ink); font-size: var(--fs-14);
}
.flash__icon, .alert__icon { color: var(--a-ink, var(--info)); margin-top: 2px; flex: none; }
.flash__body, .alert__body { flex: 1; min-width: 0; }
.flash__title, .alert__title { font-weight: var(--fw-bold); }
.flash__text, .alert__text { color: var(--ink-2); }
.flash__title + .flash__text, .alert__title + .alert__text { margin-top: 2px; }
.flash__actions, .alert__actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.flash__x { margin: -4px -8px -4px 0; }
.flash--success, .alert--success { --a-bg: var(--success-bg); --a-line: var(--success-line); --a-ink: var(--success); }
.flash--warning, .alert--warning { --a-bg: var(--warning-bg); --a-line: var(--warning-line); --a-ink: var(--warning); }
.flash--error, .alert--error { --a-bg: var(--error-bg); --a-line: var(--error-line); --a-ink: var(--error); }
.flash--info, .alert--info { --a-bg: var(--info-bg); --a-line: var(--info-line); --a-ink: var(--info); }
.flash--progress { --a-bg: var(--info-bg); --a-line: var(--info-line); --a-ink: var(--info); }
.flash.is-gone { opacity: 0; transform: translateY(-4px); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.alert--plain { --a-bg: var(--surface-2); --a-line: var(--line); --a-ink: var(--ink-2); }

/* ============================================================ Toasts */
.toasts { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-2) var(--s-3) var(--s-4); background: var(--chrome); color: var(--chrome-ink); border-radius: var(--r); box-shadow: var(--shadow-pop); font-size: var(--fs-14); animation: ui-rise var(--t-slow) var(--ease); }
.toast__text { flex: 1; min-width: 0; }
.toast__icon { flex: none; }
.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--error); }
.toast--success .toast__icon, .toast--error .toast__icon { filter: brightness(1.6); }
.toast .btn--icon { color: var(--chrome-muted); }
.toast .btn--icon:hover { background: var(--chrome-2); color: var(--chrome-ink); }
.toast.is-gone { opacity: 0; transform: translateY(6px); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
@keyframes ui-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes ui-pop { from { opacity: 0; transform: translateY(-4px); } }

/* ============================================================ Modal, confirm, drawer (native <dialog>) */
.modal, .drawer { border: 0; padding: 0; color: var(--ink); background: var(--surface); box-shadow: var(--shadow-pop); }
.modal::backdrop, .drawer::backdrop { background: var(--scrim); }
.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); border-radius: var(--r-lg); border: 1px solid var(--line); }
.modal[open] { display: flex; flex-direction: column; animation: ui-pop var(--t-slow) var(--ease); }
.modal--sm { width: min(420px, calc(100vw - 32px)); }
.modal--lg { width: min(820px, calc(100vw - 32px)); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.modal__title { font-size: var(--fs-18); font-weight: var(--fw-bold); }
.modal__body { padding: var(--s-5); overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal__x { margin: -4px -8px 0 0; }
.confirm__text { color: var(--ink-2); }
.confirm__check { margin-top: var(--s-4); }

.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100vh; max-height: 100vh; width: min(440px, 100vw); border-left: 1px solid var(--line); }
.drawer--left { inset: 0 auto 0 0; border-left: 0; border-right: 1px solid var(--line); }
.drawer--wide { width: min(640px, 100vw); }
.drawer[open] { display: flex; flex-direction: column; animation: ui-slide-in var(--t-slow) var(--ease); }
.drawer--left[open] { animation-name: ui-slide-in-left; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); min-height: 56px; }
.drawer__title { font-size: var(--fs-16); font-weight: var(--fw-bold); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--s-5); }
.drawer__foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); background: var(--surface-2); }
@keyframes ui-slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes ui-slide-in-left { from { transform: translateX(-24px); opacity: 0; } }
html.is-locked { overflow: hidden; }

/* ============================================================ Dropdown menu, popover, tooltip */
.dropdown, .popover { position: relative; display: inline-block; }
.dropdown > summary, .popover > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker, .popover > summary::-webkit-details-marker { display: none; }
.dropdown[open] > summary.btn:not(.btn--primary) { background: var(--surface-3); }
.dropdown__caret { transition: transform var(--t) var(--ease); }
.dropdown[open] .dropdown__caret { transform: rotate(180deg); }
.menu {
  position: absolute; z-index: var(--z-menu); top: calc(100% + 4px); left: 0; min-width: 200px; max-width: 320px;
  padding: var(--s-1) 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-pop); animation: ui-pop var(--t) var(--ease); font-size: var(--fs-14);
}
.menu--right { left: auto; right: 0; }
.menu--up { top: auto; bottom: calc(100% + 4px); }
.menu__label { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--muted); }
.menu__head { padding: var(--s-2) var(--s-3); display: flex; flex-direction: column; min-width: 0; }
.menu__item { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: 6px var(--s-3); border: 0; background: none; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; font-size: var(--fs-14); white-space: nowrap; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-3); color: var(--ink); text-decoration: none; outline-offset: -2px; }
.menu__item .i { color: var(--ink-2); }
.menu__item.is-on { font-weight: var(--fw-semibold); }
.menu__item.is-on > .menu__check { color: var(--link); }
.menu__item--danger, .menu__item--danger .i { color: var(--error); }
.menu__item[aria-disabled="true"] { color: var(--muted); pointer-events: none; }
.menu__meta { margin-left: auto; color: var(--muted); font-size: var(--fs-12); }
.menu__sep { height: 1px; background: var(--line); margin: var(--s-1) 0; border: 0; }
.menu form { margin: 0; }

.popover__body { position: absolute; z-index: var(--z-menu); top: calc(100% + 6px); left: 0; width: 300px; max-width: calc(100vw - 32px); padding: var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop); animation: ui-pop var(--t) var(--ease); }
.popover__body--right { left: auto; right: 0; }
.popover__title { font-weight: var(--fw-bold); margin-bottom: var(--s-2); }
.popover__trigger { border-bottom: 1px dashed var(--muted); cursor: pointer; color: var(--ink); }

.tip { position: relative; display: inline-flex; vertical-align: middle; }
.tip__trigger { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; background: none; border-radius: 50%; color: var(--muted); cursor: help; }
.tip__trigger:hover { color: var(--link); }
.tip__bubble { position: absolute; z-index: var(--z-menu); bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 260px; padding: 6px var(--s-2); border-radius: var(--r-sm); background: var(--chrome); color: var(--chrome-ink); font-size: var(--fs-12); font-weight: var(--fw-regular); line-height: var(--lh-snug); opacity: 0; visibility: hidden; transition: opacity var(--t) var(--ease), visibility var(--t); pointer-events: none; text-align: left; white-space: normal; }
.tip:hover .tip__bubble, .tip:focus-within .tip__bubble { opacity: 1; visibility: visible; }
.tip--right .tip__bubble { left: auto; right: 0; transform: none; }

/* ============================================================ Stat tiles, sparkline, chart */
.stats { display: grid; grid-template-columns: repeat(var(--stats-cols, 4), minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.stats--3 { --stats-cols: 3; } .stats--2 { --stats-cols: 2; } .stats--5 { --stats-cols: 5; }
.stats > .stat { border: 0; border-radius: 0; }
.stats > .stat + .stat { border-left: 1px solid var(--line); }
.stat { position: relative; display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4) var(--s-5); min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); }
a.stat:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.stat__label { font-size: var(--fs-14); color: var(--ink-2); font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--s-1); }
.stat__row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-1) var(--s-3); flex-wrap: wrap; }
.stat__value { font-size: var(--fs-32); font-weight: var(--fw-regular); letter-spacing: var(--track-tight); line-height: var(--lh-tight); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat__value--link { color: var(--link); }
.stat__unit { font-size: var(--fs-16); color: var(--muted); margin-left: 2px; }
.stat__foot { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-12); color: var(--muted); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; color: var(--muted); }
.delta--good { color: var(--success); }
.delta--bad { color: var(--error); }

.spark { display: block; overflow: visible; flex: none; }
.spark__line { fill: none; stroke: var(--data-1); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark__area { fill: var(--data-1-soft); stroke: none; }
.spark__dot { fill: var(--data-1); }
.spark--brand .spark__line { stroke: var(--data-2); } .spark--brand .spark__dot { fill: var(--data-2); }
.spark--success .spark__line { stroke: var(--data-3); } .spark--success .spark__dot { fill: var(--data-3); }

.chart { position: relative; padding-left: 48px; }
.chart__svg { display: block; width: 100%; height: var(--chart-h, 180px); overflow: visible; }
.chart__grid { stroke: var(--data-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart__area { fill: var(--data-1-soft); }
.chart__line { fill: none; stroke: var(--data-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart__cursor { stroke: var(--line-input); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0; }
.chart.is-hover .chart__cursor { opacity: 1; }
.chart__hit { fill: transparent; cursor: crosshair; }
.chart__y { position: absolute; left: 0; top: 0; width: 42px; height: var(--chart-h, 180px); pointer-events: none; }
.chart__y span { position: absolute; right: 0; top: var(--y); transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart__x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: var(--s-2); }
.chart__tip { position: absolute; top: 0; left: 0; pointer-events: none; padding: 6px var(--s-2); border-radius: var(--r-sm); background: var(--chrome); color: var(--chrome-ink); font-size: var(--fs-12); white-space: nowrap; transform: translate(-50%, -115%); display: flex; flex-direction: column; box-shadow: var(--shadow-pop); }
.chart__tip span { color: var(--chrome-muted); }

/* ============================================================ Progress */
.progress { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.progress__top { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-14); }
.progress__label { font-weight: var(--fw-semibold); }
.progress__value { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress__track { height: 4px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.progress__fill { height: 100%; width: var(--v, 0%); border-radius: inherit; background: var(--pf, var(--link)); transition: width var(--t-slow) var(--ease); }
.progress--success { --pf: var(--success); } .progress--warning { --pf: var(--warning); } .progress--error { --pf: var(--error); } .progress--brand { --pf: var(--brand); }
.progress--thick .progress__track { height: 8px; }
.progress__desc { font-size: var(--fs-12); color: var(--muted); }

/* ============================================================ Pagination */
.pager { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-14); }
.pager__btn, .pager__num { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: var(--r-sm); color: var(--ink-2); border: 0; background: none; font-variant-numeric: tabular-nums; text-decoration: none; }
.pager__btn:hover, .pager__num:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.pager__num[aria-current="page"] { font-weight: var(--fw-bold); color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0; }
.pager__btn.is-disabled { color: var(--line-strong); pointer-events: none; }
.pager__gap { min-width: 20px; text-align: center; color: var(--muted); }
.pager__info { color: var(--muted); font-size: var(--fs-12); margin-right: var(--s-2); font-variant-numeric: tabular-nums; }

/* ============================================================ Table + filter bar */
.filterbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-3) var(--s-5); }
.panel__head + .filterbar { padding-top: var(--s-3); }
.filterbar__search { flex: 1 1 260px; max-width: 420px; }
.filterbar__filters { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
.filterbar__filters .select { width: auto; max-width: 220px; }
.filterbar__meta { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.filterbar__chips { display: flex; gap: var(--s-1); flex-wrap: wrap; width: 100%; align-items: center; font-size: var(--fs-12); }
.chip { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 2px 0 var(--s-2); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-12); color: var(--ink); }
.chip__x { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 0; background: none; color: var(--muted); border-radius: var(--r-sm); text-decoration: none; }
.chip__x:hover { background: var(--surface-3); color: var(--ink); }

.table-wrap { position: relative; overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table-wrap--sticky { max-height: var(--table-max-h, 640px); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: var(--fw-bold); color: var(--ink-2); padding: var(--s-2) var(--s-5); background: var(--surface-2); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); white-space: nowrap; font-size: var(--fs-14); }
.panel__head + .table-wrap .table th, .panel > .table-wrap:first-child .table th { border-top: 0; }
.table td { padding: 10px var(--s-5); border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table--wrap td, .table td.wrap { white-space: normal; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr { transition: background var(--t) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--surface-sel); }
.table tbody tr.is-selected td:first-child { box-shadow: inset 2px 0 0 var(--link); }
.table tr[data-href] { cursor: pointer; }
.table__sel { width: 40px; padding-right: 0 !important; }
.table__sel input { width: 16px; height: 16px; margin: 0; accent-color: var(--link); vertical-align: middle; }
.table__actions { width: 1%; white-space: nowrap; text-align: right; }
.table--compact td { padding-top: 6px; padding-bottom: 6px; }
.table--compact th, .table--compact td { padding-left: var(--s-3); padding-right: var(--s-3); }
.table--plain th { background: none; border-top: 0; }
.table--plain th:first-child, .table--plain td:first-child { padding-left: 0; }
.table--plain th:last-child, .table--plain td:last-child { padding-right: 0; }
.th-sort { display: inline-flex; align-items: center; gap: 2px; color: inherit; font: inherit; border: 0; background: none; padding: 0; cursor: pointer; text-decoration: none; }
.th-sort:hover { color: var(--ink); text-decoration: none; }
.th-sort .i { color: var(--muted); }
th[aria-sort] .th-sort .i { color: var(--ink); }
.table__state td { padding: 0 !important; }
.table__state:hover { background: none !important; }
.who { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.who__text { min-width: 0; display: flex; flex-direction: column; }
.who__name { font-weight: var(--fw-semibold); color: var(--ink); }
a.who__name { color: var(--link); }
.who__sub { font-size: var(--fs-12); color: var(--muted); }
.bulkbar { display: flex; align-items: center; gap: var(--s-2); }
.bulkbar__count { font-size: var(--fs-14); color: var(--muted); }

/* ============================================================ Empty, skeleton */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: var(--s-9) var(--s-6); color: var(--muted); }
.empty__icon { color: var(--muted); margin-bottom: var(--s-1); }
.empty__title { font-size: var(--fs-16); font-weight: var(--fw-bold); color: var(--ink); }
.empty__text { max-width: 440px; }
.empty__actions { display: flex; gap: var(--s-2); margin-top: var(--s-2); flex-wrap: wrap; justify-content: center; }
.empty--compact { padding: var(--s-6) var(--s-4); font-size: var(--fs-14); }
.empty--compact .empty__title { font-size: var(--fs-14); }
.empty--error .empty__icon { color: var(--error); }
.empty--loading .empty__icon { color: var(--link); }

.skel { display: block; border-radius: var(--r-sm); background: var(--surface-3); animation: ui-pulse 1.4s ease-in-out infinite; }
.skel--text { height: 12px; margin: 6px 0; width: var(--w, 100%); }
.skel--title { height: 18px; width: 40%; margin-bottom: var(--s-3); }
.skel--avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.skel--block { height: var(--h, 120px); border-radius: var(--r); }
.skel--value { height: 32px; width: 60%; margin: var(--s-1) 0; }
.skel-row { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) 0; }
.skel-row + .skel-row { border-top: 1px solid var(--line); }
.skel-row .skel--text { margin: 0; }
@keyframes ui-pulse { 50% { opacity: 0.45; } }

/* ============================================================ Copy, code chip */
.copy { display: flex; align-items: stretch; width: 100%; }
.copy > .input { border-radius: var(--r) 0 0 var(--r); min-width: 0; flex: 1; }
.copy > .btn { border-radius: 0 var(--r) var(--r) 0; margin-left: -1px; }
.copy-inline { display: inline-flex; align-items: center; gap: var(--s-1); max-width: 100%; }
.copy-inline > .copy-inline__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-copy].is-copied { color: var(--success); }
.code-chip { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; height: 24px; padding: 0 2px 0 var(--s-2); border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--line); font-family: var(--mono); font-size: var(--fs-12); color: var(--ink); vertical-align: middle; }
.code-chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-chip__label { font-family: var(--font); color: var(--muted); margin-right: 2px; }
.code-chip .btn--icon { width: 22px; height: 22px; }
.code-chip--plain { padding-right: var(--s-2); }
.codeblock { margin: 0; padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line); font-family: var(--mono); font-size: var(--fs-12); line-height: var(--lh); overflow-x: auto; white-space: pre; }

/* ============================================================ Date range, tag input, file upload */
.daterange > summary .i { color: var(--ink-2); }
.daterange__body { width: 320px; }
.daterange__presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-1); margin-bottom: var(--s-3); }
.daterange__presets .seg__item { justify-content: center; border: 1px solid var(--line-strong); }
.daterange__custom { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.daterange__foot { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); }

.taginput { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); min-height: var(--control-h); padding: 3px var(--s-2); border: 1px solid var(--line-input); border-radius: var(--r); background: var(--surface); cursor: text; }
.taginput:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.taginput__field { flex: 1 1 120px; min-width: 80px; height: 24px; border: 0; outline: 0; background: none; padding: 0 var(--s-1); }
.taginput__field::placeholder { color: var(--muted); font-style: italic; }
.taginput .chip { height: 22px; }

.upload { display: flex; flex-direction: column; gap: var(--s-2); }
.upload__drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s-1); padding: var(--s-6) var(--s-4); border: 1px dashed var(--line-input); border-radius: var(--r); background: var(--surface-2); text-align: center; color: var(--ink-2); cursor: pointer; transition: border-color var(--t) var(--ease), background var(--t) var(--ease); }
.upload__drop:hover, .upload.is-over .upload__drop { border-color: var(--focus); background: var(--surface-sel); }
.upload__drop:focus-within { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
.upload__input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.upload__cta { color: var(--link); font-weight: var(--fw-semibold); }
.upload__hint { font-size: var(--fs-12); color: var(--muted); }
.upload__list { display: flex; flex-direction: column; gap: var(--s-1); }
.upload__file { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-14); }
.upload__file .i { color: var(--muted); }
.upload__size { margin-left: auto; color: var(--muted); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.upload--compact .upload__drop { flex-direction: row; justify-content: center; padding: var(--s-3); }

/* ============================================================ Stepper, timeline */
.stepper { display: flex; flex-direction: column; gap: 0; counter-reset: step; }
.step { position: relative; display: flex; gap: var(--s-3); padding-bottom: var(--s-5); counter-increment: step; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 28px; bottom: 4px; width: 1px; background: var(--line-strong); }
.step__mark { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 1px solid var(--line-input); background: var(--surface); color: var(--muted); font-size: var(--fs-12); font-weight: var(--fw-semibold); }
.step__mark::before { content: counter(step); }
.step.is-done .step__mark { background: var(--success); border-color: var(--success); color: var(--ink-inverse); }
.step.is-done .step__mark::before { content: none; }
.step.is-current .step__mark { border: 2px solid var(--link); color: var(--link); }
.step.is-error .step__mark { border-color: var(--error); color: var(--error); }
.step__text { display: flex; flex-direction: column; min-width: 0; padding-top: 2px; }
.step__label { font-weight: var(--fw-semibold); color: var(--ink-2); }
.step.is-current .step__label { color: var(--ink); }
a.step__label { color: var(--link); }
.step__desc { font-size: var(--fs-12); color: var(--muted); }
.stepper--h { flex-direction: row; gap: var(--s-2); overflow-x: auto; }
.stepper--h .step { flex: 1 1 0; min-width: 120px; flex-direction: column; gap: var(--s-2); padding: 0; }
.stepper--h .step:not(:last-child)::before { left: 32px; right: var(--s-2); top: 12px; bottom: auto; width: auto; height: 1px; }
.stepper--h .step.is-done:not(:last-child)::before { background: var(--success); }

.tl { position: relative; }
.tl__item { position: relative; display: flex; gap: var(--s-3); padding-bottom: var(--s-4); }
.tl__item:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 1px; background: var(--line); }
.tl__dot { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2); }
.tl__item--success .tl__dot { color: var(--success); border-color: var(--success-line); background: var(--success-bg); }
.tl__item--warning .tl__dot { color: var(--warning); border-color: var(--warning-line); background: var(--warning-bg); }
.tl__item--error .tl__dot { color: var(--error); border-color: var(--error-line); background: var(--error-bg); }
.tl__item--info .tl__dot { color: var(--info); border-color: var(--info-line); background: var(--info-bg); }
.tl__item--brand .tl__dot { color: var(--brand-ink); border-color: var(--brand-soft); background: var(--brand-soft); }
.tl__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.tl__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.tl__title { font-weight: var(--fw-semibold); }
.tl__time { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl__text { color: var(--ink-2); }
.tl__body { margin-top: var(--s-1); }

/* ============================================================ Avatar */
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--line); font-size: var(--fs-12); font-weight: var(--fw-semibold); letter-spacing: 0.02em; line-height: 1; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { width: 20px; height: 20px; font-size: 9px; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 48px; height: 48px; font-size: var(--fs-16); }
.avatar--square { border-radius: var(--r-sm); }
.avatar--chrome { background: var(--chrome); color: var(--chrome-ink); border-color: var(--chrome); }
.avatar--brand { background: var(--brand); color: var(--chrome-ink); border-color: var(--brand); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }

/* ============================================================ Action list, messages, form section */
.alist { margin: 0; padding: 0; list-style: none; }
.alist__item + .alist__item { border-top: 1px solid var(--line); }
.alist__link { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; color: var(--ink); text-decoration: none; }
.alist__link:hover { color: var(--link); text-decoration: none; }
.alist__icon { color: var(--muted); }
.alist__item--warning .alist__icon { color: var(--warning); }
.alist__item--error .alist__icon { color: var(--error); }
.alist__item--success .alist__icon { color: var(--success); }
.alist__item--info .alist__icon { color: var(--info); }
.alist__text { flex: 1; min-width: 0; }
.alist__meta { color: var(--muted); font-size: var(--fs-12); white-space: nowrap; }
.alist__go { color: var(--muted); }

.msg { position: relative; max-width: min(520px, 80%); padding: var(--s-2) var(--s-3); border-radius: var(--r-lg); font-size: var(--fs-14); line-height: 1.45; overflow-wrap: anywhere; }
.msg--in { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-top-left-radius: var(--r-sm); }
.msg--out { align-self: flex-end; background: var(--surface-sel); border: 1px solid var(--info-line); border-top-right-radius: var(--r-sm); }
.msg--note { align-self: center; background: var(--warning-bg); border: 1px dashed var(--warning-line); font-size: var(--fs-12); color: var(--ink-2); }
.msg__by { display: block; font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--ink-2); margin-bottom: 2px; }
.msg__meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg__meta .i { color: var(--info); }

.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: var(--chat-h, 600px); min-height: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.chat__list { border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; }
.conv { position: relative; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.conv:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.conv.is-on { background: var(--surface-sel); box-shadow: inset 3px 0 0 var(--link); }
.conv__main { flex: 1; min-width: 0; }
.conv__top { display: flex; justify-content: space-between; gap: var(--s-2); }
.conv__name { min-width: 0; font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv__time { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; }
.conv__last { display: block; font-size: var(--fs-12); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.is-unread .conv__name, .conv.is-unread .conv__last { color: var(--ink); font-weight: var(--fw-semibold); }
.chat__thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.chat__back { display: none; }
.chat__msgs { flex: 1; overflow-y: auto; padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); background: var(--surface-2); }
.chat__day { align-self: center; font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 1px var(--s-2); border-radius: var(--r-pill); margin: var(--s-2) 0; }
.composer { display: flex; gap: var(--s-2); align-items: flex-end; padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--surface); }
.composer .textarea { min-height: 36px; max-height: 160px; resize: none; }
.composer__note { padding: 0 var(--s-4) var(--s-3); font-size: var(--fs-12); color: var(--muted); background: var(--surface); }

.form-section { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: var(--s-6); padding: var(--s-5); }
.form-section + .form-section { border-top: 1px solid var(--line); }
.form-section__title { font-size: var(--fs-16); font-weight: var(--fw-bold); }
.form-section__desc { margin-top: var(--s-1); color: var(--muted); font-size: var(--fs-14); }
.form-section__body { min-width: 0; max-width: 640px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--s-2); margin-top: var(--s-5); flex-wrap: wrap; }
.form-errors { margin-bottom: var(--s-4); }

/* ============================================================ Console shell */
.console { min-height: 100vh; }
.c-top {
  position: sticky; top: 0; z-index: var(--z-top); height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-3); background: var(--chrome); color: var(--chrome-ink); border-bottom: 1px solid var(--chrome-line);
}
.c-top a { color: var(--chrome-ink); }
.c-top a:hover { text-decoration: none; }
.c-brand { display: inline-flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2); height: 36px; border-radius: var(--r-sm); font-weight: var(--fw-bold); font-size: var(--fs-14); white-space: nowrap; color: var(--chrome-ink); }
.c-brand:hover { background: var(--chrome-2); }
.c-brand .brand__name b { color: var(--brand); font-weight: var(--fw-bold); }
.mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px 6px 6px 2px; background: var(--brand); color: var(--chrome-ink); font-weight: var(--fw-bold); font-size: 13px; line-height: 1; flex: none; }
.mark--lg { width: 30px; height: 30px; font-size: 16px; border-radius: 7px 7px 7px 2px; }
.c-icon { display: inline-grid; place-items: center; position: relative; width: 36px; height: 36px; border: 0; border-radius: var(--r-sm); background: none; color: var(--chrome-ink-2); cursor: pointer; list-style: none; }
.c-icon::-webkit-details-marker { display: none; }
.c-icon:hover, details[open] > .c-icon { background: var(--chrome-2); color: var(--chrome-ink); }
.c-icon__dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--chrome); }
.c-pill { display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-2); border-radius: var(--r-sm); color: var(--chrome-ink); font-size: var(--fs-14); font-weight: var(--fw-medium); white-space: nowrap; cursor: pointer; list-style: none; max-width: 240px; }
.c-pill::-webkit-details-marker { display: none; }
.c-pill:hover, details[open] > .c-pill { background: var(--chrome-2); }
.c-pill .i { color: var(--chrome-muted); }
.c-pill__text { overflow: hidden; text-overflow: ellipsis; }
.c-search { flex: 1 1 auto; max-width: 560px; margin: 0 var(--s-2); display: flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-2) 0 var(--s-3); border-radius: var(--r-sm); background: var(--chrome-2); border: 1px solid var(--chrome-line); color: var(--chrome-muted); transition: border-color var(--t) var(--ease), background var(--t) var(--ease); }
.c-search:focus-within { border-color: var(--chrome-muted); background: var(--chrome-3); }
.c-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--chrome-ink); }
.c-search input::placeholder { color: var(--chrome-muted); }
.c-search input::-webkit-search-cancel-button { display: none; }
.c-search kbd { background: var(--chrome); color: var(--chrome-muted); border-color: var(--chrome-line); }
.c-top__right { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.c-top .dropdown .menu, .c-top .popover__body { color: var(--ink); }
.c-top .menu a, .c-top .menu .menu__item { color: var(--ink); }
.c-sep { width: 1px; height: 20px; background: var(--chrome-line); margin: 0 var(--s-1); }
.c-search-btn { display: none; }

.launcher { position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-menu); width: min(760px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop); animation: ui-pop var(--t) var(--ease); }
.launcher__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.launcher__grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-4); padding: var(--s-4); max-height: calc(100vh - 140px); overflow-y: auto; }
.launcher__group h3 { font-size: var(--fs-12); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--track-caps); color: var(--muted); margin-bottom: var(--s-2); padding: 0 var(--s-2); }
.launcher__item { display: flex; align-items: flex-start; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-sm); color: var(--ink) !important; text-decoration: none; }
.launcher__item:hover { background: var(--surface-3); text-decoration: none; }
.launcher__item .i { color: var(--ink-2); margin-top: 2px; }
.launcher__name { display: block; font-weight: var(--fw-semibold); font-size: var(--fs-14); }
.launcher__desc { display: block; font-size: var(--fs-12); color: var(--muted); line-height: var(--lh-snug); }
.launcher__item.is-soon .launcher__name::after { content: "Soon"; margin-left: 6px; font-size: 10px; font-weight: var(--fw-semibold); color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 4px; vertical-align: 1px; }
.launcher__foot { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); font-size: var(--fs-12); color: var(--muted); }

.c-body { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.c-side { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); width: var(--side-w); flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); transition: width var(--t-slow) var(--ease); z-index: var(--z-sticky); }
.c-side__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2) var(--s-5); }
.c-side__title { font-size: var(--fs-16); font-weight: var(--fw-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.c-nav { flex: 1; overflow-y: auto; padding: var(--s-1) 0 var(--s-4); }
.c-nav__group + .c-nav__group { margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--line); }
.c-nav__label { padding: var(--s-2) var(--s-5) var(--s-1); font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--muted); }
.c-nav__item { position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 32px; padding: 4px var(--s-4) 4px var(--s-5); color: var(--ink-2); font-size: var(--fs-14); text-decoration: none; white-space: nowrap; }
.c-nav__item:hover { color: var(--link); text-decoration: none; background: var(--surface-2); }
.c-nav__item[aria-current="page"] { color: var(--link); font-weight: var(--fw-bold); background: var(--surface-sel); }
.c-nav__item[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 0 2px 2px 0; background: var(--link); }
.c-nav__item .i { color: var(--muted); }
.c-nav__item[aria-current="page"] .i { color: var(--link); }
.c-nav__text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.c-nav__ext { color: var(--muted); }
.c-side__foot { border-top: 1px solid var(--line); padding: var(--s-2) 0; }
.c-collapse .i { transition: transform var(--t) var(--ease); }
.is-rail .c-side { width: var(--side-w-rail); }
.is-rail .c-side .c-nav__text, .is-rail .c-side .c-nav__label, .is-rail .c-side .c-side__title, .is-rail .c-side .badge, .is-rail .c-side .c-nav__ext { display: none; }
.is-rail .c-side .c-nav__item { justify-content: center; padding: 4px 0; }
.is-rail .c-side .c-side__head { justify-content: center; padding-left: var(--s-2); padding-right: var(--s-2); }
.is-rail .c-collapse .i { transform: scaleX(-1); }
.c-scrim { display: none; }

.c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.c-content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s-4) var(--s-7) var(--s-10); }
.c-content--full { max-width: none; }
.c-crumbs { margin-bottom: var(--s-3); }
.c-drawer-btn { display: none; }

/* ============================================================ Focus shell */
.focus-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.f-top { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: 0 var(--s-6); background: var(--surface); border-bottom: 1px solid var(--line); }
.f-brand { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--ink); font-weight: var(--fw-bold); font-size: var(--fs-16); }
.f-brand:hover { color: var(--ink); text-decoration: none; }
.f-brand b { color: var(--brand-ink); }
.f-top__right { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-14); color: var(--muted); }
.f-main { flex: 1; width: 100%; margin: 0 auto; padding: var(--s-8) var(--s-4) var(--s-9); }
.f-main--narrow { max-width: calc(var(--focus-narrow) + var(--s-8)); }
.f-main--wide { max-width: calc(var(--focus-wide) + var(--s-8)); }
.f-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-7); }
.f-card__title { font-size: var(--fs-24); font-weight: var(--fw-bold); letter-spacing: var(--track-tight); }
.f-card__sub { color: var(--muted); margin-top: var(--s-1); margin-bottom: var(--s-6); }
.f-alt { text-align: center; margin-top: var(--s-5); color: var(--muted); font-size: var(--fs-14); }
.f-foot { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s-2) var(--s-5); padding: var(--s-5) var(--s-4); font-size: var(--fs-12); color: var(--muted); }
.f-foot a { color: var(--muted); }
.f-foot a:hover { color: var(--link); }
.f-split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s-6); align-items: start; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.summary__row { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) 0; font-variant-numeric: tabular-nums; }
.summary__row + .summary__row { border-top: 1px solid var(--line); }
.summary__row--total { font-weight: var(--fw-bold); font-size: var(--fs-16); border-top: 1px solid var(--ink) !important; margin-top: var(--s-1); padding-top: var(--s-3); }
.secure-note { display: flex; align-items: center; justify-content: center; gap: var(--s-2); font-size: var(--fs-12); color: var(--muted); margin-top: var(--s-3); }

/* ============================================================ Responsive */
@media (max-width: 1100px) {
  .launcher__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { --stats-cols: 2 !important; }
  .stats > .stat:nth-child(odd) { border-left: 0; }
  .stats > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
}
@media (max-width: 900px) {
  .c-drawer-btn { display: inline-grid; }
  .c-side { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; height: auto; width: 280px; transform: translateX(-100%); transition: transform var(--t-slow) var(--ease); z-index: var(--z-drawer); }
  .is-rail .c-side { width: 280px; }
  .is-rail .c-side .c-nav__text, .is-rail .c-side .c-nav__label, .is-rail .c-side .c-side__title, .is-rail .c-side .badge { display: revert; }
  .is-rail .c-side .c-nav__item { justify-content: flex-start; padding: 4px var(--s-4) 4px var(--s-5); }
  .c-collapse { display: none; }
  .is-drawer .c-side { transform: none; box-shadow: var(--shadow-pop); }
  .is-drawer .c-scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: calc(var(--z-drawer) - 1); background: var(--scrim); }
  .c-content { padding: var(--s-4) var(--s-4) var(--s-9); }
  .c-search { display: none; }
  .c-search.is-open { display: flex; position: absolute; left: var(--s-2); right: var(--s-2); top: 8px; margin: 0; max-width: none; z-index: 2; }
  .c-search-btn { display: inline-grid; }
  .c-pill__text, .c-pill .dropdown__caret { display: none; }
  .c-brand .brand__name { display: none; }
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat.has-thread .chat__list { display: none; }
  .chat:not(.has-thread) .chat__thread { display: none; }
  .chat__back { display: inline-grid; }
  .f-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .launcher { position: fixed; top: var(--topbar-h); left: 0; right: 0; width: auto; border-radius: 0; max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
  .launcher__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kv--cols-3, .kv--cols-4 { --kv-cols: 2; }
  .kv--rows .kv__item { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .filterbar { padding: var(--s-3) var(--s-4); }
  .filterbar__search { max-width: none; flex-basis: 100%; }
  .filterbar__meta { margin-left: 0; width: 100%; justify-content: space-between; }
  .table th, .table td { padding-left: var(--s-3); padding-right: var(--s-3); }
  .panel__head, .panel__body, .panel__foot { padding-left: var(--s-4); padding-right: var(--s-4); }
  .page-head { align-items: flex-start; }
  .page-head__title { font-size: var(--fs-20); }
  .stat__value { font-size: var(--fs-24); }
  .stat { padding: var(--s-3) var(--s-4); }
  .f-top { padding: 0 var(--s-4); }
  .f-main { padding-top: var(--s-6); }
  .f-card { padding: var(--s-5); border-radius: var(--r); }
  .form-section { padding: var(--s-4); }
  .modal__body { padding: var(--s-4); }
  .msg { max-width: 88%; }
  .daterange__body { width: min(320px, calc(100vw - 32px)); }
  .stepper--h .step__desc { display: none; }
}
@media (max-width: 420px) {
  .kv--cols-2, .kv--cols-3, .kv--cols-4 { --kv-cols: 1; }
  .stats { --stats-cols: 1 !important; }
  .stats > .stat { border-left: 0 !important; }
  .stats > .stat:nth-child(n+2) { border-top: 1px solid var(--line); }
  .launcher__grid { grid-template-columns: minmax(0, 1fr); }
}

/* Django RadioSelect / CheckboxSelectMultiple rendered by field.html (bf=...) */
.field__control > div[id] { display: flex; flex-direction: column; gap: var(--s-2); }
.field__control > div[id] label { display: inline-flex; align-items: flex-start; gap: var(--s-2); font-weight: var(--fw-regular); cursor: pointer; }
.field__control > div[id] input[type="radio"], .field__control > div[id] input[type="checkbox"] { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--link); flex: none; }

/* ============================================================ WP-1.6 additions */
.conv__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; align-self: center; margin-left: auto; margin-right: var(--s-2); }
.conv__top { align-items: center; }
.alist--links .alist__link { padding: var(--s-3) var(--s-2); }
.alist--links .alist__link:hover { background: var(--surface-2); }
.alist--links .alist__text { font-weight: var(--fw-semibold); }

.range { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.range__label { font-size: var(--fs-14); font-weight: var(--fw-semibold); }
.range__row { display: flex; align-items: center; gap: var(--s-3); }
.range__input { flex: 1; min-width: 0; height: 24px; margin: 0; accent-color: var(--link); cursor: pointer; }
.range__input:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.range__input:disabled { cursor: not-allowed; opacity: .5; }
.range__out { min-width: 4.5ch; text-align: right; font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--ink); }

.err-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--s-9) var(--s-4); }
.err { max-width: 520px; width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.err__icon { color: var(--muted); }
.err__code { font-size: var(--fs-12); font-weight: var(--fw-semibold); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.err__title { font-size: var(--fs-24); font-weight: var(--fw-bold); letter-spacing: var(--track-tight); margin: 0; }
.err__text { color: var(--muted); margin: 0; }
.err__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); margin-top: var(--s-3); }

/* Keep line breaks in user-supplied copy (swipe kits, captions). */
.pre-line { white-space: pre-line; }
.input-group--pw .pw-toggle { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); padding: 0 var(--s-3); cursor: pointer; border-radius: 0 var(--r) var(--r) 0; }
.input-group--pw .pw-toggle:hover { color: var(--ink); }
.input-group--pw .pw-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.input-group .pw-toggle .pw-off, .input-group .pw-toggle[aria-pressed="true"] .pw-on { display: none; }
.input-group .pw-toggle[aria-pressed="true"] .pw-off { display: inline-block; }

/* ============================================================ WP-9D: FAB, cookie bar, meter, upgrade prompt,
   language toggle, OTP input. --cookiebar-h is set on <html> by ui.js while a cookie bar is visible. */

/* Floating action button */
.fab { position: fixed; right: calc(var(--fab-gap) + env(safe-area-inset-right, 0px)); bottom: calc(var(--fab-gap) + env(safe-area-inset-bottom, 0px) + var(--cookiebar-h, 0px)); z-index: var(--z-fab); display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-width: var(--fab-size); height: var(--fab-size); padding: 0 var(--s-5) 0 var(--s-4); border: 1px solid var(--fab-ring); border-radius: var(--r-pill); background: var(--brand-btn); color: var(--brand-btn-ink); font: inherit; font-size: var(--fs-16); font-weight: var(--fw-semibold); line-height: 1; text-decoration: none; cursor: pointer; box-shadow: var(--shadow-pop); transition: background-color var(--t) var(--ease), bottom var(--t-slow) var(--ease); }
.fab:hover { background: var(--brand-btn-hover); color: var(--brand-btn-ink); text-decoration: none; }
.fab:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 3px; border-radius: var(--r-pill); }
.fab--icon { width: var(--fab-size); padding: 0; }
.fab--left { right: auto; left: calc(var(--fab-gap) + env(safe-area-inset-left, 0px)); }
.fab--success { background: var(--fab-success); color: var(--fab-success-ink); }
.fab--success:hover { background: var(--fab-success-hover); color: var(--fab-success-ink); }
.fab__icon { flex: none; }
.fab__label { white-space: nowrap; }
html.is-locked .fab { visibility: hidden; }
body:has(.fab) .toasts { bottom: calc(var(--fab-gap) + var(--fab-size) + var(--s-3) + env(safe-area-inset-bottom, 0px) + var(--cookiebar-h, 0px)); }
@media (max-width: 640px) {
  .fab { min-width: var(--fab-size-sm); height: var(--fab-size-sm); }
  .fab:not(.fab--keep) { width: var(--fab-size-sm); padding: 0; }
  .fab:not(.fab--keep) .fab__label { display: none; }
}

/* Cookie bar: floating card on desktop, edge-to-edge sheet on phones */
.cookiebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-cookie); padding: 0 var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom, 0px)); pointer-events: none; }
.cookiebar[hidden] { display: none; }
.cookiebar__in { pointer-events: auto; max-width: var(--cookie-max); margin: 0 auto; display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-5); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); animation: ui-rise var(--t-slow) var(--ease); }
.cookiebar__icon { flex: none; color: var(--link); }
.cookiebar__body { flex: 1; min-width: 0; font-size: var(--fs-14); }
.cookiebar__title { margin: 0 0 2px; font-weight: var(--fw-semibold); }
.cookiebar__text { margin: 0; color: var(--ink-2); }
.cookiebar__actions { display: flex; gap: var(--s-2); flex: none; margin: 0; }
body { padding-bottom: var(--cookiebar-h, 0px); }
@media (max-width: 640px) {
  .cookiebar { padding: 0; }
  .cookiebar__in { flex-wrap: wrap; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .cookiebar__icon { display: none; }
  .cookiebar__body { flex-basis: 100%; font-size: var(--fs-12); }
  .cookiebar__actions { width: 100%; }
  .cookiebar__actions .btn { flex: 1; justify-content: center; }
}
@media print { .fab, .cookiebar { display: none; } }

/* Usage meter */
.meter { --mf: var(--data-1); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.meter--near { --mf: var(--warning); }
.meter--over { --mf: var(--error); }
.meter__top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-1) var(--s-3); font-size: var(--fs-14); }
.meter__label { font-weight: var(--fw-semibold); color: var(--ink); }
.meter__value { color: var(--ink); white-space: nowrap; }
.meter__value strong { font-weight: var(--fw-semibold); }
.meter__of { color: var(--muted); }
.meter__track { height: var(--meter-h); border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter__fill { height: 100%; border-radius: inherit; background: var(--mf); transition: width var(--t-slow) var(--ease); }
.meter__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); font-size: var(--fs-12); color: var(--muted); }
.meter__state { display: inline-flex; align-items: center; gap: var(--s-1); font-weight: var(--fw-semibold); color: var(--mf); }
.meter__action { display: inline-flex; align-items: center; gap: var(--s-1); margin-left: auto; font-weight: var(--fw-semibold); color: var(--link); }
.meter--sm { gap: var(--s-1); }
.meter--sm .meter__top { font-size: var(--fs-12); }
.meter--sm .meter__track { height: 6px; }

/* Upgrade prompt: card (inline) and banner (one line) */
.upsell { --us-accent: var(--accent, var(--brand-ink)); --us-soft: var(--accent-soft, var(--brand-soft)); }
.upsell--card { display: flex; gap: var(--s-4); padding: var(--s-5); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card, none); }
.upsell__icon { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r); background: var(--us-soft); color: var(--us-accent); }
.upsell__icon--lg { width: 40px; height: 40px; }
.upsell__main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.upsell__plan { display: inline-flex; align-items: center; height: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--us-soft); color: var(--us-accent); font-size: var(--fs-12); font-weight: var(--fw-semibold); }
.upsell__title { margin: 0; font-size: var(--fs-18); font-weight: var(--fw-semibold); line-height: var(--lh-snug); color: var(--ink); }
.upsell__body { margin: 0; max-width: 64ch; font-size: var(--fs-14); color: var(--ink-2); }
.upsell__meter { width: 100%; max-width: 420px; }
.upsell__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-2); }
.upsell--banner { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3); background: var(--us-soft); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-14); }
.upsell--banner .upsell__icon { background: var(--surface); }
.upsell--banner .upsell__line { flex: 1; min-width: 0; margin: 0; }
.upsell--banner .upsell__title { display: inline; font-size: inherit; }
.upsell--banner .upsell__body { font-size: inherit; }
.upsell--banner .upsell__actions { flex: none; margin: 0; }
.upsell.is-gone { opacity: 0; transition: opacity var(--t) var(--ease); }
@media (max-width: 640px) {
  .upsell--card { flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
  .upsell--banner { flex-wrap: wrap; }
  .upsell--banner .upsell__line { flex-basis: calc(100% - 44px); }
}

/* Language toggle (EN / Hindi) */
.langtog { display: inline-flex; margin: 0; }
.langtog__group { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface); }
.langtog__btn { min-width: 40px; height: 28px; padding: 0 var(--s-2); border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-2); font: inherit; font-size: var(--fs-12); font-weight: var(--fw-semibold); line-height: 1; cursor: pointer; transition: background-color var(--t) var(--ease), color var(--t) var(--ease); }
.langtog__btn:hover { background: var(--surface-3); color: var(--ink); }
.langtog__btn[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.langtog__btn:focus-visible { border-radius: var(--r-pill); }
.langtog--lg .langtog__btn { min-width: 64px; height: 40px; padding: 0 var(--s-4); font-size: var(--fs-14); }

/* One-time code input: one field, large spaced digits sized to --otp-len */
.otp { display: block; width: calc(var(--otp-len, 6) * (1ch + var(--otp-track)) + var(--otp-track) + 2 * var(--s-4) + 2px); max-width: 100%; height: 56px; padding: 0 var(--s-4) 0 calc(var(--s-4) + var(--otp-track)); background: var(--surface); color: var(--ink); border: 1px solid var(--line-input); border-radius: var(--r); font-family: var(--mono); font-size: var(--otp-size); font-weight: var(--fw-semibold); letter-spacing: var(--otp-track); font-variant-numeric: tabular-nums; transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.otp:hover { border-color: var(--ink-2); }
.otp:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.otp.is-invalid, .otp[aria-invalid="true"] { border-color: var(--error); }
.otp.is-invalid:focus { box-shadow: 0 0 0 1px var(--error); }
.otp:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.otp::placeholder { color: var(--muted); letter-spacing: var(--otp-track); }
.fab--inline { position: static; }
.cookiebar--inline { position: static; padding: 0; z-index: auto; }
.cookiebar--inline .cookiebar__in { animation: none; }

/* Focus shell top bar on phones (WP-9D): the right slot shrinks (a segmented control scrolls) instead of widening the page. */
.f-top > :first-child { flex: none; }
.f-top__right { min-width: 0; justify-content: flex-end; }

/* ============================================================ WP-10F: install prompt, push toggle (PWA) */
.install { --in-accent: var(--accent, var(--brand-ink)); --in-soft: var(--accent-soft, var(--brand-soft)); position: relative; display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-9) var(--s-4) var(--s-4); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card, none); }
.install[hidden], .install__variant[hidden] { display: none; }
.install__icon { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r); background: var(--in-soft); color: var(--in-accent); }
.install__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.install__title { margin: 0; font-size: var(--fs-16); font-weight: var(--fw-semibold); color: var(--ink); }
.install__body { margin: 0; font-size: var(--fs-14); color: var(--ink-2); }
.install__steps { margin: 0; padding-left: var(--s-5); display: grid; gap: var(--s-1); font-size: var(--fs-14); color: var(--ink-2); }
.install__glyph { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-semibold); color: var(--ink); vertical-align: -3px; }
.install__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-1); }
.install__x { position: absolute; top: var(--s-2); right: var(--s-2); }
.install--floating { position: fixed; z-index: var(--z-install); left: calc(var(--s-4) + env(safe-area-inset-left, 0px)); right: calc(var(--s-4) + env(safe-area-inset-right, 0px)); bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px) + var(--cookiebar-h, 0px)); max-width: 440px; margin-left: auto; box-shadow: var(--shadow-pop); }
@media (prefers-reduced-motion: no-preference) { .install--floating { animation: install-in var(--t-slow) var(--ease); } }
@keyframes install-in { from { transform: translateY(var(--s-3)); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) {
  .install--floating { left: 0; right: 0; bottom: var(--cookiebar-h, 0px); max-width: none; padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .install__actions .btn { min-height: var(--touch-min); }
}
@media print { .install--floating { display: none; } }

.push-toggle { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.push-toggle__icon { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); background: var(--surface-3); color: var(--ink-2); }
.push-toggle[data-push-status="on"] .push-toggle__icon { background: var(--success-bg); color: var(--success); }
.push-toggle[data-push-status="blocked"] .push-toggle__icon, .push-toggle[data-push-status="error"] .push-toggle__icon { background: var(--warning-bg); color: var(--warning); }
.push-toggle__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.push-toggle__label { margin: 0; font-weight: var(--fw-semibold); color: var(--ink); }
.push-toggle__desc { margin: 0; font-size: var(--fs-14); color: var(--muted); }
.push-toggle__state { margin: var(--s-1) 0 0; font-size: var(--fs-14); color: var(--ink-2); }
.push-toggle[data-push-status="on"] .push-toggle__state { color: var(--success); }
.push-toggle[data-push-status="blocked"] .push-toggle__state, .push-toggle[data-push-status="error"] .push-toggle__state { color: var(--warning); }
.push-toggle__btn { flex: none; align-self: center; }
@media (max-width: 480px) {
  .push-toggle { flex-wrap: wrap; }
  .push-toggle__btn { width: 100%; min-height: var(--touch-min); }
}

/* WP-10L: agency logo in the brand lock-up (whitelabel). */
.brand__logo { display: block; height: 28px; width: auto; max-width: 160px; object-fit: contain; }
