:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: rgba(19, 22, 31, 0.86);
  --panel-solid: #13161f;
  --panel-2: #191d28;
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(154, 125, 255, 0.35);
  --text: #f3f1fa;
  --muted: #9b9aaa;
  --faint: #6f7080;
  --purple: #9a7dff;
  --purple-2: #6e4cf5;
  --cyan: #5dd6d0;
  --green: #63d89d;
  --orange: #ffae66;
  --red: #ff7285;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 16% -10%, rgba(110, 76, 245, 0.24), transparent 33rem),
    radial-gradient(circle at 88% 12%, rgba(93, 214, 208, 0.08), transparent 28rem),
    var(--bg);
}
button, input { font: inherit; }
button { color: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 26px 18px;
  border-right: 1px solid var(--border); background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(18px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  color: #fff; font-weight: 850; letter-spacing: -0.05em;
  background: linear-gradient(145deg, var(--purple), var(--purple-2));
  box-shadow: 0 12px 30px rgba(110, 76, 245, 0.34);
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.02em; }
.brand span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.nav { display: grid; gap: 6px; }
.nav button {
  border: 0; background: transparent; border-radius: 11px; text-align: left; padding: 11px 12px;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 11px;
}
.nav button:hover { background: rgba(255,255,255,.045); color: var(--text); }
.nav button.active { background: rgba(154,125,255,.13); color: #d8cdff; }
.nav-icon { width: 20px; text-align: center; opacity: .9; }
.profile {
  position: absolute; left: 18px; right: 18px; bottom: 20px; padding: 12px;
  border: 1px solid var(--border); border-radius: 14px; background: rgba(255,255,255,.025);
}
.profile-row { display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #242939; color: #d8cdff; font-weight: 700; }
.profile strong { font-size: 13px; display: block; }
.profile small { color: var(--muted); }
.logout { border: 0; background: transparent; color: var(--faint); cursor: pointer; padding: 8px 0 0 44px; font-size: 12px; }
.logout:hover { color: var(--red); }

.main { min-width: 0; padding: 30px clamp(20px, 4vw, 52px) 60px; }
.main-fixed { height: 100vh; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.main-fixed .topbar { flex: 0 0 auto; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { color: var(--purple); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 750; }
h1 { margin: 5px 0 0; font-size: clamp(28px, 3vw, 42px); line-height: 1.05; letter-spacing: -.045em; }
.subtitle { margin: 10px 0 0; color: var(--muted); max-width: 700px; line-height: 1.55; }
.status-pill { border: 1px solid rgba(99,216,157,.2); background: rgba(99,216,157,.08); color: var(--green); padding: 8px 11px; border-radius: 999px; font-size: 12px; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.card { border: 1px solid var(--border); border-radius: 17px; background: var(--panel); box-shadow: var(--shadow); }
.metric { padding: 18px; min-height: 130px; }
.metric-label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.metric-value { font-size: 30px; font-weight: 760; letter-spacing: -.04em; margin-top: 15px; }
.metric-detail { color: var(--faint); font-size: 11px; margin-top: 5px; }
.bar { height: 5px; background: rgba(255,255,255,.06); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple-2), var(--purple)); }
.bar.cyan > span { background: linear-gradient(90deg, #318f9d, var(--cyan)); }
.bar.orange > span { background: linear-gradient(90deg, #cc7044, var(--orange)); }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 30px 0 13px; }
.section-title h2 { font-size: 16px; margin: 0; letter-spacing: -.015em; }
.section-title span { color: var(--faint); font-size: 12px; }
.instances { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.instance { padding: 18px; }
.instance-head { display: flex; justify-content: space-between; align-items: center; }
.instance-name { display: flex; gap: 11px; align-items: center; }
.instance-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px rgba(99,216,157,.6); }
.instance h3 { margin: 0; font-size: 15px; }
.instance-state { color: var(--green); font-size: 11px; }
.instance-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.tiny-label { color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.tiny-value { margin-top: 5px; font-size: 14px; }

.vault-layout { flex: 1; height: auto; min-height: 0; display: grid; grid-template-columns: 330px minmax(0,1fr); overflow: hidden; }
.file-pane { border-right: 1px solid var(--border); min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.pane-head { padding: 16px; border-bottom: 1px solid var(--border); }
.search {
  width: 100%; border: 1px solid var(--border); background: #0c0f16; color: var(--text);
  border-radius: 11px; padding: 10px 12px; outline: none;
}
.search:focus { border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(154,125,255,.08); }
.file-list { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 8px; scrollbar-gutter: stable; }
.folder-label { padding: 12px 9px 5px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; font-size: 9px; }
.file-item { width: 100%; border: 0; background: transparent; border-radius: 9px; color: var(--muted); text-align: left; padding: 9px 10px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item:hover, .file-item.active { background: rgba(154,125,255,.1); color: var(--text); }
.note-pane { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: clamp(24px, 5vw, 70px); scrollbar-gutter: stable; }
.note { max-width: 850px; margin: 0 auto; }
.note-path { color: var(--faint); font-size: 11px; margin-bottom: 24px; }
.note h1 { font-size: 34px; margin: 0 0 28px; }
.note h2 { margin: 32px 0 12px; font-size: 21px; }
.note h3 { margin: 26px 0 10px; font-size: 17px; }
.note p, .note li { color: #cbc9d5; line-height: 1.75; }
.note code { background: #0c0f16; border: 1px solid var(--border); border-radius: 5px; padding: 2px 5px; }
.note pre { background: #0c0f16; border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow: auto; }
.note a { color: var(--cyan); }
.empty { height: 100%; min-height: 300px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }

.graph-card { flex: 1; height: auto; min-height: 0; overflow: hidden; position: relative; }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-legend { position: absolute; left: 16px; bottom: 16px; background: rgba(9,11,16,.75); border: 1px solid var(--border); padding: 10px 12px; border-radius: 10px; color: var(--muted); font-size: 11px; backdrop-filter: blur(10px); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 430px); padding: 30px; border: 1px solid var(--border); border-radius: 22px; background: rgba(18,21,30,.92); box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 30px; }
.auth-card h1 { font-size: 28px; }
.auth-card p { color: var(--muted); line-height: 1.6; }
.field { display: grid; gap: 7px; margin-top: 16px; }
.field label { color: var(--muted); font-size: 12px; }
.field input { border: 1px solid var(--border); background: #0c0f16; color: var(--text); border-radius: 11px; padding: 12px; outline: none; }
.field input:focus { border-color: var(--border-bright); }
.primary { width: 100%; margin-top: 22px; border: 0; border-radius: 11px; padding: 12px; background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: #fff; font-weight: 700; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: wait; }
.error { margin-top: 14px; color: #ff9aaa; font-size: 12px; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.08), rgba(255,255,255,.03)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 22px 12px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand-copy, .nav-label, .profile-copy, .logout { display: none; }
  .nav button { justify-content: center; padding: 12px; }
  .profile { left: 12px; right: 12px; padding: 9px; }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .vault-layout { grid-template-columns: 280px 1fr; }
}
@media (max-width: 640px) {
  .shell { display: block; padding-bottom: 70px; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 64px; padding: 7px 12px; border-right: 0; border-top: 1px solid var(--border); }
  .brand, .profile { display: none; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .nav button { display: grid; gap: 1px; text-align: center; font-size: 9px; padding: 7px; }
  .nav-label { display: block; }
  .main { padding: 22px 14px 30px; }
  .main-fixed { height: calc(100vh - 64px); padding-bottom: 14px; }
  .topbar { margin-bottom: 20px; }
  .status-pill { display: none; }
  .metrics, .instances { grid-template-columns: 1fr; }
  .vault-layout { height: auto; min-height: 0; display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(190px, 38%) minmax(0, 1fr); }
  .file-pane { border-right: 0; height: auto; min-height: 0; border-bottom: 1px solid var(--border); }
  .note-pane { min-height: 0; padding: 28px 20px; }
  .graph-card { height: auto; min-height: 0; }
}
