/* ============================================================
   Synet design system — black & white, shared across all pages.
   ============================================================ */

:root {
  /* Surfaces — pure grayscale */
  --bg-0:      #ffffff;
  --bg-1:      #fafafa;
  --bg-2:      #f4f4f5;
  --surface:   #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;

  /* Lines */
  --border:      #e4e4e7;
  --border-hi:   #d4d4d8;
  --border-faint:#f4f4f5;

  /* Text */
  --text-0:      #09090b;
  --text-1:      #27272a;
  --text-2:      #52525b;
  --text-3:      #a1a1aa;

  /* Accent — black for primary actions */
  --accent:      #09090b;
  --accent-glow: rgba(9, 9, 11, 0.08);

  /* Semantic */
  --good:        #16a34a;
  --good-dim:    rgba(22, 163, 74, 0.08);
  --good-line:   rgba(22, 163, 74, 0.25);
  --warn:        #ca8a04;
  --warn-dim:    rgba(202, 138, 4, 0.08);
  --warn-line:   rgba(202, 138, 4, 0.25);
  --bad:         #dc2626;
  --bad-dim:     rgba(220, 38, 38, 0.08);
  --bad-line:    rgba(220, 38, 38, 0.25);

  /* Gradients — removed. Use solid colors only. */
  --grad-primary: #09090b;
  --grad-soft:    transparent;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg:   0 8px 24px -4px rgba(0,0,0,0.08);

  /* Radii */
  --r-sm:  6px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;
  --r-full: 999px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Sidebar sizing */
  --sidebar-w:          240px;
  --sidebar-w-collapsed:56px;
}


/* === Dark theme === */
[data-theme="dark"] {
  --bg-0:      #09090b;
  --bg-1:      #131316;
  --bg-2:      #1c1c1f;
  --surface:   #131316;
  --surface-2: #1c1c1f;
  --surface-3: #27272a;

  --border:      #27272a;
  --border-hi:   #3f3f46;
  --border-faint:#1c1c1f;

  --text-0:      #fafafa;
  --text-1:      #d4d4d8;
  --text-2:      #a1a1aa;
  --text-3:      #71717a;

  --accent:      #fafafa;
  --accent-glow: rgba(250, 250, 250, 0.08);

  --good:        #22c55e;
  --good-dim:    rgba(34, 197, 94, 0.10);
  --good-line:   rgba(34, 197, 94, 0.25);
  --warn:        #eab308;
  --warn-dim:    rgba(234, 179, 8, 0.10);
  --warn-line:   rgba(234, 179, 8, 0.25);
  --bad:         #ef4444;
  --bad-dim:     rgba(239, 68, 68, 0.10);
  --bad-line:    rgba(239, 68, 68, 0.25);

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.20);
  --shadow-md:   0 2px 8px rgba(0,0,0,0.30);
  --shadow-lg:   0 8px 24px -4px rgba(0,0,0,0.40);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-0);
  background: var(--bg-0);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
code, pre, .mono { font-family: var(--font-mono); }

/* === App shell — sidebar + main === */
.shell { display: flex; min-height: 100vh; }

/* === Sidebar — fixed left rail === */
aside.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s ease;
  z-index: 50;
}
aside.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
aside.sidebar.collapsed .label-text,
aside.sidebar.collapsed .sidebar-section-title { display: none; }
aside.sidebar.collapsed .sidebar-nav-link { justify-content: center; padding: 10px; }
aside.sidebar.collapsed .sidebar-foot .account-id { display: none; }
aside.sidebar.collapsed .sidebar-foot .signout { font-size: 0; padding: 8px; justify-content: center; }
aside.sidebar.collapsed .sidebar-foot .signout::before { content: "←"; font-size: 14px; }
aside.sidebar.collapsed .sidebar-tab { justify-content: center; padding: 10px; }

/* Sidebar head — brand + collapse toggle */
.sidebar-head {
  padding: 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-faint);
  min-height: 64px;
  flex-shrink: 0;
}
.sidebar-head .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  flex: 1; min-width: 0;
  overflow: hidden;
}
.sidebar-head .brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--accent);
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 15px;
  flex-shrink: 0;
}
.sidebar-head .brand-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-0);
}
.sidebar-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-1); border-radius: var(--r-sm);
  width: 28px; height: 28px; flex-shrink: 0;
  display: grid; place-items: center;
  cursor: pointer;
}
.sidebar-toggle:hover { background: var(--surface-2); }

/* Sidebar nav */
.sidebar-nav {
  padding: 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.sidebar-nav-link:hover { background: var(--surface-2); color: var(--text-0); }
.sidebar-nav-link.active { background: var(--surface-3); color: var(--text-0); }
.sidebar-nav-link .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.sidebar-nav-link.active .ico { opacity: 1; }
.sidebar-nav-link[hidden] { display: none; }

.sidebar-section-title {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 16px 12px 6px;
}

.sidebar-tab {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left; width: 100%;
  white-space: nowrap;
  border: 0;
  background: transparent;
}
.sidebar-tab:hover { background: var(--surface-2); color: var(--text-0); }
.sidebar-tab.active { background: var(--surface-3); color: var(--text-0); }
.sidebar-tab .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.sidebar-tab.active .ico { opacity: 1; }


.theme-toggle {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer;
  transition: all 0.15s;
}
.theme-toggle:hover { color: var(--text-0); background: var(--surface-2); }
[data-theme="dark"] .theme-toggle svg circle { fill: var(--text-1); stroke: none; }
[data-theme="dark"] .theme-toggle svg path { opacity: 0; }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border-faint);
  flex-shrink: 0;
}
.sidebar-foot .account-id {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-foot .signout {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: all 0.15s;
}
.sidebar-foot .signout:hover {
  color: var(--bad);
  border-color: var(--bad-line);
  background: var(--bad-dim);
}
.sidebar-foot .signout:active {
  transform: scale(0.98);
}
.sidebar-foot .signout[hidden] {
  display: none !important;
}

/* Main content area */
main.content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  background: var(--bg-0);
}

.content-wrap {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 0;
}
/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  transition: all 0.15s; white-space: nowrap;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #27272a; border-color: #27272a; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-0); border-color: var(--border-hi); }
.btn-icon {
  padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-1); display: grid; place-items: center;
  width: 30px; height: 30px;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text-0); }

/* === Inputs === */
.input {
  width: 100%; padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-0);
  font-size: 14px;
  transition: all 0.15s; outline: none;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }
.input-lg { padding: 12px 14px; font-size: 15px; }

.label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-hi); }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-faint);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-head h3 { font-size: 13px; font-weight: 600; color: var(--text-1); }
.card-body { padding: 18px; }

/* === Status pill === */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 500;
  border: 1px solid;
  font-family: var(--font-mono);
}
.pill-good { background: var(--good-dim); border-color: var(--good-line); color: var(--good); }
.pill-bad  { background: var(--bad-dim);  border-color: var(--bad-line);  color: var(--bad); }
.pill-warn { background: var(--warn-dim); border-color: var(--warn-line); color: var(--warn); }
.pill-info { background: var(--bg-2); border-color: var(--border); color: var(--text-1); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* === Code block === */
.code {
  position: relative; background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 50px 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.6;
  word-break: break-all;
}
.code .copy {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-1);
}
.code .copy:hover { background: var(--surface-2); }
.code .copy.copied { color: var(--good); border-color: var(--good-line); }

/* === Stat === */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.stat .lbl { font-size: 11px; color: var(--text-2); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.stat .lbl .chip { font-size: 9px; padding: 1px 6px; border-radius: 3px; background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .val { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.stat .val.tbd { color: var(--text-3); font-size: 22px; font-weight: 500; }
.stat .val.mono { font-size: 14px; word-break: break-all; }
.stat .sub { font-size: 12px; color: var(--text-2); }
.stat .sub.good { color: var(--good); }
.stat .sub.bad { color: var(--bad); }

/* === K/V list === */
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.kv .k { font-size: 13px; color: var(--text-2); }
.kv .v { font-size: 13px; font-weight: 500; font-family: var(--font-mono); text-align: right; word-break: break-all; }
.kv .v.good { color: var(--good); }
.kv .v.bad { color: var(--bad); }
.kv .v.muted { color: var(--text-3); }

/* === Toast === */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  padding: 12px 18px; background: var(--text-0);
  border: 1px solid var(--text-0);
  color: white;
  border-radius: var(--r-sm); font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: all 0.2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === Empty state === */
.empty {
  text-align: center; padding: 48px 20px;
  color: var(--text-2); font-size: 13px;
}
.empty .empty-title { font-size: 15px; color: var(--text-1); margin-bottom: 4px; }

/* === Helpers === */
.muted { color: var(--text-2); }
.mono { font-family: var(--font-mono); }
.h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.h3 { font-size: 16px; font-weight: 600; }
.text-grad { color: var(--text-0); }
.muted-2 { color: var(--text-3); }
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; } .mt-12 { margin-top: 48px; }

/* === Page header === */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 28px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.page-head .sub { color: var(--text-2); font-size: 14px; margin-top: 4px; max-width: 600px; }

/* === Mobile: sidebar collapses to top bar === */
@media (max-width: 768px) {
  .shell { flex-direction: column; }
  aside.sidebar {
    width: 100% !important;
    height: auto;
    position: sticky;
    top: 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  aside.sidebar .sidebar-head { min-height: 56px; padding: 10px 16px; }
  aside.sidebar .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 6px 8px;
  }
  aside.sidebar .sidebar-nav-link { white-space: nowrap; padding: 8px 12px; }
  aside.sidebar .sidebar-tab { white-space: nowrap; padding: 8px 12px; }
  aside.sidebar .sidebar-section-title { display: none; }
  aside.sidebar.collapsed .sidebar-nav-link { justify-content: flex-start; }
  main.content { padding: 24px 20px 48px; }
}

/* Collapsible sidebar section (Model Marketplace) */
.sidebar-section {
  margin: 0;
}
.sidebar-section-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}
.sidebar-section-toggle:hover { background: var(--surface-2); color: var(--text-0); }
.sidebar-section-toggle .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.sidebar-section-toggle .chevron {
  margin-left: auto;
  width: 12px; height: 12px;
  transition: transform 0.2s;
  opacity: 0.5;
}
.sidebar-section.expanded .chevron { transform: rotate(90deg); }
.sidebar-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  padding-left: 28px;
}
.sidebar-section.expanded .sidebar-children {
  max-height: 500px;
}
.sidebar-children a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px; font-weight: 400;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.sidebar-children a:hover { background: var(--surface-2); color: var(--text-0); }
.sidebar-children a.active { background: var(--surface-3); color: var(--text-0); }
aside.sidebar.collapsed .sidebar-section-toggle { justify-content: center; }
aside.sidebar.collapsed .sidebar-children { display: none; }
aside.sidebar.collapsed .sidebar-section-toggle .label-text,
aside.sidebar.collapsed .sidebar-section-toggle .chevron { display: none; }
