:root {
  --background: #faf5f2;
  --foreground: #1a0c10;
  --card: #ffffff;
  --primary: #b8184a;
  --primary-text: #ffffff;
  --secondary: #fdedf3;
  --muted: #ede5e1;
  --muted-foreground: #8a6c72;
  --input: #f4ebe8;
  --border: rgba(26, 12, 16, 0.09);
  --border-strong: rgba(26, 12, 16, 0.18);
  --success: #1a7a4a;
  --success-bg: #edfbf3;
  --danger: #d92d42;
  --shadow: 0 18px 50px rgba(26, 12, 16, 0.08);
  color-scheme: light;
}

:root.dark {
  --background: #1a0a0e;
  --foreground: #f9eff2;
  --card: #250f17;
  --primary: #e0507a;
  --primary-text: #ffffff;
  --secondary: #3a1622;
  --muted: #2e1219;
  --muted-foreground: #b997a1;
  --input: #2e1219;
  --border: rgba(249, 239, 242, 0.1);
  --border-strong: rgba(249, 239, 242, 0.2);
  --success: #3ab870;
  --success-bg: #0d2a1a;
  --danger: #e84060;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { padding: 28px; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--card) 82%, transparent); position: sticky; top: 0; height: 100vh; }
.brand-lockup { display: flex; gap: 14px; align-items: center; margin-bottom: 34px; }
.brand-mark { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--primary); color: var(--primary-text); font-weight: 900; }
.eyebrow { margin: 0 0 6px; color: var(--muted-foreground); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 20px; }
h2 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 48px); line-height: 1; }
h3 { margin-bottom: 0; font-size: 18px; }
.page-heading p:last-child { color: var(--muted-foreground); }
.nav-list { display: grid; gap: 10px; }
.nav-item { border: 0; border-radius: 14px; padding: 14px 16px; text-align: left; color: var(--muted-foreground); background: transparent; font-weight: 800; transition: .2s ease; }
.nav-item.active, .nav-item:hover { color: var(--foreground); background: var(--secondary); }
.main-panel { padding: 36px; overflow: hidden; }
.page { display: none; max-width: 1180px; margin: 0 auto; animation: pageIn .28s ease; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 28px 0; }
.stat-card, .panel, .form-panel, .settings-row, .agent-card, .chat-layout { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-card { border-radius: 18px; padding: 20px; }
.stat-card span { color: var(--muted-foreground); font-size: 13px; font-weight: 800; }
.stat-card strong { display: block; margin-top: 14px; font-size: 34px; }
.panel, .form-panel, .chat-layout { border-radius: 24px; padding: 22px; }
.section-title, .row-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.text-button { border: 0; background: transparent; color: var(--primary); font-weight: 900; }
.form-panel { display: grid; gap: 16px; max-width: 680px; }
label { display: grid; gap: 8px; color: var(--muted-foreground); font-size: 13px; font-weight: 900; }
input, select { width: 100%; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--input); color: var(--foreground); padding: 14px 16px; outline: none; }
input:focus, select:focus { border-color: var(--primary); }
.primary-button, .secondary-button, .send-button { border: 0; border-radius: 16px; background: var(--primary); color: var(--primary-text); padding: 14px 18px; font-weight: 900; }
.primary-button.small { padding: 11px 14px; }
.secondary-button { background: var(--secondary); color: var(--primary); }
.agent-list { display: grid; gap: 14px; }
.agent-list.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.agent-card { border-radius: 20px; padding: 18px; }
.agent-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.agent-name { margin: 0 0 6px; font-size: 18px; font-weight: 900; }
.agent-url { margin: 0 0 14px; color: var(--muted-foreground); font-size: 13px; overflow-wrap: anywhere; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-weight: 900; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); box-shadow: 0 0 0 5px var(--success-bg); animation: blink 1.3s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.agent-actions { display: flex; gap: 10px; margin-top: 14px; }
.agent-actions button { flex: 1; }
.chat-layout { min-height: calc(100vh - 72px); display: grid; grid-template-rows: auto 1fr auto; padding: 0; overflow: hidden; }
.chat-header { display: grid; grid-template-columns: 1fr minmax(220px, 360px); gap: 18px; padding: 24px; border-bottom: 1px solid var(--border); }
.chat-transcript { padding: 24px; background: color-mix(in srgb, var(--input) 52%, transparent); overflow-y: auto; }
.message { max-width: 720px; margin-bottom: 16px; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--border); }
.message.user { margin-left: auto; background: var(--secondary); }
.message small { display: block; margin-top: 8px; color: var(--muted-foreground); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 18px 24px; border-top: 1px solid var(--border); }
.send-button { min-width: 88px; }
.settings-stack { display: grid; gap: 14px; max-width: 760px; }
.settings-row { border-radius: 20px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-row span { font-weight: 900; }
.settings-row strong { color: var(--muted-foreground); font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch i { display: block; width: 58px; height: 34px; border-radius: 999px; background: var(--muted); position: relative; transition: .2s ease; }
.switch i::after { content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%; left: 4px; top: 4px; background: var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.12); transition: .2s ease; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(24px); }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--foreground); color: var(--background); padding: 12px 16px; border-radius: 14px; transition: .2s ease; font-weight: 800; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty-state { color: var(--muted-foreground); padding: 18px 0; }

@media (max-width: 860px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 10; height: 72px; padding: 8px 10px; border-right: 0; border-top: 1px solid var(--border); }
  .brand-lockup { display: none; }
  .nav-list { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .nav-item { padding: 10px 4px; text-align: center; font-size: 12px; border-radius: 12px; }
  .main-panel { padding: 22px 16px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-list.compact { grid-template-columns: 1fr; }
  .row-heading, .section-title, .chat-header { align-items: stretch; flex-direction: column; grid-template-columns: 1fr; }
  .chat-layout { min-height: calc(100vh - 116px); }
  .chat-form { grid-template-columns: 1fr auto; padding: 14px; }
  .send-button { min-width: 64px; padding-inline: 14px; }
}
