:root {
  --topbar-height: 4rem;
  --radius: 0.625rem;
  --radius-md: calc(var(--radius) - 2px);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-xl: calc(var(--radius) + 4px);

  --nebula: #6a0dad;
  --nebula-muted: #e1b7ff;
  --capella-gold: #e6c36a;
  --polaris: #c9ccd6;
  --aqua: #92e6e8;
  --azure: #7aacf0;
  --peach: #fddece;
  --burnt-orange: #b24209;

  --success: #30b209;
  --warning: #ff9d00;
  --destructive: #c3131c;

  --background: oklch(1 0 0);
  --foreground: oklch(0.129 0.042 264.695);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.129 0.042 264.695);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.129 0.042 264.695);
  --primary: oklch(0.208 0.042 265.755);
  --primary-foreground: oklch(0.984 0.003 247.858);
  --secondary: oklch(0.968 0.007 247.896);
  --secondary-foreground: oklch(0.208 0.042 265.755);
  --surface-muted: oklch(0.968 0.007 247.896);
  --muted-foreground: oklch(0.554 0.046 257.417);
  --surface-accent: oklch(0.968 0.007 247.896);
  --accent-foreground: oklch(0.208 0.042 265.755);
  --border: oklch(0.929 0.013 255.508);
  --input: oklch(0.929 0.013 255.508);
  --ring: var(--nebula);
  --sidebar: oklch(0.984 0.003 247.858);
  --sidebar-foreground: oklch(0.129 0.042 264.695);
  --sidebar-border: oklch(0.929 0.013 255.508);

  --bg: var(--background);
  --surface: var(--card);
  --text: var(--foreground);
  --muted: var(--muted-foreground);
  --accent: var(--primary);
  --danger: var(--destructive);

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow: var(--shadow-sm);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

.dark {
  --background: oklch(0.129 0.042 264.695);
  --foreground: oklch(0.984 0.003 247.858);
  --card: oklch(0.208 0.042 265.755);
  --card-foreground: oklch(0.984 0.003 247.858);
  --popover: oklch(0.208 0.042 265.755);
  --popover-foreground: oklch(0.984 0.003 247.858);
  --primary: oklch(0.929 0.013 255.508);
  --primary-foreground: oklch(0.208 0.042 265.755);
  --secondary: oklch(0.279 0.041 260.031);
  --secondary-foreground: oklch(0.984 0.003 247.858);
  --surface-muted: oklch(0.279 0.041 260.031);
  --muted-foreground: oklch(0.704 0.04 256.788);
  --surface-accent: oklch(0.279 0.041 260.031);
  --accent-foreground: oklch(0.984 0.003 247.858);
  --destructive: #b24209;
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: var(--nebula-muted);
  --sidebar: oklch(0.208 0.042 265.755);
  --sidebar-foreground: oklch(0.984 0.003 247.858);
  --sidebar-border: oklch(1 0 0 / 10%);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.5), 0 1px 2px -1px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

button, a, input, .tab {
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

button:focus-visible, a:focus-visible, input:focus-visible, .tab:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}

button:disabled { opacity: 0.5; cursor: wait; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-row {
  min-height: 4rem;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--foreground);
  text-decoration: none;
}
.brand:hover { opacity: 0.8; }
.logo { height: 32px; width: auto; display: block; }
.dark .logo { filter: invert(1); }
.product { margin: 0 8px 0 10px; font-size: 14px; font-weight: 500; color: var(--foreground); }

.tabs { display: flex; gap: 4px; flex: 1; align-items: center; }
.tab {
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 500;
}
.tab:hover, .tab.active { background: var(--surface-accent); }
.tab.active { color: var(--foreground); }

.cluster { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icon-button.nav-toggle { display: none; }

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  padding: 0;
}
.icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { background: var(--surface-accent); color: var(--foreground); }

.account { position: relative; }
.avatar {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: var(--nebula);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  box-shadow: none;
}
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 240px;
  padding: 4px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.identity { padding: 8px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.identity .name { font-size: 14px; font-weight: 500; }
.identity .email { font-size: 12px; color: var(--muted-foreground); }
.menu-label { font-size: 12px; font-weight: 500; color: var(--muted-foreground); padding: 8px 8px 4px; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 14px;
  box-shadow: none;
}
.menu-item:hover { background: var(--surface-accent); }

.segment {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  margin: 0 4px 6px;
}
.segment label { flex: 1; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
}
.segment input:checked + span {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}
.dark .segment input:checked + span { background: var(--input); }
.segment input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }

main { padding: 24px; }
.prose { max-width: 40rem; margin: 0 auto; padding: 32px 24px 64px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}
.title-block { margin-right: auto; display: flex; align-items: center; gap: 8px; }
h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.search { position: relative; flex: 1 1 320px; max-width: 560px; min-width: 240px; }
.search svg {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted-foreground);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.search input { padding-left: 32px; }

.page-actions { display: flex; gap: 8px; }

.btn, button.btn, .page-actions button, .dialog-actions button, .lightbox-actions button {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}
.dark .btn, .dark button.btn, .dark .page-actions button, .dark .dialog-actions button, .dark .lightbox-actions button {
  background: color-mix(in oklab, var(--input) 30%, transparent);
}
.btn:hover, .page-actions button:hover, .dialog-actions button:hover, .lightbox-actions button:hover {
  background: var(--surface-accent);
}
.primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.primary:hover, button.primary:hover {
  background: color-mix(in oklab, var(--primary) 90%, transparent);
  border-color: transparent;
}
.btn.small, button.small { height: 28px; padding: 0 10px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
label, .field label { font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
input[type="email"], input[type="text"], input[type="search"] {
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: transparent;
  box-shadow: var(--shadow-xs);
}
.dark input[type="email"], .dark input[type="text"], .dark input[type="search"] {
  background: color-mix(in oklab, var(--input) 30%, transparent);
}
input::placeholder { color: var(--muted-foreground); }
input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.hint { margin: 8px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted-foreground); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 -24px 12px;
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-muted) 20%, transparent);
  color: var(--muted-foreground);
  font-size: 12.5px;
}
input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--nebula); }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; vertical-align: top; }
th {
  font-weight: 500;
  color: var(--muted-foreground);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 8px 12px;
  background: color-mix(in oklab, var(--surface-muted) 50%, var(--card));
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: color-mix(in oklab, var(--surface-accent) 40%, transparent); }
tr.selected { background: color-mix(in oklab, var(--nebula) 6%, transparent); box-shadow: inset 3px 0 0 var(--nebula); }
.clip { max-width: 420px; }
.clip strong, .clip span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip span, .meta { color: var(--muted-foreground); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted-foreground); }

.status {
  display: inline-flex;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  text-transform: lowercase;
}
.status.ok { background: color-mix(in oklab, var(--success) 20%, white); color: color-mix(in oklab, var(--success) 70%, black); }
.status.warn { background: color-mix(in oklab, var(--warning) 20%, white); color: color-mix(in oklab, var(--warning) 65%, black); }
.status.bad { background: color-mix(in oklab, var(--destructive) 30%, white); color: color-mix(in oklab, var(--destructive) 70%, black); }

.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.banner.ok { background: color-mix(in oklab, var(--success) 20%, white); color: color-mix(in oklab, var(--success) 70%, black); }
.banner.warn { background: color-mix(in oklab, var(--warning) 20%, white); color: color-mix(in oklab, var(--warning) 65%, black); }
.banner.bad { background: color-mix(in oklab, var(--destructive) 30%, white); color: color-mix(in oklab, var(--destructive) 70%, black); }

.panel {
  border-radius: var(--radius-xl);
  padding: 16px;
  background: var(--card);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--foreground) 10%, transparent);
}
.panel h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.note { margin: 0 0 12px; color: var(--muted-foreground); font-size: 13px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--card);
}
.kpi b { display: block; font-size: 24px; font-weight: 620; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted-foreground); }

iframe.preview {
  width: 100%;
  height: 720px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: white;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 16px 24px 28px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.backdrop, .lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}
.lightbox-backdrop { z-index: 55; }
.backdrop { z-index: 65; display: grid; place-items: center; padding: 16px; }
.dialog {
  width: min(480px, calc(100vw - 32px));
  z-index: 66;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  box-shadow: 0 16px 48px rgba(10, 12, 16, 0.28);
}
.dialog h2, .lightbox h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dialog-title, .lightbox-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dialog-actions, .lightbox-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog p { margin: 0; }

.lightbox-backdrop { display: grid; place-items: center; padding: 20px; }
.lightbox {
  width: min(720px, calc(100vw - 40px));
  max-height: min(92vh, 1000px);
  overflow: auto;
  z-index: 56;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px -20px rgba(15, 23, 42, 0.45);
  padding: 16px;
}
.lightbox .meta { margin: 8px 0; }
.lightbox li { margin: 4px 0; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .topbar-row { padding: 0 12px; }
  .logo { height: 26px; }
  .icon-button.nav-toggle { display: inline-flex; width: 22px; height: 44px; }
  .tabs {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 4px;
  }
  .topbar.open .tabs { display: flex; }
  .tab { height: 44px; justify-content: flex-start; font-size: 15px; padding: 0 12px; text-align: left; }
  iframe.preview { height: 520px; }
  .search { min-width: 0; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop, .lightbox-backdrop, .menu, .tabs { transition: none; }
}
