@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --sidebar: #0b1f33;
  --sidebar-2: #0f2a44;
  --sidebar-fg: #c8d4e0;
  --sidebar-muted: #7f93a8;
  --sidebar-active: rgba(6, 182, 212, 0.14);
  --text: #1a2332;
  --text-2: #5b6b7c;
  --text-3: #8a97a6;
  --border: #e4e9ef;
  --border-strong: #d0d8e2;
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-soft: #ecfeff;
  --accent-ring: rgba(8, 145, 178, 0.35);
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.1);
  --sidebar-w: 260px;
  --sidebar-collapsed: 76px;
  --topbar-h: 64px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: 160ms ease;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--text-2); }
.hidden { display: none !important; }

/* —— Shell —— */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--ease);
}
.shell.is-collapsed { grid-template-columns: var(--sidebar-collapsed) 1fr; }

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 18px;
  min-height: 52px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.35);
}
.brand-text strong {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand-text small {
  display: block;
  color: var(--sidebar-muted);
  font-size: 11px;
  margin-top: 1px;
}
.shell.is-collapsed .brand-text { display: none; }

.nav-groups { flex: 1; overflow-y: auto; padding: 0 4px; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 14px 12px 6px;
}
.shell.is-collapsed .nav-label { opacity: 0; height: 8px; padding: 8px 0 0; overflow: hidden; }

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--sidebar-fg);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background var(--ease), color var(--ease);
  margin-bottom: 2px;
}
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-btn.active {
  background: var(--sidebar-active);
  color: #67e8f9;
}
.nav-btn.active svg { opacity: 1; }
.shell.is-collapsed .nav-btn { justify-content: center; padding: 10px; }
.shell.is-collapsed .nav-btn span { display: none; }

.side-foot {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 12px 8px 4px;
  display: grid;
  gap: 8px;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(255,255,255,0.1);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650; color: #fff;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-meta strong { display: block; color: #fff; font-size: 13px; font-weight: 600; }
.user-meta span { display: block; color: var(--sidebar-muted); font-size: 11px; }
.shell.is-collapsed .user-meta { display: none; }
.side-actions { display: flex; gap: 6px; }
.shell.is-collapsed .side-actions { flex-direction: column; }

.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px;
  background: rgba(244, 246, 249, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: #a5f3fc; }
.icon-btn svg { width: 18px; height: 18px; }

.sys-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.sys-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.sys-status.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.sys-status.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.sys-popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 260px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  display: none;
  z-index: 50;
}
.sys-popover.open { display: block; }
.sys-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 8px; border-radius: 8px; font-size: 13px;
}
.sys-row:hover { background: var(--bg); }
.sys-row .name { color: var(--text-2); }
.sys-row .val { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }

.content {
  flex: 1;
  padding: 20px 24px 40px;
  width: 100%;
  max-width: none;
}
.mobile-nav { display: none; }

/* —— Page header —— */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-header p {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 14px;
}
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--text-2);
  cursor: pointer; padding: 0; margin-bottom: 8px; font-size: 13px;
}
.back-link:hover { color: var(--accent); }

/* —— Buttons —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: #fff;
  font-weight: 600; font-size: 13.5px;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease), opacity var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.secondary:hover { background: var(--bg); border-color: #b8c4d1; }
.btn.ghost {
  background: transparent; color: var(--text-2); border-color: transparent;
}
.btn.ghost:hover { background: var(--bg); color: var(--text); }
.btn.danger { background: var(--bad); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

/* —— Cards / metrics —— */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-h h2, .card-h h3 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.card-b { padding: 16px 18px; }
.mt { margin-top: 16px; }
.stack { display: grid; gap: 12px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-height: 96px;
}
.metric .k {
  display: block;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 8px;
}
.metric .v {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.metric .h {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 12px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.tool-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 168px;
}
.tool-card .tool-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.tool-card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.tool-card .stats { display: grid; gap: 4px; color: var(--text-2); font-size: 13px; flex: 1; }
.tool-card .stats strong { color: var(--text); font-weight: 550; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-main { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }

/* —— Status —— */
.st, .status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 550;
  padding: 3px 8px; border-radius: 999px;
  background: #f1f5f9; color: var(--text-2);
}
.st::before, .status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.st.ok, .status.ok { background: var(--ok-soft); color: var(--ok); }
.st.warn, .status.warn { background: var(--warn-soft); color: var(--warn); }
.st.bad, .status.bad { background: var(--bad-soft); color: var(--bad); }

/* —— Filters / toolbar —— */
.toolbar, .filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.search {
  position: relative; flex: 1; min-width: 220px; max-width: 360px;
}
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.search input {
  width: 100%; min-height: 40px; padding: 0 12px 0 36px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--bg-elevated);
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #eef2f6; border-radius: 10px;
}
.seg button {
  border: 0; background: transparent; color: var(--text-2);
  min-height: 32px; padding: 0 12px; border-radius: 8px;
  cursor: pointer; font-weight: 550; font-size: 12.5px;
}
.seg button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* —— Tables —— */
.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
table.data th {
  text-align: left; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3); padding: 12px 14px;
  border-bottom: 1px solid var(--border); background: #fafbfc;
  white-space: nowrap;
}
table.data td {
  padding: 13px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { transition: background var(--ease); }
table.data.selectable tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #f8fafc; }
table.data tbody tr.active { background: var(--accent-soft); }
table.data .row-actions {
  display: flex; gap: 4px; opacity: 0; transition: opacity var(--ease);
  justify-content: flex-end;
}
table.data tbody tr:hover .row-actions,
table.data tbody tr:focus-within .row-actions { opacity: 1; }

/* —— Forms —— */
.field { display: grid; gap: 6px; }
.field > span,
.field-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: help;
  vertical-align: middle;
}
.tip-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  line-height: 11px;
  text-align: center;
  display: grid;
  place-items: center;
  background: #fff;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}
.tip:hover .tip-icon,
.tip:focus .tip-icon,
.tip:focus-visible .tip-icon {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.tip:focus { outline: none; }
.tip-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: min(280px, 70vw);
  padding: 8px 10px;
  border-radius: 8px;
  background: #0b1f33;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.45;
  text-align: left;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  z-index: 90;
}
.tip-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #0b1f33;
}
.tip:hover .tip-bubble,
.tip:focus .tip-bubble,
.tip:focus-visible .tip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.check .tip { margin-left: 2px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
  flex-wrap: wrap;
}
h3 .tip { margin-left: 6px; vertical-align: middle; }
/* Keep tooltip on-screen near right edge */
.field:nth-child(even) .tip-bubble,
.row-3 .field:nth-child(3n) .tip-bubble {
  left: auto;
  right: 0;
  transform: translateY(4px);
}
.field:nth-child(even) .tip-bubble::after,
.row-3 .field:nth-child(3n) .tip-bubble::after {
  left: auto;
  right: 8px;
  transform: none;
}
.field:nth-child(even) .tip:hover .tip-bubble,
.field:nth-child(even) .tip:focus .tip-bubble,
.row-3 .field:nth-child(3n) .tip:hover .tip-bubble,
.row-3 .field:nth-child(3n) .tip:focus .tip-bubble {
  transform: translateY(0);
}
.field input, .field select, .field textarea,
input[type="text"], input[type="search"], input[type="number"], input[type="tel"], input[type="password"],
select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: #fff;
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none;
}
.row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 18px;
  margin-bottom: 14px;
}
.form-section h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 650;
}
.form-footer {
  position: sticky; bottom: 0;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 0 4px;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}

/* —— Prompt editor —— */
.prompt-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.prompt-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.prompt-editor textarea {
  border: 0; border-radius: 0; min-height: 320px; box-shadow: none;
  font-family: var(--mono); font-size: 13px; padding: 16px;
}
.prompt-editor textarea:focus { box-shadow: none; }
.prompt-editor.is-expanded {
  position: fixed; inset: 24px; z-index: 80;
  min-height: auto; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.prompt-editor.is-expanded textarea { flex: 1; min-height: 0; }
.prompt-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 70;
}

/* —— Tabs —— */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.tabs button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 10px 14px; cursor: pointer; font-weight: 550; font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* —— Drawer / Modal —— */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  z-index: 60; display: none;
}
.overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100%);
  background: var(--bg-elevated); z-index: 70;
  transform: translateX(100%); transition: transform 200ms ease;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.drawer-b { flex: 1; overflow: auto; padding: 16px 18px; }
.modal {
  position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(15, 23, 42, 0.4);
}
.modal.open { display: flex; }
.modal-card {
  width: min(440px, 100%); background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 20px;
}
.modal-card h3 { margin: 0 0 8px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* —— Activity —— */
.activity { display: grid; gap: 0; }
.activity-item {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: 0; }
.activity-item .time { color: var(--text-3); font-size: 12px; font-family: var(--mono); padding-top: 2px; }
.activity-item .body { font-size: 13.5px; }
.activity-item .body .tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 6px; margin-right: 6px;
  background: #f1f5f9; color: var(--text-2);
}
.activity-item .body .tag.bad { background: var(--bad-soft); color: var(--bad); }
.activity-item .body .tag.warn { background: var(--warn-soft); color: var(--warn); }

/* —— Talk / chat —— */
.talk-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 16px; min-height: 480px;
}
.chat {
  display: flex; flex-direction: column; min-height: 420px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.chat-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.chat-log {
  flex: 1; overflow: auto; padding: 16px; display: grid; gap: 10px;
  align-content: start;
}
.bubble {
  max-width: 85%; padding: 10px 12px; border-radius: 12px; font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word;
}
.bubble.user { justify-self: end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { justify-self: start; background: #f1f5f9; color: var(--text); border-bottom-left-radius: 4px; }
.bubble.sys { justify-self: center; background: transparent; color: var(--text-3); font-size: 12px; padding: 2px; }
.chat-compose {
  display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border);
}
.log-raw {
  font-family: var(--mono); font-size: 12px; white-space: pre-wrap;
  background: #0b1f33; color: #d7e3ef; border-radius: 10px; padding: 12px;
  max-height: 220px; overflow: auto;
}

/* —— Empty / skeleton / alert —— */
.empty {
  text-align: center; padding: 48px 24px; color: var(--text-2);
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty p { margin: 0 0 16px; font-size: 13.5px; }
.skeleton {
  background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 50%, #eef2f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px; height: 16px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.alert {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13.5px;
}
.alert.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.alert.info { background: var(--accent-soft); border-color: #a5f3fc; color: #155e75; }
.alert.bad { background: var(--bad-soft); border-color: #fecaca; color: #991b1b; }
.kv {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0;
}
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; font-size: 13.5px; }
.pre {
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  background: #0b1f33; color: #fff; padding: 12px 16px;
  border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px;
  max-width: min(360px, calc(100vw - 40px));
}

.provider-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.provider-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.provider-card h3 { margin: 0 0 10px; font-size: 15px; }
.provider-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.provider-meta div { background: var(--bg); border-radius: 8px; padding: 10px; }
.provider-meta .k { display: block; color: var(--text-3); font-size: 11px; margin-bottom: 2px; }
.provider-meta .v { font-weight: 650; font-size: 16px; }

.chart-placeholder {
  height: 180px; border-radius: var(--radius); border: 1px dashed var(--border-strong);
  background: repeating-linear-gradient(-45deg, #fff, #fff 8px, #f8fafc 8px, #f8fafc 16px);
  display: grid; place-items: center; color: var(--text-3); font-size: 13px;
}

/* —— Login —— */
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(800px 400px at 10% 0%, rgba(8,145,178,0.12), transparent 60%),
    radial-gradient(700px 400px at 90% 100%, rgba(11,31,51,0.08), transparent 55%),
    var(--bg);
}
.login-box {
  width: min(400px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 28px;
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.login-box .lead { margin: 0 0 20px; color: var(--text-2); }

/* —— Agent Builder (SalesBot-style) —— */
.builder {
  display: grid;
  grid-template-columns: minmax(340px, 42%) 1fr;
  gap: 16px;
  min-height: 640px;
  align-items: stretch;
}
.builder-pane {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.builder-pane-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.builder-pane-h h2 { margin: 0; font-size: 15px; font-weight: 650; }
.builder-pane-b {
  flex: 1;
  overflow: auto;
  padding: 14px 16px 20px;
}
.builder-add-wrap { position: relative; }
.builder-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
}
.builder-menu.open { display: block; }
.builder-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
}
.builder-menu button:hover { background: var(--accent-soft); color: var(--accent-hover); }

.builder-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fff;
}
.builder-card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.builder-card-h strong { font-size: 13.5px; }
.builder-card .field { margin-bottom: 8px; }

.stress-vowels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
  padding: 10px;
  background: var(--accent-soft);
  border: 1px solid #a5f3fc;
  border-radius: 10px;
}
.stress-vowels button {
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.stress-vowels button:hover { border-color: var(--accent); color: var(--accent); }
.stress-hint {
  font-size: 12.5px;
  color: #155e75;
  margin: 0 0 6px;
  line-height: 1.4;
}

.flow-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.flow-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.flow-palette .btn {
  background: #0b1f33;
  border-color: #0b1f33;
}
.flow-palette .btn:hover { background: #16324d; }

.flow-canvas {
  background:
    radial-gradient(circle, #d0d8e2 1px, transparent 1px);
  background-size: 18px 18px;
  background-color: #f8fafc;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 18px 16px 28px;
  min-height: 420px;
}
.flow-node {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  max-width: 480px;
  box-shadow: var(--shadow);
  position: relative;
  margin: 0 auto 18px;
}
.flow-node::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -18px;
  width: 2px;
  height: 16px;
  background: #cbd5e1;
  transform: translateX(-50%);
}
.flow-node:last-child::after { display: none; }
.flow-node.has-branches::after {
  background: linear-gradient(180deg, #94a3b8, #cbd5e1);
}
.flow-node-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.flow-node-h .badge-type {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.flow-node textarea {
  min-height: 72px;
  font-size: 13px;
}
.flow-transitions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.flow-transitions-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.flow-transitions-h strong {
  font-size: 12.5px;
  font-weight: 650;
}
.flow-branch {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.flow-branch-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr auto;
  gap: 8px;
  align-items: end;
}
.flow-branch-grid .field { margin-bottom: 0; }
.flow-branch-del { align-self: end; margin-bottom: 2px; }
.flow-branch-empty {
  font-size: 12.5px;
  margin: 0 0 8px;
}
@media (max-width: 720px) {
  .flow-branch-grid {
    grid-template-columns: 1fr;
  }
  .flow-branch-del { justify-self: start; }
}
.flow-text-preview {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  background: #0b1f33;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  max-height: 520px;
  overflow: auto;
}
.builder-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 0 0;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 28%);
}

@media (max-width: 1280px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .provider-grid { grid-template-columns: 1fr 1fr; }
  .builder { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .shell, .shell.is-collapsed { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav {
    display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px;
    background: var(--sidebar); position: sticky; top: 0; z-index: 40;
  }
  .mobile-nav .nav-btn { width: auto; white-space: nowrap; color: #fff; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools-grid, .grid-2, .talk-layout, .row-2, .row-3, .provider-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .page-header { flex-direction: column; }
  table.data .row-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
