/* ARGUS Social Admin UI — BOC-aligned AAMOS interface standard */
:root {
  --asset-border: #e4e7ec;
  color-scheme: light;
  --bg-primary: #fafaf8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f8f8f6;
  --bg-card: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #667085;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37, 99, 235, .08);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --border: rgba(0, 0, 0, .06);
  --border-light: rgba(0, 0, 0, .10);
  --shadow: 0 2px 10px rgba(0, 0, 0, .04);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
}

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

html, body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Reserve both scrollbars so loading another view cannot move the complete
   application shell sideways. The UI uses the local system font stack to
   avoid a second layout pass when a remote webfont finishes loading. */
html { overflow-y: scroll; scrollbar-gutter: stable; }
body { min-width: 320px; }

/* Loading state */
.loading-overlay {
  position: fixed; inset: 0; background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.loading-spinner {
  width: 48px; height: 48px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* FIX: Inline loading styles externalized */
.loading-inline {
  position: relative;
  min-height: 200px;
}

/* Login page */
.login-container {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.login-card::before { content: none; }
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.brand-mark {
  width: 34px; height: 34px; margin: 0 auto 16px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #5856d6); color: #fff;
  display: grid; place-items: center; font-size: 17px;
}
.login-logo h1 {
  font-size: 28px; font-weight: 700; color: var(--text-primary);
  letter-spacing: -0.5px;
}
.login-logo p {
  color: var(--text-secondary); font-size: 14px; margin-top: 4px;
}
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input {
  width: 100%; padding: 12px 14px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-size: 15px; transition: var(--transition);
}
.form-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.14);
}
.form-input::placeholder { color: var(--text-muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: #fff; width: 100%;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.campaign-nav-icon { color: #5965d8; font-weight: 800; }
.btn-info { background: var(--info, #3b82f6); color: #fff; }
.btn-info:hover { background: #2563eb; }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }
.btn-outline:hover { background: var(--accent-light); color: var(--accent); }

.breakglass { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.breakglass summary {
  color: var(--text-muted); cursor: pointer; font-size: 13px; text-align: center;
  list-style: none; user-select: none;
}
.breakglass summary::-webkit-details-marker { display: none; }
.breakglass summary::after { content: '  ▾'; }
.breakglass[open] summary::after { content: '  ▴'; }
.breakglass-form, .breakglass form { margin-top: 16px; }

.error-message {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger); padding: 12px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 16px; display: none;
}
.error-message.visible { display: block; }

/* FIX: Error spacing class replaces inline style */
.error-spaced {
  margin-bottom: 16px;
}

/* Dashboard layout — shared across all pages */
.dashboard, .page-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100;
  top: 0; left: 0;
}
/* Mobile: sidebar collapses to hamburger */
@media (max-width: 768px) {
  .sidebar {
    width: min(82vw, 300px);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 12px 0 32px rgba(17,24,39,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; padding: 76px 16px 16px !important; }
  .mobile-menu-toggle {
    display: block !important;
    position: fixed; top: 16px; left: 16px; z-index: 101;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px;
    color: var(--text-primary); font-size: 18px; cursor: pointer;
  }
}
@media (min-width: 769px) {
  .mobile-menu-toggle { display: none !important; }
}
.sidebar-header {
  padding: 20px; border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.sidebar-header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; scrollbar-gutter: stable; overflow-anchor: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: var(--radius); color: var(--text-secondary);
  font-size: 14px; cursor: pointer; transition: var(--transition); border: none; background: none; width: 100%; text-align: left;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 20px; text-align: center; font-size: 16px; }

/* FIX #2: Sidebar footer layout */
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logout-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 8px; border-radius: var(--radius); cursor: pointer; font-size: 16px;
  transition: var(--transition); flex-shrink: 0;
}
.logout-btn:hover {
  border-color: var(--danger); color: var(--danger);
}

.main-content {
  flex: 1; margin-left: 240px; padding: 24px 32px;
  min-width: 0; min-height: 100vh; overflow-anchor: none;
}
/* Standalone pages use same layout */
body > .main-content {
  margin-left: 240px;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; }
.page-header-actions { display:flex; align-items:center; justify-content:flex-end; gap:10px; flex-wrap:wrap; }

@media (max-width: 768px) {
  .page-header { align-items:flex-start; flex-direction:column; gap:14px; }
  .page-header-actions { width:100%; justify-content:flex-start; }
}

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-header p { font-size: 13px; color: var(--text-muted); }

/* Stats grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.stat-card .stat-value {
  font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px;
}
.stat-card .stat-change {
  font-size: 12px; margin-top: 8px; font-weight: 500;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* FIX #1: Platform list with actions container */
.platform-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px;
}
.platform-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.platform-icon {
  width: 48px; height: 48px; border-radius: var(--radius); background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  flex-shrink: 0;
}
/* Consistent, legible platform marks across calendar, posts and composer. */
.platform-icon-svg {
  width: 1.25em;
  height: 1.25em;
  display: inline-block;
  vertical-align: -0.2em;
  flex: 0 0 auto;
}
.platform-header .platform-icon-svg,
.platform-name .platform-icon-svg { width: 1.5rem; height: 1.5rem; vertical-align: -0.35em; }
.event-platform .platform-icon-svg,
.day-post-platform .platform-icon-svg,
.upcoming-platforms .platform-icon-svg { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
.post-platform .platform-icon-svg,
.detail-platform .platform-icon-svg,
.platform-chip-icon .platform-icon-svg { width: 1.15em; height: 1.15em; vertical-align: -0.2em; }
.platform-info { flex: 1; min-width: 120px; }
.platform-info h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.platform-info p { font-size: 12px; color: var(--text-muted); }

/* FIX #1: Platform actions container prevents overlap */
.platform-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
}

.platform-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.status-connected { background: rgba(16,185,129,0.15); color: var(--success); }
.status-disconnected { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; display: inline-block;
}
.status-connected .status-dot { background: var(--success); }
.status-disconnected .status-dot { background: var(--danger); }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; max-width: 400px; margin: 0 auto 20px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--border-light);
}
.data-table tr:hover td { background: var(--bg-tertiary); }

/* Toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 18px; border-radius: var(--radius); font-size: 14px;
  box-shadow: var(--shadow); animation: slideIn 0.3s ease;
  max-width: 400px;
}
.toast.success { background: var(--bg-card); border-left: 4px solid var(--success); }
.toast.error { background: var(--bg-card); border-left: 4px solid var(--danger); }
.toast.info { background: var(--bg-card); border-left: 4px solid var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Posts page */
.posts-list { display: flex; flex-direction: column; gap: 16px; }
.post-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.post-card .post-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.status-badge {
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.status-badge.draft { background: var(--bg-tertiary); color: var(--text-muted); }
.status-badge.scheduled { background: #1e3a5f; color: #60a5fa; }
.status-badge.published { background: #064e3b; color: #34d399; }
.status-badge.failed { background: #450a0a; color: #f87171; }
.post-card .post-content { margin-bottom: 12px; line-height: 1.6; }
.native-media-previews { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:18px; }
.native-media-frame { position:relative; width:100%; max-width:420px; background:#fff; overflow:hidden; }
.native-media-frame img, .native-media-frame video { display:block; width:100%; height:100%; object-fit:contain; }
.native-media-safe { position:absolute; border:2px dashed #1a8d55; pointer-events:none; }
.post-context { display:block; margin:-4px 0 10px; color:var(--text-muted); font-size:12px; }
.post-card .post-meta {
  display: flex; gap: 16px; font-size: 13px; color: var(--text-muted);
}

/* Calendar */
.calendar-grid { margin-top: 20px; }
.calendar-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 8px; margin-bottom: 8px;
}
.day-header { text-align: center; font-size: 12px; color: var(--text-muted); padding: 8px; }
.calendar-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.day {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); min-height: 100px; padding: 8px;
}
.day.empty { background: transparent; border: none; }
.day-number { font-size: 14px; font-weight: 600; }
.day .event {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day .event.scheduled { background: #1e3a5f; color: #60a5fa; }
.day .event.published { background: #064e3b; color: #34d399; }

/* Upcoming posts */
.upcoming-posts { margin-top: 40px; }
.upcoming-posts h2 { font-size: 18px; margin-bottom: 16px; }
.upcoming-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.upcoming-item .upcoming-time { font-size: 13px; color: var(--text-muted); }
.upcoming-item .upcoming-platforms { font-size: 12px; color: var(--accent-light); margin-left: 12px; }

/* Analytics */
.metrics-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
  margin: 24px 0;
}
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; text-align: center;
}
.metric-card h3 { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.metric-value { font-size: 36px; font-weight: 700; color: var(--accent-light); }
.chart-section { margin-top: 40px; }
.chart-section h2 { font-size: 18px; margin-bottom: 20px; }
.bar-chart {
  display: flex; align-items: flex-end; gap: 12px;
  height: 200px; padding: 20px 0;
}
.bar-wrapper { flex: 1; display: flex; flex-direction: column; align-items: center; }
.bar {
  width: 100%; background: var(--accent);
  border-radius: 4px 4px 0 0; min-height: 4px;
}
.bar-label { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* Composer */
.composer-form { max-width: 600px; }
.form-group { margin-bottom: 24px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.form-group textarea, .form-group input[type="datetime-local"] {
  width: 100%; padding: 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-size: 14px;
}
.form-group textarea:focus { outline: none; border-color: var(--accent); }
.char-count { text-align: right; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.char-count.warning { color: var(--danger); }
.platform-selector { display: flex; gap: 16px; flex-wrap: wrap; }
.platform-selector label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.platform-selector label:hover { border-color: var(--accent); }
.form-actions { display: flex; gap: 12px; }
.preview-panel {
  margin-top: 40px; padding: 24px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.preview-panel h2 { font-size: 16px; margin-bottom: 16px; }
.preview-post { padding: 16px; background: var(--bg-primary); border-radius: var(--radius); }
.preview-post p { margin-bottom: 12px; line-height: 1.6; }
.preview-meta { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; }

/* Responsive */
@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .platform-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Platform Keys / Brand Mail pages */
.platforms-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1.5rem;
}
.platforms-grid .platform-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
}
.platforms-grid .platform-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem;
}
.platforms-grid .platform-name {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 1.25rem; font-weight: 600;
}
.platforms-grid .platform-icon { font-size: 1.5rem; }
.platforms-grid .status-badge {
  padding: 0.25rem 0.75rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 600;
}
.platforms-grid .status-configured {
  background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.25);
}
.platforms-grid .status-missing {
  background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.25);
}
.platforms-grid .form-group {
  margin-bottom: 1rem;
}
.platforms-grid .form-group label {
  display: block; font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.25rem;
}
.platforms-grid .form-group input {
  width: 100%; padding: 0.75rem; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-size: 0.875rem; font-family: monospace;
}
.platforms-grid .form-group input:focus {
  outline: none; border-color: var(--accent);
}
.platforms-grid .input-hint {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem;
}
.platforms-grid .toggle-container {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0; border-top: 1px solid var(--border); margin-top: 0.5rem;
}
.platforms-grid .toggle-label { font-size: 0.875rem; color: var(--text-muted); }
.platforms-grid .toggle {
  position: relative; width: 48px; height: 24px;
  background: #333; border-radius: 12px; cursor: pointer; transition: background 0.2s;
}
.platforms-grid .toggle.active { background: var(--success); }
.platforms-grid .toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.platforms-grid .toggle.active::after { transform: translateX(24px); }
.platforms-grid .message {
  padding: 0.75rem; border-radius: var(--radius); margin-top: 0.75rem;
  font-size: 0.875rem; display: none;
}
.platforms-grid .message.show { display: block; }
.platforms-grid .message-success {
  background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.25);
}
.platforms-grid .message-error {
  background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.25);
}

/* Email cards */
.email-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1rem;
}
.email-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.email-card .meta { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1rem; }
.gdpr-notice {
  background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius); padding: 1rem; margin: 1rem 0;
  font-size: 0.875rem; color: var(--warning);
}

/* Company Switcher */
.company-switcher {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  min-height: 82px;
}
.company-switcher-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.company-switcher-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.company-switcher-select:hover {
  border-color: var(--accent);
}
.company-switcher-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.company-switcher-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}
.company-switcher-error {
  margin-top: 7px;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.35;
}

/* ─── Composer Page ─── */
.composer-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  max-width: 1200px;
}

@media (max-width: 1024px) {
  .composer-layout {
    grid-template-columns: 1fr;
  }
}

.composer-editor {
  min-width: 0;
}

.composer-form .form-group {
  margin-bottom: 20px;
}

.composer-form label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.composer-form label .required {
  color: var(--danger);
}

.composer-form .form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.platform-option-card {
  margin-top: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
}

.platform-option-card h3 {
  margin: 0 0 0.75rem;
}

.platform-option-card > label {
  display: block;
  margin-top: 0.75rem;
}

.platform-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.platform-option-grid.compact label,
.platform-consent {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.composer-textarea {
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  min-height: 160px;
}

.composer-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

/* Character count */
.char-count {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  transition: var(--transition);
}

.char-count.near-limit {
  color: var(--warning);
}

.char-count.over-limit {
  color: var(--danger);
}

.char-status {
  font-weight: 500;
}

.char-status.ok { color: var(--success); }
.char-status.warning { color: var(--warning); }
.char-status.error { color: var(--danger); }

/* Platform grid */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.platform-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.platform-chip:hover {
  border-color: var(--border-light);
  background: var(--bg-tertiary);
}

.platform-chip.selected {
  border-color: var(--accent);
  background: rgba(124,58,237,0.1);
}

.platform-chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.platform-chip-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.platform-chip-limit {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Validation errors */
.validation-errors {
  margin-top: 10px;
}

.validation-error {
  padding: 8px 12px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 6px;
}

.validation-warning {
  padding: 8px 12px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius);
  color: var(--warning);
  font-size: 13px;
  margin-bottom: 6px;
}

/* Form actions */
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.form-actions .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 14px;
}

/* Composer preview panel */
.composer-preview {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-panel {
  flex: 1;
}

.preview-panel h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Preview cards */
.preview-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  transition: var(--transition);
}

.preview-card.near-limit {
  border-color: var(--warning);
}

.preview-card.over-limit {
  border-color: var(--danger);
  background: rgba(239,68,68,0.05);
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.preview-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.preview-platform {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.preview-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.preview-count.error { color: var(--danger); }
.preview-count.warning { color: var(--warning); }

.preview-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
}

.preview-body p {
  margin: 0;
  white-space: pre-wrap;
}

.preview-error {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(239,68,68,0.1);
  border-radius: 4px;
  font-size: 12px;
  color: var(--danger);
}

/* Platform limits panel */
.platform-limits {
  padding: 16px;
}

.platform-limits h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.limits-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.limit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  transition: var(--transition);
}

.limit-item.ok {
  background: rgba(16,185,129,0.1);
}

.limit-item.warning {
  background: rgba(245,158,11,0.1);
}

.limit-item.error {
  background: rgba(239,68,68,0.1);
}

.limit-icon {
  font-size: 14px;
}

.limit-name {
  flex: 1;
  color: var(--text-secondary);
}

.limit-value {
  color: var(--text-muted);
  font-weight: 500;
}

.limit-item.ok .limit-value { color: var(--success); }
.limit-item.warning .limit-value { color: var(--warning); }
.limit-item.error .limit-value { color: var(--danger); }

/* Error banner */
.error-banner {
  padding: 12px 16px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 16px;
}

/* Keep the first media asset visible in the review list so similar scheduled
   posts can be distinguished before opening the full detail view. */
.post-thumb {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.post-thumb-video,
.post-thumb-empty {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 28px;
}
.post-thumb-video { color: var(--accent); background: var(--accent-light); }
.post-thumb-empty { font-size: 20px; }

.posts-onboarding-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(79, 99, 224, 0.10), rgba(79, 99, 224, 0.04));
  border: 1px solid rgba(79, 99, 224, 0.22);
  border-radius: var(--radius-lg);
}

.posts-onboarding-copy { min-width: 0; }
.posts-onboarding-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.posts-onboarding-copy h2 { margin: 0 0 5px; font-size: 17px; }
.posts-onboarding-copy p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

@media (max-width: 768px) {
  .posts-onboarding-callout { align-items: stretch; flex-direction: column; }
  .posts-onboarding-callout .btn { width: 100%; }
}

/* ─── Posts Page ─── */
.posts-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.posts-filters {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.posts-filters input[type="text"] {
  flex: 1;
  min-width: 200px;
}

.posts-filters select {
  width: auto;
  min-width: 160px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bulk-actions span {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Post cards */
.post-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: var(--transition);
  cursor: pointer;
}

.post-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

.post-select {
  padding-top: 2px;
}

.post-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.post-main {
  flex: 1;
  min-width: 0;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.status-draft     { background: rgba(107,114,128,0.2); color: #9ca3af; }
.status-badge.status-scheduled { background: rgba(59,130,246,0.2);  color: #60a5fa; }
.status-badge.status-queued    { background: rgba(245,158,11,0.2);  color: #fbbf24; }
.status-badge.status-published { background: rgba(16,185,129,0.2);  color: #34d399; }
.status-badge.status-failed    { background: rgba(239,68,68,0.2);   color: #f87171; }

.post-time {
  font-size: 12px;
  color: var(--text-muted);
}

.post-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
  word-break: break-word;
}

.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.post-platforms {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.post-platform-text {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(42vw, 280px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.post-platform {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.post-platform[title] { cursor: help; }

.post-jobs {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Modals ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-panel.modal-wide {
  max-width: 700px;
}

.modal-panel.modal-sm {
  max-width: 400px;
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: var(--transition);
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

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

/* Detail view */
.detail-section {
  margin-bottom: 20px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

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

.detail-id {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

.detail-content {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.detail-media-item {
  margin: 0;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.detail-media {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: calc(var(--radius) - 2px);
  background: #0b1020;
}

.detail-media-item figcaption {
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
}

.detail-media-item figcaption a {
  color: var(--accent);
}

.detail-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.detail-times {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.detail-times div {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.detail-times span {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.detail-jobs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.job-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.job-row.completed { border-color: rgba(16,185,129,0.3); }
.job-row.failed    { border-color: rgba(239,68,68,0.3); }
.job-row.running   { border-color: rgba(245,158,11,0.3); }

.job-icon {
  font-size: 14px;
}

.job-platform {
  flex: 1;
  color: var(--text-secondary);
}

.job-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.job-error {
  color: var(--danger);
  cursor: help;
}

/* Pagination */
.pagination {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Campaign review previews */
.free-preview-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
}
.free-preview-panel > div:first-child { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.free-preview-panel h3 { font-size: 16px; margin-bottom: 4px; }
.free-preview-panel p { color: var(--text-secondary); font-size: 13px; }
.free-preview-output { margin-top: 16px; }
.free-preview-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.free-preview-step { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.free-preview-step h4 { margin: 0 0 5px; font-size: 16px; }
.free-preview-purpose { margin: 0 0 12px; color: var(--text-secondary); font-size: 13px; }
.free-preview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.free-preview-caption { padding: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.free-preview-caption strong { display: block; font-size: 13px; }
.free-preview-format { display: block; color: var(--text-muted); font-size: 11px; margin: 3px 0 8px; }
.free-preview-caption p { margin-top: 10px; line-height: 1.45; }
.free-preview-image { display: block; width: 100%; max-height: 280px; object-fit: contain; border-radius: 6px; background: #10131f; }
@media (max-width: 900px) { .free-preview-grid { grid-template-columns: 1fr; } }

/* Responsive */
@media (max-width: 768px) {
  .post-thumb { width: 72px; height: 72px; flex-basis: 72px; }
  .post-platform-text { max-width: 38vw; }
  .posts-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .posts-filters {
    flex-direction: column;
  }

  .posts-filters input[type="text"],
  .posts-filters select {
    width: 100%;
    min-width: auto;
  }

  .modal-panel {
    max-height: 95vh;
    margin: 10px;
  }

  .detail-times {
    grid-template-columns: 1fr;
  }
}

/* ─── Calendar Page ─── */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-month-label {
  font-weight: 600;
  font-size: 18px;
  min-width: 160px;
  text-align: center;
}

/* Calendar grid */
.calendar-grid {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.day-header {
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 480px;
}

.day-cell {
  min-height: 100px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px;
  position: relative;
  transition: var(--transition);
  cursor: pointer;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell.empty {
  background: var(--bg-primary);
}

.day-cell:hover {
  background: var(--bg-tertiary);
}

.day-cell.today {
  background: rgba(124,58,237,0.08);
}

.day-cell.today .day-number {
  background: var(--accent);
  color: white;
}

.day-cell.drag-over {
  background: rgba(124,58,237,0.2);
  border-color: var(--accent);
}

.day-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.day-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.day-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 10px;
}

.day-cell-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Event chips */
.event-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-left: 3px solid;
  border-radius: 4px;
  font-size: 11px;
  cursor: grab;
  transition: var(--transition);
  overflow: hidden;
}

.event-chip:hover {
  background: var(--bg-tertiary);
}

.event-chip.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.event-time {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.event-platform {
  font-size: 11px;
  flex-shrink: 0;
}

.event-title {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-more {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 2px;
}

/* Upcoming posts sidebar */
.upcoming-posts {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.upcoming-posts h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.upcoming-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.upcoming-item:last-child {
  border-bottom: none;
}

.upcoming-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.upcoming-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
}

.upcoming-platforms {
  display: flex;
  gap: 4px;
  font-size: 13px;
}

.upcoming-content {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.4;
}

.upcoming-content:hover {
  color: var(--text-primary);
}

/* Mobile upcoming (shown on small screens instead of grid) */
.mobile-upcoming {
  margin-bottom: 24px;
}

.mobile-upcoming h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Day panel (slides in) */
.day-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100%;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

.day-panel-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.day-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition);
}

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

.day-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Day post cards in panel */
.day-post {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  transition: var(--transition);
}

.day-post:hover {
  border-color: var(--border-light);
}

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

.day-post-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
}

.day-post-status {
  font-size: 11px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.day-post-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
  word-break: break-word;
}

.day-post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-post-platforms {
  display: flex;
  gap: 6px;
  font-size: 14px;
}

/* Small button variant */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Empty state variants */
.empty-state.small {
  padding: 24px;
}

.empty-state.small .icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.empty-state.small p {
  font-size: 13px;
  margin-bottom: 12px;
}

/* Small loading spinner */
.loading-spinner.small {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

/* Responsive calendar */
@media (max-width: 768px) {
  .calendar-grid {
    display: none;
  }

  .mobile-upcoming {
    display: block;
  }

  .upcoming-posts {
    display: none;
  }

  .calendar-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .calendar-month-label {
    order: -1;
    width: 100%;
    margin-bottom: 8px;
  }
}

@media (min-width: 769px) {
  .mobile-upcoming {
    display: none;
  }
}

/* ─── Analytics Page ─── */
.analytics-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}

.metric-card:hover {
  border-color: var(--border-light);
}

.metric-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.metric-card h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

/* Charts grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.chart-card.chart-wide {
  grid-column: 1 / -1;
}

.chart-header {
  margin-bottom: 16px;
}

.chart-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.chart-body canvas {
  max-height: 280px;
}

.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  text-align: center;
}

.chart-empty .icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.chart-empty p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Activity timeline */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.activity-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.activity-time {
  font-size: 12px;
  color: var(--text-muted);
}

.activity-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

.activity-details {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: monospace;
}

/* Responsive analytics */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-card.chart-wide {
    grid-column: 1;
  }
}

@media (max-width: 768px) {
  .analytics-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

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

  .metric-value {
    font-size: 24px;
  }
}

/* ─── Settings Page ─── */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

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

.tab-panel {
  display: none;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.settings-card h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.settings-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.settings-card-header h2 {
  margin-bottom: 0;
}

/* Profile */
.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-value {
  font-size: 14px;
  color: var(--text-primary);
  text-align: right;
}

.profile-value.mono,
.mono {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Active company badge */
.active-company-badge {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
}

/* Audit filters */
.audit-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.form-input-sm {
  padding: 6px 10px;
  font-size: 13px;
  width: auto;
  min-width: 140px;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--bg-tertiary);
}

/* Badges */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
}

.action-create { background: rgba(16,185,129,0.15); color: #10b981; }
.action-update { background: rgba(59,130,246,0.15); color: #3b82f6; }
.action-delete { background: rgba(239,68,68,0.15); color: #ef4444; }
.action-publish { background: rgba(16,185,129,0.15); color: #10b981; }
.action-schedule { background: rgba(245,158,11,0.15); color: #f59e0b; }
.action-login { background: rgba(124,58,237,0.15); color: #7c3aed; }
.action-logout { background: rgba(107,114,128,0.15); color: #6b7280; }

.audit-details {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Disabled button tooltip */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive settings */
@media (max-width: 1024px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .settings-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .audit-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .audit-filters .form-input-sm {
    width: 100%;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }

  .audit-details {
    max-width: 120px;
  }
}

/* Utility */
.hidden { display: none !important; }
.platform-checkbox {position:absolute;width:1px;height:1px;opacity:0;}
.platform-chip:has(input:focus-visible) {outline:3px solid var(--accent);outline-offset:3px;}
.input-hint,.text-muted,.form-hint,.profile-label,.detail-section label {color:#667085;}
.publication-paused {padding:9px 14px;background:#fff4df;color:#7a4900;border:1px solid #e9c985;border-radius:8px;margin-bottom:18px;font-size:13px;}
.text-muted { color: var(--text-muted); }

.company-platform-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:10px; margin:4px 0 18px; }
.company-platform-option { display:flex; align-items:center; gap:10px; padding:12px 14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--bg-secondary); cursor:pointer; }
.company-platform-option:has(input:checked) { border-color:var(--accent); background:rgba(124,58,237,.08); }
.company-platform-option input { width:18px; height:18px; accent-color:var(--accent); }
.form-actions { display:flex; gap:12px; align-items:center; }

/* Visibility Engine — manual-first controls */
.visibility-page { max-width: 1500px; }
.visibility-safety-banner { display:flex; justify-content:space-between; align-items:center; gap:20px; margin-bottom:24px; padding:18px 20px; border:1px solid rgba(16,185,129,.3); border-radius:var(--radius-lg); background:rgba(16,185,129,.08); }
.visibility-safety-banner div { display:flex; flex-direction:column; gap:3px; }
.visibility-safety-banner span { color:var(--text-secondary); font-size:13px; }
.visibility-safe-badge { padding:7px 11px; border-radius:999px; background:rgba(16,185,129,.15); color:#047857 !important; font-weight:700; white-space:nowrap; }
.visibility-stats { margin-bottom:24px; }
.visibility-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.visibility-form-actions { display:flex; gap:10px; align-items:center; grid-column:1/-1; }
.visibility-source-list, .visibility-run-list { display:flex; flex-direction:column; }
.visibility-source, .visibility-run { padding:18px 20px; border-top:1px solid var(--border); }
.visibility-source-main, .visibility-source-info, .visibility-source-actions, .visibility-run-numbers { display:flex; align-items:center; gap:12px; }
.visibility-source-main { justify-content:space-between; }
.visibility-source-info { flex-wrap:wrap; margin:12px 0; color:var(--text-secondary); font-size:13px; }
.visibility-source-info span:not(:last-child)::after { content:'·'; margin-left:12px; color:var(--text-muted); }
.visibility-status { padding:5px 9px; border-radius:999px; background:var(--bg-tertiary); color:var(--text-secondary); font-size:12px; font-weight:700; }
.visibility-status.is-active { background:rgba(16,185,129,.12); color:#047857; }
.visibility-meta { margin-top:4px; color:var(--text-muted); font-size:12px; }
.visibility-run { display:grid; grid-template-columns:minmax(190px,1fr) auto minmax(280px,2fr); align-items:center; gap:20px; }
.visibility-run-numbers { color:var(--text-secondary); font-size:13px; white-space:nowrap; }
.visibility-run p { margin:0; color:var(--text-secondary); font-size:13px; }
.visibility-empty { padding:28px 20px; text-align:center; color:var(--text-muted); }
.asset-grid { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(260px,100%),1fr));gap:16px;margin-top:20px; }
.asset-card { border:1px solid var(--asset-border);border-radius:12px;padding:16px;min-width:0; }
.asset-card h3,.asset-card p { overflow-wrap:anywhere; }
.asset-card p { color:var(--text-secondary);font-size:13px;margin:8px 0; }
.asset-preview { display:block;width:100%;height:240px;object-fit:contain;background:var(--bg-secondary);margin:12px 0;border-radius:8px; }
.asset-card .btn { margin:4px;white-space:normal; }
.visibility-feedback { margin-top:14px; padding:11px 13px; border-radius:8px; background:rgba(16,185,129,.1); color:#047857; font-size:13px; }
.visibility-feedback.is-error { background:rgba(239,68,68,.1); color:var(--danger); }
.visibility-dialog { position:fixed; inset:0; z-index:1100; display:flex; align-items:center; justify-content:center; padding:20px; background:rgba(15,23,42,.55); }
.visibility-dialog-card { width:min(520px,100%); padding:26px; border-radius:var(--radius-lg); background:var(--bg-primary); box-shadow:var(--shadow-lg); }
.visibility-dialog-card h2 { margin-bottom:8px; }
.visibility-dialog-card > p { margin-bottom:20px; color:var(--text-secondary); }
.visibility-cost-preview { margin:12px 0; padding:12px; border-radius:8px; background:var(--bg-tertiary); color:var(--text-secondary); font-size:13px; }
@media (max-width:768px) { .visibility-safety-banner,.visibility-source-main { align-items:flex-start; flex-direction:column; } .visibility-form { grid-template-columns:1fr; } .visibility-run { grid-template-columns:1fr; } .visibility-run-numbers { flex-wrap:wrap; } }
