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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2333;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --teal: #00d4c8;
  --teal-dim: rgba(0,212,200,0.12);
  --yellow: #f0a500;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 32px;
}

/* HEADER */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-ai {
  background: var(--teal);
  color: #000;
  font-weight: 800;
  font-size: 15px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.logo-text { font-weight: 700; font-size: 16px; }
.store-badge {
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(0,212,200,0.3);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
}

/* AGENTS */
.agents-section {
  padding: 24px 0 0;
}
.agents-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.agent-card {
  flex: 1;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
  cursor: default;
}
.agent-card:hover { transform: translateY(-2px); }
.agent-manager { border-top: 3px solid var(--teal); }
.agent-analyst { border-top: 3px solid #58a6ff; }
.agent-procurement { border-top: 3px solid var(--orange); }
.agent-marketer { border-top: 3px solid #bc8cff; }
.agent-financier { border-top: 3px solid var(--green); }

.agent-icon { font-size: 28px; margin-bottom: 8px; }
.agent-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.agent-desc { font-size: 11px; color: var(--text-muted); }

.agent-card.active {
  background: var(--teal-dim);
  border-color: var(--teal);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.kpi-card.skeleton {
  height: 100px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 8px; }
.kpi-change { font-size: 12px; font-weight: 600; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }
.kpi-change.neutral { color: var(--text-muted); }

/* CHARTS */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-top: 0;
}
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* TWO COL */
.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* TABLE */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 0;
  border-bottom: 1px solid rgba(48,54,61,0.5);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.trend-up { color: var(--green); font-size: 16px; }
.trend-down { color: var(--red); font-size: 16px; }
.trend-stable { color: var(--text-muted); font-size: 16px; }

/* ALERTS */
.alert-group { margin-bottom: 14px; }
.alert-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.alert-group-title.critical { color: var(--red); }
.alert-group-title.low { color: var(--orange); }
.alert-group-title.overstock { color: #58a6ff; }
.alert-item {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  line-height: 1.4;
}
.alert-item.critical { background: rgba(248,81,73,0.1); border-left: 3px solid var(--red); }
.alert-item.low { background: rgba(210,153,34,0.1); border-left: 3px solid var(--orange); }
.alert-item.overstock { background: rgba(88,166,255,0.1); border-left: 3px solid #58a6ff; }

/* CAMPAIGNS */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.campaign-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg);
}
.campaign-name { font-size: 12px; font-weight: 600; margin-bottom: 8px; line-height: 1.3; }
.campaign-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.campaign-stat { font-size: 11px; }
.campaign-stat span { color: var(--text-muted); }
.campaign-roas { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.roas-good { color: var(--green); }
.roas-ok { color: var(--orange); }
.roas-bad { color: var(--red); }
.campaign-rec {
  font-size: 11px;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.rec-stop { background: rgba(248,81,73,0.15); color: var(--red); }
.rec-scale { background: rgba(63,185,80,0.15); color: var(--green); }
.rec-ok { background: rgba(125,133,144,0.15); color: var(--text-muted); }
.campaign-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-weight: 600;
}
.badge-active { background: rgba(63,185,80,0.2); color: var(--green); }
.badge-paused { background: rgba(125,133,144,0.2); color: var(--text-muted); }

/* CHAT */
.chat-section { padding-top: 0; }
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
}
.chat-title { font-weight: 700; font-size: 15px; }
.chat-hint { font-size: 12px; color: var(--text-muted); }

.quick-questions {
  padding: 14px 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.quick-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.quick-btn:hover {
  border-color: var(--teal);
  background: var(--teal-dim);
  color: var(--teal);
}

.chat-messages {
  padding: 20px;
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-welcome {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
}
.welcome-icon { font-size: 40px; margin-bottom: 12px; }
.chat-welcome p { font-size: 14px; line-height: 1.6; }

.msg-user {
  align-self: flex-end;
  background: var(--teal-dim);
  border: 1px solid rgba(0,212,200,0.3);
  border-radius: 12px 12px 0 12px;
  padding: 12px 16px;
  max-width: 70%;
  font-size: 14px;
  color: var(--teal);
}

.msg-ai {
  align-self: flex-start;
  max-width: 85%;
}
.msg-agents-badge {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.agent-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.msg-content {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 0 12px 12px 12px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.msg-content strong, .msg-content b { color: var(--teal); }

.msg-loading {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}
.dots span {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--teal);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--teal); }
.chat-input::placeholder { color: var(--text-muted); }
.chat-send {
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  cursor: pointer;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.chat-send:hover { opacity: 0.85; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* FOOTER */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .campaigns-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .campaigns-grid { grid-template-columns: 1fr; }
  .msg-user, .msg-ai { max-width: 95%; }
}
