:root {
  --bg:#0d0d1a;
  --sidebar:#141425;
  --surface:#1a1a2e;
  --surface2:#20203a;
  --border:#2a2a45;
  --border2:rgba(255,255,255,.14);
  --text:#fff8dc;
  --muted:#c0c0c0;
  --accent:#ffd700;
  --accent2:#4dd0e1;
  --error:#ef5350;
  --success:#4caf50;
  --warning:#ffa726;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,sans-serif;
  color:var(--text);
  background:var(--bg);
}
* { box-sizing:border-box; }
body { margin:0; min-height:100vh; overflow:hidden; background:var(--bg); }
button, input, select { font:inherit; }
.titlebar {
  height:48px; display:flex; align-items:center; gap:10px; padding:0 12px;
  background:rgba(20,20,37,.98); border-bottom:1px solid var(--border);
}
.brand-mark { width:18px; height:18px; border-radius:4px; background:linear-gradient(180deg,#f5c542,#d4961c); box-shadow:0 0 0 1px rgba(0,0,0,.25); }
.title { font-size:14px; font-weight:700; line-height:1.1; }
.subtitle { font-size:11px; color:var(--muted); line-height:1.2; }
.icon-btn {
  width:34px; height:34px; display:grid; place-items:center; border:1px solid var(--border);
  border-radius:8px; color:var(--muted); background:transparent; cursor:pointer;
}
.icon-btn:hover { color:var(--accent); border-color:var(--border2); background:rgba(255,255,255,.04); }
.icon-btn svg, .rail-btn svg { width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.refresh { margin-left:auto; }
.mobile-menu { display:none; }
.shell { display:grid; grid-template-columns:52px 260px 1fr; height:calc(100vh - 48px); }
.rail { display:flex; flex-direction:column; gap:8px; align-items:center; padding:10px 6px; background:#0f0f20; border-right:1px solid var(--border); }
.rail-btn { width:38px; height:38px; display:grid; place-items:center; color:var(--muted); background:transparent; border:1px solid transparent; border-radius:8px; cursor:pointer; }
.rail-btn:hover, .rail-btn.active { color:var(--accent); background:rgba(255,215,0,.08); border-color:rgba(255,215,0,.18); }
.sidebar { display:flex; flex-direction:column; min-width:0; background:var(--sidebar); border-right:1px solid var(--border); padding:12px; }
.panel-head { font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin:4px 4px 12px; }
.side-tab { text-align:left; color:var(--muted); background:transparent; border:1px solid transparent; padding:10px 12px; border-radius:8px; cursor:pointer; }
.side-tab:hover, .side-tab.active { color:var(--text); background:rgba(255,255,255,.05); border-color:var(--border); }
.sidebar-spacer { flex:1; }
.mini-status { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12px; padding:10px; border:1px solid var(--border); border-radius:8px; background:rgba(0,0,0,.12); }
.dot { width:8px; height:8px; border-radius:999px; background:var(--warning); box-shadow:0 0 0 3px rgba(255,167,38,.12); }
.dot.ok { background:var(--success); box-shadow:0 0 0 3px rgba(76,175,80,.12); }
.dot.err { background:var(--error); box-shadow:0 0 0 3px rgba(239,83,80,.12); }
.main { position:relative; min-width:0; overflow:auto; padding:22px; background:linear-gradient(180deg,rgba(255,255,255,.02),rgba(255,255,255,0)); }
.view { display:none; max-width:1180px; margin:0 auto; }
.view.active { display:block; }
.topline { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:18px; }
h1 { margin:0; font-size:24px; letter-spacing:0; line-height:1.15; }
.topline span { color:var(--muted); font-size:12px; }
.metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.metric, .service-card, .login-box {
  border:1px solid var(--border); border-radius:8px; background:rgba(26,26,46,.78); padding:14px;
}
.metric span { display:block; color:var(--muted); font-size:12px; margin-bottom:8px; }
.metric strong { display:block; font-size:28px; line-height:1; margin-bottom:12px; }
.bar { height:7px; border-radius:999px; overflow:hidden; background:rgba(255,255,255,.08); }
.bar i { display:block; height:100%; width:0; background:linear-gradient(90deg,var(--accent),var(--accent2)); transition:width .2s ease; }
.section-title { margin:24px 0 10px; color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.06em; }
.service-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.service-list { display:grid; gap:10px; }
.service-card { display:flex; align-items:center; gap:12px; min-height:76px; }
.service-main { min-width:0; flex:1; }
.service-name { font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.service-meta { color:var(--muted); font-size:12px; margin-top:3px; }
.pill { color:var(--muted); border:1px solid var(--border); border-radius:999px; padding:3px 8px; font-size:11px; }
.pill.ok { color:var(--success); border-color:rgba(76,175,80,.35); background:rgba(76,175,80,.08); }
.pill.err { color:var(--error); border-color:rgba(239,83,80,.35); background:rgba(239,83,80,.08); }
.action-btn, .login-box button {
  color:#191400; background:var(--accent); border:0; border-radius:8px; padding:9px 12px; font-weight:700; cursor:pointer;
}
.action-btn:disabled { opacity:.45; cursor:wait; }
select, input {
  color:var(--text); background:rgba(255,255,255,.04); border:1px solid var(--border); border-radius:8px; padding:9px 10px; outline:none;
}
select:focus, input:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(255,215,0,.1); }
.log-box {
  min-height:60vh; max-height:70vh; overflow:auto; margin:0; padding:14px; border:1px solid var(--border);
  border-radius:8px; background:#080812; color:#e6e1c7; font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  white-space:pre-wrap;
}
.chat-box {
  height:min(62vh,680px); overflow:auto; display:flex; flex-direction:column; gap:12px; padding:14px;
  border:1px solid var(--border); border-radius:8px; background:#080812;
}
.chat-msg { max-width:min(820px,92%); display:grid; gap:5px; }
.chat-msg.user { align-self:flex-end; }
.chat-msg.assistant { align-self:flex-start; }
.chat-role { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.06em; }
.chat-body { white-space:pre-wrap; color:var(--text); background:rgba(255,255,255,.05); border:1px solid var(--border); border-radius:8px; padding:11px 12px; line-height:1.45; }
.chat-msg.user .chat-body { color:#191400; background:var(--accent); border-color:transparent; transition:background .2s ease, border-color .2s ease, box-shadow .2s ease; }
.chat-msg.user.read .chat-body { background:linear-gradient(180deg,#4dd0e1,#2eb7cc); border-color:rgba(77,208,225,.4); box-shadow:0 0 0 1px rgba(77,208,225,.18); }
.chat-receipt { justify-self:end; color:var(--muted); font-size:11px; line-height:1.2; min-height:14px; }
.chat-msg.user.read .chat-receipt { color:var(--accent2); font-weight:700; }
.chat-compose { display:grid; grid-template-columns:1fr auto; gap:10px; margin-top:12px; align-items:end; }
.chat-compose textarea {
  resize:vertical; min-height:72px; max-height:220px; color:var(--text); background:rgba(255,255,255,.04);
  border:1px solid var(--border); border-radius:8px; padding:10px; outline:none;
}
.chat-compose textarea:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(255,215,0,.1); }
.login {
  position:absolute; inset:0; display:none; align-items:center; justify-content:center; z-index:5;
  background:rgba(13,13,26,.92); backdrop-filter:blur(8px);
}
.login.active { display:flex; }
.login-box { width:min(360px,calc(100vw - 32px)); display:grid; gap:10px; }
.login-title { font-size:18px; font-weight:700; }
.error { min-height:18px; color:var(--error); font-size:12px; }
@media (max-width: 820px) {
  body { overflow:auto; }
  .mobile-menu { display:grid; }
  .shell { grid-template-columns:1fr; height:calc(100vh - 48px); }
  .rail { display:none; }
  .sidebar { position:fixed; z-index:4; inset:48px auto 0 0; width:250px; transform:translateX(-100%); transition:transform .18s ease; }
  .sidebar.open { transform:translateX(0); }
  .main { padding:16px; }
  .metrics, .service-grid { grid-template-columns:1fr; }
  .topline { align-items:flex-start; flex-direction:column; }
  .chat-compose { grid-template-columns:1fr; }
  .chat-compose .action-btn { width:100%; }
}
