/* style.css — BH Intelligence Reports Dashboard
   Art direction: SaaS marketing analytics dashboard → dark professional
   Palette: Cool dark charcoal surfaces, teal/cyan accent for precision/intelligence
   Typography: DM Sans (display/headings) + Inter (body/UI) — serious, dense, data-ready
   Density: Dense dashboard layout */

/* ============================================
   GLOBAL OVERRIDES
   ============================================ */
html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}

/* Tabular nums on all data */
.tabular-nums {
  font-variant-numeric: tabular-nums lining-nums;
}

/* ============================================
   APP SHELL
   ============================================ */
#app {
  height: 100dvh;
  overflow: hidden;
}

/* View transitions */
.view {
  display: none;
  opacity: 0;
  transition: opacity 300ms ease;
}

.view.active {
  display: flex;
  opacity: 1;
}

/* ============================================
   LOGIN VIEW
   ============================================ */
#login-view {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: var(--color-bg);
}

#login-view.active {
  display: flex;
}

/* Subtle animated background */
.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.login-bg::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, oklch(from var(--color-primary) l c h / 0.06) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: float-orb 20s ease-in-out infinite;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, oklch(from var(--color-primary) l c h / 0.04) 0%, transparent 70%);
  bottom: -150px;
  left: -100px;
  animation: float-orb 25s ease-in-out infinite reverse;
}

@keyframes float-orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  width: min(420px, calc(100% - var(--space-8)));
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-6);
}

.login-logo svg {
  width: 56px;
  height: 56px;
}

.login-brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.login-tagline {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  background: #fff;
  color: #3c4043;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid #dadce0;
  cursor: pointer;
  transition: background var(--transition-interactive), box-shadow var(--transition-interactive);
}

.btn-google:hover {
  background: #f7f8f8;
  box-shadow: 0 2px 8px oklch(0 0 0 / 0.15);
}

.btn-google:active {
  background: #eee;
}

.btn-google svg {
  display: inline;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.login-footer {
  position: absolute;
  bottom: var(--space-6);
  left: 0;
  right: 0;
  text-align: center;
  z-index: 1;
}

.login-footer a {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--color-text-muted);
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.dashboard-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  background: var(--color-bg);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  grid-row: 1 / -1;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 20;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.sidebar-logo svg {
  width: 32px;
  height: 32px;
  display: block;
}

.sidebar-brand {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive);
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}

.nav-item:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
}

.nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-item i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-divider);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  flex-shrink: 0;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-signout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1) 0;
}

.btn-signout:hover {
  color: var(--color-error);
}

/* ============================================
   HEADER
   ============================================ */
.main-header {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
  gap: var(--space-4);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
}

.btn-hamburger:hover {
  background: var(--color-surface-dynamic);
}

/* ============================================
   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-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: background var(--transition-interactive), color var(--transition-interactive), box-shadow var(--transition-interactive);
}

.btn i {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

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

.btn-primary:active {
  background: var(--color-primary-active);
}

.btn-secondary {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover {
  color: var(--color-text);
  background: var(--color-surface-dynamic);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn-icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

/* Theme toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  grid-column: 2;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6);
}

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.kpi-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.kpi-value {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums lining-nums;
}

.kpi-delta.positive {
  color: var(--color-success);
}

.kpi-delta.negative {
  color: var(--color-error);
}

/* ============================================
   DATA TABLE
   ============================================ */
.table-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.table-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.table-scroll {
  overflow-x: auto;
}

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

.data-table th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
  background: var(--color-surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--color-surface-2);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
}

.badge-active {
  background: oklch(from var(--color-success) l c h / 0.12);
  color: var(--color-success);
}

.badge-inactive {
  background: oklch(from var(--color-text-faint) l c h / 0.15);
  color: var(--color-text-muted);
}

.badge-warning {
  background: oklch(from var(--color-warning) l c h / 0.12);
  color: var(--color-warning);
}

.badge-critical {
  background: oklch(from var(--color-error) l c h / 0.12);
  color: var(--color-error);
}

.table-actions {
  display: flex;
  gap: var(--space-2);
}

/* ============================================
   REPORT VIEW
   ============================================ */
.report-layout {
  display: flex;
  gap: var(--space-6);
  min-height: 0;
}

.report-metrics {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

.report-metrics-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.metric-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.metric-value {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.2;
}

.metric-delta {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums lining-nums;
}

.metric-delta.positive {
  color: var(--color-success);
}

.metric-delta.negative {
  color: var(--color-error);
}

/* Report content area */
.report-content {
  flex: 1;
  min-width: 0;
}

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

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
}

.btn-back:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

.report-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

.month-select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-left: auto;
  cursor: pointer;
}

.month-select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: var(--space-5);
}

.tab-btn {
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-interactive), border-color var(--transition-interactive);
  margin-bottom: -1px;
}

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

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* AI Narrative */
.narrative-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.narrative-content h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
}

.narrative-content h2:first-child {
  margin-top: 0;
}

.narrative-content p {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-3);
}

.narrative-content strong {
  color: var(--color-text);
  font-weight: 600;
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

/* Anomaly cards */
.anomaly-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

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

.anomaly-metric {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.anomaly-detail {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.6;
}

.anomaly-action {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.anomaly-action i {
  flex-shrink: 0;
  color: var(--color-primary);
  margin-top: 2px;
}

/* ============================================
   REPORT STATUS BAR
   ============================================ */
.report-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.status-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.status-text {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.status-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Status-specific badge styles */
.badge-draft {
  background: oklch(from var(--color-warning) l c h / 0.12);
  color: var(--color-warning);
}

.badge-approved {
  background: oklch(from var(--color-success) l c h / 0.12);
  color: var(--color-success);
}

.badge-declined {
  background: oklch(from var(--color-error) l c h / 0.12);
  color: var(--color-error);
}

.badge-complete {
  background: oklch(from var(--color-primary) l c h / 0.12);
  color: var(--color-primary);
}

/* Approve / Decline buttons */
.btn-approve {
  background: oklch(from var(--color-success) l c h / 0.12);
  color: var(--color-success);
  border: 1px solid oklch(from var(--color-success) l c h / 0.25);
}

.btn-approve:hover {
  background: oklch(from var(--color-success) l c h / 0.2);
}

.btn-decline {
  background: oklch(from var(--color-error) l c h / 0.12);
  color: var(--color-error);
  border: 1px solid oklch(from var(--color-error) l c h / 0.25);
}

.btn-decline:hover {
  background: oklch(from var(--color-error) l c h / 0.2);
}

/* ============================================
   NARRATIVE EDITING
   ============================================ */
.narrative-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: oklch(from var(--color-primary) l c h / 0.08);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.toolbar-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-primary);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Editable narrative styling */
.narrative-content.editing {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px oklch(from var(--color-primary) l c h / 0.15);
}

.narrative-content.editing h2,
.narrative-content.editing p {
  cursor: text;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  margin-left: calc(var(--space-2) * -1);
  margin-right: calc(var(--space-2) * -1);
  transition: background var(--transition-interactive);
}

.narrative-content.editing h2:hover,
.narrative-content.editing p:hover {
  background: oklch(from var(--color-primary) l c h / 0.06);
}

.narrative-content.editing h2:focus,
.narrative-content.editing p:focus {
  background: oklch(from var(--color-primary) l c h / 0.1);
  outline: none;
}

.narrative-content.editing .section-modified {
  border-left: 3px solid var(--color-primary);
  padding-left: var(--space-3);
}

/* ============================================
   REVIEW MODAL
   ============================================ */
.review-modal-body {
  margin-bottom: var(--space-2);
}

.review-modal-desc {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

/* ============================================
   EDIT HISTORY
   ============================================ */
.modal-wide {
  width: min(640px, calc(100% - var(--space-8)));
}

.history-list {
  max-height: 480px;
  overflow-y: auto;
}

.history-entry {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-divider);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-icon.action-edit {
  background: oklch(from var(--color-primary) l c h / 0.12);
  color: var(--color-primary);
}

.history-icon.action-approve {
  background: oklch(from var(--color-success) l c h / 0.12);
  color: var(--color-success);
}

.history-icon.action-decline {
  background: oklch(from var(--color-error) l c h / 0.12);
  color: var(--color-error);
}

.history-icon.action-regenerate {
  background: oklch(from var(--color-warning) l c h / 0.12);
  color: var(--color-warning);
}

.history-body {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.history-meta {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}

.history-notes {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  line-height: 1.5;
}

.history-diff {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

.diff-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
}

.diff-tag.modified {
  background: oklch(from var(--color-primary) l c h / 0.1);
  color: var(--color-primary);
}

.diff-tag.added {
  background: oklch(from var(--color-success) l c h / 0.1);
  color: var(--color-success);
}

.diff-tag.removed {
  background: oklch(from var(--color-error) l c h / 0.1);
  color: var(--color-error);
}

.history-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}

/* Report action bar */
.report-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-6);
  flex-wrap: wrap;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.6);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 200ms ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: min(500px, calc(100% - var(--space-8)));
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform 200ms ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

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

.form-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.form-input {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.form-input::placeholder {
  color: var(--color-text-faint);
}

.form-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}

.upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}

.upload-icon {
  color: var(--color-text-faint);
  margin-bottom: var(--space-3);
  display: flex;
  justify-content: center;
}

.upload-text {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.upload-hint {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  .dashboard-layout {
    grid-template-columns: 72px 1fr;
  }

  .sidebar-brand,
  .nav-label,
  .nav-badge,
  .user-info,
  .btn-signout span {
    display: none;
  }

  .sidebar-header {
    justify-content: center;
    padding: var(--space-4) var(--space-2);
  }

  .sidebar-nav {
    padding: var(--space-2);
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-3);
  }

  .sidebar-footer {
    padding: var(--space-3) var(--space-2);
  }

  .sidebar-user {
    justify-content: center;
    margin-bottom: var(--space-2);
  }

  .btn-signout {
    justify-content: center;
  }

  .report-metrics {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transition: left 300ms cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }

  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0.5);
    z-index: 99;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .btn-hamburger {
    display: flex;
  }

  .main-header {
    grid-column: 1;
  }

  .main-content {
    grid-column: 1;
    padding: var(--space-4);
  }

  .report-layout {
    flex-direction: column;
  }

  .report-metrics {
    width: 100%;
    position: static;
  }

  .report-metrics-stack {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-3);
  }

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

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

  .table-actions {
    flex-direction: column;
    gap: var(--space-1);
  }

  .report-actions {
    flex-direction: column;
  }

  .report-actions .btn {
    justify-content: center;
  }
}

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

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

/* ============================================
   PIPELINE GENERATION STEPPER
   ============================================ */

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

.generate-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
  line-height: 1.5;
}

.pipeline-stepper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: background 200ms, border-color 200ms;
}

.pipeline-step.step-running {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 5%, var(--color-surface));
}

.pipeline-step.step-done {
  border-color: var(--color-border);
  opacity: 0.85;
}

.pipeline-step.step-error {
  border-color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 5%, var(--color-surface));
}

.pipeline-step.step-skipped {
  opacity: 0.5;
}

.step-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-faint);
}

.step-running .step-icon {
  color: var(--color-primary);
  animation: pulse-icon 1.5s ease-in-out infinite;
}

.step-done .step-icon {
  color: var(--color-success);
}

.step-error .step-icon {
  color: var(--color-error);
}

@keyframes pulse-icon {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.step-body {
  flex: 1;
  min-width: 0;
}

.step-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.step-detail {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-status {
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: 500;
  min-width: 56px;
  text-align: right;
}

.step-status-pending { color: var(--color-text-faint); }
.step-status-running { color: var(--color-primary); }
.step-status-done { color: var(--color-success); }
.step-status-error { color: var(--color-error); }
.step-status-skipped { color: var(--color-text-faint); }

/* Running spinner */
.step-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

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

/* Result section */
.generate-result {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: color-mix(in srgb, var(--color-success) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-success) 20%, var(--color-border));
  border-radius: var(--radius-lg);
}

.generate-result-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-success);
  margin-bottom: var(--space-3);
}

.generate-result-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.generate-result-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Error section */
.generate-error {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: color-mix(in srgb, var(--color-error) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-error) 20%, var(--color-border));
  border-radius: var(--radius-lg);
}

.generate-error-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-error);
  margin-bottom: var(--space-3);
}

.generate-error-list {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.8;
}

/* ============================================
   CONTENT STRATEGY ADVISOR
   ============================================ */

/* Intro state */
.strategy-intro {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.strategy-intro-icon {
  color: var(--color-primary);
  margin-bottom: var(--space-4);
  opacity: 0.7;
}

.strategy-intro-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.strategy-intro-desc {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto var(--space-6);
}

.strategy-actions-row {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-4);
}

.strategy-plan-info {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: inline-block;
}

.strategy-plan-info .plan-stat {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0 var(--space-2);
}

.strategy-plan-info .plan-stat strong {
  color: var(--color-text);
}

/* Loading state */
.strategy-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-10);
  text-align: center;
}

.strategy-loading p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Summary card */
.strategy-summary-card {
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, var(--color-border));
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.strategy-summary-card strong {
  color: var(--color-text);
}

/* Section headers */
.strategy-section {
  margin-bottom: var(--space-6);
}

.strategy-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
}

.strategy-section-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.strategy-section-header h3 i {
  color: var(--color-primary);
}

.strategy-count {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 500;
}

/* Strategy cards grid */
.strategy-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Copy suggestion card */
.strategy-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: border-color 200ms;
}

.strategy-card:hover {
  border-color: color-mix(in srgb, var(--color-primary) 30%, var(--color-border));
}

.strategy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
}

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

.strategy-card-title .platform-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.strategy-card-priority {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.priority-high {
  background: oklch(from var(--color-error) l c h / 0.12);
  color: var(--color-error);
}

.priority-medium {
  background: oklch(from var(--color-warning) l c h / 0.12);
  color: var(--color-warning);
}

.priority-low {
  background: oklch(from var(--color-text-faint) l c h / 0.15);
  color: var(--color-text-muted);
}

/* Copy comparison */
.copy-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.copy-col {
  min-width: 0;
}

.copy-col-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-1);
}

.copy-current {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  line-height: 1.5;
}

.copy-suggested {
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.5;
}

.copy-suggested .copy-option {
  background: color-mix(in srgb, var(--color-success) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-success) 15%, var(--color-border));
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.copy-suggested .copy-option:last-child {
  margin-bottom: 0;
}

/* Rationale */
.strategy-rationale {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.5;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
}

/* Image brief card */
.image-brief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.brief-field {
  min-width: 0;
}

.brief-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
  margin-bottom: 2px;
}

.brief-value {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.ai-prompt-block {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
}

.ai-prompt-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.ai-prompt-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  font-style: italic;
}

/* Budget card */
.budget-change {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.budget-arrow {
  font-size: var(--text-lg);
  color: var(--color-text-faint);
}

.budget-amount {
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.budget-amount.current {
  color: var(--color-text-muted);
  text-decoration: line-through;
  opacity: 0.6;
}

.budget-amount.suggested {
  color: var(--color-text);
}

.budget-direction {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.budget-direction.increase {
  background: oklch(from var(--color-success) l c h / 0.12);
  color: var(--color-success);
}

.budget-direction.decrease {
  background: oklch(from var(--color-error) l c h / 0.12);
  color: var(--color-error);
}

.budget-direction.maintain {
  background: oklch(from var(--color-text-faint) l c h / 0.15);
  color: var(--color-text-muted);
}

/* Strategy recommendation card */
.strat-rec-meta {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.strat-rec-effort {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.strat-rec-impact {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.5;
  margin-top: var(--space-2);
}

/* Footer actions */
.strategy-footer-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-divider);
}

/* Upload plan modal extras */
.upload-plan-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.upload-plan-preview {
  margin-top: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.upload-plan-preview .plan-file-name {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.upload-plan-preview .plan-preview-stats {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

@media (max-width: 768px) {
  .copy-comparison,
  .image-brief-grid {
    grid-template-columns: 1fr;
  }

  .strategy-footer-actions {
    flex-direction: column;
  }
}
