:root {
  --bg: #0b0f14;
  --panel: #121826;
  --panel2: #182134;
  --border: #273450;
  --text: #e8edf6;
  --muted: #93a0b5;
  --accent: #7c5cff;
  --accent2: #2dd4bf;
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  --shadow: 0 18px 60px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, sans-serif; }
button, input, textarea, select { font: inherit; }
button, input, textarea, select { min-height: 44px; }
button { color: var(--text); background: var(--panel2); border: 1px solid var(--border); border-radius: 11px; padding: 9px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(45,212,191,.55); outline-offset: 2px; }
button.primary { border: 0; background: linear-gradient(135deg, var(--accent), #5b3df5); font-weight: 700; }
input, textarea, select { width: 100%; color: var(--text); background: #090d13; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); }
h1, h2, p { margin-top: 0; }
h1 { font-size: 18px; margin-bottom: 0; }
h2 { font-size: 17px; margin-bottom: 8px; }
.skip-link { position: fixed; z-index: 30; top: -100px; left: 12px; padding: 10px 14px; background: var(--accent2); color: #07110f; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 12px; }
#app { min-height: 100vh; display: flex; }
.sidebar { width: 236px; min-width: 236px; min-height: 100vh; max-height: 100vh; overflow-y: auto; position: sticky; top: 0; align-self: flex-start; display: flex; flex-direction: column; gap: 18px; padding: 16px 12px; background: var(--panel); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark, .avatar { display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #081016; font-weight: 900; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
.brand-name { font-size: 18px; font-weight: 750; letter-spacing: .4px; }
.brand-sub, .muted { color: var(--muted); font-size: 12px; }
#nav { display: grid; gap: 5px; }
.nav-divider { margin: 8px 4px 2px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.nav-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.nav-btn { width: 100%; display: flex; align-items: center; gap: 9px; text-align: left; background: transparent; border-color: transparent; }
.nav-btn.active { background: var(--panel2); border-color: var(--border); }
.sidebar-status { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel2); }
.eyebrow { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 5px; }
.status-line { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(147,160,181,.12); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.12); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.12); }
main { min-width: 0; flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border); background: rgba(18,24,38,.82); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }
.top-actions, .button-row, .section-head { display: flex; align-items: center; gap: 9px; }
.section-head { justify-content: space-between; margin-bottom: 14px; }
.icon-button { min-width: 44px; padding: 8px; font-size: 20px; }
#menu-toggle { display: none; }
.badge { border: 1px solid currentColor; border-radius: 999px; padding: 4px 9px; font-size: 11px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: rgba(52,211,153,.08); }
.badge.warn { color: var(--warn); background: rgba(251,191,36,.08); }
.badge.bad { color: var(--danger); background: rgba(248,113,113,.08); }
.view { display: none; min-height: 0; flex: 1; }
.view.active { display: flex; flex-direction: column; }
.notice { margin: 16px 18px 0; padding: 11px 13px; color: #f7d77a; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.25); border-radius: 11px; }
.messages { flex: 1; min-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.message { max-width: 820px; display: flex; gap: 11px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.message.user { margin-left: auto; background: linear-gradient(135deg, #5137dc, var(--accent)); }
.message p { margin: 4px 0 0; white-space: pre-wrap; }
.avatar { width: 34px; height: 34px; min-width: 34px; border-radius: 10px; }
.composer { position: sticky; bottom: 0; display: grid; grid-template-columns: minmax(160px, 220px) 1fr auto; gap: 10px; align-items: end; padding: 14px 18px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: rgba(18,24,38,.92); }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 20px; overflow: auto; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr); gap: 16px; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.direction-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-bottom: 14px; }
.card, .flow-card { padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.node-card .node-head { display: flex; justify-content: space-between; gap: 10px; }
.node-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin-bottom: 0; }
.node-card dt { color: var(--muted); }
.node-card dd { margin: 0; overflow-wrap: anywhere; }
.flow-card { grid-column: 1/-1; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flow-card div { display: grid; text-align: center; }
.flow-card small { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: 1/-1; }
.output { min-height: 260px; max-height: 480px; overflow: auto; padding: 13px; color: #b9c8dc; background: #080c12; border: 1px solid var(--border); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.output.tall { min-height: 500px; }
.owner-card { display: grid; align-content: start; gap: 11px; }
.confirm-line, .switch-line { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 9px; }
.confirm-line input, .switch-line input { width: 20px; min-height: 20px; }
.danger-action { color: #ffd7d7; border-color: rgba(248,113,113,.55); background: rgba(248,113,113,.1); }
.result-line { min-height: 24px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.list-empty { color: var(--muted); padding: 14px 0; }
.ticket { padding: 11px 0; border-bottom: 1px solid var(--border); }
.plain-list { margin: 0; padding-left: 20px; }
.gate-table { display: grid; gap: 0; }
.gate-row { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.danger-text { color: var(--danger); }
dialog { width: min(560px, calc(100vw - 28px)); color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 80px #000; }
dialog::backdrop { background: rgba(3,6,10,.76); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: 12px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-105%); transition: transform .18s ease; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: translateX(0); }
  #menu-toggle { display: inline-grid; place-items: center; }
  .two-column, .card-grid, .direction-grid { grid-template-columns: 1fr; }
  .flow-card { overflow-x: auto; justify-content: flex-start; }
  .flow-card div { min-width: 130px; }
}
@media (max-width: 620px) {
  .topbar { padding-inline: 12px; }
  .top-actions .badge { display: none; }
  .content { padding: 13px; }
  .notice { margin: 12px 12px 0; }
  .messages { padding: 12px; }
  .composer { grid-template-columns: 1fr auto; padding-inline: 12px; }
  .composer select { grid-column: 1/-1; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .button-row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
