/* namiai.cfd — NIMA Core control center */
:root {
  --navy: #101827;
  --cyan: #32D6E8;
  --cyan-08: rgba(50, 214, 232, .08);
  --cyan-15: rgba(50, 214, 232, .15);
  --cyan-30: rgba(50, 214, 232, .3);
  --bg: #0B1120;
  --surface: #151F30;
  --card: #1B293C;
  --text: #F1F5F9;
  --muted: #91A1B5;
  --dim: #64748B;
  --line: rgba(145, 161, 181, .14);
  --line-2: rgba(145, 161, 181, .24);
  --ok: #36D399;
  --warn: #FBBF24;
  --bad: #FB7185;
  --chain: #32D6E8;
  --chain-2: #9DEBF4;
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 252px;
  --sidebar-c: 74px;
  --top: 64px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--cyan-30); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #22324a; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
svg { display: block; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.cyan { color: var(--cyan); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.hidden { display: none !important; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: linear-gradient(180deg, #0E1626 0%, var(--bg) 100%);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: width .22s ease, transform .22s ease;
}
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; transition: margin .22s ease; display: flex; flex-direction: column; }
body.collapsed .sidebar { width: var(--sidebar-c); }
body.collapsed .main { margin-left: var(--sidebar-c); }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; min-height: 68px; }
.brand-link { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.wordmark { font-weight: 700; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.wordmark span { color: var(--cyan); }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
body.collapsed .brand-text { display: none; }
body.collapsed .brand { justify-content: center; padding: 18px 0 14px; }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 16px; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: .12em; color: var(--dim); padding: 0 10px 6px; white-space: nowrap; }
body.collapsed .nav-label { visibility: hidden; height: 6px; padding: 0; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0;
  border-radius: 9px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { color: var(--text); background: rgba(145, 161, 181, .07); }
.nav a.active { color: var(--text); background: var(--cyan-08); box-shadow: inset 0 0 0 1px var(--cyan-15); }
.nav a.active svg { color: var(--cyan); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cyan); }
body.collapsed .nav a { justify-content: center; padding: 10px 0; }
body.collapsed .nav a span { display: none; }
body.collapsed .nav a:hover::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--card); color: var(--text); border: 1px solid var(--line-2); padding: 5px 10px; border-radius: 7px;
  font-size: 12.5px; z-index: 60; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.collapse-btn { width: 100%; display: flex; align-items: center; gap: 10px; justify-content: flex-start; }
body.collapsed .collapse-btn { justify-content: center; }
body.collapsed .collapse-btn span { display: none; }
body.collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ---------------- Token bar ---------------- */
.tokenbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 24px; border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--chain) 14%, transparent), transparent 55%),
    #0D1424;
  font-size: 12.5px;
}
.chain-badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 4px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--chain) 45%, transparent); background: color-mix(in srgb, var(--chain) 12%, transparent);
  font-weight: 600; color: var(--text); white-space: nowrap; }
.chain-badge svg { width: 20px; height: 20px; }
.token-id { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.token-id b { font-weight: 700; }
.token-sym { color: var(--chain-2); font-weight: 600; }
.ca-box { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.ca-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
.ca-value { font-family: var(--mono); font-size: 12.5px; color: var(--text); word-break: break-all; overflow-wrap: anywhere;
  padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.token-links { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.ca-value { white-space: nowrap; }
@media (max-width: 720px) { .ca-value { white-space: normal; } .ca-box { flex: 1 1 100%; } .token-links { margin-left: 0; } }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: rgba(11, 17, 32, .86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.page-crumb { font-size: 11.5px; color: var(--dim); letter-spacing: .06em; text-transform: uppercase; }
.top-search { flex: 1; max-width: 420px; margin-left: auto; position: relative; }
.top-search input[type=search] { width: 100%; padding-left: 36px; padding-right: 64px; }
.top-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--dim); }
.top-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); white-space: nowrap; background: var(--surface); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(54,211,153,.15); flex: none; }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.15); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(251,113,133,.15); }
.dot.off { background: var(--dim); box-shadow: none; }
.icon-btn { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; }
.badge-count { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--cyan);
  color: var(--navy); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px;
  background: linear-gradient(135deg, #1f3a52, #12283a); border: 1px solid var(--cyan-30); color: var(--cyan); cursor: pointer; }
.menu-btn { display: none; }
.dropdown { position: relative; }
.dropdown-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--card); border: 1px solid var(--line-2);
  border-radius: 12px; box-shadow: 0 18px 48px rgba(0,0,0,.45); padding: 6px; z-index: 50; display: none; }
.dropdown.open .dropdown-panel { display: block; }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); width: 100%;
  background: none; border: 0; text-align: left; }
.dd-item:hover { background: rgba(145,161,181,.08); }
.dd-item svg { width: 16px; height: 16px; color: var(--muted); }
.dd-head { padding: 8px 10px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; display: flex; justify-content: space-between; }
.notif { padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; }
.notif:hover { background: rgba(145,161,181,.06); }
.notif.unread { background: var(--cyan-08); }
.notif small { color: var(--dim); display: block; }

/* ---------------- Content ---------------- */
.content { padding: 24px; max-width: 1560px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; align-items: center; gap: 20px; margin-bottom: 22px; padding: 18px 22px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--surface), #111a2b); border: 1px solid var(--line); position: relative; overflow: hidden; }
.page-head::after { content: ""; position: absolute; inset: 0; background: radial-gradient(500px 160px at 85% 50%, var(--cyan-08), transparent 70%); pointer-events: none; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); max-width: 720px; }
.page-head .illus { width: 168px; height: 96px; margin-left: auto; flex: none; color: var(--cyan); position: relative; z-index: 1; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.footer { padding: 16px 24px; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side-l { grid-template-columns: minmax(280px, 1fr) minmax(0, 2.2fr); }
.span-2 { grid-column: span 2; }
.mt { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.elev { background: var(--card); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 16px; height: 16px; color: var(--cyan); }
.card-sub { color: var(--muted); font-size: 12.5px; }
.chart-box { position: relative; height: 240px; }
.chart-box.sm { height: 190px; }
.chart-box.lg { height: 320px; }

.stat { position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.stat .label svg { width: 15px; height: 15px; color: var(--cyan); }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; }
.stat .delta { font-size: 12px; margin-top: 2px; }
.stat .spark { position: absolute; right: 12px; bottom: 12px; width: 84px; height: 30px; opacity: .8; }

/* ---------------- Controls ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--text); cursor: pointer; font-weight: 550; font-size: 13px; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--cyan-30); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--cyan); color: var(--navy); border-color: var(--cyan); }
.btn.primary:hover { background: #5ce1f0; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.06); }
.btn.danger.solid { background: var(--bad); color: #2a0c13; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.chain { border-color: color-mix(in srgb, var(--chain) 45%, transparent); background: color-mix(in srgb, var(--chain) 12%, transparent); }
.btn.chain:hover { border-color: var(--chain); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  background: #0F1828; border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 11px; outline: none; min-width: 0; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-15); }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2391A1B5' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
textarea { resize: vertical; min-height: 90px; width: 100%; }
input[type=date] { color-scheme: dark; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: #24344c; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--cyan); border: 3px solid var(--navy); box-shadow: 0 0 0 1px var(--cyan); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); border: 3px solid var(--navy); cursor: pointer; }
kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--dim); background: var(--surface); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 13.5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1 1 260px; }
.toolbar .search input { width: 100%; padding-left: 34px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; color: var(--dim); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: #0F1828; border: 1px solid var(--line); gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 550; }
.seg button.on { background: var(--card); color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan-15); }

.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #24344c; border-radius: 22px; cursor: pointer; transition: .18s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #c8d3e0; transition: .18s; }
.switch input:checked + span { background: var(--cyan); }
.switch input:checked + span::before { transform: translateX(16px); background: var(--navy); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--cyan-30); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row b { font-weight: 550; display: block; }
.toggle-row small { color: var(--muted); }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 550;
  border: 1px solid var(--line-2); color: var(--muted); background: rgba(145,161,181,.06); white-space: nowrap; }
.tag.cyan { color: var(--cyan); border-color: var(--cyan-30); background: var(--cyan-08); }
.tag.ok { color: var(--ok); border-color: rgba(54,211,153,.35); background: rgba(54,211,153,.08); }
.tag.warn { color: var(--warn); border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.08); }
.tag.bad { color: var(--bad); border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.08); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.sim-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--warn); border: 1px dashed rgba(251,191,36,.45); padding: 3px 8px; border-radius: 6px; background: rgba(251,191,36,.06); white-space: nowrap; }
.sim-label svg { width: 13px; height: 13px; flex: none; }

.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.li-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--cyan-08); color: var(--cyan); flex: none; }
.li-icon svg { width: 16px; height: 16px; }
.li-title { font-weight: 550; }
.li-sub { color: var(--muted); font-size: 12.5px; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.bar { height: 6px; border-radius: 6px; background: #22324a; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--cyan); transition: width .5s ease; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 550; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 120px; height: 70px; margin: 0 auto 12px; color: var(--cyan); opacity: .7; }

/* ---------------- Memory cards ---------------- */
.mem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.mem-card { cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; gap: 10px; }
.mem-card:hover { border-color: var(--cyan-30); transform: translateY(-1px); }
.mem-card h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.mem-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); align-items: center; }
.mem-meta span { display: inline-flex; align-items: center; gap: 4px; }
.mem-meta svg { width: 13px; height: 13px; }
.score { font-family: var(--mono); font-size: 12px; color: var(--cyan); }
.type-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------------- Drawer / modal / toast ---------------- */
.scrim { position: fixed; inset: 0; background: rgba(4, 8, 16, .6); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); border-left: 1px solid var(--line-2); z-index: 80;
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer.show { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 12px; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin: 20px 0 10px; }

.modal-wrap { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(4, 8, 16, .66); }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55); animation: pop .18s ease; }
.modal-head { padding: 18px 20px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 11px 14px; border-radius: 11px; background: var(--card);
  border: 1px solid var(--line-2); box-shadow: 0 16px 40px rgba(0,0,0,.45); animation: slide .2s ease; font-size: 13px; }
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok svg { color: var(--ok); } .toast.warn svg { color: var(--warn); } .toast.bad svg { color: var(--bad); } .toast.info svg { color: var(--cyan); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Graph ---------------- */
.graph-wrap { position: relative; height: 620px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #12203400 0, #0c1424 100%), repeating-linear-gradient(0deg, transparent 0 39px, rgba(145,161,181,.05) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, rgba(145,161,181,.05) 39px 40px); }
.graph-wrap svg { width: 100%; height: 100%; cursor: grab; }
.graph-wrap svg.grabbing { cursor: grabbing; }
.graph-ctrl { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.graph-legend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted);
  background: rgba(11,17,32,.8); padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); }
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.gnode { cursor: pointer; }
.gnode text { font-size: 11px; fill: var(--muted); pointer-events: none; }
.gnode.dim, .gedge.dim { opacity: .12; }
.gnode.sel text { fill: var(--text); font-weight: 600; }
.gedge { stroke: rgba(145,161,181,.28); stroke-width: 1.2; }
.gedge.hl { stroke: var(--cyan); stroke-width: 2; }

/* ---------------- Timeline ---------------- */
.tl { position: relative; padding-left: 28px; }
.tl::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: linear-gradient(var(--cyan-30), var(--line)); }
.tl-group { margin-bottom: 22px; }
.tl-group-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan); margin: 0 0 10px -28px; padding-left: 28px; position: relative; }
.tl-group-label::before { content: ""; position: absolute; left: 4px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--cyan); }
.tl-item { position: relative; margin-bottom: 10px; }
.tl-item::before { content: ""; position: absolute; left: -23px; top: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tl-item.important::before { background: var(--warn); box-shadow: 0 0 0 4px rgba(251,191,36,.15); }
.tl-item.important .card { border-color: rgba(251,191,36,.3); }

/* ---------------- Chat ---------------- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 11px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: #13304a; border-color: var(--cyan-15); border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.captured { box-shadow: inset 3px 0 0 var(--cyan); }
.msg-meta { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--dim); margin-bottom: 4px; flex-wrap: wrap; }
.conv-item { padding: 12px; border-radius: 11px; cursor: pointer; border: 1px solid transparent; }
.conv-item:hover { background: rgba(145,161,181,.05); }
.conv-item.active { background: var(--cyan-08); border-color: var(--cyan-15); }

/* ---------------- Analyzer ---------------- */
.analyzed { line-height: 2; font-size: 15px; padding: 14px; border-radius: 10px; background: #0F1828; border: 1px solid var(--line); }
.w-pos { background: rgba(54,211,153,.16); color: #8ff0c7; border-radius: 4px; padding: 1px 3px; }
.w-neg { background: rgba(251,113,133,.16); color: #ffb3c1; border-radius: 4px; padding: 1px 3px; }
.w-mod { background: rgba(251,191,36,.14); color: #fde08a; border-radius: 4px; padding: 1px 3px; text-decoration: underline dotted; }
.affect-row { display: grid; grid-template-columns: 82px 1fr 44px; gap: 10px; align-items: center; font-size: 12.5px; margin: 7px 0; }
.affect-row b { font-weight: 600; letter-spacing: .04em; font-size: 11.5px; }
.affect-row .num { font-family: var(--mono); color: var(--muted); text-align: right; }
.dominant { display: flex; align-items: center; gap: 16px; }
.dominant .ring { width: 86px; height: 86px; flex: none; }
.dominant h2 { margin: 0; font-size: 24px; letter-spacing: .04em; }

/* ---------------- Code ---------------- */
.code { position: relative; background: #0A101C; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--dim); }
.code pre { margin: 0; padding: 14px; overflow-x: auto; font: 12.5px/1.65 var(--mono); color: #d7e2ee; }
.tk-k { color: #32D6E8; } .tk-s { color: #9be29b; } .tk-c { color: #5d6f86; font-style: italic; } .tk-n { color: #fbbf24; } .tk-f { color: #c4a7ff; } .tk-p { color: #7aa2ff; }
.doc-nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--muted); }
.doc-nav a:hover { color: var(--text); background: rgba(145,161,181,.06); }
.doc-nav a.on { color: var(--cyan); background: var(--cyan-08); }

/* ---------------- Token card ---------------- */
.token-card { position: relative; overflow: hidden; border-color: color-mix(in srgb, var(--chain) 35%, transparent); }
.token-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(420px 180px at 100% 0%, color-mix(in srgb, var(--chain) 18%, transparent), transparent 70%); pointer-events: none; }
.token-card > * { position: relative; }
.token-ca-full.tba { word-break: normal; font-family: var(--font); color: var(--muted); }
.token-ca-full { font-family: var(--mono); font-size: 13px; word-break: break-all; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 9px;
  background: rgba(0,0,0,.28); border: 1px solid color-mix(in srgb, var(--chain) 30%, transparent); line-height: 1.5; }

/* ---------------- Misc components ---------------- */
.provider-icon, .hook-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--cyan-08); border: 1px solid var(--cyan-15); color: var(--cyan); flex: none; }
.provider-icon svg, .hook-icon svg { width: 24px; height: 24px; }
.card.selected { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan-30), 0 0 30px -10px var(--cyan-30); }
.archetype-art { height: 120px; display: grid; place-items: center; color: var(--cyan); background: radial-gradient(circle, var(--cyan-08), transparent 70%); border-radius: 12px; margin-bottom: 12px; }
.archetype-art svg { width: 130px; height: 110px; }
.path-list code { display: block; font-family: var(--mono); font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: #0F1828; border: 1px solid var(--line); margin-bottom: 6px; color: var(--text); }
.progress-ring circle { transition: stroke-dashoffset .6s ease; }
.log { font: 12px/1.7 var(--mono); background: #0A101C; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-height: 190px; overflow-y: auto; color: var(--muted); }
.log .t { color: var(--dim); } .log .i { color: var(--cyan); } .log .o { color: var(--ok); } .log .w { color: var(--warn); }
.settings-nav button { display: flex; width: 100%; padding: 9px 12px; border: 0; background: none; color: var(--muted); border-radius: 9px; cursor: pointer; text-align: left; font-weight: 500; }
.settings-nav button:hover { color: var(--text); background: rgba(145,161,181,.06); }
.settings-nav button.on { color: var(--cyan); background: var(--cyan-08); }
.color-swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.color-swatch.on { border-color: var(--text); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .g-3, .g-side, .g-side-l { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .top-search { max-width: 260px; }
  .status-pill .txt { display: none; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar) !important; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  body.nav-open .sidebar { transform: none; z-index: 75; }
  body.collapsed .brand-text, body.collapsed .nav a span { display: initial; }
  body.collapsed .nav a { justify-content: flex-start; padding: 8px 10px; }
  body.collapsed .nav-label { visibility: visible; height: auto; padding: 0 10px 6px; }
  .main, body.collapsed .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .sidebar-foot { display: none; }
  .g-2, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .top-search { display: none; }
  .content { padding: 16px; }
  .topbar, .tokenbar { padding-left: 16px; padding-right: 16px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head .illus { margin: 0; width: 140px; height: 80px; }
  .graph-wrap { height: 460px; }
  .msg { max-width: 92%; }
  .kv { grid-template-columns: 110px 1fr; }
  .agent-sel .txt { display: none; }
}
@media (max-width: 520px) {
  .mem-grid { grid-template-columns: minmax(0, 1fr); }
  .page-crumb { display: none; }
  .status-pill { display: none; }
  .stat .value { font-size: 22px; }
}

/* Compact density */
body.compact .card { padding: 14px; }
body.compact .content { padding: 18px; }
body.compact .grid { gap: 12px; }
body.compact .list-item { padding: 8px 0; }
body.compact .nav a { padding: 6px 10px; }
