/* Tesla Vita cabinet. Tokens follow site/public/css/site.css: graphite, warm ivory text, champagne actions. */
:root {
  --bg: oklch(18% .008 75);
  --surface: oklch(22% .008 75);
  --raised: oklch(25.5% .009 75);
  --ink: oklch(94% .012 85);
  --muted: oklch(72% .014 80);
  --faint: oklch(58% .012 80);
  --gold: oklch(81% .076 77);
  --gold-soft: oklch(81% .076 77 / .14);
  --ok: oklch(78% .09 150);
  --ok-soft: oklch(78% .09 150 / .13);
  --wait: oklch(82% .07 85);
  --bad: oklch(72% .13 28);
  --bad-soft: oklch(72% .13 28 / .14);
  --blue: oklch(76% .08 235);
  --violet: oklch(74% .09 305);
  --line: oklch(94% .012 85 / .12);
  --line-strong: oklch(94% .012 85 / .2);
  --dark: oklch(25% .01 75);
  --radius: 10px;
  --side: 260px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 15px/1.6 'Onest', system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 400; letter-spacing: -.03em; text-wrap: balance; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
small { font-size: 13px; }
.muted { color: var(--muted); }
.block { display: block; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; letter-spacing: 0; word-break: break-all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.logo { display: inline-flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 500; letter-spacing: -.06em; white-space: nowrap; }

/* Avatars */
.avatar { flex: none; border-radius: 50%; object-fit: cover; background: var(--raised); box-shadow: 0 0 0 1px var(--line); }
.avatar-36 { width: 36px; height: 36px; }
.avatar-72 { width: 72px; height: 72px; }
.avatar-96 { width: 96px; height: 96px; }
.avatar-initials { display: inline-grid; place-items: center; color: var(--gold); font-weight: 500; }
.avatar-36.avatar-initials { font-size: 13px; }
.avatar-72.avatar-initials { font-size: 24px; }
.avatar-96.avatar-initials { font-size: 32px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: 6px; font-size: 14px; font-weight: 500; line-height: 1.2; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); color: var(--dark); box-shadow: inset 0 1px 0 oklch(96% .03 80 / .45); }
.btn-gold:hover { background: oklch(85% .07 78); }
.btn-line { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn-line:hover { border-color: var(--gold); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
/* Google's dark button: https://developers.google.com/identity/branding-guidelines */
.btn-google { width: 100%; min-height: 48px; background: #131314; border-color: #8e918f; color: #e3e3e3; border-radius: 24px; font-weight: 500; }
.btn-google:hover { background: #1f1f20; }

/* Pills */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; line-height: 1.4; }
.pill .i { width: 15px; height: 15px; }
.pill-ok { color: var(--ok); background: var(--ok-soft); }
.pill-gold { color: var(--gold); background: var(--gold-soft); }
.pill-bad { color: var(--bad); background: var(--bad-soft); }
.pill-wait { color: var(--wait); background: oklch(82% .07 85 / .12); }

/* Sign-in and notices: a centred card on the graphite field */
.bare { display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(60% 50% at 50% 0%, oklch(81% .076 77 / .09), transparent 70%), var(--bg); }
.gate { width: 100%; max-width: 420px; display: grid; justify-items: center; gap: 28px; }
.gate-card { width: 100%; display: grid; justify-items: center; gap: 16px; text-align: center; padding: 40px 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.gate-title { font-size: 28px; line-height: 1.2; }
.gate-text { color: var(--muted); max-width: 34ch; text-wrap: pretty; }
.gate-note { color: var(--muted); font-size: 13px; }
.gate-card .btn { margin-top: 8px; }
.gate-who { display: grid; justify-items: center; gap: 12px; }
.gate-who span { display: grid; }
.gate-who small { color: var(--muted); }
.gate-foot { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); font-size: 13px; }
.gate-foot:hover { color: var(--gold); }
.gate-foot .i { width: 16px; height: 16px; }

/* Signed-in shell: sidebar + content */
.shell { display: grid; grid-template-columns: var(--side) 1fr; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 32px; padding: 26px 16px 18px;
  background: var(--surface); border-right: 1px solid var(--line); }
.side .logo { padding: 0 10px; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.nav a:hover { color: var(--ink); background: oklch(94% .012 85 / .05); }
.nav a[aria-current] { color: var(--ink); background: var(--gold-soft); }
.nav a[aria-current] .i { color: var(--gold); }
.badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--gold); color: var(--dark); font-size: 12px; font-weight: 600; text-align: center; }
.side-foot { margin-top: auto; display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; }
.me:hover { background: oklch(94% .012 85 / .05); }
.signout { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 8px 12px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-size: 14px; text-align: left; }
.signout:hover { color: var(--ink); background: oklch(94% .012 85 / .05); }
.me span, .who span { display: grid; min-width: 0; }
.me b, .who b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small, .who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; padding: 36px clamp(16px, 4vw, 56px) 56px; }
/* Cards take as many columns as the window fits, each at least 440px */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; align-items: start; }
.board > .card .section-title:first-child { margin-top: 0; }
/* With the wide knowledge base card: account and apps stack in a narrow left column, the guide takes the rest */
.board:has(> .wide) { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1500px) {
  .board:has(> .wide) { grid-template-columns: minmax(360px, 1fr) minmax(0, 2fr); grid-template-rows: auto 1fr; }
  .board:has(> .wide) > .wide { grid-column: 2; grid-row: 1 / span 2; }
}
.top { margin-bottom: 28px; }
.top h1 { font-size: clamp(28px, 3vw, 36px); font-weight: 300; letter-spacing: -.045em; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }

/* Profile */
.profile { padding: clamp(20px, 3vw, 32px); }
.profile-head { display: flex; align-items: center; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.profile-name { font-size: 26px; line-height: 1.2; }
.section-title { margin: 28px 0 14px; font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.section-title small { margin-left: 8px; color: var(--faint); font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts div { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.facts div:nth-last-child(-n+2):nth-child(odd), .facts div:last-child { border-bottom: 0; }
.facts div:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.facts dt { color: var(--faint); font-size: 12.5px; }
.facts dd { margin-top: 2px; overflow-wrap: anywhere; }

/* Knowledge base */
.cmd { display: block; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; letter-spacing: 0; overflow-wrap: anywhere; user-select: all; }
.apps { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius); }
.apps li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.apps li:last-child { border-bottom: 0; }
.apps b { font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { min-height: 32px; padding: 4px 12px; border: 0; border-right: 1px solid var(--line); background: none; color: var(--muted); font-size: 13px; }
.seg button:last-of-type { border-right: 0; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed] { color: var(--dark); background: var(--gold); }
.facts-stack, .facts-tight { grid-template-columns: 1fr; }
.facts-stack div:nth-child(odd), .facts-stack div:nth-last-child(-n+2):nth-child(odd) { border-right: 0; border-bottom: 1px solid var(--line); }
.facts.facts-stack div:last-child { border-bottom: 0; }
.facts-tight { margin: 18px 0; text-align: left; }
.facts-tight div:nth-child(odd) { border-right: 0; }
.facts-tight div:nth-last-child(-n+2):nth-child(odd) { border-bottom: 1px solid var(--line); }
.facts-tight div:last-child { border-bottom: 0; }
.gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.small-note { font-size: 13px; }
.cmd-inline { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; color: var(--ink); }
.kb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kb-stat { display: grid; gap: 4px; padding: 18px 20px; }

/* Knowledge base block in the profile */
.board > .wide { grid-column: 1 / -1; }
.kb { display: grid; gap: 4px; }
.kb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.kb-title { display: flex; align-items: center; gap: 12px; font-size: 24px; line-height: 1.2; }
.kb-title .i { width: 26px; height: 26px; color: var(--gold); }
.kb-lead { margin-top: 10px; max-width: 72ch; color: var(--muted); text-wrap: pretty; }
.kb-head .pill { flex: none; }
.kb-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 22px 0 6px; padding: 0; list-style: none; counter-reset: ov; }
.kb-overview li { counter-increment: ov; display: grid; align-content: start; gap: 2px; padding: 14px 14px 14px 52px; position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); }
.kb-overview li::before { content: counter(ov); position: absolute; left: 16px; top: 14px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-weight: 600; font-size: 14px; }
.kb-overview b { font-weight: 500; }
.kb-overview span { color: var(--muted); font-size: 13.5px; }
.tabs-kb { display: flex; flex-wrap: wrap; gap: 6px; margin: 24px 0 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; width: fit-content; max-width: 100%; }
.tabs-kb [role=tab] { min-height: 38px; padding: 6px 16px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 14px; }
.tabs-kb [role=tab]:hover { color: var(--ink); }
.tabs-kb [role=tab][aria-selected=true] { background: var(--gold); color: var(--dark); font-weight: 500; }
.kb-panel { padding-top: 6px; }
.steps { display: grid; gap: 18px; margin: 18px 0 8px; padding: 0; list-style: none; counter-reset: st; }
.steps > li { counter-increment: st; position: relative; padding-left: 44px; line-height: 1.65; }
.steps > li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--gold); font-size: 13px; font-weight: 600; }
.steps b { font-weight: 500; }
.steps a:not(.btn) { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.steps code, .faq code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; padding: 1px 6px; border-radius: 5px; background: oklch(94% .012 85 / .08); }
kbd { font-family: inherit; font-size: 12px; padding: 1px 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--raised); }
.cmdline { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; padding: 8px 8px 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: oklch(14% .008 75); }
.cmdline code { background: none; padding: 0; border-radius: 0; flex: 1; min-width: 0; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; line-height: 1.5; color: var(--ink); overflow-wrap: anywhere; user-select: all; }
.copy { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--raised); color: var(--ink); font-size: 13px; }
.copy .i { width: 16px; height: 16px; }
.copy:hover { border-color: var(--gold); }
.copy.done { border-color: var(--ok); color: var(--ok); }
.prompts { display: grid; gap: 2px; }
.cmdline.say code { font-family: inherit; font-size: 14px; }
.faq { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.faq details { border-bottom: 1px solid var(--line); }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; padding: 14px 16px; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--gold); font-size: 18px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq summary:hover { background: oklch(94% .012 85 / .03); }
.faq details p { padding: 0 16px 16px; color: var(--muted); max-width: 80ch; }
@media (max-width: 860px) {
  .kb-head { flex-direction: column-reverse; gap: 12px; }
  .cmdline { flex-direction: column; align-items: stretch; }
  .copy { justify-content: center; }
  .steps > li { padding-left: 38px; }
}

/* Users */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 14px; }
.tabs a:hover { color: var(--ink); border-color: var(--line-strong); }
.tabs a[aria-current] { color: var(--ink); border-color: var(--gold); background: var(--gold-soft); }
.tabs span { color: var(--faint); font-variant-numeric: tabular-nums; }
.tabs a[aria-current] span { color: var(--gold); }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 14px; text-align: left; font-size: 12.5px; font-weight: 500; color: var(--faint); border-bottom: 1px solid var(--line); }
.table td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.table td[data-label] { white-space: nowrap; }
/* The first column gets a third of the width, the buttons only what they need; the rest spread over the others */
.table th:first-child, .table td:first-child { width: 34%; min-width: 180px; }
.table .actions { width: 1%; }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table tbody tr:hover { background: oklch(94% .012 85 / .025); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline-flex; gap: 8px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* Servers */
#live > .section-title:first-of-type, #live > .alert + .section-title { margin-top: 0; }
.alert { margin-bottom: 18px; padding: 14px 18px; color: var(--bad); border-color: var(--bad-soft); }
.servers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 540px), 1fr)); gap: 16px; align-items: start; }
.server { padding: clamp(18px, 3vw, 26px); }
.server-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.server-head h3 { font-size: 22px; line-height: 1.2; }
.server-head small { flex-basis: 100%; }
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 22px 28px; padding: 22px 0; }
.gauge { display: grid; gap: 6px; align-content: start; }
.gauge-label { color: var(--faint); font-size: 12.5px; }
.gauge-value { font-size: 30px; font-weight: 300; line-height: 1.1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.gauge-value small { margin-left: 2px; color: var(--muted); font-size: 15px; letter-spacing: 0; }
.gauge-value.bad { color: var(--bad); font-size: 20px; }
.meter { display: block; width: 100%; height: 4px; }
.meter-track { fill: var(--line); }
.meter-ok .meter-fill { fill: var(--ok); }
.meter-warn .meter-fill { fill: var(--wait); }
.meter-bad .meter-fill { fill: var(--bad); }
.live-dot { display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--ok); animation: live 2.4s ease-in-out infinite; }
@keyframes live { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Charts: the plot is stretched to its box; the scale and times are HTML around it, so text is never stretched. */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 22px 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.chart { display: grid; gap: 12px; align-content: start; margin: 0; min-width: 0; }
.chart figcaption { display: flex; align-items: baseline; gap: 10px; min-height: 24px; }
.chart figcaption small { font-size: 12px; }
.chart-now { margin-left: auto; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--gold); }
.chart-body { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 132px auto; column-gap: 8px; row-gap: 6px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; margin: -7px 0; color: var(--faint); font-size: 11px; line-height: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.plot { display: block; width: 100%; height: 100%; overflow: visible; }
.plot-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.plot-grid:first-of-type { stroke: var(--line-strong); }
.plot-line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.chart-x { grid-column: 2; display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.s-cpu.plot-line { stroke: var(--gold); }
.s-cpu.plot-area { fill: var(--gold-soft); }
/* Disks: one tile per mount, as many side by side as fit */
.disks { display: grid; gap: 14px; align-content: start; min-width: 0; }
.disks ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 18px 28px; margin: 0; padding: 0; list-style: none; }
.disks li { display: grid; gap: 8px; align-content: start; }
.disk-name { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.disk-name .mono { font-size: 14px; color: var(--ink); word-break: normal; }
.disk-name b { font-size: 22px; font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.disk-name b small { margin-left: 2px; color: var(--muted); font-size: 13px; letter-spacing: 0; }
.refresh-note { margin-top: 18px; color: var(--faint); font-size: 13px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .logo { padding: 0; margin-right: auto; }
  .nav { display: flex; order: 3; width: 100%; overflow-x: auto; }
  .nav a { min-height: 38px; flex: none; white-space: nowrap; }
  .side-foot { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 4px; }
  .me { padding: 0; }
  .me span, .signout span { display: none; }
  .signout { width: 40px; padding: 10px; justify-content: center; }
  .main { padding: 24px 16px 48px; }
  .profile-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .facts { grid-template-columns: 1fr; }
  .facts div:nth-child(odd) { border-right: 0; }
  .facts div:nth-last-child(-n+2):nth-child(odd) { border-bottom: 1px solid var(--line); }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td, .table td:first-child, .table td:last-child { padding: 4px 0; border: 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--faint); font-size: 12.5px; }
  .table td:first-child { width: auto; padding-bottom: 10px; min-width: 0; }
  .table .actions { width: auto; }
  .table td[data-label] { white-space: normal; }
  .table td small.block { display: block; }
  .actions { text-align: left; padding-top: 12px !important; }
}

/* «База знаний»: documents being added right now. */
.kb-progress { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; padding: 16px 20px; border-color: oklch(82% .07 85 / .35); }
.kb-progress[hidden] { display: none; }
.kb-progress p { margin: 4px 0 0; }
.kb-spinner { flex: none; width: 18px; height: 18px; margin-top: 2px; border: 2px solid var(--line); border-top-color: var(--wait); border-radius: 50%; animation: kb-spin .9s linear infinite; }
@keyframes kb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .kb-spinner { animation: none; border-color: var(--wait); } }

/* «База знаний»: the 3D graph. The stage fills the card; tools float over its top, the panel sits on the right. */
/* The card has a fixed height and the canvas is taken out of the flow: if its size decided the stage's, a
   window made taller once (full screen, a rotated tablet) left the graph taller than the panel for good. */
.kb3d { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 320px; height: min(80vh, 860px); min-height: 420px; padding: 0; overflow: hidden; margin-bottom: 8px; background: #15130f; }
.kb3d-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.kb3d-stage > div { position: absolute; inset: 0; }
.kb3d-stage canvas { display: block; outline: none; }
.kb3d-tools { position: absolute; top: 14px; left: 14px; right: 334px; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; pointer-events: none; }
.kb3d-tools > * { pointer-events: auto; }
.kb3d-search input { width: min(320px, 100%); padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: oklch(18% .008 75 / .82); color: var(--ink); font: inherit; font-size: 14px; backdrop-filter: blur(6px); }
.kb3d-search input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.kb3d-found { display: grid; gap: 2px; min-width: 0; max-width: 320px; flex-basis: 100%; order: 3; }
.kb3d-found:empty { display: none; }
.kb3d-found .kb3d-link, .kb3d-found small { padding: 6px 10px; border-radius: 6px; background: oklch(22% .008 75 / .92); }
.kb3d-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.kb3d-buttons button { padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: oklch(18% .008 75 / .82); color: var(--muted); font-size: 13px; backdrop-filter: blur(6px); }
.kb3d-buttons button:hover { color: var(--ink); }
.kb3d-buttons button[aria-pressed="true"] { color: var(--gold); border-color: oklch(81% .076 77 / .45); }
.kb3d-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 18px 18px 16px; border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.kb3d-side h4 { margin: 8px 0 2px; color: var(--faint); font-size: 12.5px; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.kb3d-info { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.kb3d-info p { font-size: 14px; }
.kb3d-head { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12.5px; }
.kb3d-name { font-size: 20px; line-height: 1.25; }
.kb3d-topic { color: var(--gold); font-size: 13px !important; }
.kb3d-about { color: var(--muted); line-height: 1.55; }
.kb3d-docs, .kb3d-rels { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.kb3d-rels li { display: grid; gap: 1px; }
.kb3d-dot { flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.kb3d-link { display: flex; align-items: center; gap: 8px; width: 100%; padding: 2px 0; border: 0; background: none; color: var(--ink); text-align: left; font-size: 14px; }
.kb3d-link:hover span:last-child { color: var(--gold); }
.kb3d-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.kb3d-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); font-size: 12.5px; }
.kb3d-chip small { color: var(--faint); font-size: 11.5px; }
.kb3d-chip[aria-pressed="false"] { opacity: .4; }
.kb3d-chip[aria-pressed="false"] .kb3d-dot { box-shadow: none; }
.kb3d-hint { margin-top: auto; font-size: 12.5px; line-height: 1.5; }
.kb3d-hint a { color: var(--gold); }
.kb3d-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }
.kb3d-empty[hidden] { display: none; }
.kb3d:fullscreen { height: 100vh; border-radius: 0; }
@media (max-width: 900px) {
  .kb3d { grid-template-columns: 1fr; grid-template-rows: 62vh auto; height: auto; }
  .kb3d-tools { right: 14px; }
  .kb3d-buttons { margin-left: 0; }
  .kb3d-side { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
}

/* «База знаний»: adding files — dropped anywhere on the file browser, or «Добавить файлы». */
.kb-add { position: relative; gap: 6px; cursor: pointer; }
.kb-add[hidden] { display: none; }
.kb-add .i { width: 16px; height: 16px; }
.kb-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.kb-add:has(:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.kb-explorer { position: relative; }
.kb-dropzone { position: absolute; inset: 8px; z-index: 5; display: none; place-items: center; border: 2px dashed var(--gold); border-radius: var(--radius); background: oklch(18% .008 75 / .88); backdrop-filter: blur(3px); pointer-events: none; }
.kb-explorer.dropping .kb-dropzone { display: grid; }
.kb-dropzone span { display: grid; gap: 6px; justify-items: center; text-align: center; color: var(--ink); }
.kb-dropzone .i { width: 34px; height: 34px; color: var(--gold); }
.kb-dropzone b { font-size: 18px; font-weight: 500; }
.kb-dropzone small { color: var(--muted); }
.kb-ex-noscript { padding: 12px 16px 0; }
.kb-queue-head { margin: 0; }
.kb-queue { display: grid; gap: 14px; padding: 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.kb-queue[hidden] { display: none; }
.kb-files { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.kb-file { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); overflow: hidden; }
.kb-file > div { display: grid; gap: 2px; min-width: 0; }
.kb-file input { width: 100%; padding: 4px 6px; margin-left: -6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink); font: inherit; font-weight: 500; }
.kb-file input:hover:not(:disabled), .kb-file input:focus { border-color: var(--line-strong); outline: none; }
.kb-file small.muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-file-state { color: var(--muted); white-space: nowrap; }
.kb-file.ok .kb-file-state { color: var(--ok); }
.kb-file.bad .kb-file-state { color: var(--bad); white-space: normal; }
.kb-file-rm { width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--faint); font-size: 18px; line-height: 1; }
.kb-file-rm:hover { color: var(--ink); background: var(--line); }
.kb-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: var(--p, 0%); background: var(--gold); transition: width .2s; }
.kb-file.ok .kb-bar { background: var(--ok); }
.kb-file.bad .kb-bar { display: none; }
.kb-upload-fields { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; }
.kb-upload-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.kb-upload-fields input { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; color-scheme: dark; }
.kb-upload-fields input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.kb-upload-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kb-upload-actions button:disabled { opacity: .5; cursor: default; }
@media (max-width: 640px) {
  .kb-upload-fields { grid-template-columns: 1fr; }
  .kb-file { grid-template-columns: minmax(0, 1fr) auto; }
  .kb-file-state { grid-column: 1 / -1; grid-row: 2; }
}

/* «База знаний»: the two tabs and the «Документы» file browser. */
.kb-tabs a .i { width: 17px; height: 17px; }
.kb-explorer { padding: 0; overflow: hidden; }
.kb-ex-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.kb-ex-search { flex: 1 1 240px; }
.kb-ex-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; }
.kb-ex-search input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.kb-ex-search[hidden], .kb-ex-filter[hidden], .kb-ex-view[hidden], .kb-ex-search input[hidden] { display: none; }
.kb-ex-filter, .kb-ex-view { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; }
.kb-ex-filter button, .kb-ex-view button { display: grid; place-items: center; min-height: 32px; padding: 4px 11px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 13px; }
.kb-ex-view button { padding: 4px 8px; }
.kb-ex-filter button:hover, .kb-ex-view button:hover { color: var(--ink); }
.kb-ex-filter button[aria-pressed="true"], .kb-ex-view button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); }
.kb-ex-view .i { width: 18px; height: 18px; }
.kb-ex-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 420px; }
.kb-explorer:not(.js) .kb-ex-body { grid-template-columns: 1fr; }
.kb-ex-main { padding: 6px 16px 18px; min-width: 0; }
.kb-ex-side { padding: 20px; border-left: 1px solid var(--line); background: var(--surface); }
.kb-ex-side[hidden] { display: none; }
.kb-ex-empty, .kb-ex-none { padding: 40px 0; text-align: center; }
.kb-ex-none[hidden] { display: none; }
.kb-month[hidden] { display: none; }
.kb-month h3 { margin: 16px 0 10px; color: var(--faint); font-size: 12.5px; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.kb-month h3 small { margin-left: 4px; font-size: 12px; }
.kb-docs { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
[data-view="grid"] .kb-docs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kb-doc[hidden] { display: none; }
.kb-doc-open { position: relative; display: grid; width: 100%; height: 100%; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--ink); text-align: left; transition: background .12s, border-color .12s; }
.kb-doc-open:hover { background: var(--raised); }
.kb-doc.selected .kb-doc-open { background: var(--gold-soft); border-color: oklch(81% .076 77 / .45); }
[data-view="grid"] .kb-doc-open { justify-items: center; gap: 10px; padding: 16px 10px 12px; text-align: center; }
[data-view="list"] .kb-docs { gap: 2px; }
[data-view="list"] .kb-doc-open { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px; }
.kb-doc-text { display: grid; gap: 2px; min-width: 0; }
.kb-doc-text b { font-weight: 500; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
[data-view="grid"] .kb-doc-text b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
[data-view="list"] .kb-doc-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-doc-text small { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A file icon: a sheet with a folded corner, coloured by type, the extension on it. */
.kb-ext { position: relative; display: grid; place-items: end center; width: 46px; height: 56px; padding-bottom: 8px; border-radius: 6px 14px 6px 6px; background: var(--c, var(--faint)); color: oklch(20% .01 75); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; }
.kb-ext::after { content: ""; position: absolute; top: 0; right: 0; width: 14px; height: 14px; border-radius: 0 14px 0 5px; background: oklch(100% 0 0 / .35); }
[data-view="list"] .kb-ext { width: 30px; height: 36px; padding-bottom: 4px; font-size: 8px; border-radius: 4px 9px 4px 4px; }
[data-view="list"] .kb-ext::after { width: 9px; height: 9px; border-radius: 0 9px 0 3px; }
.kb-ext-big { width: 64px; height: 78px; font-size: 13px; margin-bottom: 4px; }
.kb-ext-word { --c: oklch(72% .1 250); }
.kb-ext-pdf { --c: oklch(70% .13 28); }
.kb-ext-excel { --c: oklch(74% .11 150); }
.kb-ext-audio { --c: oklch(74% .1 305); }
.kb-ext-text { --c: oklch(82% .02 80); }
.kb-ext-image { --c: oklch(76% .11 200); }
.kb-ext-video { --c: oklch(72% .12 340); }
.kb-ext-file { --c: oklch(70% .02 250); }
.kb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wait); }
[data-view="grid"] .kb-dot { position: absolute; top: 10px; right: 10px; }
.kb-dot-done { background: var(--ok); }
.kb-dot-failed { background: var(--bad); }
.kb-doc-detail { display: none; }
.kb-explorer:not(.js) .kb-doc-detail { display: block; padding: 4px 10px 14px; }
.kb-ex-side .kb-doc-detail { display: grid; gap: 10px; }
.kb-doc-detail h3 { font-size: 19px; line-height: 1.3; overflow-wrap: anywhere; }
.kb-doc-detail dl { display: grid; gap: 10px; margin: 6px 0; }
.kb-doc-detail dt { color: var(--faint); font-size: 12.5px; }
.kb-doc-detail dd { font-size: 14px; overflow-wrap: anywhere; }
.kb-doc-error { color: var(--bad); font-size: 14px; }
.kb-doc-detail .kb-doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.kb-doc-detail .kb-doc-actions .i { width: 16px; height: 16px; }
.kb-doc-detail .kb-doc-actions form { margin: 0; }
.kb-delete:hover { color: var(--bad); border-color: var(--bad-soft); }
@media (max-width: 900px) {
  .kb-ex-body { grid-template-columns: 1fr; }
  .kb-ex-side { border-left: 0; border-top: 1px solid var(--line); }
}
