/* ----------------------------------------------------
   Manifesto Metrics — Brand Theme (V1)
   PR Intelligence OS
   Primary: Signal Blue #0057FF
   Canvas: Porcelain #F8F7F4
   Typeface: Geist Sans | Geist Mono
   Grid: 9-column
   ---------------------------------------------------- */

:root {
  /* Core Spacing & Grid System */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --grid-columns: 9;
  --content-max: 1440px;

  /* Core Design Tokens — Warm Dark Mode */
  --bg-base:          #0c0b0a;   /* Deep warm black */
  --bg-elevated:      #161413;   /* Slightly lifted charcoal */
  --bg-overlay:       #221f1c;   /* Cards, dropdowns, hover */
  --bg-muted:         #2e2a26;   /* Disabled / subtle fills */

  /* Borders */
  --border-subtle:    #2a2622;
  --border-default:   #3a3530;
  --border-strong:    #4f4841;

  /* Text – warm off-white */
  --text-primary:     #f5f0e8;   /* Warm ivory */
  --text-secondary:   #b8b0a4;   /* Muted warm gray */
  --text-tertiary:    #8a8278;   /* Quiet meta */
  --text-disabled:    #5c564e;

  /* Brand Accent — Signal Blue */
  --signal-blue:      #0057ff;
  --signal-blue-hover:#0047d6;
  --signal-blue-soft: #e8f0ff;
  --porcelain:        #f8f7f4;
  --accent:           var(--signal-blue);
  --accent-hover:     var(--signal-blue-hover);
  --accent-muted:     #003ca6;
  --accent-subtle:    rgba(0, 87, 255, 0.12);

  /* Secondary Brand – Ivy Green */
  --ivy:              #4a6b52;   /* Deep botanical green */
  --ivy-hover:        #5d8264;
  --ivy-muted:        rgba(74, 107, 82, 0.15);
  --ivy-subtle:       rgba(74, 107, 82, 0.08);

  /* Semantic */
  --success:          #4a6b52;   /* Use ivy green for positive / growth */
  --success-muted:    rgba(74, 107, 82, 0.12);
  --warning:          #c4923a;   /* Warm amber */
  --warning-muted:    rgba(196, 146, 58, 0.12);
  --danger:           #dc2626;
  --danger-muted:     rgba(220, 38, 38, 0.12);
  --info:             #5b7c99;   /* Muted steel blue */

  /* Data & Scores */
  --score-hot:        #dc2626;
  --score-high:       #4a6b52;
  --score-mid:        #c4923a;
  --score-low:        #8a8278;
  --da-bar:           var(--signal-blue);
  --aws-bar:          #6b5b95;   /* Soft violet for Active Writer Score */

  /* Alignment Aliases (Legacy support) */
  --manifesto-rojo: var(--accent);
  --manifesto-rojo-dark: var(--accent-muted);
  --manifesto-rojo-glow: var(--accent-subtle);
  --manifesto-negro: var(--bg-base);
  --manifesto-negro-elevated: var(--bg-elevated);
  --manifesto-negro-card: var(--bg-overlay);
  --manifesto-white: #ffffff;
  --manifesto-green: var(--ivy);
  --manifesto-green-glow: var(--ivy-subtle);
  --manifesto-muted: var(--text-tertiary);
  --manifesto-border: var(--border-subtle);
  --manifesto-border-strong: var(--border-strong);

  --bg-primary: var(--bg-base);
  --bg-secondary: var(--bg-elevated);
  --bg-card: var(--bg-overlay);
  --bg-card-hover: var(--bg-muted);

  --border-color: var(--border-subtle);
  --border-color-hover: var(--border-default);

  --accent-indigo: var(--accent);
  --accent-purple: var(--accent-muted);
  --accent-violet: #003ca6;
  --accent-indigo-glow: var(--accent-subtle);
  --accent-purple-glow: rgba(0, 60, 166, 0.14);

  --font-sans: "Geist", "Geist Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: var(--font-sans);
  --font-serif: var(--font-sans);
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --text-muted: var(--text-tertiary);

  --glass-blur: blur(12px);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --glow-shadow: 0 0 24px var(--accent-subtle);
}

* {
  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.panel-title h2,
.stat-value,
.breadcrumb .active-tab-title,
.nav-divider span,
.drawer-section-title,
.seo-card-title {
  font-family: var(--font-display);
  font-weight: 600;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
}

.brand-title {
  letter-spacing: 0.04em;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--manifesto-rojo);
}

/* Sidebar */
.sidebar {
  background: #0d0d0d;
  border-right: 1px solid var(--border-color);
}

.sidebar-header {
  padding: 18px 36px 16px 20px;
}

.sidebar-collapse-btn:hover {
  color: var(--manifesto-rojo);
  border-color: var(--manifesto-border-strong);
  background: var(--manifesto-rojo-glow);
}

.sidebar-toggle-btn:hover {
  border-color: var(--manifesto-rojo);
  box-shadow: 0 0 0 1px var(--manifesto-rojo-glow);
}

body.light-theme .sidebar-collapse-btn {
  background: #ffffff;
  border-color: rgba(17, 17, 17, 0.12);
}

body.light-theme .sidebar-collapse-btn:hover {
  background: var(--manifesto-rojo-glow);
}

body.light-theme .sidebar-toggle-btn,
body.light-theme .theme-toggle-btn,
body.light-theme .header-btn {
  background: #ffffff;
  border-color: rgba(17, 17, 17, 0.12);
}

.brand-mark-wrap {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.brand-title {
  text-transform: uppercase;
  color: var(--manifesto-white);
}

.brand-subtitle {
  color: var(--manifesto-rojo);
  font-family: var(--font-display);
}

.sidebar-account {
  border-top-color: rgba(255, 255, 255, 0.06);
}

.account-avatar {
  background: var(--manifesto-rojo);
  border-radius: 8px;
}

.nav-item.active {
  background: linear-gradient(90deg, var(--manifesto-rojo-glow) 0%, transparent 100%);
  border-left: 3px solid var(--manifesto-rojo);
  color: var(--manifesto-white);
}

/* Icon shells — consistent Manifesto iconography */
.nav-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  transition: var(--transition-fast, 0.2s ease);
}

.nav-icon svg,
.stat-icon-wrapper svg,
.sidebar-toggle-btn svg,
.header-btn svg,
.theme-toggle-btn svg,
.stat-trend svg,
.status-icon svg {
  stroke-width: 1.75;
}

.nav-item:hover .nav-icon {
  color: var(--manifesto-rojo);
  border-color: var(--manifesto-rojo-glow);
  background: rgba(0, 87, 255, 0.08);
}

.nav-item.active .nav-icon {
  color: var(--manifesto-white);
  background: var(--manifesto-rojo);
  border-color: var(--manifesto-rojo);
  box-shadow: 0 6px 18px var(--manifesto-rojo-glow);
}

.nav-item.active i,
.nav-item:hover i,
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  color: inherit;
}

.stat-icon-wrapper {
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-trend i,
.stat-trend svg {
  width: 14px !important;
  height: 14px !important;
  vertical-align: -2px;
  margin-right: 2px;
}

.header-btn,
.theme-toggle-btn {
  color: var(--text-secondary);
}

.header-btn:hover,
.theme-toggle-btn:hover {
  color: var(--manifesto-rojo);
  border-color: var(--manifesto-border-strong);
}

.system-status .status-icon {
  color: var(--manifesto-green);
  opacity: 0.9;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.status-dot {
  background-color: var(--manifesto-green);
  box-shadow: 0 0 8px var(--manifesto-green);
}

/* Main shell */
.main-panel {
  background-color: var(--bg-primary);
  background-image:
    linear-gradient(180deg, rgba(0, 87, 255, 0.04) 0%, transparent 28%),
    radial-gradient(circle at 85% 0%, rgba(0, 177, 60, 0.05) 0%, transparent 35%);
}

.app-header {
  background: rgba(17, 17, 17, 0.92);
  border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.breadcrumb .parent {
  color: var(--text-secondary);
}

.breadcrumb .active-tab-title {
  color: var(--manifesto-rojo);
}

.client-selector-container label {
  font-family: var(--font-display);
  color: var(--text-muted);
}

.client-dropdown:hover,
.client-dropdown:focus {
  border-color: var(--manifesto-rojo);
  box-shadow: 0 0 0 1px var(--manifesto-rojo-glow);
}

.notifications-btn .badge {
  background-color: var(--manifesto-rojo);
  box-shadow: 0 0 6px var(--manifesto-rojo);
}

/* 9-column content grid */
.global-stats-bar {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 16px;
  padding: 20px 32px 8px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.global-stats-bar .stat-card {
  grid-column: span 2;
}

.global-stats-bar .stat-card:nth-child(1) {
  grid-column: span 3;
}

.viewport-canvas {
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 8px 32px 40px;
}

@media (max-width: 1280px) {
  .global-stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .global-stats-bar .stat-card,
  .global-stats-bar .stat-card:nth-child(1) {
    grid-column: span 1;
  }
}

/* Cards & stats */
.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: none;
}

.stat-card:hover {
  border-color: var(--manifesto-border-strong);
  transform: translateY(-1px);
}

.stat-icon-wrapper.blue,
.stat-icon-wrapper.indigo,
.stat-icon-wrapper.purple {
  background: var(--manifesto-rojo-glow);
  color: var(--manifesto-rojo);
}

.stat-icon-wrapper.green {
  background: var(--manifesto-green-glow);
  color: var(--manifesto-green);
}

.stat-label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem !important;
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
}

.stat-trend.positive {
  color: var(--manifesto-green);
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: none;
}

.panel-header {
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  padding-bottom: 16px;
}

.panel-title h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--manifesto-white);
}

.panel-title p {
  color: #c8c8c8;
  line-height: 1.55;
  max-width: 62ch;
}

.form-control,
select.form-control,
input.form-control,
textarea.form-control {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--manifesto-white);
}

.form-control:focus,
select.form-control:focus,
input.form-control:focus,
textarea.form-control:focus {
  border-color: var(--manifesto-rojo);
  box-shadow: 0 0 0 3px var(--manifesto-rojo-glow);
}

select.form-control option {
  background: var(--manifesto-negro-elevated);
  color: var(--manifesto-white);
}

/* Buttons */
.primary-btn,
.action-btn.primary,
.sub-tab-btn.active,
.btn-primary {
  background: var(--manifesto-rojo) !important;
  border-color: var(--manifesto-rojo) !important;
  color: var(--manifesto-white) !important;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.primary-btn:hover,
.action-btn.primary:hover,
.sub-tab-btn.active:hover {
  background: var(--manifesto-rojo-dark) !important;
  border-color: var(--manifesto-rojo-dark) !important;
}

.sub-tab-btn {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sub-tab-btn.active {
  box-shadow: 0 8px 24px var(--manifesto-rojo-glow);
}

body.light-theme .sub-tab-btn:not(.active) {
  background: #ffffff;
}

/* Tables & data */
.directory-table th {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
}

.metric-bar-fill.da,
.progress-fill {
  background: linear-gradient(90deg, var(--manifesto-rojo), var(--manifesto-rojo-dark)) !important;
}

.card-link:hover {
  color: var(--manifesto-rojo);
}

.keyword-intent-chip.trans {
  background: var(--manifesto-rojo-glow);
  color: var(--manifesto-rojo);
}

/* Agent terminal accents */
.terminal-line.system,
.agent-terminal-line.agent {
  color: var(--manifesto-rojo);
}

/* Light theme — Manifesto on cream (high-contrast surfaces) */
body.light-theme {
  --bg-primary: #f8f7f4;      /* Porcelain */
  --bg-secondary: #f1f0ec;
  --bg-card: #ffffff;
  --bg-card-hover: #faf8f5;
  --border-color: rgba(26, 24, 22, 0.12);
  --border-color-hover: rgba(0, 87, 255, 0.28);
  --text-primary: #171717;
  --text-secondary: #626262;
  --text-muted: #7a7a7a;
  --glass-shadow: 0 1px 2px rgba(26, 24, 22, 0.05), 0 4px 14px rgba(26, 24, 22, 0.06);
  --manifesto-rojo: #0057ff;
  --manifesto-rojo-dark: #0047d6;
  --manifesto-rojo-glow: rgba(0, 87, 255, 0.12);
  --manifesto-green: #3d5c45;
  --manifesto-green-glow: rgba(61, 92, 69, 0.1);
  --success: #3d5c45;
}

body.light-theme .sidebar {
  background: #f8f7f4;
  border-right-color: rgba(17, 17, 17, 0.12);
}

body.light-theme .sidebar-header {
  background: #ffffff;
  border-bottom-color: rgba(17, 17, 17, 0.12);
}

body.light-theme .sidebar-account {
  border-top-color: rgba(17, 17, 17, 0.1);
}

body.light-theme .brand-title {
  color: var(--manifesto-negro);
}

body.light-theme .nav-icon {
  background: rgba(17, 17, 17, 0.05);
  border-color: rgba(17, 17, 17, 0.1);
  color: var(--text-secondary);
}

body.light-theme .nav-item {
  color: var(--text-secondary);
}

body.light-theme .nav-item:hover,
body.light-theme .nav-item.active {
  background: var(--manifesto-rojo-glow);
  color: var(--manifesto-rojo);
}

body.light-theme .nav-item.active .nav-icon {
  color: var(--manifesto-white);
}

body.light-theme .main-panel {
  background-image: none;
  background: var(--bg-primary);
}

body.light-theme .app-header {
  background: #ffffff;
  border-bottom-color: rgba(17, 17, 17, 0.12);
  box-shadow: 0 1px 0 rgba(17, 17, 17, 0.04);
}

body.light-theme .breadcrumb .parent {
  color: #4a4a4a;
}

body.light-theme .breadcrumb .separator {
  color: #8a8a8a;
}

body.light-theme .breadcrumb .active-tab-title {
  color: var(--manifesto-rojo);
}

body.light-theme .client-selector-container label {
  color: var(--text-secondary);
}

body.light-theme .client-dropdown {
  background: #ffffff;
  border-color: rgba(17, 17, 17, 0.14);
}

body.light-theme .panel-title h2 {
  color: var(--manifesto-negro);
}

body.light-theme .stat-card,
body.light-theme .glass-card {
  background: var(--bg-card);
  border-color: rgba(17, 17, 17, 0.13);
  box-shadow: var(--glass-shadow);
}

body.light-theme .stat-card:hover,
body.light-theme .glass-card:hover {
  border-color: rgba(17, 17, 17, 0.2);
  box-shadow: 0 2px 6px rgba(17, 17, 17, 0.06), 0 8px 24px rgba(17, 17, 17, 0.07);
}

body.light-theme .stat-label {
  color: var(--text-secondary);
}

body.light-theme .stat-icon-wrapper.blue,
body.light-theme .stat-icon-wrapper.indigo,
body.light-theme .stat-icon-wrapper.purple {
  background: rgba(0, 87, 255, 0.1);
  border: 1px solid rgba(0, 87, 255, 0.16);
}

body.light-theme .stat-icon-wrapper.green {
  background: rgba(0, 177, 60, 0.1);
  border: 1px solid rgba(0, 177, 60, 0.16);
}

body.light-theme .sub-tab-btn {
  background: #ffffff;
  border-color: rgba(17, 17, 17, 0.14);
  color: var(--text-secondary);
}

body.light-theme .sub-tab-btn:hover {
  border-color: rgba(17, 17, 17, 0.22);
  color: var(--text-primary);
}

body.light-theme .sub-tab-btn.active {
  background: var(--manifesto-rojo);
  border-color: var(--manifesto-rojo);
  color: var(--manifesto-white);
}

body.light-theme .writer-form-group label,
body.light-theme .client-selector-container label {
  color: var(--text-secondary);
}

body.light-theme .writer-input,
body.light-theme .writer-select,
body.light-theme .form-control,
body.light-theme input:not([type="range"]),
body.light-theme select,
body.light-theme textarea {
  background: var(--bg-secondary);
  border-color: rgba(17, 17, 17, 0.16);
  color: var(--text-primary);
}

body.light-theme .panel-title p {
  color: var(--text-secondary);
}

body.light-theme select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a5a5a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

body.light-theme select.form-control option {
  background: #ffffff;
  color: var(--text-primary);
}

body.light-theme .form-control:focus,
body.light-theme select.form-control:focus,
body.light-theme input.form-control:focus,
body.light-theme textarea.form-control:focus {
  background: #ffffff;
  border-color: var(--manifesto-rojo);
  box-shadow: 0 0 0 3px var(--manifesto-rojo-glow);
}

body.light-theme .writer-input:focus,
body.light-theme .writer-select:focus,
body.light-theme input:not([type="range"]):focus,
body.light-theme select:focus,
body.light-theme textarea:focus {
  background: #ffffff;
  border-color: var(--manifesto-rojo);
  box-shadow: 0 0 0 3px var(--manifesto-rojo-glow);
}

body.light-theme input[type="range"] {
  accent-color: var(--manifesto-rojo);
}

body.light-theme .progress-bar-bg,
body.light-theme .metric-bar-bg {
  background: rgba(17, 17, 17, 0.12);
}

body.light-theme .badge-region {
  background: rgba(17, 17, 17, 0.04);
  border-color: rgba(17, 17, 17, 0.12);
  color: var(--text-secondary);
}

body.light-theme .nav-divider span {
  color: var(--text-muted);
}

body.light-theme .directory-table th {
  background: rgba(17, 17, 17, 0.04);
  color: var(--text-primary);
}

body.light-theme .directory-table tr:hover {
  background: rgba(17, 17, 17, 0.03);
}

body.light-theme .btn-secondary {
  background: #ffffff;
  border-color: rgba(17, 17, 17, 0.16);
  color: var(--text-primary);
}

body.light-theme .btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(17, 17, 17, 0.24);
}

body.light-theme .audit-score-ring {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.06);
}

.event-date-stamp {
  background: linear-gradient(145deg, var(--manifesto-rojo), var(--manifesto-rojo-dark));
  box-shadow: 0 4px 14px var(--manifesto-rojo-glow);
}

.event-details h3 {
  color: var(--text-primary) !important;
}

.event-goals-badge {
  background: var(--manifesto-rojo-glow) !important;
  color: var(--manifesto-rojo) !important;
  border-color: rgba(0, 87, 255, 0.2) !important;
}

.search-input-wrapper .search-icon,
.search-input-wrapper svg {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--manifesto-rojo);
  box-shadow: 0 0 0 3px var(--manifesto-rojo-glow);
}

.col-resize-handle:hover::after,
body.col-resize-active .col-resize-handle::after {
  background: var(--manifesto-rojo);
}

/* Live Neon data badge */
.live-data-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary, #a1a1aa);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-data-badge.is-live {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}
