/* PPL Track console — single stylesheet, no external assets. */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-50: #EEF2FF;
  --primary-100: #E0E7FF;
  --sidebar: #111827;
  --sidebar-2: #1F2937;
  --sidebar-text: #E5E7EB;
  --sidebar-muted: #9CA3AF;
  --bg: #F7F8FB;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #111827;
  --text-2: #374151;
  --muted: #6B7280;
  --productive: #16A34A;
  --neutral: #94A3B8;
  --unproductive: #DC2626;
  --idle: #F59E0B;
  --break: #3B82F6;
  --offline: #9CA3AF;
  --clocked-out: #D1D5DB;
  --untracked: #E2E8F0;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --ring: 0 0 0 3px rgba(79, 70, 229, .28);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 10px; }
code, kbd, pre, .mono { font-family: var(--mono); }
code { font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-100); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.noscript { padding: 24px; margin: 24px; background: #FEF3C7; border: 1px solid #FCD34D; border-radius: 12px; color: #78350F; font-size: 15px; }

/* ───────────── App shell ───────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 40; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: none; display: block; }
.brand-name { font-size: 17px; font-weight: 750; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: 11px; font-weight: 500; color: var(--sidebar-muted); letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 12px; }
.nav-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #6B7280; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text);
  font-weight: 500; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a:hover { background: var(--sidebar-2); text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(79, 70, 229, .22); color: #fff; box-shadow: inset 2px 0 0 #818CF8; }
.nav a[aria-current="page"] svg { opacity: 1; color: #A5B4FC; }
.sidebar-foot { margin-top: auto; padding: 14px 20px 18px; border-top: 1px solid #1F2937; font-size: 12px; color: var(--sidebar-muted); }
.sidebar-foot .mode-line { display: flex; align-items: center; gap: 8px; color: var(--sidebar-text); font-weight: 500; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 35; }

.main-col { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(6px); border-bottom: 1px solid var(--border);
}
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 750; font-size: 16px; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand .brand-mark { width: 26px; height: 26px; }
.topbar-tz { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-spacer { flex: 1; }
.menu-btn { display: none; }
.mode-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text-2); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; max-width: 100%;
}
.mode-pill:hover { border-color: var(--border-strong); background: #F9FAFB; }
.mode-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.mode-pill.connected .dot { background: var(--productive); }
.mode-pill.error .dot { background: var(--danger); }
.mode-pill .label-host { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 1; outline: none; min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 24px 28px 48px; }
.page-wide { max-width: none; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header .sub { color: var(--muted); margin: 4px 0 0; max-width: 760px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } * { scroll-behavior: auto !important; } }

/* ───────────── Cards & layout utilities ───────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-pad, .card > .card-body { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2, .card-header h3 { font-size: 15px; }
.card-header .sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: #FAFAFB; border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.split-wide { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.row-nowrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tabular, .num { font-variant-numeric: tabular-nums; }
.break-all { word-break: break-all; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; user-select: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #F9FAFB; border-color: #9CA3AF; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: #F3F4F6; }
.btn-danger { background: #fff; color: var(--danger); border-color: #FCA5A5; }
.btn-danger:hover:not(:disabled) { background: #FEF2F2; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #B91C1C; }
.btn-success { background: var(--productive); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803D; }
.btn-break { background: var(--break); color: #fff; }
.btn-break:hover:not(:disabled) { background: #2563EB; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: #F3F4F6; }
.icon-btn svg { width: 20px; height: 20px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* ───────────── Forms ───────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .hint, .hint { font-size: 12px; color: var(--muted); }
.field.highlight { background: var(--primary-50); border: 1px solid var(--primary-100); border-radius: 10px; padding: 12px; }
.input, .select, .textarea, input[type="text"].input, input[type="search"] {
  width: 100%; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff;
  font: inherit; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input:disabled, .select:disabled { background: #F3F4F6; color: var(--muted); }
.input-sm { height: 32px; font-size: 13px; }
.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: #F9FAFB; color: var(--muted); font-size: 13px; white-space: nowrap; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); align-items: start; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.form-section { padding: 20px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { margin-bottom: 4px; }
.form-section > .hint { margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 38px; height: 22px; background: #D1D5DB; border-radius: 999px; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch input:disabled + .track { opacity: .5; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; max-width: 100%; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 0 12px; height: 34px; font: inherit; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--primary-50); color: var(--primary-hover); }
.segmented button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }

/* ───────────── Chips, badges ───────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; line-height: 1;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip-working { background: #DCFCE7; color: #166534; }
.chip-working::before { background: var(--productive); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.chip-idle { background: #FEF3C7; color: #92400E; }
.chip-idle::before { background: var(--idle); }
.chip-on_break { background: #DBEAFE; color: #1E40AF; }
.chip-on_break::before { background: var(--break); }
.chip-offline { background: #F3F4F6; color: #4B5563; }
.chip-offline::before { background: var(--offline); }
.chip-clocked_out { background: #F9FAFB; color: #6B7280; border-color: var(--border); }
.chip-clocked_out::before { background: var(--clocked-out); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #F3F4F6; color: var(--text-2); white-space: nowrap; }
.badge-primary { background: var(--primary-50); color: var(--primary-hover); }
.badge-success { background: #DCFCE7; color: #166534; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.label-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.label-dot::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--neutral); flex: none; }
.label-dot.productive::before { background: var(--productive); }
.label-dot.unproductive::before { background: var(--unproductive); }
.label-dot.neutral::before { background: var(--neutral); }
.prod-text-productive { color: #15803D; }
.prod-text-unproductive { color: #B91C1C; }
.prod-text-neutral { color: #475569; }
.method { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; height: 22px; padding: 0 6px; border-radius: 6px; font: 700 11px/1 var(--mono); letter-spacing: .02em; text-transform: uppercase; flex: none; }
.method-get { background: #DCFCE7; color: #166534; }
.method-post { background: #E0E7FF; color: #3730A3; }
.method-put { background: #FEF3C7; color: #92400E; }
.method-patch { background: #CCFBF1; color: #115E59; }
.method-delete { background: #FEE2E2; color: #991B1B; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #fff; flex: none; background: var(--primary); }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .meta { min-width: 0; }
.person .name { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .name:hover { text-decoration: underline; }
.person .sub { font-size: 12px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────────── Tables ───────────── */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #FAFAFB; white-space: nowrap; position: relative; }
.table td { padding: 11px 14px; border-bottom: 1px solid #F0F1F4; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFAFF; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.table th.sortable button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.table th[aria-sort="ascending"] button::after { content: "▲"; font-size: 9px; }
.table th[aria-sort="descending"] button::after { content: "▼"; font-size: 9px; }
.table tfoot td { font-weight: 700; background: #FAFAFB; border-top: 1px solid var(--border); }
.table-compact td, .table-compact th { padding: 7px 10px; }
.table .cell-title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: #C7CBD4; margin-bottom: 8px; }
.empty h3 { color: var(--text-2); margin-bottom: 4px; }

/* ───────────── Stats, bars, charts ───────────── */
.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.bar { position: relative; height: 8px; background: #EEF0F4; border-radius: 999px; overflow: hidden; min-width: 40px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: 999px; }
.bar.productive > span { background: var(--productive); }
.bar.neutral > span { background: var(--neutral); }
.bar.unproductive > span { background: var(--unproductive); }
.stackbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #EEF0F4; min-width: 60px; }
.stackbar > span { height: 100%; flex: none; }
.seg-productive { background: var(--productive); }
.seg-neutral { background: var(--neutral); }
.seg-unproductive { background: var(--unproductive); }
.seg-untracked { background: #CBD5E1; }
.seg-idle { background: var(--idle); }
.seg-break { background: var(--break); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }

/* Timeline (employee day) */
.timeline { position: relative; }
.tl-track { position: relative; height: 46px; background: #F3F4F6; border-radius: 8px; overflow: hidden; }
.tl-lane { position: absolute; left: 0; right: 0; }
.tl-lane.shift { top: 0; height: 6px; }
.tl-lane.acts { top: 10px; bottom: 0; }
.tl-seg { position: absolute; top: 0; bottom: 0; min-width: 1px; }
.tl-seg.shift { background: #A5B4FC; border-radius: 3px; }
.tl-seg.break { background: var(--break); opacity: .85; }
.tl-seg.idle { background: repeating-linear-gradient(135deg, #F59E0B 0 4px, #FCD34D 4px 8px); }
.tl-seg.productive { background: var(--productive); }
.tl-seg.neutral { background: var(--neutral); }
.tl-seg.unproductive { background: var(--unproductive); }
.tl-seg.now { background: transparent; border-left: 2px dashed var(--primary); }
.tl-axis { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.tl-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ───────────── Live feed ───────────── */
.feed { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.feed li { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #F0F1F4; animation: feed-in .35s ease-out; }
.feed li:last-child { border-bottom: 0; }
.feed .ico { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: #F3F4F6; color: var(--text-2); }
.feed .ico svg { width: 15px; height: 15px; }
.feed .ico.green { background: #DCFCE7; color: #166534; }
.feed .ico.amber { background: #FEF3C7; color: #92400E; }
.feed .ico.blue { background: #DBEAFE; color: #1E40AF; }
.feed .ico.grey { background: #F3F4F6; color: #4B5563; }
.feed .ico.red { background: #FEE2E2; color: #991B1B; }
.feed .ico.indigo { background: var(--primary-50); color: var(--primary-hover); }
.feed .txt { min-width: 0; flex: 1; font-size: 13px; }
.feed .txt b { font-weight: 650; }
.feed .txt .detail { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .when { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed .type { font-family: var(--mono); font-size: 10.5px; color: #9CA3AF; }
@keyframes feed-in { from { background: var(--primary-50); } to { background: transparent; } }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--productive); display: inline-block; box-shadow: 0 0 0 0 rgba(22,163,74,.5); animation: pulse 2s infinite; }
.pulse-dot.off { background: var(--offline); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.45); } 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
.current-app { display: flex; align-items: center; gap: 8px; min-width: 0; }
.current-app .app-ico { width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; }
.current-app .what { min-width: 0; }
.current-app .what b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.current-app .what span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.prod-bar { display: inline-block; width: 4px; align-self: stretch; border-radius: 2px; background: var(--neutral); flex: none; }
.prod-bar.productive { background: var(--productive); }
.prod-bar.unproductive { background: var(--unproductive); }

/* ───────────── Tabs ───────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: thin; }
.tab { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); border-radius: 6px 6px 0 0; }

/* ───────────── Alerts & banners ───────────── */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; border: 1px solid; font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-info { background: #EFF6FF; border-color: #BFDBFE; color: #1E3A8A; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #78350F; }
.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #14532D; }
.alert-danger { background: #FEF2F2; border-color: #FECACA; color: #7F1D1D; }
.alert .grow { flex: 1; min-width: 0; }
.alert b { font-weight: 650; }
.mode-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid #C7D2FE; background: linear-gradient(90deg, #EEF2FF, #F5F3FF); flex-wrap: wrap; }
.mode-banner.connected { border-color: #BBF7D0; background: linear-gradient(90deg, #F0FDF4, #ECFEFF); }
.mode-banner .grow { flex: 1; min-width: 220px; }
.secret-box { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #0B1020; color: #E5E7EB; border-radius: 10px; font-family: var(--mono); font-size: 13px; word-break: break-all; }
.secret-box .grow { flex: 1; min-width: 0; }
.big-code { font: 800 44px/1.1 var(--mono); letter-spacing: .08em; color: var(--text); text-align: center; padding: 18px 12px; background: var(--primary-50); border: 2px dashed #A5B4FC; border-radius: 14px; word-break: break-all; }

/* ───────────── Dialogs & toasts ───────────── */
dialog.dialog { border: 0; padding: 0; border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--text); background: #fff; }
dialog.dialog::backdrop { background: rgba(17, 24, 39, .5); }
dialog.dialog[open] { display: flex; flex-direction: column; animation: dialog-in .16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.dialog-head h2 { font-size: 17px; }
.dialog-body { padding: 4px 20px 16px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: #FAFAFB; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: #111827; color: #F9FAFB; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: dialog-in .2s ease-out; }
.toast .grow { flex: 1; min-width: 0; word-wrap: break-word; }
.toast b { display: block; font-weight: 650; }
.toast .x { background: none; border: 0; color: #9CA3AF; cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.toast-error { background: #7F1D1D; }
.toast-success { background: #14532D; }
.toast-warning { background: #78350F; }

/* ───────────── Code ───────────── */
pre.code, .md pre { position: relative; margin: 0 0 14px; padding: 14px 16px; background: #0B1020; color: #E5E7EB; border-radius: 10px; overflow-x: auto; font: 12.5px/1.55 var(--mono); tab-size: 2; }
pre.code code, .md pre code { background: none; padding: 0; color: inherit; font-size: inherit; white-space: pre; }
.code-wrap { position: relative; }
.copy-btn { position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 8px; border-radius: 6px; border: 1px solid #374151; background: #1F2937; color: #D1D5DB; font: 600 11px var(--font); cursor: pointer; opacity: .85; }
.copy-btn:hover { opacity: 1; background: #374151; }
.json-key { color: #A5B4FC; } .json-str { color: #86EFAC; } .json-num { color: #FCD34D; } .json-lit { color: #F9A8D4; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ───────────── Markdown ───────────── */
.md { font-size: 14.5px; line-height: 1.65; color: var(--text-2); max-width: 860px; overflow-wrap: break-word; }
.md h1 { font-size: 28px; margin: 0 0 16px; color: var(--text); }
.md h2 { font-size: 21px; margin: 32px 0 12px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text); }
.md h3 { font-size: 17px; margin: 24px 0 8px; color: var(--text); }
.md h4 { font-size: 15px; margin: 18px 0 6px; color: var(--text); }
.md .anchor { margin-left: 6px; color: #C7CBD4; font-weight: 500; opacity: 0; text-decoration: none; }
.md h1:hover .anchor, .md h2:hover .anchor, .md h3:hover .anchor, .md h4:hover .anchor, .md .anchor:focus { opacity: 1; }
.md p { margin: 0 0 14px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 24px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md code { background: #F1F2F6; padding: 1px 5px; border-radius: 5px; font-size: .88em; color: #1F2937; }
.md blockquote { margin: 0 0 14px; padding: 8px 16px; border-left: 3px solid #A5B4FC; background: #F8F9FF; color: var(--text-2); border-radius: 0 8px 8px 0; }
.md blockquote p:last-child { margin-bottom: 0; }
.md table { border-collapse: collapse; margin: 0 0 16px; font-size: 13.5px; width: 100%; }
.md .table-wrap { margin-bottom: 16px; }
.md .table-wrap table { margin: 0; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.md th { background: #F9FAFB; font-weight: 650; color: var(--text); }
.md hr { margin: 24px 0; }
.md img { border-radius: 8px; }

/* ───────────── Overview ───────────── */
.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: center; padding: 36px 40px; border-radius: 18px; background: radial-gradient(1200px 400px at 0% 0%, #EEF2FF 0%, transparent 60%), linear-gradient(135deg, #FFFFFF 0%, #F5F3FF 100%); border: 1px solid #E0E7FF; box-shadow: var(--shadow); }
.hero h1 { font-size: 36px; line-height: 1.12; letter-spacing: -.02em; }
.hero h1 .accent { color: var(--primary); }
.hero .lead { font-size: 16px; color: var(--text-2); margin: 14px 0 22px; max-width: 560px; }
.hero .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--primary-hover); background: #fff; border: 1px solid var(--primary-100); padding: 4px 10px; border-radius: 999px; margin-bottom: 14px; }
.hero-illustration { width: 100%; height: auto; display: block; filter: drop-shadow(0 18px 30px rgba(79, 70, 229, .16)); }
.feature { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.feature .f-ico { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); }
.feature .f-ico svg { width: 22px; height: 22px; }
.feature h3 { font-size: 15px; }
.feature p { color: var(--muted); margin: 0; font-size: 13.5px; }
.part { padding: 20px; display: flex; gap: 14px; align-items: flex-start; }
.part .num-badge { width: 32px; height: 32px; border-radius: 50%; background: var(--sidebar); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 12px; }
.steps > li { counter-increment: step; position: relative; padding: 14px 16px 14px 56px; border: 1px solid var(--border); border-radius: 12px; background: #fff; min-width: 0; }
.steps > li::before { content: counter(step); position: absolute; left: 16px; top: 14px; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.steps h3 { font-size: 14px; margin-bottom: 4px; }
.steps p { margin: 0; color: var(--muted); font-size: 13px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 32px 0 14px; flex-wrap: wrap; }
.section-title h2 { font-size: 19px; }
.section-title p { margin: 0; color: var(--muted); }

/* ───────────── Agent window replica ───────────── */
.agent-stage { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 24px; align-items: start; }
.agent-window { width: 100%; max-width: 380px; background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); border: 1px solid #D1D5DB; overflow: hidden; font-family: "Segoe UI", var(--font); }
.agent-titlebar { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 0 0 12px; background: #F3F4F6; border-bottom: 1px solid #E5E7EB; font-size: 12px; color: #374151; user-select: none; }
.agent-titlebar .brand-mark { width: 16px; height: 16px; }
.agent-titlebar .ctl { margin-left: auto; display: flex; }
.agent-titlebar .ctl span { width: 40px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: #6B7280; font-size: 13px; }
.agent-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.agent-head { display: flex; align-items: center; gap: 12px; }
.agent-head .who { min-width: 0; flex: 1; }
.agent-head .who b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-head .who span { font-size: 12px; color: var(--muted); }
.agent-status { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.agent-timer-wrap { text-align: center; padding: 6px 0 2px; }
.agent-timer { font: 700 46px/1 "Segoe UI", var(--font); font-variant-numeric: tabular-nums; letter-spacing: .01em; color: var(--text); }
.agent-timer-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.agent-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); padding: 10px 12px; background: #F9FAFB; border-radius: 8px; border: 1px solid #F0F1F4; }
.agent-activity { display: flex; align-items: center; gap: 10px; font-size: 13px; min-height: 40px; padding: 8px 12px; border-radius: 8px; border: 1px dashed var(--border-strong); color: var(--text-2); }
.agent-activity .grow { flex: 1; min-width: 0; }
.agent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.agent-actions .btn { height: 42px; font-size: 14px; }
.agent-actions .full { grid-column: 1 / -1; }
.agent-notice { padding: 12px 14px; border-radius: 8px; background: #FFFBEB; border: 1px solid #FDE68A; color: #78350F; font-size: 13px; }
.agent-confirm { padding: 14px; border-radius: 8px; background: #F9FAFB; border: 1px solid var(--border); }
.agent-confirm p { font-weight: 600; margin-bottom: 10px; }
.agent-foot { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid #F0F1F4; padding-top: 10px; }
.app-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.app-pick button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; font: inherit; font-size: 13px; text-align: left; cursor: pointer; min-width: 0; }
.app-pick button:hover { border-color: #A5B4FC; }
.app-pick button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-50); box-shadow: inset 0 0 0 1px var(--primary); }
.app-pick .app-ico { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; }
.app-pick .t { min-width: 0; }
.app-pick .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-pick .t span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-log { list-style: none; margin: 0; padding: 0; font: 12px/1.5 var(--mono); max-height: 260px; overflow-y: auto; }
.req-log li { display: flex; gap: 8px; padding: 4px 16px; border-bottom: 1px solid #F3F4F6; align-items: baseline; }
.req-log .st { font-weight: 700; min-width: 30px; }
.req-log .st.ok { color: var(--productive); } .req-log .st.err { color: var(--danger); } .req-log .st.pend { color: var(--muted); }
.req-log .p { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-log .t { color: var(--muted); }

/* ───────────── API reference ───────────── */
.ref-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.ref-side { position: sticky; top: 72px; max-height: calc(100vh - 88px); display: flex; flex-direction: column; overflow: hidden; }
.ref-side .ref-search { padding: 12px; border-bottom: 1px solid var(--border); }
.ref-list { overflow-y: auto; padding: 6px 6px 12px; flex: 1; }
.ref-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 10px 4px; }
.ref-op { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 13px; min-width: 0; }
.ref-op:hover { background: #F3F4F6; text-decoration: none; }
.ref-op[aria-current="true"] { background: var(--primary-50); color: var(--primary-hover); }
.ref-op .method { min-width: 46px; height: 18px; font-size: 10px; }
.ref-op .p { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.op-path { font: 600 16px var(--mono); word-break: break-all; }
.schema { font-size: 13px; }
.schema details > summary { cursor: pointer; list-style: none; }
.schema details > summary::-webkit-details-marker { display: none; }
.schema .prop { padding: 7px 0 7px 0; border-top: 1px solid #F0F1F4; }
.schema .prop:first-child { border-top: 0; }
.schema .prop-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.schema .pname { font: 600 13px var(--mono); color: var(--text); }
.schema .ptype { font: 12px var(--mono); color: #7C3AED; }
.schema .preq { font-size: 11px; font-weight: 700; color: var(--danger); }
.schema .pdesc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.schema .pdesc p { margin: 0 0 4px; }
.schema .enum { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.schema .enum code { background: #F3F4F6; padding: 0 5px; border-radius: 4px; font-size: 11.5px; }
.schema .children { margin: 6px 0 0 6px; padding-left: 12px; border-left: 2px solid #EEF0F4; }
.schema .toggle { font-size: 12px; color: var(--primary); font-weight: 600; }
.try-panel { border: 1px solid var(--border); border-radius: 12px; background: #FAFAFB; padding: 16px; }
.resp-status { font: 700 13px var(--mono); }
.resp-status.ok { color: var(--productive); } .resp-status.err { color: var(--danger); }

/* ───────────── Checklist (test page) ───────────── */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checklist > li { display: flex; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; align-items: flex-start; }
.checklist > li.done { border-color: #BBF7D0; background: #F7FEF9; }
.checklist > li.active { border-color: #A5B4FC; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.checklist .tick { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; flex: none; font-weight: 800; color: #fff; font-size: 13px; }
.checklist li.done .tick { background: var(--productive); border-color: var(--productive); }
.checklist li.active .tick { border-color: var(--primary); color: var(--primary); }
.checklist .grow { flex: 1; min-width: 0; }
.checklist h3 { font-size: 14px; margin-bottom: 4px; }
.checklist p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.checklist .expect { font-size: 12.5px; color: var(--text-2); }
.checklist .observed { font-size: 12.5px; color: #166534; font-weight: 600; }

/* ───────────── Responsive ───────────── */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .agent-stage { grid-template-columns: minmax(0, 1fr); }
  .agent-stage .agent-window { margin: 0 auto; }
}
@media (max-width: 980px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-wide { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 28px; }
  .hero-illustration { max-width: 520px; margin: 0 auto; }
  .ref-layout { grid-template-columns: minmax(0, 1fr); }
  .ref-side { position: static; max-height: 380px; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { width: 272px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main-col { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar-brand { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .page { padding: 16px 14px 40px; }
  h1 { font-size: 21px; }
  .topbar-tz { display: none; }
  .mode-pill .label-host { max-width: 110px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 19px; }
  .card-pad, .card > .card-body, .form-section { padding: 16px; }
  .card-header { padding: 14px 16px; }
  .hero { padding: 22px 18px; border-radius: 14px; }
  .hero h1 { font-size: 27px; }
  .hero .lead { font-size: 15px; }
  .big-code { font-size: 30px; }
  .agent-timer { font-size: 40px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page-header .actions { width: 100%; }
  /* tables become cards */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table-cards tbody tr:hover td { background: transparent; }
  .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border: 0; text-align: right; min-width: 0; }
  .table-cards td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; flex: none; max-width: 45%; }
  .table-cards td[data-label=""]::before, .table-cards td:not([data-label])::before { content: none; }
  .table-cards td.cell-main { display: block; text-align: left; padding-bottom: 8px; }
  .table-cards td.cell-main::before { content: none; }
  .table-cards td > * { min-width: 0; }
  .table-cards .num { text-align: right; }
  .table-cards tfoot { display: block; }
  .table-cards tfoot tr { background: #FAFAFB; }
  .table-cards .cell-title { max-width: 60vw; }
  .current-app .what b, .current-app .what span { max-width: 52vw; }
  .tabs { margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .dialog-foot .btn { flex: 1; }
  .toasts { right: 12px; left: 12px; bottom: 12px; width: auto; }
}
@media (max-width: 380px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .sidebar, .topbar, .toasts { display: none !important; }
  .main-col { margin-left: 0; }
}

/* ───────────── API reference & guides (reference.js, guides.js) ───────────── */
.ref-list { position: relative; }
.ref-op svg { width: 16px; height: 16px; flex: none; }
.ref-detail { scroll-margin-top: 72px; min-width: 0; }
.badge svg { width: 12px; height: 12px; flex: none; }
.try-panel h3 { display: inline-flex; align-items: center; gap: 6px; }
.try-panel h3 svg { width: 16px; height: 16px; color: var(--primary); }
.try-panel .textarea { min-height: 120px; }
.schema-top { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.schema .props { border: 1px solid var(--border); border-radius: 10px; padding: 2px 12px; background: #fff; }
.schema .children .props { border: 0; padding: 0; background: transparent; }
.schema details.nested { margin-top: 4px; }
.schema details.nested > summary { display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; }
.schema details.nested > summary::before { content: "▸"; font-size: 10px; transition: transform .12s; }
.schema details.nested[open] > summary::before { transform: rotate(90deg); }
.schema details.nested[open] > summary { color: var(--muted); }
.resp-block + .resp-block { border-top: 1px solid var(--border); padding-top: 16px; }
.ref-group { display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; box-shadow: none; }
.ref-group:hover { border-color: #A5B4FC; text-decoration: none; background: #FAFAFF; }
.ref-group .method { min-width: 44px; height: 18px; font-size: 10px; }
details > summary.small { cursor: pointer; }
.guide-side { position: sticky; top: 72px; }
.guide-list { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.guide-link { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; min-width: 0; }
.guide-link:hover { background: #F3F4F6; text-decoration: none; }
.guide-link[aria-current="page"] { background: var(--primary-50); color: var(--primary-hover); }
.guide-link svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.guide-link b { display: block; font-weight: 600; }
.guide-link .small { display: block; line-height: 1.4; }
.toc { max-height: calc(100vh - 340px); overflow-y: auto; }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.toc li a { display: block; padding: 3px 0; font-size: 13px; color: var(--text-2); }
.toc li.lvl3 a { padding-left: 12px; font-size: 12.5px; color: var(--muted); }
.toc li a:hover { color: var(--primary); }
.guide-body { min-width: 0; }
.md h1, .md h2, .md h3, .md h4 { scroll-margin-top: 72px; }
.md h1:first-child, .md h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.md .code-wrap { margin-bottom: 14px; }
.md .code-wrap pre { margin: 0; }
@media (max-width: 980px) {
  .guide-side { position: static; }
  .guide-side .toc, .guide-side .guide-try { display: none !important; }
}
@media (max-width: 640px) {
  .op-path { font-size: 14px; }
  .try-panel { padding: 12px; }
  .md { font-size: 14px; }
  .md h1 { font-size: 23px; }
  .md h2 { font-size: 18px; }
}

/* ───────────── Validation states (core) ───────────── */
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }

/* ───────────── Reports & settings (reports.js, settings.js, charts.js) ───────────── */
.filter-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filter-row .field { min-width: 0; }
.filter-row .filter-team { min-width: 180px; flex: 0 1 220px; }
.report-filters #rep-period svg { width: 14px; height: 14px; vertical-align: -2px; }
#rep-body.is-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }
.stat-small .stat { padding: 12px 16px; }
.stat-small .stat-value { font-size: 18px; }
.adds-up .stackbar { height: 14px; margin: 12px 0 10px; }
.equations { margin: 0 0 8px; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.equations li { margin: 2px 0; }
.chart-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-scroll svg { display: block; margin: 0 auto; }
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bar-list li { display: grid; grid-template-columns: minmax(90px, 180px) minmax(0, 1fr) 72px; gap: 12px; align-items: center; }
.bar-list .bl-label { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list .bl-val { text-align: right; font-size: 13px; color: var(--text-2); }
.report-table .cell-bar { min-width: 140px; }
.report-table td.cell-main .person { min-width: 150px; }
.rank-list { list-style: none; margin: 0; padding: 4px 0; }
.rank-list li { display: grid; grid-template-columns: 22px 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 20px; border-bottom: 1px solid #F0F1F4; }
.rank-list li:last-child { border-bottom: 0; }
.rank-list .rank { color: var(--muted); font-size: 12px; font-weight: 700; text-align: right; }
.rank-list .app-ico, .rule-app .app-ico { width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; }
.rank-list .rk-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rank-list .rk-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank-list .rk-name b { font-weight: 600; min-width: 0; }
.rank-list .rk-name .label-dot { font-size: 11.5px; color: var(--muted); flex: none; }
.rank-list .rk-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .rk-val { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.rank-list .bar { height: 6px; }
.policy-origin { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.policy-origin .badge { height: 20px; font-size: 11px; }
.rule-filters { gap: 6px; }
.rule-filters .input, .rule-filters .select { width: auto; min-width: 0; max-width: 100%; }
.rule-filters input[type="search"] { width: 180px; }
.classify-out { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #FAFAFB; }
.override-list { display: flex; flex-wrap: wrap; gap: 4px; }
.override-list .badge { white-space: normal; height: auto; min-height: 22px; padding: 2px 8px; }
.policy-dialog .form-section { padding: 14px 0; }
.policy-dialog .form-section:first-of-type { padding-top: 4px; }
.events-pick { border: 0; padding: 0; margin: 0; min-width: 0; }
.events-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-top: 6px; }
.events-grid .check { align-items: flex-start; }
.events-grid .check input { margin-top: 3px; }
.hook-list { list-style: none; margin: 0; padding: 0; }
.hook { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.hook:last-child { border-bottom: 0; }
.hook-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.hook-head .grow { flex: 1; min-width: 0; }
.hook-url { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
.hook-url svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--muted); }
.hook-deliveries { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.audit-cell { max-width: 360px; }
.audit-details summary { font-family: var(--mono); font-size: 12px; color: var(--text-2); max-width: 340px; }
.audit-details pre.code { margin: 6px 0 0; max-height: 260px; }
@media (max-width: 640px) {
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row .filter-team { flex: 1 1 auto; }
  .bar-list li { grid-template-columns: minmax(0, 1fr) 64px; }
  .bar-list .bl-bar { grid-column: 1 / -1; grid-row: 2; }
  .rank-list li { padding: 10px 14px; grid-template-columns: 18px 28px minmax(0, 1fr) auto; gap: 8px; }
  .report-table .cell-bar { min-width: 0; }
  .report-table .cell-bar .stackbar { width: 60%; }
  .table-cards td.cell-bar::before { flex: none; }
  .rule-filters, .rule-filters input[type="search"] { width: 100%; }
  .rule-filters .select { flex: 1 1 40%; }
  .audit-cell, .audit-details summary { max-width: 60vw; }
  .hook { padding: 14px 16px; }
}

/* ───────────── Test page & agent (core) ───────────── */
.test-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
.test-layout .agent-window { max-width: none; }
@media (max-width: 1180px) { .test-layout { grid-template-columns: minmax(0, 1fr); } .test-layout .agent-window { max-width: 420px; margin: 0 auto; } }
.agent-window .alert { font-size: 12.5px; padding: 10px 12px; }
.agent-window .agent-status.chip { height: 26px; }
.page-header > div:first-child { min-width: 0; max-width: 100%; }
.page-header .sub { overflow-wrap: anywhere; }
.page-header .person .sub { white-space: normal; overflow: visible; }
