/* ═══════════════════════════════════════════════════════════════════════════
   TikTok Ads Intelligence Platform — Design System
   Palette: "Ash & Sage" — warm muted tones, calm, professional
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Background layers ─────────────────────────────────────────────────── */
  --bg-base:        #F5F4F1;
  --bg-surface:     #FAFAF8;
  --bg-elevated:    #FFFFFF;
  --bg-sunken:      #EDECE8;

  /* ── Accent — Sage Green ───────────────────────────────────────────────── */
  --accent-50:      #F0F4F0;
  --accent-100:     #D8E8D8;
  --accent-300:     #8EB89E;
  --accent-500:     #5A8A6A;
  --accent-700:     #3A6048;
  --accent-900:     #1E3A28;

  /* ── Neutrals — Warm Gray ──────────────────────────────────────────────── */
  --neutral-50:     #F5F4F1;
  --neutral-100:    #EAE9E5;
  --neutral-200:    #D5D3CC;
  --neutral-400:    #9B9890;
  --neutral-600:    #6B6862;
  --neutral-800:    #3A3832;
  --neutral-950:    #1A1916;

  /* ── Semantic colors ───────────────────────────────────────────────────── */
  --green-soft:     #D6EDD8;
  --green-text:     #2D6B3A;
  --yellow-soft:    #F5EACC;
  --yellow-text:    #8A6520;
  --red-soft:       #F5DDD8;
  --red-text:       #8A2A1E;
  --blue-soft:      #D8E8F5;
  --blue-text:      #1E4A7A;

  /* ── Typography ────────────────────────────────────────────────────────── */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Mono', monospace;

  /* ── Font sizes ────────────────────────────────────────────────────────── */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  32px;
  --text-4xl:  48px;

  /* ── Shadows ────────────────────────────────────────────────────────────── */
  --shadow-xs:  0 1px 2px rgba(26,25,22,0.04);
  --shadow-sm:  0 1px 3px rgba(26,25,22,0.06), 0 1px 2px rgba(26,25,22,0.04);
  --shadow-md:  0 4px 12px rgba(26,25,22,0.08), 0 2px 4px rgba(26,25,22,0.04);
  --shadow-lg:  0 8px 24px rgba(26,25,22,0.10), 0 4px 8px rgba(26,25,22,0.05);

  /* ── Border radius ──────────────────────────────────────────────────────── */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* ── Spacing ────────────────────────────────────────────────────────────── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Layout ─────────────────────────────────────────────────────────────── */
  --sidebar-width:       220px;
  --sidebar-collapsed:   64px;
  --topbar-height:       56px;
  --ai-panel-width:      360px;
  --content-max-width:   1400px;

  /* ── Transitions ────────────────────────────────────────────────────────── */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   350ms ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--neutral-800);
  background: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Number display — monospace for metrics */
.metric-value, .kpi-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   Typography
   ═══════════════════════════════════════════════════════════════════════════ */
h1 { font-size: var(--text-3xl); font-weight: 700; line-height: 1.2; }
h2 { font-size: var(--text-2xl); font-weight: 600; line-height: 1.25; }
h3 { font-size: var(--text-xl);  font-weight: 600; line-height: 1.3; }
h4 { font-size: var(--text-lg);  font-weight: 600; line-height: 1.4; }
h5 { font-size: var(--text-base);font-weight: 600; }
p  { line-height: 1.6; color: var(--neutral-600); }

/* ═══════════════════════════════════════════════════════════════════════════
   Layout Shell
   ═══════════════════════════════════════════════════════════════════════════ */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Login Screen ────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-10) var(--space-8);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 48px;
  height: 48px;
  background: var(--accent-500);
  border-radius: var(--radius-md);
  margin: 0 auto var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
}

.login-card h1 {
  font-size: var(--text-2xl);
  color: var(--neutral-950);
  margin-bottom: var(--space-2);
}

.login-card p {
  margin-bottom: var(--space-8);
  font-size: var(--text-sm);
}

.login-error {
  color: var(--red-text);
  background: var(--red-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  display: none;
}

.login-error.visible { display: block; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--neutral-100);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-base);
  overflow: hidden;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--neutral-100);
  height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent-500);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--neutral-950);
  white-space: nowrap;
  line-height: 1.2;
}

.sidebar-logo-text span {
  display: block;
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--neutral-400);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  margin: 2px var(--space-2);
  color: var(--neutral-600);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-sunken);
  color: var(--neutral-950);
}

.nav-item.active {
  background: var(--accent-50);
  color: var(--accent-700);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--neutral-100);
}

/* ── Main area ───────────────────────────────────────────────────────────── */
#main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

#main-area.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

#main-area.ai-open {
  margin-right: var(--ai-panel-width);
}

/* ── Top Bar ──────────────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-height);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--neutral-100);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-toggle {
  color: var(--neutral-400);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.topbar-toggle:hover {
  background: var(--bg-sunken);
  color: var(--neutral-800);
}

#page-title {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--neutral-950);
  flex: 1;
}

.date-range-picker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-sunken);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.date-range-picker input[type="date"] {
  border: none;
  background: transparent;
  font-size: var(--text-sm);
  color: var(--neutral-800);
  outline: none;
}

.date-range-picker span {
  color: var(--neutral-400);
  font-size: var(--text-sm);
}

.ai-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--accent-50);
  color: var(--accent-700);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.ai-toggle-btn:hover {
  background: var(--accent-100);
}

.ai-toggle-btn.active {
  background: var(--accent-500);
  color: white;
}

/* ── Content ──────────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Components
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-100);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--neutral-100);
}

.card-header h3 {
  font-size: var(--text-base);
  color: var(--neutral-800);
}

.card-body {
  padding: var(--space-5);
}

/* ── KPI Summary Cards Grid ───────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-100);
  transition: box-shadow var(--transition-fast);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--neutral-400);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--neutral-950);
  line-height: 1.1;
  margin-bottom: var(--space-2);
}

.kpi-sub {
  font-size: var(--text-xs);
  color: var(--neutral-400);
}

/* Traffic light for ROAS */
.kpi-card.kpi-good   { border-left: 3px solid var(--green-text); }
.kpi-card.kpi-warn   { border-left: 3px solid #D4A017; }
.kpi-card.kpi-bad    { border-left: 3px solid var(--red-text); }

.kpi-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 600;
}

.kpi-badge.good { background: var(--green-soft); color: var(--green-text); }
.kpi-badge.warn { background: var(--yellow-soft); color: var(--yellow-text); }
.kpi-badge.bad  { background: var(--red-soft);    color: var(--red-text); }

/* Progress bar for CAC */
.progress-bar-wrap {
  margin-top: var(--space-2);
}

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--neutral-400);
  margin-bottom: 4px;
}

.progress-bar {
  height: 4px;
  background: var(--neutral-100);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-500);
  transition: width var(--transition-base);
}

.progress-bar-fill.warn  { background: #D4A017; }
.progress-bar-fill.bad   { background: var(--red-text); }

/* ── Charts Grid ──────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.chart-container {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-100);
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--neutral-800);
  margin-bottom: var(--space-4);
}

.chart-canvas-wrap {
  position: relative;
  height: 220px;
}

/* ── Campaigns Table ──────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-100);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--neutral-100);
}

.table-header h3 {
  font-size: var(--text-base);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--neutral-400);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--neutral-100);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--neutral-800); }
thead th.sorted { color: var(--accent-700); }

tbody tr {
  border-bottom: 1px solid var(--neutral-100);
  transition: background var(--transition-fast);
}

tbody tr:hover { background: var(--bg-sunken); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--neutral-800);
  white-space: nowrap;
}

.td-number {
  font-family: var(--font-mono);
  text-align: right;
}

/* Status badge for campaigns */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.status-badge.scale    { background: var(--green-soft); color: var(--green-text); }
.status-badge.optimize { background: var(--yellow-soft); color: var(--yellow-text); }
.status-badge.stop     { background: var(--red-soft); color: var(--red-text); }
.status-badge.insufficient { background: var(--neutral-100); color: var(--neutral-400); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.btn-primary {
  background: var(--accent-500);
  color: white;
}

.btn-primary:hover { background: var(--accent-700); }

.btn-secondary {
  background: var(--bg-sunken);
  color: var(--neutral-800);
  border: 1px solid var(--neutral-200);
}

.btn-secondary:hover { background: var(--neutral-100); }

.btn-ghost {
  color: var(--neutral-600);
}

.btn-ghost:hover {
  background: var(--bg-sunken);
  color: var(--neutral-950);
}

.btn-danger {
  color: var(--red-text);
  background: var(--red-soft);
}

.btn-danger:hover { opacity: 0.8; }

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

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--neutral-800);
  margin-bottom: var(--space-2);
}

.form-label span { color: var(--neutral-400); font-weight: 400; }

.form-input, .form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--neutral-800);
  background: var(--bg-elevated);
  transition: border-color var(--transition-fast);
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent-500);
}

.form-input.error { border-color: var(--red-text); }

.form-hint {
  font-size: var(--text-xs);
  color: var(--neutral-400);
  margin-top: var(--space-1);
}

/* ── Drop Zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-500);
  background: var(--accent-50);
}

.drop-zone-icon {
  font-size: 40px;
  margin-bottom: var(--space-3);
}

.drop-zone h4 {
  color: var(--neutral-800);
  margin-bottom: var(--space-2);
}

.drop-zone p {
  font-size: var(--text-sm);
  color: var(--neutral-400);
}

.drop-zone input[type="file"] {
  display: none;
}

/* ── AI Panel ─────────────────────────────────────────────────────────────── */
#ai-panel {
  width: var(--ai-panel-width);
  min-height: 100vh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--neutral-100);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  transform: translateX(100%);
  transition: transform var(--transition-base);
}

#ai-panel.open {
  transform: translateX(0);
}

.ai-panel-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--neutral-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  flex-shrink: 0;
}

.ai-panel-title {
  font-weight: 600;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--neutral-950);
}

.ai-model-badge {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  background: var(--accent-50);
  color: var(--accent-700);
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ai-message {
  max-width: 100%;
}

.ai-message-user .ai-bubble {
  background: var(--accent-50);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-xs) var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--neutral-800);
  font-size: var(--text-sm);
  align-self: flex-end;
  margin-left: auto;
}

.ai-message-assistant .ai-bubble {
  background: var(--bg-sunken);
  border-radius: var(--radius-xs) var(--radius-md) var(--radius-md) var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--neutral-800);
}

.ai-message-assistant .ai-bubble h1,
.ai-message-assistant .ai-bubble h2,
.ai-message-assistant .ai-bubble h3 {
  font-size: var(--text-sm);
  margin: var(--space-2) 0 var(--space-1);
}

.ai-message-assistant .ai-bubble p {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--neutral-800);
  margin-bottom: var(--space-2);
}

.ai-message-assistant .ai-bubble ul,
.ai-message-assistant .ai-bubble ol {
  padding-left: var(--space-4);
  margin-bottom: var(--space-2);
}

.ai-message-assistant .ai-bubble li {
  font-size: var(--text-sm);
  margin-bottom: 2px;
  list-style-type: disc;
}

.ai-message-assistant .ai-bubble table {
  font-size: var(--text-xs);
  border-collapse: collapse;
  margin: var(--space-2) 0;
  width: 100%;
}

.ai-message-assistant .ai-bubble th,
.ai-message-assistant .ai-bubble td {
  padding: 4px 8px;
  border: 1px solid var(--neutral-200);
  text-align: left;
}

.ai-message-assistant .ai-bubble th {
  background: var(--neutral-100);
  font-weight: 600;
}

.ai-message-assistant .ai-bubble code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--neutral-100);
  padding: 1px 4px;
  border-radius: var(--radius-xs);
}

.ai-message-assistant .ai-bubble strong { font-weight: 700; color: var(--neutral-950); }

.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  width: fit-content;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--neutral-400);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.ai-input-area {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--neutral-100);
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  flex-shrink: 0;
}

.ai-input {
  flex: 1;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color var(--transition-fast);
  line-height: 1.5;
}

.ai-input:focus { border-color: var(--accent-500); }

.ai-send-btn {
  width: 34px;
  height: 34px;
  background: var(--accent-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.ai-send-btn:hover { background: var(--accent-700); }
.ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--space-3);
  color: var(--neutral-400);
  text-align: center;
  padding: var(--space-6);
}

.ai-empty-icon { font-size: 40px; }
.ai-empty p { font-size: var(--text-sm); }

/* ── AI Insights Banner ───────────────────────────────────────────────────── */
.ai-insights-banner {
  background: linear-gradient(135deg, var(--accent-50), var(--bg-elevated));
  border: 1px solid var(--accent-100);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}

.ai-insights-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.ai-insights-header h4 {
  font-size: var(--text-sm);
  color: var(--accent-700);
}

.ai-insights-content {
  font-size: var(--text-sm);
  color: var(--neutral-800);
  line-height: 1.6;
}

/* ── Import View ──────────────────────────────────────────────────────────── */
.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.import-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-100);
}

.import-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.import-card-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-50);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ── Payments View ────────────────────────────────────────────────────────── */
.payments-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--space-6);
}

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--neutral-400);
}

.empty-state-icon { font-size: 48px; margin-bottom: var(--space-4); }

.empty-state h3 {
  color: var(--neutral-800);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

/* ── Loading skeleton ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-50) 50%, var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.wide  { width: 80%; }
.skeleton-text.full  { width: 100%; }
.skeleton-text.short { width: 40%; }

.skeleton-kpi {
  height: 80px;
  border-radius: var(--radius-md);
}

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--neutral-950);
  color: white;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  max-width: 360px;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  animation: slideUp 0.25s ease;
}

.toast.success { background: var(--green-text); }
.toast.error   { background: var(--red-text); }
.toast.warn    { background: var(--yellow-text); }

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

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,25,22,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--neutral-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--neutral-100);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ── Scrollbar styling ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--neutral-200);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--neutral-400); }

/* ═══════════════════════════════════════════════════════════════════════════
   Utility classes
   ═══════════════════════════════════════════════════════════════════════════ */
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--neutral-400); }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
  #ai-panel { width: 100%; max-width: 400px; }
}

@media (max-width: 768px) {
  #sidebar {
    width: var(--sidebar-collapsed);
  }

  #main-area {
    margin-left: var(--sidebar-collapsed);
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .payments-layout {
    grid-template-columns: 1fr;
  }

  #content {
    padding: var(--space-4);
  }

  .topbar-date-range { display: none; }
}

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

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