:root {
  --bg: #0a0d13;
  --bg2: #0f131b;
  --panel: #131925;
  --panel2: #18202e;
  --line: #222b3b;
  --line2: #2c3749;
  --text: #dbe1ea;
  --text2: #a3aec0;
  --muted: #6f7b8f;
  --accent: #5b8cff;
  --accent2: #3f6fe0;
  --ok: #2fbf71;
  --ok-bg: rgba(47, 191, 113, .12);
  --warn: #e5a50a;
  --warn-bg: rgba(229, 165, 10, .12);
  --bad: #ef5350;
  --bad-bg: rgba(239, 83, 80, .13);
  --info-bg: rgba(91, 140, 255, .12);
  --violet: #a97bff;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
  --r2: 7px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13.5px/1.45 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: .92em; }
::selection { background: rgba(91, 140, 255, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232c3c; border-radius: 6px; border: 2px solid var(--bg); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 212px 1fr; height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 6px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 14px; letter-spacing: .2px; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: radial-gradient(circle at 50% 50%, var(--ok) 0 22%, transparent 24%), conic-gradient(from 45deg, var(--accent), var(--violet), var(--accent)); box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset; }
nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-btn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text2); background: none; border: 0; cursor: pointer; text-align: left; width: 100%; text-decoration: none !important; }
.nav-btn:hover { background: var(--panel); color: var(--text); }
.nav-btn.active { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-btn svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-btn .badge { margin-left: auto; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.jobs { display: flex; flex-direction: column; gap: 4px; }
.job { font-size: 12px; color: var(--text2); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; display: flex; gap: 8px; align-items: center; }
.job .spin { width: 10px; height: 10px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
.job.done .spin { animation: none; border-color: var(--ok); }
.job.failed .spin { animation: none; border-color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--bg); min-height: 58px; }
.top h1 { font-size: 17px; margin: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 10px; }
.top-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.search-btn { display: flex; align-items: center; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px 6px 12px; color: var(--muted); cursor: pointer; }
.search-btn:hover { border-color: var(--line2); color: var(--text2); }
kbd { font-family: var(--mono); font-size: 11px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 5px; padding: 1px 5px; color: var(--text2); }
.view { flex: 1; overflow: auto; padding: 20px 22px 40px; min-height: 0; }
.term-layer { position: absolute; inset: 58px 0 0 0; display: flex; flex-direction: column; background: var(--bg); }
.only-narrow { display: none; }

/* ---------- primitives ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r2); border: 1px solid var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; white-space: nowrap; font-weight: 500; line-height: 1.3; text-decoration: none !important; }
.btn:hover { border-color: #3a4760; background: #1d2636; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent2); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: #ffb4b2; border-color: rgba(239, 83, 80, .45); background: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn.xs { padding: 1px 6px; font-size: 12px; border-radius: 5px; }
.btn .k { color: var(--muted); font-size: 11px; }
.icon-btn { background: none; border: 0; color: var(--text2); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 16px; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--panel2); color: var(--text2); border: 1px solid var(--line); white-space: nowrap; font-weight: 500; }
.badge.ok { background: var(--ok-bg); color: #7fe0a9; border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: #f3c75d; border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: #ff9a97; border-color: transparent; }
.badge.info { background: var(--info-bg); color: #9db8ff; border-color: transparent; }
.badge.violet { background: rgba(169, 123, 255, .14); color: #c7a8ff; border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.muted { color: var(--muted); }
.dim { color: var(--text2); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.sp { height: 14px; }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
.ok-t { color: #6ad59a; } .warn-t { color: #f0bd4a; } .bad-t { color: #ff8a87; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { cursor: copy; border-bottom: 1px dashed transparent; }
.copy:hover { border-bottom-color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 650; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.card h3 .grow + * { text-transform: none; letter-spacing: 0; }
.card.flush { padding: 0; }
.card.flush > h3 { padding: 12px 16px 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .val { font-size: 26px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.kpi .sub { color: var(--text2); font-size: 12.5px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv > :nth-child(odd) { color: var(--muted); }
.kv > :nth-child(even) { min-width: 0; overflow-wrap: anywhere; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .45px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 1; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text2); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid rgba(34, 43, 59, .65); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: rgba(91, 140, 255, .045); }
.tbl tr.off td { opacity: .5; }
.tbl tr.sub td { background: var(--bg2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.srv-name { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.srv-name b { font-weight: 600; }
.srv-name .meta { font-size: 11.5px; color: var(--muted); }
.flag { font-size: 16px; line-height: 1; width: 20px; text-align: center; flex: none; }

.bar { position: relative; height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 54px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.meter { display: flex; flex-direction: column; gap: 3px; min-width: 64px; }
.meter span { font-size: 11.5px; color: var(--text2); font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .lbl2 { font-size: 12px; color: var(--text2); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r2); padding: 7px 10px; outline: none; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, .15); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 70px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; margin: 0 0 12px; }
legend { padding: 0 6px; color: var(--text2); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r2); overflow: hidden; }
.seg button { background: var(--bg2); border: 0; padding: 5px 11px; cursor: pointer; color: var(--text2); border-right: 1px solid var(--line2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line2); background: var(--bg2); border-radius: 99px; padding: 3px 10px; cursor: pointer; color: var(--text2); font-size: 12.5px; }
.chip.on { border-color: var(--accent); color: var(--text); background: var(--info-bg); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 14px; border: 0; background: none; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 6, 10, .66); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; backdrop-filter: blur(2px); }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; width: min(720px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal.wide { width: min(1100px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-b { padding: 16px 18px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: 9px; padding: 10px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: tin .18s ease-out; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

pre.out { background: #070a0f; border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 12px; margin: 0; overflow: auto; max-height: 60vh; font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: #c8d0dc; }
pre.out.short { max-height: 260px; }

.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line2); border-radius: var(--r); }
.notice { border: 1px solid var(--line2); background: var(--bg2); border-radius: var(--r); padding: 10px 14px; color: var(--text2); display: flex; gap: 10px; align-items: flex-start; }
.notice.warn { border-color: rgba(229, 165, 10, .35); background: var(--warn-bg); color: #f3d38a; }
.notice.bad { border-color: rgba(239, 83, 80, .4); background: var(--bad-bg); color: #ffc0be; }
.notice.info { border-color: rgba(91, 140, 255, .35); background: var(--info-bg); color: #c3d3ff; }

/* ---------- overview wall ---------- */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 7px; position: relative; text-decoration: none !important; color: inherit; }
.tile:hover { border-color: var(--line2); background: #151c29; }
.tile.bad { border-color: rgba(239, 83, 80, .55); }
.tile.warn { border-color: rgba(229, 165, 10, .45); }
.tile.off { opacity: .5; }
.tile .t-head { display: flex; gap: 8px; align-items: center; min-width: 0; }
.tile .t-head b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .t-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 11.5px; color: var(--muted); }
.tile .t-stats b { display: block; color: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .when { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

.hbar { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.hbar .bars { display: flex; flex-direction: column; gap: 2px; }
.hbar .bars i { display: block; height: 5px; border-radius: 3px; background: var(--accent); min-width: 2px; }
.hbar .bars i.tx { background: var(--violet); }

/* ---------- RU matrix ---------- */
.matrix th.probe { writing-mode: vertical-rl; transform: rotate(180deg); text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 11.5px; padding: 8px 4px; height: 150px; vertical-align: bottom; text-align: left; white-space: nowrap; }
.matrix td.cell { text-align: center; padding: 4px 3px; min-width: 50px; }
.cellv { border-radius: 6px; padding: 4px 2px; line-height: 1.15; font-variant-numeric: tabular-nums; cursor: default; }
.cellv b { display: block; font-size: 12.5px; }
.cellv span { font-size: 10.5px; opacity: .8; }
.c0 { background: rgba(47, 191, 113, .16); color: #8ee6b4; }
.c1 { background: rgba(160, 200, 60, .16); color: #cde58b; }
.c2 { background: rgba(229, 165, 10, .18); color: #f6cd6b; }
.c3 { background: rgba(239, 120, 40, .2); color: #ffb27a; }
.c4 { background: rgba(239, 83, 80, .24); color: #ffa3a0; }
.cna { color: var(--muted); }

/* ---------- terminal ---------- */
.term-tabs { display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid var(--line); background: var(--bg2); overflow-x: auto; min-height: 38px; }
.term-tab { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 14px; border-right: 1px solid var(--line); cursor: pointer; color: var(--text2); white-space: nowrap; font-size: 12.5px; user-select: none; }
.term-tab:hover { background: var(--panel); }
.term-tab.on { background: var(--bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.term-tab .x { opacity: .5; padding: 2px 4px; border-radius: 4px; }
.term-tab .x:hover { opacity: 1; background: var(--panel2); }
.term-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; }
.term-body { flex: 1; position: relative; min-height: 0; }
.term-pane { position: absolute; inset: 0; padding: 6px 4px 4px 10px; background: #070a0f; }
.term-pane .xterm { height: 100%; }
.term-over { position: absolute; top: 10px; right: 18px; z-index: 5; display: flex; gap: 8px; align-items: center; background: rgba(15, 19, 27, .92); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }
.term-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 14px; color: var(--muted); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 50% -10%, #142039 0, var(--bg) 60%); padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.login-card h2 { margin: 0; font-size: 20px; display: flex; gap: 10px; align-items: center; }

/* ---------- palette ---------- */
.palette { width: min(560px, 100%); }
.palette input { font-size: 15px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; background: transparent; box-shadow: none !important; }
.pal-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pal-item.on { background: var(--panel2); }
.pal-item .hint { margin-left: auto; font-size: 11.5px; color: var(--muted); }

/* ---------- выпадающее меню (⋯) ---------- */
.menu { position: fixed; z-index: 60; min-width: 220px; padding: 5px; background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); cursor: pointer; text-align: left; font: inherit; font-size: 13px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--panel2); outline: none; }
.menu-item.danger { color: #ff9a97; }
.menu-item .hint { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }

.spark { display: block; }
.chart-card { display: flex; flex-direction: column; gap: 6px; }
.chart-card .ch-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); }
.chart-card .ch-head b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.snip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.snip { text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; color: var(--text); }
.snip:hover { border-color: var(--accent); }
.snip .s-t { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.snip .s-n { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .15s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .only-narrow { display: inline-block; }
  .search-btn span, .search-btn kbd { display: none; }
  .search-btn::before { content: "⌕"; font-size: 16px; }
  .search-btn { padding: 5px 10px; }
  .g2, .g3, .g4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 14px 16px 40px; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top-actions { order: 5; width: 100%; justify-content: flex-start; margin-left: 0; }
  .term-layer { inset: 0; top: auto; height: calc(100% - 58px); }
}
.lc0 { color: #7fe0a9; } .lc1 { color: #cde58b; } .lc2 { color: #f6cd6b; } .lc3 { color: #ffb27a; } .lc4 { color: #ff8a87; } .lcna { color: var(--muted); }
.row > select, .row > input:not([type=checkbox]) { width: auto; }
table.tbl.matrix { width: auto; min-width: 520px; }
.matrix td:first-child { min-width: 220px; }

/* ---------- Claude ---------- */
.view.view-chat { padding: 0; overflow: hidden; display: flex; }
.chat { display: grid; grid-template-columns: 250px 1fr; flex: 1; min-height: 0; min-width: 0; }
.chat-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg2); }
.chat-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.chat-item { position: relative; padding: 8px 26px 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text2); }
.chat-item:hover { background: var(--panel); color: var(--text); }
.chat-item.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.chat-item .x { position: absolute; right: 6px; top: 8px; opacity: 0; padding: 0 4px; border-radius: 4px; }
.chat-item:hover .x { opacity: .6; } .chat-item .x:hover { opacity: 1; background: var(--line2); }
.chat-ver { padding: 8px 12px; border-top: 1px solid var(--line); }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; }
.chat-compose { border-top: 1px solid var(--line); padding: 12px 24px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-input { font-family: var(--sans) !important; font-size: 14px !important; min-height: 52px; max-height: 240px; }
.msg { max-width: min(900px, 100%); }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--accent2); color: #fff; padding: 9px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ai { align-self: flex-start; line-height: 1.55; }
.msg.ai.streaming { opacity: .85; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; } .md li { margin: 2px 0; }
.md code { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.md .md-h { font-weight: 650; margin: 10px 0 6px; color: var(--text); }
.md .tbl-wrap { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 8px; }
.md table.md-tbl th { position: static; }
.tool { align-self: flex-start; max-width: min(900px, 100%); border: 1px solid var(--line); border-radius: 9px; background: var(--bg2); }
.tool-h { display: flex; gap: 8px; align-items: center; padding: 5px 10px; cursor: pointer; font-size: 12.5px; min-width: 0; }
.tool-h b { font-weight: 600; white-space: nowrap; }
.tool-h .ell { min-width: 0; flex: 1; }
.tool-ic { color: var(--accent); }
.tool-st { font-size: 11.5px; white-space: nowrap; }
.tool pre { margin: 0 8px 8px; }
.approval { align-self: flex-start; max-width: min(900px, 100%); border: 1px solid rgba(229, 165, 10, .5); background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.approval.prot { border-color: rgba(169, 123, 255, .6); background: rgba(169, 123, 255, .1); }
.approval.done { opacity: .7; }
.msg-meta { align-self: flex-start; font-size: 11.5px; color: var(--muted); }
.chat-empty { margin: auto; max-width: 640px; display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; }
.sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.sugg .chip { text-align: left; }
@media (max-width: 820px) { .chat { grid-template-columns: 1fr; } .chat-side { display: none; } .chat-msgs, .chat-compose { padding-left: 14px; padding-right: 14px; } }
