/**
 * FeedStock Intelligence Desk - Design System & Glassmorphism Styling
 * Aesthetic: Apple-grade Modern Minimalism, Monochrome Slate + Single Accent (#00E599)
 */

:root {
  --bg-base: #0a0b0d;
  --bg-surface: rgba(18, 20, 24, 0.65);
  --bg-surface-hover: rgba(26, 29, 36, 0.85);
  --bg-card: rgba(15, 17, 21, 0.7);
  
  --border-hairline: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-active: rgba(0, 229, 153, 0.4);

  /* Single Accent Color: Electric Mint / Clean Emerald */
  --accent: #00e599;
  --accent-muted: rgba(0, 229, 153, 0.12);
  --accent-glow: rgba(0, 229, 153, 0.25);
  --accent-dark: #00b377;

  /* Monochromatic Typographic Tiers */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-faint: #475569;

  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, Monaco, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --glass-blur: blur(24px) saturate(180%);
}

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

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

/* Ambient glow subtle lighting behind glass cards */
.glow-bg {
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 229, 153, 0.04) 0%, rgba(10, 11, 13, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 11, 13, 0.82);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 1.5rem;
}

.header-inner {
  max-width: 1360px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  color: var(--text-primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.brand-desk {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-family: var(--font-mono);
  text-transform: uppercase;
}

/* Telemetry Status Pill */
.telemetry-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-ring 2.5s infinite;
}

@keyframes pulse-ring {
  0% { opacity: 0.4; }
  50% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0.4; }
}

.telemetry-divider {
  width: 1px;
  height: 10px;
  background: var(--border-subtle);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Standardized Minimalist Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid var(--border-active);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

.action-btn:hover {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 14px var(--accent-glow);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-icon.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* Glass Card Core */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.glass-card:hover {
  border-color: var(--border-subtle);
}

/* Main Layout */
.main-layout {
  max-width: 1360px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem 1.5rem;
  position: relative;
  z-index: 1;
}

/* Intro Section */
.desk-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.desk-headline {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.desk-subhead {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 680px;
}

.source-badges {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.badge-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.badge-val {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  padding: 1.25rem 1.4rem;
}

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

.kpi-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-tag {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
}

.kpi-tag.alert {
  color: var(--accent);
  border-color: var(--border-active);
  background: var(--accent-muted);
}

.kpi-number {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
}

.kpi-number.highlight {
  color: var(--accent);
}

.kpi-foot {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Charts Section */
.charts-section {
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.charts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chart-tab-group {
  display: flex;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
}

.chart-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.chart-tab:hover {
  color: var(--text-primary);
}

.chart-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.chart-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
}

.accent-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.chart-body {
  height: 240px;
  width: 100%;
  position: relative;
}

/* Persona Section */
.persona-section {
  margin-bottom: 1.5rem;
}

.persona-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.6rem;
}

.persona-tabs {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.persona-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  font-family: inherit;
}

.persona-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.persona-btn.active {
  background: var(--text-primary);
  color: #000;
  border-color: var(--text-primary);
  font-weight: 600;
}

/* Toolbar & Filters */
.toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  flex: 1;
  min-width: 280px;
  max-width: 480px;
  transition: border-color 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--border-active);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  width: 100%;
  outline: none;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-dropdowns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-dropdowns select {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-hairline);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.filter-dropdowns select:hover,
.filter-dropdowns select:focus {
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

/* Stream Header & Grid */
.stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stream-legend {
  display: flex;
  gap: 0.85rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.stream-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Stream Cards (Single-accent Apple Minimalist) */
.stream-card {
  padding: 1.35rem 1.6rem;
  cursor: pointer;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.stream-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: transparent;
  transition: background 0.2s ease;
}

.stream-card.critical::before {
  background: var(--accent);
}

.stream-card.elevated::before {
  background: rgba(255, 255, 255, 0.4);
}

.stream-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-subtle);
  background: var(--bg-surface-hover);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  gap: 0.75rem;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  text-transform: uppercase;
}

.badge.impact-critical {
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid var(--border-active);
}

.badge.impact-elevated {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.badge.impact-standard {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid var(--border-hairline);
}

.badge.category-tag {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-hairline);
}

.badge.region-tag {
  color: var(--text-muted);
}

.card-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
  letter-spacing: -0.01em;
}

.card-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.85rem;
}

/* Feedstock tags */
.card-feedstocks {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.feedstock-pill {
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

/* Trade Desk Takeaway Highlight Box */
.desk-takeaway-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-hairline);
  border-left: 2px solid var(--accent);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.takeaway-persona-label {
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.05em;
  padding-top: 0.1rem;
}

.takeaway-text {
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Card Bottom Info */
.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-hairline);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-source {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
}

.card-action-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.card-action-link:hover {
  text-decoration: underline;
}

/* Modal Dossier */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  background: rgba(14, 16, 20, 0.95);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.modal-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-hairline);
}

.modal-section {
  margin-bottom: 1.5rem;
}

.section-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-bottom: 0.5rem;
}

.section-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.persona-matrix {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.matrix-row {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.matrix-label {
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.matrix-label .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.matrix-val {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.modal-footer-meta {
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.meta-lbl {
  color: var(--text-muted);
}

.meta-val {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.accent-val {
  color: var(--accent);
}

.external-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  background: var(--accent-muted);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.external-link-btn:hover {
  background: var(--accent);
  color: #000;
}

/* App Footer */
.app-footer {
  border-top: 1px solid var(--border-hairline);
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-sep {
  margin: 0 0.4rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .header-inner {
    height: auto;
    padding: 1rem 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .telemetry-pill {
    width: 100%;
    justify-content: center;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: none;
  }
}
