/* ================================================================
   Caculator — Hebrew RTL Fintech Design System
   Inspired by payme.io/envoria/ — dark, gradient, glassmorphism
================================================================ */

/* ── Reset & Custom Properties ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Backgrounds */
  --bg-base:        #080810;
  --bg-surface:     #0E0E1C;
  --bg-card:        rgba(255, 255, 255, 0.04);
  --bg-card-hover:  rgba(255, 255, 255, 0.07);
  --bg-input:       rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(124, 92, 231, 0.1);

  /* Brand */
  --primary:        #7C5CE7;
  --primary-dark:   #5a3fc0;
  --primary-light:  #A78BFA;
  --accent:         #00D4FF;
  --accent-soft:    rgba(0, 212, 255, 0.15);

  /* Semantic */
  --success:        #00C48C;
  --success-bg:     rgba(0, 196, 140, 0.12);
  --warning:        #FDBE2B;
  --warning-bg:     rgba(253, 190, 43, 0.12);
  --danger:         #FF6B6B;
  --danger-bg:      rgba(255, 107, 107, 0.12);

  /* Text */
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;
  --text-disabled:  #3D4A5C;

  /* Borders */
  --border:         rgba(255, 255, 255, 0.08);
  --border-focus:   rgba(124, 92, 231, 0.6);
  --border-primary: rgba(124, 92, 231, 0.3);

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow:    0 0 32px rgba(124, 92, 231, 0.25);

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #7C5CE7 0%, #00D4FF 100%);
  --gradient-card:  linear-gradient(135deg, rgba(124,92,231,0.08) 0%, rgba(0,212,255,0.04) 100%);
  --gradient-glow:  radial-gradient(ellipse at center, rgba(124,92,231,0.15) 0%, transparent 70%);

  /* Layout */
  --header-h:       64px;
  --sidebar-w:      260px;
  --results-w:      320px;
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  /* Typography */
  --font-he:        'Rubik', 'Arial Hebrew', system-ui, sans-serif;
  --font-num:       'Inter', monospace;

  /* Transitions */
  --t-fast:  0.15s ease;
  --t-mid:   0.25s ease;
  --t-slow:  0.4s ease;
}

/* ── Base ─────────────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-he);
  background-color: var(--bg-base);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(124,92,231,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 90%, rgba(0,212,255,0.05) 0%, transparent 60%);
  background-attachment: fixed;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════════════════════
   LANDING PAGE
══════════════════════════════════════════════════════════ */
.landing-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 70% 50% at 20% 10%, rgba(124,92,231,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(0,212,255,0.06) 0%, transparent 60%);
  overflow-y: auto;
}

.landing-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 16, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.landing-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.landing-brand {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: var(--font-num);
}
.landing-nav-actions { display: flex; gap: 0.625rem; align-items: center; }

.landing-hero {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 4rem 1.5rem;
}
.landing-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}
.hero-title {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}
.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2rem;
}
.hero-cta { display: flex; gap: 0.875rem; flex-wrap: wrap; }

.hero-mockup { display: flex; justify-content: center; }
.mockup-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mockup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-light);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.mockup-ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.mockup-msg {
  padding: 0.6rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 90%;
}
.mockup-msg.ai {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  align-self: flex-start;
}
.mockup-msg.user {
  background: rgba(124, 92, 231, 0.15);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  align-self: flex-end;
}
.mockup-msg strong { color: var(--accent); }

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 1100px;
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
  width: 100%;
}
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  transition: border-color var(--t-mid), transform var(--t-mid);
}
.feature-card:hover { border-color: var(--border-primary); transform: translateY(-2px); }
.feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); }
.feature-card p { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* Auth Modal overlay */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-modal.hidden { display: none !important; }
.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}
.auth-modal .auth-card { position: relative; z-index: 1; animation: fadeInUp 0.3s ease; }

/* Auth tabs */
.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.625rem 1rem;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
  margin-bottom: -1px;
}
.auth-tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }
.auth-tab:hover { color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════
   AUTH OVERLAY (legacy — kept for structure)
══════════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 70% 60% at 30% 20%, rgba(124,92,231,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 70% 80%, rgba(0,212,255,0.08) 0%, transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  justify-content: center;
  direction: ltr;
}

.logo-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.logo-icon.small { width: 32px; height: 32px; }
.logo-icon svg { width: 100%; height: 100%; }

.logo-text {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Form elements ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }

.form-group label,
.form-field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.required { color: var(--primary-light); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  color: var(--text-primary);
  font-family: var(--font-he);
  font-size: 0.9375rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type="number"] {
  font-family: var(--font-num);
  direction: ltr;
  text-align: right;
}

input:focus,
textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(124, 92, 231, 0.1);
}

input::placeholder,
textarea::placeholder { color: var(--text-muted); }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 0.3; }

.input-wrap { position: relative; }
.input-wrap input { padding-left: 2.5rem; }

.input-with-prefix,
.input-with-suffix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-with-prefix:focus-within,
.input-with-suffix:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124, 92, 231, 0.1);
}

.input-with-prefix input,
.input-with-suffix input {
  border: none;
  background: transparent;
  box-shadow: none;
  flex: 1;
  min-width: 0;
}
.input-with-prefix input:focus,
.input-with-suffix input:focus { box-shadow: none; }

.prefix, .suffix {
  display: flex;
  align-items: center;
  padding: 0 0.625rem;
  background: rgba(255,255,255,0.04);
  border-inline-start: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.prefix { border-inline-start: none; border-inline-end: 1px solid var(--border); }

.toggle-password {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  display: flex;
  transition: color var(--t-fast);
}
.toggle-password:hover { color: var(--text-secondary); }
.eye-icon { width: 18px; height: 18px; }

.form-error {
  color: var(--danger);
  font-size: 0.8125rem;
  background: var(--danger-bg);
  border: 1px solid rgba(255,107,107,0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: var(--gradient-brand);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-he);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: 0 4px 15px rgba(124, 92, 231, 0.35);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 92, 231, 0.5);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.full-width { width: 100%; }
.btn-primary.small { padding: 0.4rem 0.875rem; font-size: 0.875rem; }
.btn-primary.large { padding: 0.875rem 1.5rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-he);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: rgba(255,255,255,0.15); }
.btn-ghost.full-width { width: 100%; margin-top: 0.5rem; }
.btn-ghost.small { padding: 0.4rem 0.875rem; font-size: 0.875rem; }
.btn-ghost.large { padding: 0.875rem 1.5rem; font-size: 1rem; border-radius: var(--radius-lg); }

.btn-accent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: rgba(0, 212, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: var(--radius-md);
  font-family: var(--font-he);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-accent:hover { background: rgba(0, 212, 255, 0.2); border-color: rgba(0,212,255,0.5); }
.btn-accent.small { padding: 0.4rem 0.875rem; font-size: 0.8rem; }

/* Language toggle button */
.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-num);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: all var(--t-fast);
  letter-spacing: 0.05em;
}
.lang-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }

.btn-danger {
  padding: 0.5rem 1rem;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-he);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast);
}
.btn-danger:hover { background: #ff5252; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary-light);
  font-family: var(--font-he);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--t-fast);
}
.btn-link:hover { color: var(--accent); }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.icon-btn svg { width: 18px; height: 18px; }

.btn-icon-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  color: white;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(124, 92, 231, 0.4);
}
.btn-icon-primary:hover { transform: scale(1.05); }
.btn-icon-primary svg { width: 16px; height: 16px; }

.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-text.loading { display: none; }

/* ══════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════ */
.app-header {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: var(--header-h);
  z-index: 100;
  background: rgba(8, 8, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 100%;
  padding: 0 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  direction: ltr;
}

.header-brand {
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.875rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-he);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.nav-btn svg { width: 16px; height: 16px; }
.nav-btn:hover { background: var(--bg-card-hover); color: var(--text-secondary); }
.nav-btn.active {
  background: rgba(124, 92, 231, 0.15);
  color: var(--primary-light);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-inline-start: auto;
  flex-shrink: 0;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.logout-btn { color: var(--text-muted); }
.logout-btn:hover { color: var(--danger); background: var(--danger-bg); }

/* ══════════════════════════════════════════════════════════
   MAIN APP
══════════════════════════════════════════════════════════ */
.app-main {
  margin-top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

.view { height: 100%; overflow: hidden; display: none; }
.view.active { display: flex; flex-direction: column; }

/* ══════════════════════════════════════════════════════════
   CHAT VIEW
══════════════════════════════════════════════════════════ */
.chat-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--results-w);
  height: 100%;
  overflow: hidden;
}

/* Sessions sidebar */
.sessions-sidebar {
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); }

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.sessions-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  position: relative;
}
.session-item:hover { background: var(--bg-card-hover); }
.session-item.active {
  background: rgba(124, 92, 231, 0.12);
  border-color: var(--border-primary);
}

.session-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.session-item.active .session-item-icon {
  background: rgba(124, 92, 231, 0.2);
  color: var(--primary-light);
}
.session-item-icon svg { width: 14px; height: 14px; }

.session-item-info {
  flex: 1;
  min-width: 0;
}
.session-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-item-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.session-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.session-status-dot.completed { background: var(--primary-light); }

/* Chat main */
.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Empty state */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  gap: 1rem;
}
.empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 0.5rem;
}
.chat-empty-state h2 {
  font-size: 1.375rem;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.chat-empty-state p { color: var(--text-secondary); max-width: 420px; line-height: 1.7; }

/* Active chat area */
#activeChatArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#activeChatArea.hidden { display: none; }

.chat-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.chat-session-info {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.ai-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 500;
}
.ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 196, 140, 0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(0, 196, 140, 0); }
}

.session-title { font-size: 0.875rem; font-weight: 600; color: var(--text-secondary); }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  gap: 0.625rem;
  max-width: 85%;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-message.model {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  align-self: flex-end;
}
.chat-message.user .msg-avatar {
  background: var(--gradient-brand);
  color: white;
}
.chat-message.model .msg-avatar {
  background: rgba(124, 92, 231, 0.2);
  border: 1px solid var(--border-primary);
  color: var(--primary-light);
  font-size: 0.625rem;
}

.msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.65;
  word-break: break-word;
}
.chat-message.user .msg-bubble {
  background: var(--gradient-brand);
  color: white;
  border-end-start-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(124, 92, 231, 0.3);
}
.chat-message.model .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-end-end-radius: var(--radius-sm);
}

/* Markdown in AI messages */
.msg-bubble strong { font-weight: 700; color: var(--primary-light); }
.msg-bubble em { font-style: italic; color: var(--text-secondary); }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-weight: 700;
  margin: 0.75rem 0 0.25rem;
  color: var(--text-primary);
}
.msg-bubble h1 { font-size: 1.125rem; }
.msg-bubble h2 { font-size: 1rem; }
.msg-bubble h3 { font-size: 0.9375rem; }
.msg-bubble p  { margin: 0.25rem 0; }
.msg-bubble ul, .msg-bubble ol {
  padding-inline-start: 1.25rem;
  margin: 0.25rem 0;
}
.msg-bubble li { margin: 0.125rem 0; }
.msg-bubble code {
  font-family: var(--font-num);
  background: rgba(255,255,255,0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.875em;
}
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 1.25rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.375rem 0.625rem;
}
.typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s ease infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Chat input */
.chat-input-area {
  padding: 0.875rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.chat-input-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124, 92, 231, 0.1);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  padding: 0;
  font-size: 0.9375rem;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}
.chat-input:focus { box-shadow: none; }

.send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(124, 92, 231, 0.4);
}
.send-btn:hover:not(:disabled) { transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--bg-card); box-shadow: none; }
.send-btn svg { width: 16px; height: 16px; }

.input-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  text-align: center;
}

/* Results panel */
.results-panel {
  border-inline-start: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.results-panel.hidden { display: none; }

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.results-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); }

.results-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.results-actions {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Health Badge ──────────────────────────────────────────── */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.health-badge.healthy  { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0,196,140,0.2); }
.health-badge.warning  { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(253,190,43,0.2); }
.health-badge.critical { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(255,107,107,0.2); }
.health-badge.large    { font-size: 0.875rem; padding: 0.375rem 0.875rem; }
.health-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Result Metric Cards ───────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 3px;
  height: 100%;
  background: var(--gradient-brand);
  opacity: 0.6;
}
.metric-card.full-width { grid-column: 1 / -1; }
.metric-card.highlight {
  background: var(--gradient-card);
  border-color: var(--border-primary);
}
.metric-card.highlight::before { opacity: 1; }

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.metric-value {
  font-family: var(--font-num);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.metric-value.success { color: var(--success); }
.metric-value.warning { color: var(--warning); }
.metric-value.danger  { color: var(--danger); }
.metric-value.primary { color: var(--primary-light); }

.metric-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.metric-card.wide-label .metric-label { font-size: 0.75rem; text-transform: none; letter-spacing: 0; }

.results-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.results-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* LTV:CAC bar */
.ratio-bar-wrap {
  margin-top: 0.5rem;
}
.ratio-bar-bg {
  height: 6px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.ratio-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--gradient-brand);
  transition: width 0.6s ease;
  max-width: 100%;
}
.ratio-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ══════════════════════════════════════════════════════════
   MANUAL CALCULATOR
══════════════════════════════════════════════════════════ */
.manual-layout {
  display: grid;
  grid-template-columns: minmax(0, 560px) 1fr;
  height: 100%;
  overflow: hidden;
  gap: 0;
}

.manual-form-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-inline-end: 1px solid var(--border);
  background: var(--bg-surface);
}

.panel-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}
.panel-header p { color: var(--text-muted); font-size: 0.875rem; }

#calcForm { padding: 1rem 1.5rem 2rem; display: flex; flex-direction: column; gap: 0.75rem; }

/* Sections */
.calc-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  transition: border-color var(--t-fast);
}
.calc-section:focus-within { border-color: var(--border-primary); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
}
.section-header:hover { background: var(--bg-card-hover); }

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.section-icon.marketing  { background: rgba(124,92,231,0.15); color: var(--primary-light); }
.section-icon.product    { background: rgba(0,212,255,0.12); color: var(--accent); }
.section-icon.operations { background: rgba(0,196,140,0.12); color: var(--success); }
.section-icon.ltv        { background: rgba(253,190,43,0.12); color: var(--warning); }
.section-icon svg { width: 18px; height: 18px; }

.section-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.section-desc { font-size: 0.75rem; color: var(--text-muted); }

.chevron { width: 18px; height: 18px; color: var(--text-muted); transition: transform var(--t-fast); flex-shrink: 0; }
.section-header.collapsed .chevron { transform: rotate(-90deg); }

.section-body {
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}
.section-body.collapsed { display: none; }

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.form-field { display: flex; flex-direction: column; gap: 0.25rem; }
.form-field.wide { grid-column: 1 / -1; }

.form-actions {
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Manual results */
.manual-results-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.manual-results-panel.hidden { display: none; }
.manual-results-panel .panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.manual-results-panel .results-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ══════════════════════════════════════════════════════════
   HISTORY VIEW
══════════════════════════════════════════════════════════ */
.history-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  overflow-y: auto;
  height: 100%;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}
.history-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-brand);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.history-card:hover { background: var(--bg-card-hover); border-color: var(--border-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.history-card:hover::before { opacity: 1; }

.history-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-card-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.history-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.hist-stat { display: flex; flex-direction: column; gap: 0.125rem; }
.hist-stat-label { font-size: 0.6875rem; color: var(--text-muted); }
.hist-stat-value { font-family: var(--font-num); font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }

.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════
   TOOLTIP
══════════════════════════════════════════════════════════ */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tooltip-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  font-style: normal;
}
.tooltip-text {
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 200;
}
.tooltip-wrap:hover .tooltip-text { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  inset-inline-start: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text-primary);
  min-width: 220px;
  max-width: 360px;
  pointer-events: auto;
  animation: toastIn 0.3s ease;
}
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-20px); }
}

.toast.success { border-color: rgba(0,196,140,0.3); }
.toast.error   { border-color: rgba(255,107,107,0.3); }
.toast.info    { border-color: var(--border-primary); }

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast.success .toast-dot { background: var(--success); }
.toast.error   .toast-dot { background: var(--danger); }
.toast.info    .toast-dot { background: var(--primary-light); }

/* ══════════════════════════════════════════════════════════
   CONFIRM DIALOG
══════════════════════════════════════════════════════════ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(8, 8, 16, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dialog-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.25s ease;
}
.dialog-card h3 { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.5rem; }
.dialog-card p  { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.dialog-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ══════════════════════════════════════════════════════════
   LOADING
══════════════════════════════════════════════════════════ */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --results-w: 280px; }
}

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sessions-sidebar { display: none; }
  .results-panel { display: none; }

  .manual-layout { grid-template-columns: 1fr; }
  .manual-results-panel { border-inline-start: none; border-top: 1px solid var(--border); max-height: 50vh; }
}

@media (max-width: 640px) {
  :root { --header-h: 56px; }
  .header-inner { padding: 0 1rem; gap: 0.75rem; }
  .nav-btn span { display: none; }
  .nav-btn { padding: 0.4rem 0.625rem; }
  .user-name { display: none; }

  .auth-card { padding: 1.75rem 1.25rem; }

  .input-grid { grid-template-columns: 1fr; }

  .results-grid { grid-template-columns: 1fr; }

  .history-list { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════
   ADMIN VIEW
══════════════════════════════════════════════════════════ */
#adminView {
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
}

.admin-layout {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.admin-section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-section h2 svg {
  color: var(--primary-light);
  flex-shrink: 0;
}

/* ── Admin Table ─────────────────────────────────────────── */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table thead {
  background: rgba(255,255,255,0.03);
}

.admin-table th {
  padding: 0.75rem 1rem;
  text-align: start;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover td {
  background: var(--bg-card-hover);
}

.admin-table td:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  line-height: 1;
}

.badge-admin {
  background: rgba(124, 92, 231, 0.2);
  color: var(--primary-light);
  border: 1px solid rgba(124, 92, 231, 0.3);
}

.badge-user {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── Form helpers ────────────────────────────────────────── */
.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-success {
  background: var(--success-bg);
  border: 1px solid rgba(0, 196, 140, 0.3);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-group label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.input-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

/* ── Webhook section ─────────────────────────────────────── */
.webhook-url-display {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  word-break: break-all;
  direction: ltr;
  text-align: left;
  font-family: var(--font-num);
}

/* ── Masked key display ──────────────────────────────────── */
.masked-key {
  font-family: var(--font-num);
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  display: inline-block;
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

@media (max-width: 640px) {
  .admin-layout { padding: 1rem; }
  .input-grid.two-col { grid-template-columns: 1fr; }
  .admin-table th, .admin-table td { padding: 0.6rem 0.75rem; }
}

/* ══════════════════════════════════════════════════════════
   BENCHMARK SECTION
══════════════════════════════════════════════════════════ */
.benchmark-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.benchmark-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.benchmark-header h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.benchmark-agent-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.benchmark-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.benchmark-content p { margin-bottom: 0.5rem; }
.benchmark-content strong { color: var(--text-primary); }
.benchmark-content h1, .benchmark-content h2, .benchmark-content h3 {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin: 0.75rem 0 0.25rem;
}

.error-text { color: var(--danger); font-size: 0.875rem; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — LANDING
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .landing-hero-inner { grid-template-columns: 1fr; gap: 2rem; text-align: center; }
  .hero-cta { justify-content: center; }
  .hero-mockup { display: none; }
  .landing-features { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════
   LTR OVERRIDES (English mode — dir="ltr" on <html>)
══════════════════════════════════════════════════════════ */

/* Chat messages: user bubbles on the right in LTR */
[dir="ltr"] .chat-message.user { flex-direction: row; }
[dir="ltr"] .chat-message.user .msg-bubble { border-radius: 18px 4px 18px 18px; }
[dir="ltr"] .chat-message.model .msg-bubble { border-radius: 4px 18px 18px 18px; }

/* Table alignment */
[dir="ltr"] .admin-table th { text-align: left; }
[dir="ltr"] .admin-table td { text-align: left; }

/* Form labels */
[dir="ltr"] .form-group label  { text-align: left; }
[dir="ltr"] .form-field label  { text-align: left; }
[dir="ltr"] .panel-header      { text-align: left; }
[dir="ltr"] .section-title     { text-align: left; }

/* Chat input */
[dir="ltr"] .chat-input        { direction: ltr; text-align: left; }
[dir="ltr"] .input-hint        { text-align: left; }

/* Results panel */
[dir="ltr"] .results-header    { text-align: left; }
[dir="ltr"] .metric-label      { text-align: left; }

/* Header */
[dir="ltr"] .header-logo       { direction: ltr; }
[dir="ltr"] .auth-logo         { direction: ltr; }

/* Sidebar */
[dir="ltr"] .sidebar-header h2 { text-align: left; }

/* Session items */
[dir="ltr"] .session-item-info { text-align: left; }

/* Auth card */
[dir="ltr"] .auth-card         { text-align: left; }
[dir="ltr"] .auth-subtitle     { text-align: left; }

/* Input prefix/suffix layout */
[dir="ltr"] .input-with-prefix .prefix { border-radius: 8px 0 0 8px; }
[dir="ltr"] .input-with-suffix .suffix { border-radius: 0 8px 8px 0; }

/* Tooltips */
[dir="ltr"] .tooltip-text { right: auto; left: 0; }

/* Toast */
[dir="ltr"] .toast-container { left: 1rem; right: auto; }

/* ══════════════════════════════════════════════════════════
   MOBILE OVERLAYS (sessions drawer + results sheet)
══════════════════════════════════════════════════════════ */
.mobile-sessions-btn { display: none; }
.mobile-results-fab  { display: none; }
.mobile-new-session-sidebar { display: none; }

.mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
}
.mobile-overlay.hidden { display: none !important; }

.mobile-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.mobile-overlay-panel {
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}
.mobile-results-panel-inner { max-height: 90dvh; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.mobile-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mobile-overlay-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.mobile-sessions-list {
  overflow-y: auto;
  padding: 0.5rem;
}

.mobile-results-fab {
  position: fixed;
  bottom: 5.5rem;
  inset-inline-end: 1rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 99px;
  font-family: var(--font-he);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,92,231,0.5);
  transition: transform var(--t-fast);
}
.mobile-results-fab:hover { transform: scale(1.05); }
.mobile-results-fab svg { width: 16px; height: 16px; }

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — COMPREHENSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Show mobile sessions toggle */
  .mobile-sessions-btn { display: flex; }
  .mobile-new-session-sidebar { display: flex; margin: 0.75rem; }

  /* Chat layout: single column */
  .chat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .sessions-sidebar { display: none; }
  .results-panel    { display: none !important; }
  .mobile-results-fab { display: flex; }

  /* Manual calculator */
  .manual-layout { grid-template-columns: 1fr; }
  .manual-results-panel {
    border-inline-start: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }

  /* History */
  .history-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  :root { --header-h: 52px; }

  /* Header */
  .header-inner   { padding: 0 0.75rem; gap: 0.5rem; }
  .header-brand   { font-size: 1.1rem; }
  .nav-btn span   { display: none; }
  .nav-btn        { padding: 0.375rem 0.5rem; min-width: 36px; justify-content: center; }
  .user-name      { display: none; }
  .header-nav     { gap: 0.125rem; }

  /* Auth card */
  .auth-card { padding: 1.5rem 1rem; max-width: 100%; }
  .auth-card .auth-logo { margin-bottom: 0.5rem; }

  /* Landing */
  .landing-header-inner { padding: 0 1rem; }
  .landing-hero         { padding: 2rem 1rem; }
  .hero-title           { font-size: 1.75rem; }
  .hero-subtitle        { font-size: 0.95rem; }
  .landing-features     { grid-template-columns: 1fr; padding: 0 1rem; margin-bottom: 2rem; }
  .feature-card         { padding: 1rem; }

  /* Chat */
  .chat-header-bar        { padding: 0.5rem 0.75rem; }
  .chat-messages          { padding: 0.75rem; gap: 0.75rem; }
  .chat-input-area        { padding: 0.5rem 0.75rem; }
  .msg-bubble             { font-size: 0.875rem; padding: 0.625rem 0.875rem; }
  .input-hint             { display: none; }

  /* Input grid */
  .input-grid             { grid-template-columns: 1fr; }
  .input-grid.two-col     { grid-template-columns: 1fr; }

  /* Results */
  .results-grid           { grid-template-columns: 1fr 1fr; }
  .results-actions        { flex-wrap: wrap; gap: 0.5rem; }

  /* History */
  .history-list           { grid-template-columns: 1fr; }

  /* Admin */
  .admin-layout           { padding: 0.75rem; gap: 1rem; }
  .admin-section          { padding: 1rem; }
  .admin-table th,
  .admin-table td         { padding: 0.5rem 0.75rem; font-size: 0.8rem; }

  /* Mobile results content */
  #mobileResultsContent   { padding: 1rem; overflow-y: auto; }
}
