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

:root {
  --bg: #0a0e17;
  --bg-surface: #111827;
  --bg-elevated: #1a2234;
  --border: #1e2d45;
  --text: #e0e6f0;
  --text-dim: #8892a8;
  --accent: #6abb45;
  --accent-dim: #4a8a30;
  --navy: #051631;
  --link: #8ab4f8;
  --danger: #ff5555;
  --warning: #f0ad4e;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

html, body { height: 100%; }

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

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navigation */
.nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--accent);
  margin-right: 30px;
  letter-spacing: -0.5px;
}

.nav-links { display: flex; gap: 4px; }

.nav-links a {
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--bg-elevated);
  text-decoration: none;
}

.nav-links a.active { color: var(--accent); }

.nav-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8em;
  color: var(--text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.status-dot.offline { background: var(--danger); }

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

.page-title {
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--accent);
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Chat Layout */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.6;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: #1a3a5c;
  border: 1px solid #2a4a6c;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.message.assistant .sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.8em;
  color: var(--text-dim);
}

.message.assistant .sources summary {
  cursor: pointer;
  color: var(--text-dim);
}

.message.assistant .sources li {
  margin: 4px 0 4px 16px;
  list-style: none;
}

.message p { margin-bottom: 8px; }
.message p:last-child { margin-bottom: 0; }
.message ul, .message ol { margin: 8px 0 8px 20px; }
.message code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.9em;
}
.message pre {
  background: var(--bg-elevated);
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 8px 0;
}
.message pre code {
  background: none;
  padding: 0;
}
.message strong { color: var(--accent); }
.message table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.message th, .message td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  font-size: 0.9em;
}
.message th { background: var(--bg-elevated); }

.chat-input-area {
  padding: 16px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.chat-input-area textarea {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 15px;
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 120px;
}

.chat-input-area textarea:focus {
  border-color: var(--accent);
}

.chat-input-area textarea::placeholder {
  color: var(--text-dim);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}
th { color: var(--text-dim); font-weight: 600; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover { background: var(--bg-elevated); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75em;
  font-weight: 600;
}
.badge.green { background: #1a3a1a; color: var(--accent); }
.badge.yellow { background: #3a3a1a; color: var(--warning); }
.badge.red { background: #3a1a1a; color: var(--danger); }
.badge.blue { background: #1a2a4a; color: var(--link); }

/* Search */
.search-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  width: 100%;
  outline: none;
  margin-bottom: 16px;
}
.search-box:focus { border-color: var(--accent); }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card .stat-value {
  font-size: 2em;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 0.85em;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Typing animation */
.typing::after {
  content: '|';
  animation: blink 0.7s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Responsive */
@media (max-width: 768px) {
  .nav { padding: 0 12px; }
  .nav-brand { margin-right: 12px; font-size: 1em; }
  .nav-links a { padding: 6px 10px; font-size: 0.8em; }
  .chat-messages { padding: 12px; }
  .message { max-width: 95%; }
  .container { padding: 12px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

/* Product Carousels & Affiliate Links */
.product-carousel {
  margin: 20px 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.carousel-title {
  font-weight: 600;
  font-size: 1em;
  margin-bottom: 12px;
  color: var(--accent);
}
.carousel-items {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.product-card {
  flex: 0 0 150px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  scroll-snap-align: start;
}
.product-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.product-card img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin-bottom: 8px;
}
.product-name {
  font-size: 0.8em;
  line-height: 1.3;
  margin-bottom: 4px;
  color: var(--text);
}
.product-price {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9em;
}
a.affiliate-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
}
a.affiliate-link:hover {
  color: #fff;
  text-decoration-style: solid;
}
.affiliate-disclosure {
  font-size: 0.75em;
  color: var(--text-dim);
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Print */
@media print {
  .nav, .chat-input-area { display: none; }
  body { background: #fff; color: #000; }
  .message { max-width: 100%; border: 1px solid #ccc; }
}
