:root {
  --bg: #080a10;
  --bg-soft: #0d1018;
  --panel: #11141d;
  --panel-2: #161a25;
  --line: #232838;
  --line-soft: #1a1e2b;
  --txt: #e8ecf6;
  --txt-dim: #9aa4bd;
  --txt-mute: #67708a;
  --acc: #6c8cff;
  --acc-2: #8b5cf6;
  --ok: #37d399;
  --warn: #f5b552;
  --err: #f0616d;
  --radius: 14px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, .85);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 78% -12%, rgba(108, 140, 255, .16), transparent 60%),
    radial-gradient(900px 520px at 12% 108%, rgba(139, 92, 246, .13), transparent 62%),
    var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.subtle { color: var(--txt-mute); font-size: 12px; }
.mono { font-family: var(--mono); }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ---------------- sidebar ---------------- */
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px;
  background: linear-gradient(180deg, rgba(17, 20, 29, .92), rgba(10, 12, 18, .92));
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(8px);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; }
.mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; color: #fff;
  background: linear-gradient(140deg, var(--acc), var(--acc-2));
  box-shadow: 0 8px 20px -10px var(--acc);
}
.mark svg { stroke-width: 1.4; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--txt-mute); }
#navToggle { display: none; margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  color: var(--txt-dim); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { opacity: .8; }
.nav-item:hover { background: var(--panel); color: var(--txt); }
.nav-item.active { background: linear-gradient(90deg, rgba(108, 140, 255, .16), rgba(108, 140, 255, .04)); color: #fff; }
.nav-item.active svg { color: var(--acc); opacity: 1; }
.nav-item .pill { margin-left: auto; }

.pill {
  font-style: normal; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
  background: var(--panel-2); color: var(--txt-dim);
  border: 1px solid var(--line);
}

.side-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--line-soft); }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--txt-dim); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 181, 82, .15); }
.conn.on i { background: var(--ok); box-shadow: 0 0 0 3px rgba(55, 211, 153, .16); }
.conn.off i { background: var(--err); box-shadow: 0 0 0 3px rgba(240, 97, 109, .16); }

/* ---------------- main ---------------- */
.main { min-width: 0; padding: 22px 26px 40px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.top h1 { font-size: 21px; letter-spacing: -.2px; }
.top-left p { margin-top: 2px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--txt-mute); width: 16px; height: 16px; }
.search input {
  width: 260px; padding: 9px 12px 9px 34px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  color: var(--txt); outline: none; transition: border .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(108, 140, 255, .14); }
.chip {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--txt-dim);
}
.chip:hover { color: var(--txt); border-color: var(--acc); }

.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, rgba(22, 26, 37, .86), rgba(17, 20, 29, .86));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head.pad-x { padding: 14px 16px 0; margin-bottom: 8px; }
.card-head h2 { font-size: 13px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--txt-dim); }
.card-head.mt { margin-top: 18px; }
.link { background: none; border: 0; color: var(--acc); font-size: 12px; padding: 2px 4px; border-radius: 6px; }
.link:hover { background: rgba(108, 140, 255, .12); }
.row { display: flex; align-items: center; gap: 8px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { position: relative; padding: 15px 16px 12px; overflow: hidden; }
.stat-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--txt-dim); }
.stat strong { display: block; font-size: 27px; font-weight: 650; letter-spacing: -.6px; margin: 6px 0 0; }
.stat small { color: var(--txt-mute); font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--txt-mute); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px rgba(55, 211, 153, .14); }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-mute); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.spark { position: absolute; inset: auto 0 0 0; height: 3px; background: var(--line-soft); }
.spark b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--acc), var(--acc-2)); transition: width .5s ease; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 16px; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 330px; overflow: auto; }
.feed.tall { max-height: calc(100vh - 220px); }
.feed li { padding: 8px 6px; border-radius: 8px; display: grid; grid-template-columns: 54px 1fr; gap: 8px; }
.feed li:hover { background: var(--panel-2); }
.feed .t { color: var(--txt-mute); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.feed .m { min-width: 0; overflow-wrap: anywhere; }
.feed .m b { font-weight: 600; }
.feed li.ok .m b { color: var(--ok); }
.feed li.error .m b { color: var(--err); }
.feed li.warn .m b { color: var(--warn); }
.feed li.info .m b { color: var(--acc); }
.empty { color: var(--txt-mute); padding: 18px 6px; text-align: center; font-size: 12px; }

.mini { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mini li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.mini li:hover { background: var(--panel-2); }
.mini .host { font-weight: 600; }
.mini .meta { margin-left: auto; color: var(--txt-mute); font-size: 11px; }

.osbars { display: flex; flex-direction: column; gap: 7px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.osbar { display: grid; grid-template-columns: 88px 1fr 34px; gap: 8px; align-items: center; font-size: 11px; color: var(--txt-dim); }
.osbar .bar { height: 6px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.osbar .bar b { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc-2)); }

/* tables */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--txt-mute); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--panel);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--panel-2); }
.table .host { font-weight: 600; }
.table .muted { color: var(--txt-mute); }
.empty-state { display: none; padding: 44px 20px; text-align: center; }
.empty-state p { font-weight: 600; margin-bottom: 4px; }
.empty-state span { color: var(--txt-mute); font-size: 12px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-mute); }
.status.online i { background: var(--ok); box-shadow: 0 0 0 3px rgba(55, 211, 153, .16); }
.status.offline { color: var(--txt-mute); }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--txt-dim); }
.badge.acc { color: var(--acc); border-color: rgba(108, 140, 255, .35); background: rgba(108, 140, 255, .08); }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--txt-dim);
}
.icon-btn:hover { background: var(--panel-2); color: var(--txt); }

/* console */
.console-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.console-side { position: sticky; top: 18px; }
.select {
  width: 100%; padding: 9px 10px; margin-bottom: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; color: var(--txt);
}
.client-card { display: grid; gap: 4px; font-size: 12px; color: var(--txt-dim); min-height: 20px; }
.client-card b { color: var(--txt); }

.tools { display: flex; flex-direction: column; gap: 12px; max-height: 44vh; overflow: auto; }
.tool-group h3 { font-size: 10px; text-transform: uppercase; letter-spacing: .7px; color: var(--txt-mute); margin: 0 0 6px; }
.tool-group .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tool {
  padding: 5px 9px; border-radius: 8px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-dim);
  transition: all .14s;
}
.tool:hover { color: #fff; border-color: var(--acc); background: rgba(108, 140, 255, .12); }

.console-main { display: flex; flex-direction: column; min-height: 64vh; }
.term {
  flex: 1; padding: 6px 16px 16px; overflow: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  display: flex; flex-direction: column; gap: 8px;
  transition: outline-color .15s;
  outline: 2px dashed transparent;
  outline-offset: -8px;
}
.term.drop { outline-color: var(--acc); }
.term-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.term-line.cmd { color: var(--acc); }
.term-line.ok { color: var(--txt); }
.term-line.err { color: var(--err); }
.term-line.muted { color: var(--txt-mute); font-style: italic; }
.term-line .meta { color: var(--txt-mute); font-size: 11px; display: block; margin-bottom: 2px; font-style: normal; }
.composer { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line-soft); }
.composer .prompt { color: var(--acc); font-family: var(--mono); }
.composer input {
  flex: 1; background: transparent; border: 0; outline: none;
  color: var(--txt); font-family: var(--mono); font-size: 13px;
}
.staged {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px 12px; font-size: 12px; color: var(--txt-dim);
}
.staged[hidden] { display: none; }
.btn {
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  background: linear-gradient(140deg, var(--acc), var(--acc-2)); color: #fff; font-weight: 600;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.wide { width: 100%; }
.btn.ghost { background: var(--panel-2); border-color: var(--line); color: var(--txt-dim); font-weight: 500; }

/* forms */
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--txt-dim); }
.form input[type=text], .form input:not([type]) {
  padding: 9px 11px; border-radius: 9px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--txt); outline: none;
}
.form input:focus { border-color: var(--acc); }
.form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--txt-dim); }
.note { margin-top: 10px; }
.note code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.msg { margin: 6px 0 0; padding: 10px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

.profiles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.profile { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: var(--panel-2); }
.profile-top { display: flex; align-items: center; gap: 8px; }
.profile-top b { font-size: 13px; }
.profile-top .subtle { margin-left: auto; }
.profile .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.profile .meta { color: var(--txt-mute); font-size: 11px; margin-top: 4px; font-family: var(--mono); overflow-wrap: anywhere; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(4, 6, 10, .6); backdrop-filter: blur(3px); z-index: 60; display: grid; justify-items: end; }
.drawer[hidden] { display: none; }
.drawer-panel {
  width: min(520px, 100%); height: 100%; overflow: auto;
  background: var(--bg-soft); border-left: 1px solid var(--line);
  padding: 20px 22px; animation: slide .22s ease;
}
@keyframes slide { from { transform: translateX(16px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.drawer-head h2 { font-size: 17px; }
.drawer-body { display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 12.5px; }
.kv dt { color: var(--txt-mute); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  min-width: 220px; max-width: 340px; padding: 10px 13px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 12.5px; animation: pop .18s ease;
}
.toast.ok { border-color: rgba(55, 211, 153, .4); }
.toast.err { border-color: rgba(240, 97, 109, .45); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .console-grid { grid-template-columns: 280px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 258px;
    transform: translateX(-102%); transition: transform .22s ease;
    height: 100%;
  }
  body.nav-open .side { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(4, 6, 10, .55); z-index: 30;
  }
  #navToggle { display: grid; }
  .main { padding: 16px 14px 34px; }
  .grid-2, .console-grid { grid-template-columns: 1fr; }
  .console-side { position: static; }
  .search input { width: 150px; }
  .top h1 { font-size: 18px; }
  .term { min-height: 40vh; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat strong { font-size: 23px; }
  .top { flex-direction: column; align-items: stretch; gap: 12px; }
  .top-right { justify-content: space-between; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .table th:nth-child(5), .table td:nth-child(5),
  .table th:nth-child(6), .table td:nth-child(6) { display: none; }
  .feed li { grid-template-columns: 46px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}