/* ============================================
   MACRO ALIEN COMMAND CENTER — STYLES
   ============================================ */

:root {
  --bg: #080b12;
  --surface: #0c1018;
  --card: #1c2330;
  --card-hover: #232b3a;
  --gold: #c9a96e;
  --gold-dim: rgba(201,169,110,0.5);
  --gold-glow: rgba(201,169,110,0.3);
  --purple: #9b6ef5;
  --purple-bg: rgba(155,110,245,0.12);
  --purple-border: rgba(155,110,245,0.3);
  --green: #3ecf6e;
  --green-bg: rgba(62,207,110,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --text: #f8f8f8;
  --muted: rgba(248,248,248,0.5);
  --border: rgba(201,169,110,0.12);
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body.modal-open { overflow: hidden; }

/* Starfield */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1.2px 1.2px at 10% 15%, rgba(255,255,255,0.25) 50%, transparent 50%),
    radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(1.4px 1.4px at 45% 8%, rgba(255,255,255,0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 60% 55%, rgba(255,255,255,0.15) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 75% 25%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(1px 1px at 85% 70%, rgba(255,255,255,0.25) 50%, transparent 50%),
    radial-gradient(1.4px 1.4px at 30% 80%, rgba(255,255,255,0.18) 50%, transparent 50%),
    radial-gradient(1px 1px at 55% 90%, rgba(255,255,255,0.22) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 90% 45%, rgba(255,255,255,0.15) 50%, transparent 50%),
    radial-gradient(1px 1px at 15% 60%, rgba(255,255,255,0.2) 50%, transparent 50%),
    radial-gradient(1.4px 1.4px at 70% 85%, rgba(255,255,255,0.28) 50%, transparent 50%),
    radial-gradient(1px 1px at 40% 45%, rgba(255,255,255,0.18) 50%, transparent 50%);
  pointer-events: none;
}

.app { position: relative; z-index: 1; }

/* ─── TOP BAR ─────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 32px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(12,16,24,0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(201,169,110,0.06);
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand h1 {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--gold), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-brand span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 1px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Mobile header toggle (Phase 4) */
.topbar-status-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 32px;
  min-width: 32px;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.live { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.warn { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.status-dot.off { background: var(--red); }

.status-item {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
}

/* ─── NAV TABS ─────────────────────────── */
.nav {
  display: flex;
  gap: 4px;
  padding: 12px 32px;
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: rgba(12,16,24,0.6);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 10px 20px;
  min-height: 44px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}

@media (hover: hover) {
  .nav-tab:hover { color: var(--text); background: rgba(248,248,248,0.04); }
}

.nav-tab.active {
  color: var(--gold);
  background: rgba(201,169,110,0.08);
  border: 1px solid var(--border);
}

/* ─── MAIN CONTENT ─────────────────────── */
.main { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }

.section-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}

.section-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
  margin-left: 8px;
}

/* ─── STATS ROW ─────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: rgba(28,35,48,0.5);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: border-color 0.2s;
}

@media (hover: hover) { .stat-card:hover { border-color: var(--gold-dim); } }

.stat-value {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 36px;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: rgba(248,248,248,0.6);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 6px;
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ─── CARDS GRID ─────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: rgba(28,35,48,0.5);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

@media (hover: hover) {
  .card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
}

.card-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.card-badge {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-pending { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.badge-approved { background: var(--green-bg); color: var(--green); border: 1px solid rgba(62,207,110,0.3); }
.badge-published { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }
.badge-rejected { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.badge-posted { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }
.badge-scheduled { background: rgba(245,158,11,0.1); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.badge-dark { background: rgba(12,16,24,0.8); color: var(--gold); border: 1px solid var(--border); }
.badge-light { background: rgba(233,235,240,0.1); color: #e9ebf0; border: 1px solid rgba(233,235,240,0.2); }
.badge-story { background: rgba(155,110,245,0.15); color: var(--purple); border: 1px solid rgba(155,110,245,0.3); }

.slide-grid-story { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 4px; }
.story-preview { width: 240px; flex-shrink: 0; }
.story-frame-preview { aspect-ratio: 9 / 16 !important; width: 100% !important; height: auto !important; border-radius: 8px; }

.card-body { padding: 20px; }

.card-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.card-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.card-caption {
  font-size: 14px;
  color: rgba(248,248,248,0.7);
  line-height: 1.6;
  max-height: 100px;
  overflow: hidden;
  position: relative;
}

.card-caption::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, rgba(28,35,48,0.9));
}

.card-actions {
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* ─── BUTTONS ─────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  min-height: 44px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.btn-gold {
  background: var(--gold);
  color: var(--surface);
  box-shadow: 0 2px 12px var(--gold-glow);
}

.btn-purple {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 2px 12px rgba(155,110,245,0.3);
}

.btn-ghost {
  background: rgba(248,248,248,0.06);
  color: var(--text);
  border: 1px solid rgba(248,248,248,0.1);
}

.btn-red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}

@media (hover: hover) {
  .btn-gold:hover { background: #d4b67a; transform: translateY(-1px); }
  .btn-purple:hover { background: #a87ff8; transform: translateY(-1px); }
  .btn-ghost:hover { background: rgba(248,248,248,0.1); }
  .btn-red:hover { background: rgba(239,68,68,0.2); }
}

.btn:active { opacity: 0.85; }

.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 36px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ─── CHART / TABLE ─────────────────────── */
.chart-container {
  background: rgba(28,35,48,0.5);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 32px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.posts-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
}

.posts-table th {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.posts-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(201,169,110,0.06);
  vertical-align: middle;
}

@media (hover: hover) {
  .posts-table tr:hover td { background: rgba(248,248,248,0.02); }
}

.metric-highlight {
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--gold);
}

/* ─── AGENT STATUS ─────────────────────── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.agent-card {
  background: rgba(28,35,48,0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.agent-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 4px;
}

.agent-schedule {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

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

.agent-last-run {
  font-size: 13px;
  color: rgba(248,248,248,0.6);
}

/* ─── WEEKLY REPORT ─────────────────────── */
.report-card {
  background: rgba(28,35,48,0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.report-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 16px;
}

.report-insight {
  padding: 12px 16px;
  background: rgba(201,169,110,0.06);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── TAB PANELS ─────────────────────────── */
.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── LOADING ─────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-gold { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes pulse-purple { 0%,100% { box-shadow: 0 0 0 0 rgba(155,110,245,0.3); } 70% { box-shadow: 0 0 0 10px rgba(155,110,245,0); } }

/* ─── FOCUS / A11Y ─────────────────────── */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

textarea:focus-visible { outline: none; }
[role="alert"] { font-weight: 600; }

/* ─── TOAST ─────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  max-width: calc(100vw - 48px);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); color: #000; }
.toast.error { background: var(--red); color: #fff; }

/* ─── EMPTY STATE ─────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  margin-bottom: 8px;
}

/* ─── POST MANAGER TOOLBAR (Phase 3) ─── */
.post-manager-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.post-manager-toolbar .create-post-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.manual-import-zone {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  margin-bottom: 0;
}

.manual-import-zone.open {
  max-height: 200px;
  opacity: 1;
  margin-bottom: 16px;
}

/* ─── UPLOAD ZONE ─────────────────────── */
.upload-zone {
  border: 2px dashed rgba(201,169,110,0.35);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  background: rgba(28,35,48,0.3);
  transition: all 0.2s;
  cursor: pointer;
}

.upload-zone.drag-over {
  border-color: var(--gold);
  background: rgba(201,169,110,0.06);
  box-shadow: 0 0 30px rgba(201,169,110,0.1);
}

@media (hover: hover) {
  .upload-zone:hover {
    border-color: var(--gold);
    background: rgba(201,169,110,0.06);
    box-shadow: 0 0 30px rgba(201,169,110,0.1);
  }
}

.upload-zone h3 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  color: var(--gold);
  margin-bottom: 4px;
}

.upload-zone p {
  font-size: 12px;
  color: var(--muted);
}

.upload-zone input[type="file"] { display: none; }

/* ─── FILTER BAR (Phase 1) ─────────────── */
.filter-bar {
  margin-bottom: 20px;
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}

.filter-pills::-webkit-scrollbar { display: none; }

.filter-pill {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}

.filter-pill.active {
  background: rgba(201,169,110,0.12);
  color: var(--gold);
  border-color: var(--gold-dim);
}

.filter-pill .count {
  font-size: 10px;
  opacity: 0.7;
}

.filter-secondary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* ─── POST CARD (full-width section) ──── */
.post-section {
  background: rgba(28,35,48,0.5);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 24px;
  overflow: hidden;
  transition: border-color 0.2s;
}

@media (hover: hover) { .post-section:hover { border-color: var(--gold-dim); } }

/* Status-based card styling (Phase 2) */
.post-section.status-pending { border-color: rgba(245,158,11,0.2); }
.post-section.status-approved { border-color: rgba(62,207,110,0.2); }
.post-section.status-approved .post-header { background: rgba(62,207,110,0.03); }
.post-section.status-published { opacity: 0.75; border-color: rgba(155,110,245,0.15); }
.post-section.status-rejected { border-color: rgba(239,68,68,0.2); }
.post-section.status-rejected .post-header { background: rgba(239,68,68,0.03); }
.post-section.status-scheduled { border-color: rgba(245,158,11,0.15); }

/* Story differentiation (Phase 2) */
.post-section.is-story { border-left: 3px solid var(--purple); }

.post-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}

@media (hover: hover) { .post-header:hover { background: rgba(248,248,248,0.02); } }

.post-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.post-header-info h3 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  line-height: 1.3;
}

.post-header-info .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.post-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-arrow {
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.2s;
}

.post-section.collapsed .post-body { display: none; }
.post-section.collapsed .collapse-arrow { transform: rotate(-90deg); }

.post-body { padding: 24px; }

/* Slide Grid */
.slide-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.slide-grid-5-top {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.slide-grid-5-bottom {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 67%;
  margin: 0 auto 24px;
}

.slide-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slide-preview-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}

.slide-preview-frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

/* Caption / Tweet Editor */
.text-section {
  margin-bottom: 20px;
}

.text-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.text-section-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}

.text-section textarea {
  width: 100%;
  min-height: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  padding: 14px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.text-section textarea:focus { border-color: var(--gold-dim); }

.char-count {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
}

/* Post Actions Row */
.post-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.post-actions .spacer { flex: 1; }

/* Publish Progress */
.publish-status {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.publish-status.rendering { color: var(--gold); animation: pulse-gold 1.5s infinite; }
.publish-status.uploading { color: var(--gold); animation: pulse-gold 1.5s infinite; }
.publish-status.publishing { color: var(--purple); animation: pulse-gold 1.5s infinite; }
.publish-status.done { color: var(--green); }
.publish-status.failed { color: var(--red); }

/* Metrics Row (for published posts) */
.metrics-row {
  display: flex;
  gap: 16px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.metric-item .val {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  color: var(--gold);
}

.metric-item .lbl {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── MODALS ─────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 8px 12px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.modal-body { padding: 24px; }

.modal-body textarea {
  width: 100%;
  min-height: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  padding: 16px;
  resize: vertical;
  outline: none;
}

.modal-body textarea:focus { border-color: var(--gold-dim); }

.modal-body label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Create Post option buttons */
.create-opt.active {
  background: rgba(201,169,110,0.15) !important;
  color: var(--gold) !important;
  border-color: var(--gold) !important;
}

/* ─── DALL-E IMAGE PREVIEW ─────────────── */
/* ─── Platform badges (IG / Threads) ─── */
.platform-badges {
  display: flex;
  gap: 4px;
  margin-right: 6px;
}
.platform-badge {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-heading);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.platform-ig {
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  color: #fff;
}
.platform-threads {
  background: var(--purple);
  color: #fff;
}

/* ─── Metrics section labels ─── */
.metrics-section {
  margin-bottom: 8px;
}
.metrics-section .metrics-label {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--gold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
  padding-left: 2px;
}

/* ─── Account stats grid ─── */
.account-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.account-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.account-stat .val {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--gold);
}
.account-stat .lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dalle-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(155,110,245,0.06);
  border: 1px solid rgba(155,110,245,0.15);
  border-radius: 10px;
}

.dalle-preview {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ─── CHART GLOW & AMBIENT (ported from app) ─── */
.chart-glow canvas {
  filter: drop-shadow(0 0 6px rgba(201,169,110,.12))
          drop-shadow(0 0 16px rgba(155,110,245,.08))
          drop-shadow(0 0 30px rgba(201,169,110,.04));
}

.chart-ambient {
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(155,110,245,.04) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 110%, rgba(201,169,110,.03) 0%, transparent 55%);
}

/* ─── KPI HERO CARDS ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.kpi-card {
  background: rgba(28,35,48,0.5);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(201,169,110,.04) 0%, transparent 60%);
  pointer-events: none;
}

@media (hover: hover) { .kpi-card:hover { border-color: var(--gold-dim); } }

.kpi-value {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 32px;
  color: var(--text);
  line-height: 1;
}

.kpi-label {
  font-size: 11px;
  color: rgba(248,248,248,0.55);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 700;
  margin-top: 6px;
}

.trend-up { background: rgba(62,207,110,.15); color: #3ecf6e; }
.trend-down { background: rgba(240,75,75,.15); color: #f04b4b; }
.trend-flat { background: rgba(248,248,248,.08); color: var(--muted); }

.sparkline-container {
  height: 28px;
  margin-top: 8px;
}

.sparkline-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ─── GROWTH RANGE PILLS ─── */
.range-pills {
  display: flex;
  gap: 4px;
}

.range-pill {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}

.range-pill.active {
  background: rgba(201,169,110,0.12);
  color: var(--gold);
  border-color: var(--gold-dim);
}

/* ─── THREADS ANALYTICS ─── */
.threads-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.threads-kpi {
  background: var(--surface);
  border: 1px solid rgba(155,110,245,0.15);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}

.threads-kpi .val {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--purple);
}

.threads-kpi .lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ─── ENGAGEMENT RATE COLORS (post table) ─── */
.eng-high { color: var(--green); font-weight: 700; }
.eng-mid { color: var(--gold); font-weight: 700; }
.eng-low { color: var(--muted); }

.threads-badge-inline {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-heading);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--purple);
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

/* ─── RESPONSIVE — tablet ─────────────── */
@media (max-width: 768px) {
  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar-status { display: none; font-size: 12px; gap: 12px; }
  .topbar-status.mobile-open {
    display: flex;
    width: 100%;
    padding: 8px 0 0;
    flex-wrap: wrap;
  }
  .topbar-status-toggle { display: flex; }
  .nav { padding: 8px 16px; }
  .main { padding: 16px; }
  .cards-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .threads-kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .slide-grid-3 { grid-template-columns: 1fr; }
  .slide-grid-5-top { grid-template-columns: 1fr; }
  .slide-grid-5-bottom { max-width: 100%; grid-template-columns: 1fr; }
  .agent-grid { grid-template-columns: 1fr; }
  .chart-responsive { height: 240px !important; }
  .post-body { padding: 16px; }
  .post-actions { gap: 6px; }
  .filter-secondary { flex-direction: column; align-items: stretch; gap: 8px; }
  .post-manager-toolbar { flex-wrap: wrap; }
}

/* ─── RESPONSIVE — small phone ─────────── */
@media (max-width: 400px) {
  .topbar-brand h1 { font-size: 18px; letter-spacing: 2px; }
  .topbar-brand span { display: none; }
  .main { padding: 12px; }
  .stats-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .threads-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 28px; }
  .kpi-value { font-size: 24px; }
  .post-header { padding: 12px 16px; }
  .post-header-info h3 { font-size: 14px; }
  .btn-sm { font-size: 11px; padding: 5px 10px; }
  .text-section textarea { min-height: 80px; font-size: 13px; }
}
