:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: #0b111a;
  --panel-2: #0f1722;
  --line: #1b2b3d;
  --text: #e7f1fb;
  --muted: #7f94a8;
  --blue: #39a9ff;
  --blue-dim: #12304a;
  --green: #3fe3a2;
  --yellow: #f2c66d;
  --red: #ff6f7c;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 20% 0%, #0c1d2e 0, transparent 32%), var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 252px; border-right: 1px solid var(--line); background: rgba(5,7,11,.88); padding: 26px 16px; display: flex; flex-direction: column; gap: 30px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--blue); color: var(--blue); font-weight: 800; letter-spacing: -2px; transform: skew(-10deg); box-shadow: 0 0 22px rgba(57,169,255,.18); }
.brand-copy strong { display: block; font-size: 14px; letter-spacing: .14em; }
.brand-copy span { display: block; margin-top: 5px; color: var(--muted); font: 10px "JetBrains Mono", monospace; letter-spacing: .12em; }
.nav { display: grid; gap: 6px; }
.nav a { color: var(--muted); text-decoration: none; padding: 11px 12px; border-radius: 10px; display: flex; justify-content: space-between; font-size: 13px; transition: .18s ease; }
.nav a:hover, .nav a.active { color: var(--text); background: linear-gradient(90deg, rgba(57,169,255,.14), transparent); box-shadow: inset 2px 0 0 var(--blue); }
.nav a small { color: #4e6c84; font: 10px "JetBrains Mono", monospace; }
.sidebar-foot { margin-top: auto; padding: 13px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); margin-right: 7px; }
.main { min-width: 0; flex: 1; padding: 26px clamp(18px, 4vw, 54px) 42px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 38px; }
.eyebrow { color: var(--blue); font: 11px "JetBrains Mono", monospace; letter-spacing: .15em; text-transform: uppercase; }
.page-title { margin: 5px 0 0; font-size: clamp(24px, 4vw, 38px); letter-spacing: -.04em; }
.page-subtitle { color: var(--muted); margin: 8px 0 0; max-width: 650px; font-size: 13px; }
.key-box { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 5px; }
.key-box input { width: 190px; border: 0; outline: 0; color: var(--muted); background: transparent; font-size: 11px; }
.icon-button, .button { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 9px 13px; font-size: 12px; transition: .18s ease; }
.button:hover, .icon-button:hover { border-color: var(--blue); transform: translateY(-1px); }
.button.primary { border-color: var(--blue); background: linear-gradient(135deg, #1677bb, #155783); box-shadow: 0 0 25px rgba(57,169,255,.15); }
.button.danger { color: var(--red); border-color: rgba(255,111,124,.35); }
.button.ghost { background: transparent; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.grid { display: grid; gap: 14px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.card { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(15,23,34,.96), rgba(8,13,20,.96)); border-radius: 14px; box-shadow: var(--shadow); }
.metric { padding: 19px; min-height: 125px; position: relative; overflow: hidden; }
.metric::after { content: ""; position: absolute; width: 110px; height: 110px; right: -54px; bottom: -55px; border: 1px solid rgba(57,169,255,.15); border-radius: 50%; }
.metric-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { display: block; margin-top: 18px; font: 700 29px "JetBrains Mono", monospace; color: var(--text); }
.metric-value.blue { color: var(--blue); }
.section-grid { grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr); align-items: start; }
.panel { padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 17px; }
.panel-heading h2 { font-size: 16px; margin: 0; letter-spacing: -.02em; }
.panel-heading p { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 99px; font-size: 10px; color: var(--muted); background: #101b27; border: 1px solid var(--line); }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.status-pill.connected, .status-pill.approved { color: var(--green); border-color: rgba(63,227,162,.24); background: rgba(63,227,162,.07); }
.status-pill.connected::before, .status-pill.approved::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pill.awaiting_qr, .status-pill.waiting_pairing, .status-pill.waiting_external { color: var(--yellow); border-color: rgba(242,198,109,.25); background: rgba(242,198,109,.06); }
.status-pill.awaiting_qr::before, .status-pill.waiting_pairing::before, .status-pill.waiting_external::before { background: var(--yellow); }
.status-pill.failed, .status-pill.dead_letter, .status-pill.error { color: var(--red); border-color: rgba(255,111,124,.25); background: rgba(255,111,124,.06); }
.status-pill.failed::before, .status-pill.dead_letter::before, .status-pill.error::before { background: var(--red); }
.pulse-line { height: 2px; margin: 20px 0; background: linear-gradient(90deg, transparent, var(--blue), transparent); opacity: .65; animation: pulse 2.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .2; transform: scaleX(.8); } }
.session-row, .log-row, .queue-row, .message-row, .test-row { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-top: 1px solid rgba(27,43,61,.7); }
.session-row:first-child, .log-row:first-child, .queue-row:first-child, .message-row:first-child, .test-row:first-child { border-top: 0; }
.row-main { min-width: 0; flex: 1; }
.row-main strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span, .mono, time { color: var(--muted); font: 11px "JetBrains Mono", monospace; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1/-1; }
.field label { color: var(--muted); font-size: 11px; }
.field input, .field select, .field textarea { width: 100%; background: #08101a; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 10px 11px; outline: 0; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(57,169,255,.08); }
.form-actions { display: flex; justify-content: end; gap: 8px; margin-top: 14px; }
.qr-box { display: grid; place-items: center; min-height: 220px; border: 1px dashed var(--blue); border-radius: 12px; background: #fff; padding: 18px; margin-top: 16px; }
.qr-box img { width: min(240px, 100%); image-rendering: auto; }
.qr-loading { color: #0b1420; background: linear-gradient(135deg, #f8fcff, #e7f4ff); text-align: center; gap: 8px; }
.qr-loading strong { color: #0b4a7a; }
.qr-loading span { color: #3d566d; font-size: 12px; }
.code-block { background: #05090e; color: #9ecbff; border: 1px solid var(--line); border-radius: 8px; padding: 13px; font: 11px/1.6 "JetBrains Mono", monospace; overflow: auto; white-space: pre-wrap; }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.table-head h2 { margin: 0; font-size: 16px; }
.search { background: #08101a; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 9px 11px; outline: 0; font-size: 12px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 14px; border: 1px solid var(--blue); background: #0b1622; border-radius: 9px; color: var(--text); box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 12px; z-index: 10; }
.toast.show { transform: translateY(0); opacity: 1; }
.notice { padding: 12px 14px; border-left: 2px solid var(--yellow); background: rgba(242,198,109,.06); color: #d9c28c; border-radius: 5px; font-size: 12px; line-height: 1.5; }
@media (max-width: 1050px) { .sidebar { width: 215px; } .metrics { grid-template-columns: repeat(2, 1fr); } .section-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .app-shell { display: block; } .sidebar { width: 100%; height: auto; position: static; padding: 16px; gap: 16px; } .nav { grid-template-columns: repeat(3, 1fr); } .nav a { padding: 9px 8px; font-size: 11px; } .nav a small { display: none; } .sidebar-foot { display: none; } .main { padding: 22px 15px 34px; } .topbar { align-items: flex-start; flex-direction: column; margin-bottom: 28px; } .key-box { width: 100%; } .key-box input { flex: 1; width: auto; } .metrics { gap: 9px; } .metric { padding: 14px; min-height: 100px; } .metric-value { font-size: 21px; margin-top: 12px; } .form-grid { grid-template-columns: 1fr; } .field.full { grid-column: auto; } .session-row, .log-row { align-items: flex-start; flex-wrap: wrap; } .row-actions { width: 100%; justify-content: start; } }
