:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #16181d;
  --muted: #5f6672;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #e6f4f2;
  --danger: #c2410c;
  --ok: #15803d;
  --code: #1f2937;
  --code-key: #0f766e;
  --code-str: #9a3412;
  --code-num: #1d4ed8;
  --thumb: #c3c9d1;
  --radius: 8px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1013;
  --surface: #16191e;
  --surface-2: #1d2127;
  --border: #2a2f37;
  --text: #e7e9ed;
  --muted: #9aa1ac;
  --accent: #2dd4bf;
  --accent-text: #06221f;
  --accent-soft: #12302d;
  --danger: #fb923c;
  --ok: #4ade80;
  --code: #d4d8de;
  --code-key: #5eead4;
  --code-str: #fdba74;
  --code-num: #93c5fd;
  --thumb: #3a414b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg.lucide { width: 16px; height: 16px; stroke-width: 2; flex: none; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* Header */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600;
}

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { width: 34px; padding: 0; }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn:focus-visible, .select:focus-visible, textarea:focus-visible, input:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.select {
  height: 34px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
}
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tab { height: 32px; padding: 0 12px; border: 0; background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tab + .tab { border-left: 1px solid var(--border); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Tooltips */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; z-index: 50; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 280px; padding: 7px 10px; border-radius: 6px;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 400; line-height: 1.45; white-space: normal; text-align: left;
  pointer-events: none;
}
[data-tip].tip-left:hover::after { left: auto; right: 0; transform: none; }
.info { display: inline-flex; color: var(--muted); cursor: help; }
.info svg.lucide { width: 15px; height: 15px; }

/* Layout */
.grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px;
  padding: 16px 20px; height: calc(100% - 57px);
}
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; height: auto; } .panel { min-height: 70vh; } }
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.panel-head, .panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px;
}
.panel-head { border-bottom: 1px solid var(--border); }
.panel-foot { border-top: 1px solid var(--border); }
.panel h2 { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

textarea#raw {
  flex: 1; min-height: 0; width: 100%; resize: none; border: 0; padding: 14px; background: transparent;
  font: 13px/1.6 "JetBrains Mono", Consolas, monospace; outline: none;
}
.out { flex: 1; min-height: 0; overflow: auto; }
pre#json {
  margin: 0; padding: 14px; font: 13px/1.6 "JetBrains Mono", Consolas, monospace; color: var(--code);
  white-space: pre-wrap; word-break: break-word;
}
.j-key { color: var(--code-key); }
.j-str { color: var(--code-str); }
.j-num { color: var(--code-num); }
.empty { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.empty svg.lucide { width: 28px; height: 28px; margin-bottom: 6px; }

/* Table view */
table.acc { width: 100%; border-collapse: collapse; font-size: 13px; }
.acc th, .acc td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.acc th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); }
.acc td.mono { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.acc .svc { font-weight: 600; text-transform: capitalize; }
.acc .group td { background: var(--accent-soft); color: var(--accent); font-weight: 600; text-transform: capitalize; }
.copy { cursor: copy; border-radius: 4px; }
.copy:hover { background: var(--surface-2); }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; margin: 1px 2px 1px 0; }

/* Status + progress */
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 2px; background: transparent; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 8px; min-width: 220px; max-width: 360px; padding: 10px 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  font-size: 13px; animation: toast-in .18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.error svg { color: var(--danger); }
.toast.ok svg { color: var(--ok); }
@keyframes toast-in { from { opacity: 0; } to { opacity: 1; } }

/* Login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 360px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; gap: 14px;
}
.login .brand { justify-content: center; font-size: 17px; }
.login .brand img { width: 32px; height: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.input {
  height: 38px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg);
}
.login .btn { height: 38px; }
.theme-corner { position: fixed; top: 12px; right: 12px; }
