/* ============================================================
   VendorIntel VIP — VRM Design System v4.0
   Full-viewport dark theme  |  sidebar + content layout
   ============================================================ */

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

/* ---- CSS Custom Properties --------------------------------- */
:root {
  --brand-primary:    #6366f1;
  --brand-secondary:  #8b5cf6;
  --brand-accent:     #22d3ee;
  --brand-emerald:    #10b981;
  --brand-rose:       #f43f5e;
  --brand-amber:      #f59e0b;

  --bg-base:          #0d0f1a;
  --bg-sidebar:       #0b0d18;
  --bg-card:          #131629;
  --bg-card-hover:    #1a1e35;
  --bg-elevated:      #1e2237;
  --bg-input:         rgba(255,255,255,0.05);

  --border-subtle:    rgba(255,255,255,0.07);
  --border-default:   rgba(255,255,255,0.10);
  --border-strong:    rgba(255,255,255,0.16);
  --border-accent:    rgba(99,102,241,0.35);

  --text-primary:     #f1f5f9;
  --text-secondary:   #94a3b8;
  --text-muted:       #475569;
  --text-white:       #ffffff;

  --grad-text:        linear-gradient(135deg, #818cf8, #a78bfa, #60a5fa);

  --color-success:    #10b981;
  --color-warning:    #f59e0b;
  --color-danger:     #f43f5e;
  --color-info:       #22d3ee;

  --sidebar-w:        260px;
  --topbar-h:         60px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-2xl:  20px;
  --r-full: 9999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 10px 32px rgba(0,0,0,0.5);
  --shadow-xl:  0 20px 48px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 24px rgba(99,102,241,0.2);

  --t-fast: 150ms ease;
  --t-base: 200ms ease;
  --t-slow: 300ms ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
  overflow-x: hidden;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: #818cf8; }
img, svg { display: block; max-width: 100%; }

/* ---- Background grid ----------------------------------- */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(99,102,241,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.03) 1px, transparent 1px);
  background-size: 52px 52px;
}

/* ============================================================
   APP SHELL — sidebar + main
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ---- Sidebar ------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.75rem; color: #fff;
  flex-shrink: 0; letter-spacing: -0.5px;
  box-shadow: 0 0 16px rgba(99,102,241,0.35);
}
.logo-text strong { display: block; font-size: 0.82rem; font-weight: 800; color: var(--text-white); line-height: 1.2; }
.logo-text span   { font-size: 0.68rem; color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.nav-section { margin-bottom: 12px; }
.nav-section-label {
  padding: 6px 20px;
  font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px;
  color: #64748b; font-size: 0.83rem; font-weight: 500;
  cursor: pointer; transition: all var(--t-fast);
  border-left: 2px solid transparent;
  text-decoration: none; white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); text-decoration: none; }
.nav-item.active {
  background: rgba(99,102,241,0.12);
  color: #818cf8; border-left-color: var(--brand-primary);
}
.nav-item .nav-icon { width: 18px; font-size: 0.88rem; flex-shrink: 0; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff; font-size: 0.6rem; font-weight: 800;
  padding: 2px 6px; border-radius: var(--r-full);
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 6px 8px;
  border-radius: var(--r-lg); transition: background var(--t-fast);
}
.user-info:hover { background: rgba(255,255,255,0.05); }
.user-avatar {
  width: 34px; height: 34px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.72rem; color: #fff; flex-shrink: 0;
}
.user-avatar.franchisor { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.user-avatar.vendor     { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.user-avatar.location   { background: linear-gradient(135deg, #10b981, #06b6d4); }
.user-meta strong { display: block; color: var(--text-primary); font-size: 0.8rem; font-weight: 700; }
.user-meta span   { font-size: 0.68rem; color: var(--text-muted); }

/* ---- Main Content --------------------------------------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

/* ---- Top Bar ------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  flex-shrink: 0;
}
.topbar-title   { font-size: 1rem; font-weight: 800; color: var(--text-white); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-left: 10px; font-weight: 400; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.topbar-icon-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--t-fast);
  position: relative; flex-shrink: 0;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.notif-dot { position: absolute; top: -3px; right: -3px; width: 7px; height: 7px; background: var(--color-danger); border-radius: 50%; border: 1.5px solid var(--bg-sidebar); }

/* ---- Page Content -------------------------------------- */
.page-content {
  flex: 1;
  padding: 24px 32px;
  width: 100%;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left h1 { font-size: 1.45rem; font-weight: 800; color: var(--text-white); }
.page-header-left p  { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }

/* ---- KPI Cards ----------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: 20px;
  transition: all var(--t-base);
}
.kpi-card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glow); }

.kpi-icon {
  width: 40px; height: 40px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 1.05rem;
}
.kpi-icon.blue   { background: rgba(99,102,241,0.15);  color: #818cf8; }
.kpi-icon.green  { background: rgba(16,185,129,0.15);  color: #34d399; }
.kpi-icon.amber  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.kpi-icon.red    { background: rgba(244,63,94,0.15);   color: #fb7185; }
.kpi-icon.violet { background: rgba(139,92,246,0.15);  color: #a78bfa; }
.kpi-icon.sky    { background: rgba(34,211,238,0.12);  color: #22d3ee; }

.kpi-value { font-size: 1.85rem; font-weight: 900; color: var(--text-white); line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 0.76rem; color: var(--text-muted); font-weight: 500; }
.kpi-trend { margin-top: 8px; font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.kpi-trend.up   { color: var(--color-success); }
.kpi-trend.down { color: var(--color-danger); }
.kpi-trend.flat { color: var(--text-muted); }
.kpi-subtitle { font-size: 0.68rem; color: var(--text-muted); }

/* ---- Cards --------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title    { font-size: 0.88rem; font-weight: 700; color: var(--text-white); }
.card-subtitle { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.card-body     { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* ---- Buttons ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-md);
  font-size: 0.8rem; font-weight: 700;
  cursor: pointer; transition: all var(--t-fast);
  border: 1px solid transparent; white-space: nowrap;
  font-family: var(--font-sans); line-height: 1.4;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover { opacity: 0.88; box-shadow: 0 4px 20px rgba(99,102,241,0.4); }

.btn-secondary {
  background: rgba(255,255,255,0.06); color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-success  { background: var(--color-success); color: #fff; }
.btn-success:hover { opacity: 0.88; }
.btn-danger   { background: var(--color-danger); color: #fff; }
.btn-danger:hover  { opacity: 0.88; }

.btn-outline {
  background: transparent; color: var(--brand-primary);
  border-color: rgba(99,102,241,0.4);
}
.btn-outline:hover { background: rgba(99,102,241,0.08); }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 0.72rem; }
.btn-lg { padding: 10px 22px; font-size: 0.92rem; }
.btn-icon { padding: 7px; }
.w-full { width: 100%; justify-content: center; }

/* ---- Badges -------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 0.68rem; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-success { background: rgba(16,185,129,0.12);  color: #34d399; }
.badge-warning { background: rgba(245,158,11,0.12);  color: #fbbf24; }
.badge-danger  { background: rgba(244,63,94,0.12);   color: #fb7185; }
.badge-info    { background: rgba(34,211,238,0.10);  color: #22d3ee; }
.badge-neutral { background: rgba(255,255,255,0.06); color: #94a3b8; }
.badge-primary { background: rgba(99,102,241,0.12);  color: #818cf8; }
.badge-violet  { background: rgba(139,92,246,0.12);  color: #a78bfa; }

/* ---- Tables -------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead tr { background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border-subtle); }
thead th {
  padding: 10px 14px; text-align: left;
  font-weight: 700; font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background var(--t-fast); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody td { padding: 10px 14px; color: var(--text-secondary); vertical-align: middle; }
.td-primary { font-weight: 600; color: var(--text-primary) !important; }

/* ---- Progress Bar -------------------------------------- */
.progress-bar { width: 100%; height: 5px; background: rgba(255,255,255,0.07); border-radius: var(--r-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--r-full); transition: width 0.6s ease; }
.progress-fill.green  { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-fill.amber  { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill.red    { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.progress-fill.blue   { background: linear-gradient(90deg, #6366f1, #818cf8); }
.progress-fill.violet { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }

/* ---- Alerts -------------------------------------------- */
.alert {
  padding: 14px; border-radius: var(--r-lg);
  border-left: 3px solid; display: flex; gap: 10px;
  margin-bottom: 16px; font-size: 0.8rem;
}
.alert-success { background: rgba(16,185,129,0.08);  border-color: var(--color-success); }
.alert-warning { background: rgba(245,158,11,0.08);  border-color: var(--color-warning); }
.alert-danger  { background: rgba(244,63,94,0.08);   border-color: var(--color-danger); }
.alert-info    { background: rgba(34,211,238,0.07);  border-color: var(--color-info); }
.alert-icon    { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.alert-title   { font-weight: 700; color: var(--text-primary); }
.alert-body    { color: var(--text-secondary); margin-top: 2px; }

/* ---- Tabs ---------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 20px; }
.tab {
  padding: 8px 14px; font-size: 0.8rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--t-fast);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }
.tab.active { color: #818cf8; border-bottom-color: var(--brand-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Modal --------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,15,26,0.85); backdrop-filter: blur(6px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  max-width: 640px; width: 100%; max-height: 90vh;
  overflow-y: auto; animation: slideUp 0.25s ease;
}
.modal-lg  { max-width: 900px; }
.modal-xl  { max-width: 1100px; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: flex-start; justify-content: space-between;
}
.modal-title    { font-size: 1.05rem; font-weight: 800; color: var(--text-white); }
.modal-subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem; padding: 4px;
  border-radius: var(--r-md); transition: all var(--t-fast);
}
.modal-close:hover { background: rgba(255,255,255,0.07); color: var(--text-primary); }
.modal-body   { padding: 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Forms --------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-hint  { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.form-control {
  width: 100%; padding: 9px 13px;
  font-size: 0.83rem; font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-default);
  border-radius: var(--r-md);
  outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-control:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 88px; }
option { background: var(--bg-elevated); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- Filter / Search Bar ------------------------------- */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.85rem; pointer-events: none; }
.search-input {
  width: 100%; padding: 8px 13px 8px 34px;
  font-size: 0.8rem; font-family: var(--font-sans);
  border: 1.5px solid var(--border-default);
  border-radius: var(--r-md);
  background: var(--bg-input); color: var(--text-primary); outline: none;
  transition: border-color var(--t-fast);
}
.search-input:focus { border-color: var(--brand-primary); }
.search-input::placeholder { color: var(--text-muted); }

/* ---- Grid Layouts -------------------------------------- */
.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3    { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ---- AI Copilot ---------------------------------------- */
.ai-panel {
  position: fixed; right: 0; top: 0; width: 360px; height: 100vh;
  background: var(--bg-card); border-left: 1px solid var(--border-default);
  display: flex; flex-direction: column; z-index: 150;
  transform: translateX(100%); transition: transform var(--t-slow);
  box-shadow: var(--shadow-xl);
}
.ai-panel.open { transform: translateX(0); }

.ai-panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.06));
  flex-shrink: 0;
}
.ai-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.95rem; flex-shrink: 0;
  box-shadow: 0 0 14px rgba(99,102,241,0.35);
}
.ai-panel-title strong { display: block; font-size: 0.88rem; font-weight: 800; color: var(--text-white); }
.ai-panel-title span   { font-size: 0.68rem; color: #818cf8; font-weight: 600; }

.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: rgba(0,0,0,0.15); }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: var(--r-xl); font-size: 0.8rem; line-height: 1.55; }
.ai-msg.bot  { background: var(--bg-elevated); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 4px; }
.ai-msg.user { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-msg.thinking { background: var(--bg-elevated); align-self: flex-start; }
.ai-typing-dots span { display: inline-block; width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; margin: 0 2px; animation: bounce 1.2s infinite ease-in-out; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.ai-quick-prompts { padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border-subtle); flex-shrink: 0; }
.ai-quick-prompt {
  padding: 4px 10px;
  background: rgba(99,102,241,0.1); color: #818cf8;
  border: 1px solid rgba(99,102,241,0.2); border-radius: var(--r-full);
  font-size: 0.7rem; font-weight: 600; cursor: pointer; transition: all var(--t-fast);
}
.ai-quick-prompt:hover { background: rgba(99,102,241,0.2); }

.ai-input-area { padding: 12px 14px; border-top: 1px solid var(--border-default); display: flex; gap: 8px; flex-shrink: 0; }
.ai-input {
  flex: 1; padding: 8px 11px; border: 1.5px solid var(--border-default);
  border-radius: var(--r-md); font-size: 0.8rem; font-family: var(--font-sans);
  background: var(--bg-input); color: var(--text-primary); outline: none; resize: none; max-height: 100px;
}
.ai-input:focus { border-color: var(--brand-primary); }
.ai-input::placeholder { color: var(--text-muted); }
.ai-send-btn {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none; border-radius: var(--r-md); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: opacity var(--t-fast);
}
.ai-send-btn:hover { opacity: 0.85; }

.ai-toggle-btn {
  position: fixed; right: 24px; bottom: 24px; z-index: 149;
  width: 50px; height: 50px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none; border-radius: var(--r-full); color: #fff; font-size: 1.2rem;
  cursor: pointer; box-shadow: 0 4px 20px rgba(99,102,241,0.45);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-base);
}
.ai-toggle-btn:hover { transform: scale(1.08); }
.ai-badge-dot { position: absolute; top: -2px; right: -2px; width: 11px; height: 11px; background: var(--color-danger); border-radius: 50%; border: 2px solid var(--bg-base); }

/* ---- Insight Card -------------------------------------- */
.insight-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.06));
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: var(--r-xl); padding: 16px;
  position: relative; overflow: hidden;
}
.insight-card::before {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 70px; height: 70px;
  background: radial-gradient(circle, rgba(99,102,241,0.12), transparent);
  border-radius: 50%; pointer-events: none;
}
.insight-card-label { font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: #818cf8; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.insight-card-body  { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.65; }

/* ---- Timeline ------------------------------------------ */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; position: relative; z-index: 1; }
.timeline-dot.green  { background: var(--color-success); box-shadow: 0 0 8px rgba(16,185,129,0.5); }
.timeline-dot.amber  { background: var(--color-warning); box-shadow: 0 0 8px rgba(245,158,11,0.5); }
.timeline-dot.blue   { background: var(--brand-primary); box-shadow: 0 0 8px rgba(99,102,241,0.5); }
.timeline-dot.red    { background: var(--color-danger); box-shadow: 0 0 8px rgba(244,63,94,0.5); }
.timeline-item::before { content: ''; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--border-subtle); }
.timeline-item:last-child::before { display: none; }
.timeline-title { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.timeline-meta  { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Empty State --------------------------------------- */
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-muted); }
.empty-state-icon  { font-size: 2.4rem; margin-bottom: 14px; }
.empty-state-title { font-size: 0.96rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-desc  { font-size: 0.8rem; max-width: 340px; margin: 0 auto 18px; }

/* ---- Toast --------------------------------------------- */
.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary); padding: 10px 18px;
  border-radius: var(--r-lg); font-size: 0.8rem; font-weight: 600;
  box-shadow: var(--shadow-xl); display: flex; align-items: center; gap: 8px;
  pointer-events: all; animation: slideUp 0.25s ease; white-space: nowrap;
}
.toast.success { border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.12); color: #34d399; }
.toast.warning { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.10); color: #fbbf24; }
.toast.danger  { border-color: rgba(244,63,94,0.3);  background: rgba(244,63,94,0.10);  color: #fb7185; }
.toast.info    { border-color: rgba(99,102,241,0.3); background: rgba(99,102,241,0.10); color: #818cf8; }

/* ---- Chart containers ---------------------------------- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap.h-200 { height: 200px; }
.chart-wrap.h-220 { height: 220px; }
.chart-wrap.h-250 { height: 250px; }
.chart-wrap.h-280 { height: 280px; }
.chart-wrap.h-300 { height: 300px; }
.chart-wrap.h-350 { height: 350px; }
/* Legacy support */
.chart-container { position: relative; width: 100%; }
.chart-container.h-200 { height: 200px; }
.chart-container.h-220 { height: 220px; }
.chart-container.h-250 { height: 250px; }
.chart-container.h-280 { height: 280px; }
.chart-container.h-300 { height: 300px; }
.chart-container.h-350 { height: 350px; }

/* ---- Utility helpers ----------------------------------- */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-1          { flex: 1; }
.flex-wrap       { flex-wrap: wrap; }
.gap-2  { gap: 8px; }  .gap-3  { gap: 10px; } .gap-4  { gap: 14px; }
.gap-5  { gap: 18px; } .gap-6  { gap: 22px; }
.text-xs   { font-size: 0.7rem; }  .text-sm   { font-size: 0.8rem; }
.text-base { font-size: 0.9rem; }  .text-lg   { font-size: 1rem; }
.text-xl   { font-size: 1.1rem; }  .text-2xl  { font-size: 1.35rem; }
.font-medium   { font-weight: 500; } .font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; } .font-extrabold{ font-weight: 800; }
.text-white    { color: var(--text-white); }
.text-primary  { color: var(--text-primary); }
.text-gray     { color: var(--text-secondary); }
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--color-success); }
.text-warning  { color: var(--color-warning); }
.text-danger   { color: var(--color-danger); }
.text-violet   { color: #a78bfa; }
.text-indigo   { color: #818cf8; }
.text-cyan     { color: #22d3ee; }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.mb-0 { margin-bottom: 0; }    .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 10px; } .mb-4 { margin-bottom: 14px; }
.mb-5 { margin-bottom: 18px; } .mb-6 { margin-bottom: 22px; }
.mt-2 { margin-top: 8px; }     .mt-3 { margin-top: 10px; }
.mt-4 { margin-top: 14px; }    .mt-6 { margin-top: 22px; }
.p-4  { padding: 14px; }       .p-5  { padding: 18px; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divide-y > * + * { border-top: 1px solid var(--border-subtle); }
.rounded-full { border-radius: var(--r-full); }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.overflow-hidden { overflow: hidden; }

/* ---- Animations ---------------------------------------- */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bounce  { 0%,80%,100% { transform: scale(0.7); } 40% { transform: scale(1); } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes pulse   { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-fadeIn  { animation: fadeIn 0.3s ease; }
.animate-slideUp { animation: slideUp 0.3s ease; }
.animate-spin    { animation: spin 1s linear infinite; }
.animate-pulse   { animation: pulse 2s infinite; }

/* ---- Scrollbar ----------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ---- Responsive ---------------------------------------- */
@media (max-width: 1280px) {
  :root { --sidebar-w: 240px; }
  .page-content { padding: 20px 24px; }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .page-content { padding: 18px 20px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); width: 260px; }
  .main-content { margin-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .ai-panel { width: 100%; }
  .page-content { padding: 16px; }
}

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