@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:         #f5f7fa;
  --bg-2:       #eef1f5;
  --surface:    rgba(255,255,255,0.95);
  --surface-2:  rgba(240,243,248,0.9);
  --surface-3:  rgba(230,235,242,0.7);
  --border:     rgba(0,0,0,0.08);
  --border-2:   rgba(0,0,0,0.14);
  --text:       #1a2332;
  --text-2:     #4a5e74;
  --text-3:     #8a9bb0;
  --accent:     #00b899;
  --accent-dim: rgba(0,184,153,0.1);
  --accent-glow:rgba(0,184,153,0.2);
  --amber:      #d48806;
  --amber-dim:  rgba(212,136,6,0.1);
  --green:      #16a34a;
  --green-dim:  rgba(22,163,74,0.1);
  --red:        #dc2626;
  --red-dim:    rgba(220,38,38,0.1);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow:     0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.1);
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --font:       'Outfit', 'Avenir Next', system-ui, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ── DARK MODE ──────────────────────────────────────────── */
html.dark-mode {
  --bg:         #060b14;
  --bg-2:       #090f1c;
  --surface:    rgba(12, 18, 32, 0.92);
  --surface-2:  rgba(16, 24, 42, 0.80);
  --surface-3:  rgba(20, 30, 52, 0.60);
  --border:     rgba(255, 255, 255, 0.07);
  --border-2:   rgba(255, 255, 255, 0.12);
  --text:       #eef2f8;
  --text-2:     #8ba4be;
  --text-3:     #4d6478;
  --accent:     #00e5c0;
  --accent-dim: rgba(0, 229, 192, 0.14);
  --accent-glow:rgba(0, 229, 192, 0.28);
  --amber:      #f5a623;
  --amber-dim:  rgba(245, 166, 35, 0.12);
  --green:      #4ade80;
  --green-dim:  rgba(74, 222, 128, 0.12);
  --red:        #f87171;
  --red-dim:    rgba(248, 113, 113, 0.12);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow:     0 4px 24px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4);
}

html.dark-mode .sidebar {
  background: rgba(8, 12, 22, 0.96);
}

html.dark-mode .sidebar-brand:hover { background: rgba(255,255,255,0.04); }

html.dark-mode .sidebar-item:hover { background: rgba(255,255,255,0.06); }

html.dark-mode .sidebar-logo {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
}

html.dark-mode .auth-card {
  background: rgba(12, 18, 32, 0.95);
}

html.dark-mode .account-avatar {
  background: rgba(0, 229, 192, 0.14);
  border-color: rgba(0, 229, 192, 0.3);
}

html.dark-mode select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238ba4be' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ── MIDNIGHT THEME ─────────────────────────────────────── */
html.theme-midnight {
  --bg:         #0b1224;
  --bg-2:       #0e1630;
  --surface:    rgba(14, 22, 48, 0.94);
  --surface-2:  rgba(18, 28, 56, 0.82);
  --surface-3:  rgba(24, 36, 68, 0.65);
  --border:     rgba(255, 255, 255, 0.07);
  --border-2:   rgba(255, 255, 255, 0.12);
  --text:       #e4ecf8;
  --text-2:     #8aa0c4;
  --text-3:     #4c6590;
  --accent:     #6494ed;
  --accent-dim: rgba(100, 148, 237, 0.14);
  --accent-glow:rgba(100, 148, 237, 0.25);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.6);
}
html.theme-midnight .sidebar { background: rgba(10, 16, 34, 0.97); }
html.theme-midnight .sidebar-brand:hover { background: rgba(255,255,255,0.04); }
html.theme-midnight .sidebar-item:hover { background: rgba(255,255,255,0.06); }
html.theme-midnight .sidebar-logo { border-color: rgba(255,255,255,0.1); background: rgba(255,255,255,0.06); }
html.theme-midnight .atmosphere { background: radial-gradient(ellipse 80% 50% at 10% 0%, rgba(60, 110, 230, 0.12) 0%, transparent 60%), radial-gradient(ellipse 60% 40% at 90% 5%, rgba(100, 148, 237, 0.08) 0%, transparent 55%), var(--bg-2); }
html.theme-midnight .atmosphere::after { background-image: linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px); }
html.theme-midnight select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238aa0c4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }

/* ── SAGE THEME ────────────────────────────────────────── */
html.theme-sage {
  --bg:         #f4f7f4;
  --bg-2:       #ecf1ec;
  --surface:    rgba(255,255,255,0.95);
  --surface-2:  rgba(236,244,236,0.9);
  --surface-3:  rgba(220,234,220,0.7);
  --border:     rgba(0,0,0,0.08);
  --border-2:   rgba(0,0,0,0.13);
  --text:       #1e2e22;
  --text-2:     #4a6650;
  --text-3:     #7fa088;
  --accent:     #3a9468;
  --accent-dim: rgba(58, 148, 104, 0.1);
  --accent-glow:rgba(58, 148, 104, 0.18);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow:     0 4px 24px rgba(0,0,0,0.07);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.09);
}
html.theme-sage .sidebar { background: rgba(248,252,248,0.98); }
html.theme-sage .atmosphere { background: radial-gradient(ellipse 80% 50% at 10% 0%, rgba(58, 148, 104, 0.06) 0%, transparent 60%), radial-gradient(ellipse 60% 40% at 90% 5%, rgba(40, 120, 80, 0.04) 0%, transparent 55%), var(--bg-2); }

/* ── WARM THEME ────────────────────────────────────────── */
html.theme-warm {
  --bg:         #faf6f1;
  --bg-2:       #f4ede4;
  --surface:    rgba(255,255,255,0.95);
  --surface-2:  rgba(248,240,230,0.9);
  --surface-3:  rgba(240,228,214,0.7);
  --border:     rgba(0,0,0,0.08);
  --border-2:   rgba(0,0,0,0.13);
  --text:       #2c2016;
  --text-2:     #6b5744;
  --text-3:     #a08c78;
  --accent:     #d4792c;
  --accent-dim: rgba(212, 121, 44, 0.1);
  --accent-glow:rgba(212, 121, 44, 0.18);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow:     0 4px 24px rgba(0,0,0,0.07);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.09);
}
html.theme-warm .sidebar { background: rgba(255,252,248,0.98); }
html.theme-warm .atmosphere { background: radial-gradient(ellipse 80% 50% at 10% 0%, rgba(212, 121, 44, 0.06) 0%, transparent 60%), radial-gradient(ellipse 60% 40% at 90% 5%, rgba(180, 100, 30, 0.04) 0%, transparent 55%), var(--bg-2); }

/* ── BACKGROUND ─────────────────────────────────────────── */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(0, 180, 150, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 5%, rgba(80, 120, 220, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse 50% 60% at 80% 95%, rgba(20, 60, 140, 0.06) 0%, transparent 50%),
    var(--bg-2);
}

/* subtle grid overlay */
.atmosphere::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
}

html.dark-mode .atmosphere {
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(0, 180, 150, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 5%, rgba(80, 120, 220, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 50% 60% at 80% 95%, rgba(20, 60, 140, 0.10) 0%, transparent 50%),
    var(--bg-2);
}

html.dark-mode .atmosphere::after {
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
}

/* ── AUTH ────────────────────────────────────────────────── */
.auth-gate {
  height: 100vh;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(440px, 95vw);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  display: grid;
  gap: 14px;
  backdrop-filter: blur(20px);
  animation: rise 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-copy {
  color: var(--text-2);
  font-size: 0.88rem;
  line-height: 1.55;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  font: 500 0.9rem/1 var(--font);
  cursor: pointer;
  transition: all 0.18s ease;
}
.google-btn:hover { background: var(--surface-3); border-color: rgba(255,255,255,0.18); }
.google-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  min-height: 18px;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
}

/* ── FORM ELEMENTS ──────────────────────────────────────── */
label {
  display: grid;
  gap: 6px;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

input, select, textarea {
  appearance: none;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 11px 14px;
  font: 400 0.92rem/1.4 var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }

textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

/* Restore native checkbox/radio after global appearance:none override */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
  background: initial;
  border: initial;
  border-radius: initial;
  padding: 0;
  box-shadow: none;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="checkbox"]:focus, input[type="radio"]:focus {
  box-shadow: none;
  border-color: initial;
}

input[type="range"] {
  padding: 0;
  height: 4px;
  border-radius: 999px;
  accent-color: var(--accent);
  background: var(--surface-3);
  border-color: transparent;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a5e74' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
button {
  font: 500 0.88rem/1 var(--font);
  cursor: pointer;
  transition: all 0.18s ease;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 16px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  background: linear-gradient(135deg, rgba(0, 229, 192, 0.24), rgba(0, 229, 192, 0.12));
  color: var(--accent);
  border-color: rgba(0, 229, 192, 0.40);
  font-weight: 600;
}
.primary-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 229, 192, 0.32), rgba(0, 229, 192, 0.18));
  border-color: rgba(0, 229, 192, 0.60);
  box-shadow: 0 0 16px var(--accent-dim);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 40px;
}

.ghost-btn {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.ghost-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

.secondary-btn {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--border);
}
.secondary-btn:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-2);
}

.tiny-btn { font-size: 0.78rem; padding: 7px 12px; }

/* ── SHELL / SIDEBAR LAYOUT ─────────────────────────────── */
.shell {
  display: flex;
  height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  animation: rise 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 228px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.98);
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand / Logo */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 16px;
  border-bottom: 1px solid var(--border);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: background 0.15s;
  flex-shrink: 0;
}
.sidebar-brand:hover { background: rgba(0,0,0,0.03); }

.sidebar-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.04);
  flex-shrink: 0;
}

.sidebar-brand-copy { min-width: 0; }
.sidebar-brand-eyebrow {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 2px;
}
.sidebar-brand-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 14px 8px 4px;
  display: block;
}

/* Sidebar items (the .tab buttons inside the sidebar) */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font: 500 0.84rem/1 var(--font);
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.sidebar-item svg { flex-shrink: 0; opacity: 0.7; transition: opacity 0.12s; }
.sidebar-item:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.sidebar-item:hover svg { opacity: 0.9; }
.sidebar-item.is-active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}
.sidebar-item.is-active svg { opacity: 1; color: var(--accent); }

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-footer .status-chip {
  border-radius: var(--radius-sm);
  width: 100%;
  justify-content: flex-start;
  font-size: 0.76rem;
  padding: 6px 10px;
  background: transparent;
  border-color: transparent;
}

.sidebar-footer .account-trigger {
  width: 100%;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  padding: 7px 10px;
}

.sidebar-footer .account-dropdown {
  left: 0;
  right: auto;
  bottom: calc(100% + 8px);
  top: auto;
  min-width: 208px;
}

/* Theme Select */
.theme-select {
  width: 100%;
  padding: 7px 32px 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--text-2);
  font: 500 0.8rem/1.3 var(--font);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.theme-select:hover { border-color: var(--border-2); color: var(--text); }
.theme-select:focus { border-color: var(--accent); outline: none; }

/* ── MAIN CONTENT AREA ──────────────────────────────────── */
.main-area {
  flex: 1;
  overflow-y: auto;
  height: 100vh;
  padding: 28px 32px 40px;
  min-width: 0;
}

/* topbar-home-btn alias (JS still looks for this class) */
.topbar-home-btn { /* handled via .sidebar-brand above */ }

.dashboard-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.account-menu {
  position: relative;
}

.account-menu summary {
  list-style: none;
}
.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font: 500 0.8rem/1 var(--font);
  cursor: pointer;
  user-select: none;
}
.account-menu[open] .account-trigger {
  border-color: rgba(255,255,255,0.18);
  color: var(--text);
  background: var(--surface-2);
}
.account-trigger svg {
  opacity: 0.72;
  transition: transform 0.18s ease;
}
.account-menu[open] .account-trigger svg {
  transform: rotate(180deg);
}

.account-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(0, 229, 192, 0.14);
  border: 1px solid rgba(0, 229, 192, 0.35);
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 40;
  display: grid;
  gap: 8px;
}

.account-email-label {
  color: var(--text-3);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.account-email {
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.35;
  word-break: break-all;
}

.account-logout-btn {
  justify-self: start;
}

.eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 4px;
}

h1 {
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0); }
}

/* ── TABS (legacy — sidebar-item handles visual style now) ── */
.tab { /* base reset — sidebar-item overrides visuals */ }

/* ── PANELS / CARDS ─────────────────────────────────────── */
.panel { animation: rise 220ms cubic-bezier(0.16, 1, 0.3, 1); }

#analytics-panel {
  min-height: min(62vh, 700px);
  display: grid;
  align-items: start;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-head p {
  color: var(--text-3);
  font-size: 0.78rem;
  white-space: nowrap;
}

.analytics-onboarding-card {
  width: min(760px, 100%);
  margin: 0 auto;
  text-align: center;
}

.analytics-onboarding {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 8px 0;
}

.analytics-illustration {
  width: 92px;
  height: 92px;
  border-radius: 16px;
  border: 1px solid rgba(0, 229, 192, 0.24);
  background: linear-gradient(160deg, rgba(0, 229, 192, 0.09), rgba(31, 67, 134, 0.09));
  display: grid;
  place-items: center;
  color: rgba(177, 223, 255, 0.9);
}

.analytics-onboarding-head {
  width: min(100%, 640px);
  justify-content: center;
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.analytics-onboarding-head h2 {
  font-size: clamp(1.1rem, 2.1vw, 1.35rem);
}

.analytics-onboarding-head p {
  color: #8ca6be;
  font-size: 0.84rem;
}

.analytics-empty-copy {
  width: min(100%, 630px);
  font-size: 0.97rem;
  color: #b7c9db;
  line-height: 1.62;
}

.analytics-onboarding-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

.analytics-doc-link {
  color: #9fc7ff;
  font-size: 0.82rem;
  text-decoration: none;
}
.analytics-doc-link:hover {
  color: #c9e2ff;
  text-decoration: underline;
}

.analytics-source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.analytics-source-card {
  min-height: 0;
}

.analytics-source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.analytics-source-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.analytics-source-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.analytics-source-list span {
  color: var(--text-2);
  font-size: 0.82rem;
}

.analytics-source-list b {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.analytics-source-list b.positive {
  color: var(--green);
}

/* ── KPI GRID ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}

.kpi-label { color: var(--text-2); font-size: 0.78rem; font-weight: 500; margin-bottom: 10px; }
.kpi-value { font-size: clamp(1.35rem, 2.5vw, 1.8rem); font-weight: 700; letter-spacing: -0.03em; margin-bottom: 8px; }
.kpi-delta { font-size: 0.78rem; color: var(--text-3); }
.kpi-delta.positive { color: var(--green); }
.kpi-delta.negative { color: var(--red); }

/* ── GRIDS ───────────────────────────────────────────────── */
.analytics-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.module-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
.card { min-height: 200px; }

/* ── TREND CHART ─────────────────────────────────────────── */
#trend-chart { width: 100%; height: 240px; display: block; }

.x-axis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 6px;
  color: var(--text-3);
  font-size: 0.72rem;
}
.x-axis span { text-align: center; }

/* ── BARS / FUNNEL ──────────────────────────────────────── */
.bar-list, .funnel-list { display: grid; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 10px;
}
.bar-row strong { font-size: 0.8rem; font-weight: 400; color: var(--text-2); }
.bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(0,229,192,0.5));
}
.bar-row em { font-style: normal; font-size: 0.78rem; color: var(--text); text-align: right; }

.funnel-step {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.funnel-step:last-child { border-bottom: none; }
.funnel-step span { color: var(--text-2); font-size: 0.82rem; }
.funnel-step b { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: 8px; }

table { width: 100%; border-collapse: collapse; min-width: 600px; }

th {
  color: var(--text-3);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-2);
  text-align: left;
}

td {
  padding: 10px 8px;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.02); }
html.dark-mode tr:hover td, html.theme-midnight tr:hover td { background: rgba(255,255,255,0.02); }

.status {
  display: inline-block;
  border: 1px solid;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  letter-spacing: 0.04em;
}
.status.scaling { color: var(--green); border-color: rgba(74,222,128,0.35); background: var(--green-dim); }
.status.stable   { color: #7ec8f0; border-color: rgba(126,200,240,0.35); background: rgba(126,200,240,0.08); }
.status.adjust   { color: var(--amber); border-color: rgba(245,166,35,0.35); background: var(--amber-dim); }
.status.pending  { color: var(--amber); border-color: rgba(245,166,35,0.35); background: var(--amber-dim); }
.status.replied  { color: var(--green); border-color: rgba(74,222,128,0.35); background: var(--green-dim); }

/* ── PRICING ─────────────────────────────────────────────── */
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 220px)) 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.snapshot { justify-self: end; color: var(--amber); font-size: 0.82rem; font-family: var(--mono); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.full-row { grid-column: 1 / -1; }
.inline-meta { color: var(--accent); font-size: 0.74rem; margin-top: 4px; }

.price-result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.big-value { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -0.04em; margin-bottom: 8px; }
.muted { color: var(--text-2); font-size: 0.84rem; line-height: 1.55; }

.policy-list {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 7px;
  color: var(--text-2);
  font-size: 0.84rem;
}
.compact-list { margin-top: 8px; gap: 5px; font-size: 0.8rem; }

.package-catalog { display: grid; gap: 16px; margin-bottom: 16px; }
.package-catalog h3 { font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }

.benchmark-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.benchmark-panel h3 { font-size: 0.88rem; font-weight: 600; margin-bottom: 8px; }

/* ── VAULT ────────────────────────────────────────────────── */
.security-warning {
  background: rgba(245, 166, 35, 0.07);
  border: 1px solid rgba(245, 166, 35, 0.2);
  color: #f5c47a;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.form-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 400;
  margin-top: 2px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.email-quick-starts {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.email-qs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.email-qs-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.email-qs-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

#email-draft-status {
  margin: 0;
  min-height: 1.1rem;
}

#email-draft-status.is-error {
  color: var(--red);
}

#email-draft-status.is-success {
  color: var(--green);
}

.email-draft-body {
  min-height: 320px;
  line-height: 1.55;
}

.email-field-row {
  position: relative;
}
.email-field-row input {
  padding-right: 70px;
}
.email-copy-inline {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  font: 500 0.72rem/1 var(--font);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.email-copy-inline:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.email-copy-inline.is-copied {
  background: var(--green-dim);
  color: var(--green);
  border-color: var(--green);
}

/* ── NOTIFICATIONS ────────────────────────────────────────── */
.notification-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.notification-list { display: grid; gap: 10px; }

.notification-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px;
  display: grid;
  gap: 8px;
  transition: border-color 0.15s;
}
.notification-item:hover { border-color: var(--border-2); }

.notification-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.notification-meta { color: var(--text-3); font-size: 0.74rem; }
.notification-review { font-size: 0.86rem; line-height: 1.5; }
.notification-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.notification-row .muted { font-size: 0.76rem; }
.notification-action-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── MARKETING MANAGER ───────────────────────────────────── */
.marketing-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  align-items: start;
}

/* Chat panel */
.marketing-chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chat-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-panel-title h2 {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chat-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.thread-select {
  min-width: 220px;
  max-width: 320px;
  height: 34px;
  padding: 6px 30px 6px 10px;
  border-radius: 10px;
  font-size: 0.76rem;
  color: var(--text-2);
  background-color: var(--surface-2);
}

.chat-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  color: var(--accent);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.marketing-chat-log {
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.marketing-chat-log::-webkit-scrollbar { width: 4px; }
.marketing-chat-log::-webkit-scrollbar-track { background: transparent; }
.marketing-chat-log::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.marketing-message {
  display: grid;
  gap: 6px;
  max-width: 88%;
  animation: msg-in 200ms ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.marketing-message.user { align-self: flex-end; }
.marketing-message.assistant { align-self: flex-start; }

.marketing-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 500;
}

.msg-bubble {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.msg-bubble p { margin: 0; }

.msg-text {
  will-change: contents;
}

.msg-loading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-2);
}

.inline-status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vr-spin 0.75s linear infinite;
  flex-shrink: 0;
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 4px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: typing-caret 0.8s steps(1, end) infinite;
}

@keyframes typing-caret {
  0%, 48% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.marketing-message.user .msg-bubble {
  background: var(--accent-dim);
  border: 1px solid rgba(0,229,192,0.22);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.marketing-message.assistant .msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* keep backward compat for direct p */
.marketing-message p { margin: 0; line-height: 1.55; white-space: pre-wrap; }

/* Video render */
.video-render-wrap { margin-top: 6px; width: 100%; }

.video-render-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--text-2);
}

.video-render-error {
  border-color: rgba(255, 99, 125, 0.45);
  color: #ffb4c1;
}

.video-render-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vr-spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes vr-spin { to { transform: rotate(360deg); } }

.rendered-video {
  width: 100%;
  max-width: 100%;
  max-height: min(64vh, 640px);
  height: auto;
  border-radius: 8px;
  display: block;
  background: #000;
  object-fit: contain;
  margin: 0;
}

.video-render-wrap.video-ready {
  display: grid;
  justify-items: center;
  width: min(100%, 760px);
  padding: 8px;
  border: 1px solid rgba(99, 117, 170, 0.26);
  border-radius: 12px;
  background: rgba(8, 15, 29, 0.58);
}

.video-render-wrap.video-ready.video-portrait {
  width: min(100%, 360px);
}

.video-render-wrap.video-ready.video-portrait .rendered-video {
  width: 100%;
  max-height: min(62vh, 620px);
  aspect-ratio: 9 / 16;
}

.video-render-wrap.video-ready.video-landscape {
  width: min(100%, 760px);
}

.video-render-wrap.video-ready.video-landscape .rendered-video {
  width: 100%;
  max-height: min(62vh, 620px);
  aspect-ratio: 16 / 9;
}

.video-actions { margin-top: 8px; }

.video-download-link {
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.85;
}
.video-download-link:hover { opacity: 1; text-decoration: underline; }

.marketing-message.assistant.has-video { max-width: 100%; width: 100%; }

#marketing-chat-status {
  margin: 0;
  min-height: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
}

#marketing-chat-status[data-state="error"] { color: #ffb4c1; }
#marketing-chat-status[data-state="done"] { color: #8cf5d8; }

.chat-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.chat-status-indicator.sending,
.chat-status-indicator.rendering,
.chat-status-indicator.typing {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0, 229, 192, 0.5);
  animation: status-pulse 1.2s ease-out infinite;
}

.chat-status-indicator.error {
  background: #ff637d;
  box-shadow: 0 0 0 0 rgba(255, 99, 125, 0.45);
  animation: status-pulse 1.2s ease-out infinite;
}

.chat-status-indicator.done {
  background: #21d79e;
}

@keyframes status-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 229, 192, 0.45);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(0, 229, 192, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 229, 192, 0);
  }
}

/* Chat input area */
.chat-input-area {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 10px;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.chat-textarea {
  border-radius: 10px;
  min-height: 76px;
  max-height: 160px;
  resize: none;
  font-size: 0.9rem;
}

.chat-input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-file-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 0.76rem;
  cursor: pointer;
  transition: color 0.15s;
}
.chat-file-label:hover { color: var(--text-2); }

.marketing-chat-form { display: grid; gap: 10px; }
.marketing-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Context sidebar */
.context-sidebar {
  display: grid;
  gap: 14px;
}

.context-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.context-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.context-card-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.context-card-header p {
  font-size: 0.72rem;
  color: var(--text-3);
}

.context-card-body {
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}

.context-card-footer {
  padding: 10px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.context-note {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.74rem;
  line-height: 1.5;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  color: var(--text-3);
  font-size: 0.84rem;
  padding: 28px 0;
  text-align: center;
  line-height: 1.6;
}

/* ── MISC ────────────────────────────────────────────────── */
code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--accent);
}

/* ── ANIMATIONS ─────────────────────────────────────────── */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-grid, .module-grid { grid-template-columns: 1fr; }
  .analytics-source-grid { grid-template-columns: 1fr; }
  .marketing-grid { grid-template-columns: 1fr; }
}

/* Sidebar always stays vertical — this is a desktop dashboard.
   No layout-switching responsive rules for .shell or .sidebar. */

/* ── TAB BADGE ───────────────────────────────────────────── */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  background: var(--accent);
  color: #060b14;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── TOAST ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  animation: toast-in 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
  max-width: 340px;
}

.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success { border-color: rgba(74, 222, 128, 0.3); }
.toast.success::before { background: var(--green); }

.toast.error { border-color: rgba(248, 113, 113, 0.3); }
.toast.error::before { background: var(--red); }

.toast.info { border-color: var(--border-2); }
.toast.info::before { background: var(--accent); }

.toast.fade-out {
  animation: toast-out 280ms cubic-bezier(0.6, 0, 0.4, 1) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

/* ── COMMAND PALETTE ─────────────────────────────────────── */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  animation: rise 120ms ease;
}

html.dark-mode .cmd-palette-overlay, html.theme-midnight .cmd-palette-overlay {
  background: rgba(0,0,0,0.55);
}

.cmd-palette {
  width: min(520px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.cmd-palette input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 16px 20px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
}
.cmd-palette input::placeholder { color: var(--text-3); }

#cmd-palette-list {
  list-style: none;
  padding: 8px;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
}

.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.cmd-palette-item:hover,
.cmd-palette-item.is-selected {
  background: var(--accent-dim);
  color: var(--text);
}
.cmd-palette-item svg { flex-shrink: 0; opacity: 0.6; }
.cmd-palette-item.is-selected svg { opacity: 1; color: var(--accent); }

/* ── PHOTO EDITOR ────────────────────────────────────────── */
.photo-editor-layout {
  display: grid;
  grid-template-columns: 316px 1fr;
  gap: 14px;
  align-items: start;
}

.photo-tool-panel {
  display: grid;
  gap: 10px;
}

.photo-tool-section {
  padding: 14px 16px !important;
  min-height: unset !important;
}

.photo-tool-section .card-head {
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.photo-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-3);
  font-size: 0.84rem;
}

.photo-upload-area:hover,
.photo-upload-area.dragover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.photo-upload-area.has-image {
  border-style: solid;
  border-color: rgba(74, 222, 128, 0.45);
  background: var(--green-dim);
  color: var(--green);
}

.photo-layout-toggle {
  display: flex;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.photo-layout-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.photo-layout-btn:hover { color: var(--text-2); background: var(--surface-3); }

.photo-layout-btn.is-active {
  background: var(--surface-3);
  border-color: var(--border-2);
  color: var(--text);
}

.photo-canvas-container {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#photo-canvas {
  display: block;
  /* JS sets style.width/height to logical px; CSS clamps on small screens */
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  cursor: crosshair;
  box-shadow: var(--shadow-lg);
  background: #0a0f1e;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.photo-layers-list {
  display: grid;
  gap: 5px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.photo-layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.photo-layer-item:hover { border-color: var(--border-2); }

.photo-layer-item.is-selected {
  border-color: rgba(0, 229, 192, 0.5);
  background: var(--accent-dim);
}

.photo-layer-item-type {
  font-size: 0.68rem;
  color: var(--text-3);
  font-family: var(--mono);
  background: var(--surface-3);
  border-radius: 4px;
  padding: 2px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.photo-layer-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.photo-layer-delete {
  color: var(--text-3);
  border: none;
  background: none;
  padding: 2px 5px;
  font-size: 0.76rem;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 4px;
  transition: all 0.15s;
}

.photo-layer-delete:hover { color: var(--red); background: var(--red-dim); }

.photo-empty-state {
  color: var(--text-3);
  font-size: 0.8rem;
  text-align: center;
  padding: 10px 0;
}

@media (max-width: 1100px) {
  .photo-editor-layout { grid-template-columns: 1fr; }
  .photo-canvas-container { position: static; }
}

@media (max-width: 760px) {
  .photo-tool-panel { grid-template-columns: 1fr; }
}

/* ── PHOTO AI COMPOSE ────────────────────────────────────── */
.photo-ai-card {
  border-color: rgba(0, 229, 192, 0.2) !important;
  background: linear-gradient(135deg, rgba(0, 229, 192, 0.04), transparent) !important;
}

.photo-ai-body {
  display: grid;
  gap: 10px;
}

.photo-ai-textarea {
  min-height: 72px;
  max-height: 140px;
  resize: vertical;
  font-size: 0.86rem;
}

.photo-ai-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-ai-vision-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-3);
  cursor: pointer;
}

.photo-ai-vision-toggle input[type="checkbox"] {
  width: 13px;
  height: 13px;
  padding: 0;
  border-radius: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}

.photo-ai-status {
  font-size: 0.78rem;
  color: var(--text-3);
  min-height: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-ai-status.composing { color: var(--accent); }
.photo-ai-status.error { color: var(--red); }
.photo-ai-status.done { color: var(--green); }

.photo-ai-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vr-spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ==================== DEV REQUEST PANEL ==================== */

.dev-panel-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 860px) {
  .dev-panel-layout {
    grid-template-columns: 1fr;
  }
}

.dev-request-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dev-request-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px 20px;
}

.dev-request-textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  line-height: 1.55;
  padding: 12px 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
  box-sizing: border-box;
}

.dev-request-textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.dev-request-textarea::placeholder {
  color: var(--text-3);
  font-size: 0.83rem;
}

.dev-submit-btn {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 7px;
}

.dev-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Status Steps */
.dev-status {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dev-status-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dev-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text-2);
}

.dev-step.done {
  color: var(--green);
}

.dev-step.done .dev-step-icon { display: none; }
.dev-step.done::before {
  content: "✓";
  font-size: 0.8rem;
  color: var(--green);
  width: 13px;
  text-align: center;
  flex-shrink: 0;
}

.dev-step.error {
  color: var(--red);
}

.dev-step-icon.spin {
  animation: vr-spin 0.9s linear infinite;
  flex-shrink: 0;
  color: var(--accent);
}

/* Result */
.dev-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dev-result-summary {
  font-size: 0.88rem;
  color: var(--text);
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.5;
}

.dev-result-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dev-result-file-tag {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  padding: 3px 8px;
}

.dev-result-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dev-result-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}

.dev-result-link:hover {
  border-color: var(--accent-dim);
  background: rgba(99, 102, 241, 0.06);
}

/* History */
.dev-history-card {
  position: sticky;
  top: 18px;
}

.dev-history-list {
  list-style: none;
  padding: 0 20px 16px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 480px;
  overflow-y: auto;
}

.dev-history-empty {
  font-size: 0.82rem;
  color: var(--text-3);
  padding: 6px 0;
}

.dev-history-item {
  font-size: 0.81rem;
  color: var(--text-2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: default;
}

.dev-history-item-summary {
  color: var(--text);
  font-size: 0.83rem;
  line-height: 1.4;
}

.dev-history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dev-history-item-time {
  color: var(--text-3);
  font-size: 0.75rem;
}

.dev-history-item-status {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
}

.dev-history-item-status.success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.dev-history-item-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.dev-history-item-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.dev-history-item-link:hover { text-decoration: underline; }


/* ── ACTIVITY FEED ───────────────────────────────────────── */
.home-activity-card { max-height: 280px; overflow: hidden; }
.home-activity-card .card-head { padding-bottom: 8px; }

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.activity-empty {
  color: var(--text-3);
  font-size: 0.82rem;
  padding: 12px 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.activity-item:hover { background: var(--surface-2); }

.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.activity-msg {
  flex: 1;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time {
  color: var(--text-3);
  font-size: 0.74rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==================== HOME PANEL ==================== */

.home-panel-layout {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 860px;
  margin: 0 auto;
}

.home-hero {
  text-align: center;
  padding: 40px 20px 10px;
}

.home-hero-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: rgba(0, 229, 192, 0.08);
  border: 1px solid rgba(0, 229, 192, 0.2);
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 16px;
}

.home-hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.home-hero-sub {
  font-size: 1rem;
  color: var(--text-2);
  margin: 0;
  max-width: 480px;
  margin: 0 auto;
}

/* Tool grid */
.home-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

@media (max-width: 560px) {
  .home-tool-grid { grid-template-columns: 1fr; }
}

.home-tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.18s, background 0.18s, transform 0.15s, box-shadow 0.18s;
}

.home-tool-card:hover {
  border-color: rgba(0, 229, 192, 0.3);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.home-tool-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}

.home-tool-icon--accent { background: rgba(0,229,192,0.08); border-color: rgba(0,229,192,0.2); color: var(--accent); }
.home-tool-icon--purple { background: rgba(139,92,246,0.1); border-color: rgba(139,92,246,0.25); color: #a78bfa; }
.home-tool-icon--amber  { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); color: var(--amber); }
.home-tool-icon--red    { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); color: var(--red); }
.home-tool-icon--green  { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.2); color: var(--green); }
.home-tool-icon--blue   { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.25); color: #818cf8; }

.home-tool-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.home-tool-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.home-tool-desc {
  font-size: 0.79rem;
  color: var(--text-3);
  line-height: 1.4;
}

.home-tool-arrow {
  color: var(--text-3);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}

.home-tool-card:hover .home-tool-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ── AI AGENT PANEL ─────────────────────────────────────── */
.agent-layout {
  display: grid;
  grid-template-columns: 220px 1fr 268px;
  gap: 0;
  height: 100vh;
  margin: -28px -32px -40px;
  overflow: hidden;
}

/* Task list sidebar */
.agent-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  height: 100%;
  overflow: hidden;
}

.agent-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.agent-sidebar-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.agent-new-task-btn {
  font-size: 0.76rem;
  padding: 6px 11px;
}

.agent-task-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.agent-empty-state {
  color: var(--text-3);
  font-size: 0.8rem;
  text-align: center;
  padding: 28px 12px;
}

.agent-task-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  margin-bottom: 2px;
}
.agent-task-item:hover { background: var(--surface-2); border-color: var(--border); }
.agent-task-item.is-selected { background: var(--accent-dim); border-color: rgba(0,229,192,0.2); }

.agent-task-item-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-task-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-task-badge {
  font-size: 0.67rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.agent-task-badge.idle     { background: var(--surface-3); color: var(--text-3); }
.agent-task-badge.running  { background: rgba(0,229,192,0.12); color: var(--accent); }
.agent-task-badge.done     { background: var(--green-dim); color: var(--green); }
.agent-task-badge.error    { background: var(--red-dim); color: var(--red); }
.agent-task-badge.repeat   { background: rgba(245,166,35,0.1); color: var(--amber); }

.agent-task-item-time {
  font-size: 0.7rem;
  color: var(--text-3);
}

/* Main log area */
.agent-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.agent-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.agent-task-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.agent-task-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-task-status-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.agent-task-status-chip.running { background: rgba(0,229,192,0.12); color: var(--accent); }
.agent-task-status-chip.idle    { background: var(--surface-3); color: var(--text-3); }
.agent-task-status-chip.done    { background: var(--green-dim); color: var(--green); }
.agent-task-status-chip.error   { background: var(--red-dim); color: var(--red); }

.agent-main-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.agent-run-btn, .agent-stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.agent-run-btn {
  background: var(--accent-dim);
  border-color: rgba(0,229,192,0.3);
  color: var(--accent);
}
.agent-run-btn:hover:not(:disabled) { background: rgba(0,229,192,0.22); }
.agent-run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.agent-stop-btn {
  background: var(--red-dim);
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}
.agent-stop-btn:hover:not(:disabled) { background: rgba(248,113,113,0.2); }
.agent-stop-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Log output */
.agent-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agent-log-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 60px 24px;
  flex: 1;
}

.agent-log-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid rgba(0,229,192,0.2);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.agent-log-welcome-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font);
}

.agent-log-welcome-sub {
  font-size: 0.84rem;
  color: var(--text-3);
  max-width: 340px;
  line-height: 1.5;
  font-family: var(--font);
}

/* Log entries */
.agent-log-entry {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  align-items: flex-start;
  line-height: 1.5;
}

.agent-log-entry.msg { color: var(--text); }
.agent-log-entry.tool-call { color: var(--accent); }
.agent-log-entry.tool-result { color: var(--text-2); }
.agent-log-entry.system { color: var(--text-3); font-style: italic; }
.agent-log-entry.error-entry { color: var(--red); }

.agent-log-ts {
  color: var(--text-3);
  flex-shrink: 0;
  font-size: 0.72rem;
  padding-top: 2px;
  min-width: 56px;
}

.agent-log-icon {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 0.75rem;
}

.agent-log-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-log-text code {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.76rem;
}

/* Tool call block */
.agent-tool-block {
  background: rgba(0,229,192,0.04);
  border: 1px solid rgba(0,229,192,0.14);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 4px 0;
  font-size: 0.75rem;
}

.agent-tool-name {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.agent-tool-args {
  color: var(--text-3);
  word-break: break-all;
}

.agent-tool-result-block {
  background: rgba(0,0,0,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 4px 0;
  font-size: 0.75rem;
  color: var(--text-2);
  max-height: 200px;
  overflow-y: auto;
}

/* Docs bar */
.agent-docs-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: var(--surface);
}

.agent-docs-bar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.agent-docs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-doc-chip {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.76rem;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
}
.agent-doc-chip:hover { color: var(--text); border-color: rgba(255,255,255,0.18); }

/* Right config panel */
.agent-config-panel {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.agent-config-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.agent-task-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
}

.agent-input {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.83rem;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.agent-input:focus { border-color: rgba(0,229,192,0.4); }

.agent-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.82rem;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  resize: vertical;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.agent-textarea:focus { border-color: rgba(0,229,192,0.4); }

.agent-select {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.83rem;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  cursor: pointer;
}
.agent-select:focus { border-color: rgba(0,229,192,0.4); }

.agent-field-hint {
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1.4;
}

.agent-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.agent-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agent-toggle-label {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
}

.agent-toggle-sub {
  font-size: 0.74rem;
  color: var(--text-3);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--text-3);
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent-dim); border-color: rgba(0,229,192,0.4); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); background: var(--accent); }

.agent-repeat-opts { display: flex; flex-direction: column; gap: 8px; }

.agent-interval-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.agent-interval-input { }

.agent-save-task-btn { width: 100%; }

.agent-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* Settings toggle */
.agent-settings-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  color: var(--text-2);
  font: 500 0.82rem/1 var(--font);
  cursor: pointer;
  padding: 4px 0;
  width: 100%;
  text-align: left;
  transition: color 0.12s;
}
.agent-settings-toggle:hover { color: var(--text); }
.agent-settings-caret { margin-left: auto; transition: transform 0.18s; opacity: 0.6; }
.agent-settings-toggle.open .agent-settings-caret { transform: rotate(180deg); }

.agent-settings-section { display: flex; flex-direction: column; gap: 0; }

.agent-settings-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.agent-save-settings-btn { width: 100%; font-size: 0.8rem; padding: 8px; }

/* Spinner */
@keyframes agent-spin {
  to { transform: rotate(360deg); }
}
.agent-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0,229,192,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: agent-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Doc viewer modal */
.agent-doc-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.agent-doc-modal-inner {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  width: min(780px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.agent-doc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.agent-doc-modal-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.agent-doc-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); transition: color 0.12s;
}
.agent-doc-modal-close:hover { color: var(--text); }
.agent-doc-modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
}

/* ── CRM & INVOICES ─────────────────────────────────────── */
.crm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.crm-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.crm-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.crm-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.crm-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.crm-stat-label {
  font-size: 0.76rem;
  color: var(--text-3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.crm-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.crm-controls input {
  flex: 1;
  max-width: 320px;
}
.crm-controls select {
  min-width: 140px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}
.status-badge--active   { background: var(--green-dim); color: var(--green); }
.status-badge--prospect { background: var(--amber-dim); color: var(--amber); }
.status-badge--churned  { background: var(--red-dim);   color: var(--red); }
.status-badge--paused   { background: var(--surface-2); color: var(--text-3); }
.status-badge--paid     { background: var(--green-dim); color: var(--green); }
.status-badge--pending  { background: var(--amber-dim); color: var(--amber); }
.status-badge--overdue  { background: var(--red-dim);   color: var(--red); }

.row-actions {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

/* CRM / Invoice form overlay */
.crm-form-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rise 120ms ease;
}

html.dark-mode .crm-form-overlay, html.theme-midnight .crm-form-overlay {
  background: rgba(0,0,0,0.5);
}

.crm-form-card {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-height: 85vh;
  overflow-y: auto;
}

.crm-form-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.crm-form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

@media (max-width: 700px) {
  .crm-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .crm-controls {
    flex-direction: column;
  }
  .crm-controls input {
    max-width: none;
  }
}
