/* Shared design system for every in-app template (base.html, auth pages).
   Tokens match the public landing page (templates/landing.html) so the
   experience feels continuous from marketing site -> login -> workspace. */

:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #0E1420;
  --muted: #5B6472;
  --line: #DDE1E6;
  --alarm: #FF4020;
  --alarm-soft: #FFE8E3;
  --safe: #00B87A;
  --safe-soft: #DFF7EC;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: -0.01em;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- nav (shared shell for authenticated app pages) ---- */
.nav {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
  z-index: 10;
}
.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.92rem;
  flex-wrap: wrap;
}
.nav-links a { text-decoration: none; color: var(--muted); }
.nav-links a:hover { color: var(--ink); }
.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg) !important;
  font-weight: 500;
  text-decoration: none;
}

main.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

/* ---- sidebar (authenticated app shell) ----
   Only becomes a flex row when it actually contains a sidebar — the
   logged-out branch of partials/_nav.html renders the old flat top bar
   instead, and this selector simply doesn't match then, so that markup
   keeps its normal block layout without any extra conditional here. */
.app-shell:has(.sidebar) {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}
.app-main { flex: 1; min-width: 0; }

.app-footer {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}
.app-footer a { color: var(--muted); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.15s ease;
}
html.sidebar-collapsed .sidebar { width: 64px; }

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}
html.sidebar-collapsed .sidebar-top { flex-direction: column; padding: 16px 8px; gap: 12px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 600;
}
.sidebar-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-toggle {
  border: none;
  background: none;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--ink); }

.sidebar-workspace { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sidebar-workspace .workspace-select-wrap { width: 100%; }
.sidebar-workspace .workspace-select { width: 100%; max-width: none; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  flex: 1;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-link:hover { background: var(--bg); color: var(--ink); }
.sidebar-link .icon { flex-shrink: 0; width: 1.15em; height: 1.15em; }

html.sidebar-collapsed .sidebar-label { display: none; }
html.sidebar-collapsed .sidebar-brand { justify-content: center; }
html.sidebar-collapsed .sidebar-link { justify-content: center; }

/* ---- notification bell (topbar, polls itself every 15s) ----
   <details>/<summary> gives a no-JS dropdown; the extra .notif-dropdown
   wrapper is what's positioned, since <details> itself can't be. Sized to
   match .user-menu-trigger's 36px circle next to it. */
.notif-dropdown { position: relative; }
.notif-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.notif-summary::-webkit-details-marker { display: none; }
.notif-summary:hover { background: var(--bg); color: var(--ink); }
.notif-icon-wrap { position: relative; display: inline-flex; }
.notif-count {
  position: absolute;
  top: -6px;
  right: -8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--alarm);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1;
  border: 2px solid var(--surface);
}
.notif-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 280px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(14, 20, 32, 0.12);
  z-index: 20;
}
.notif-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.is-unread { font-weight: 600; }
.notif-time { display: block; font-size: 0.74rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.notif-empty { padding: 14px; margin: 0; font-size: 0.84rem; color: var(--muted); }
.notif-view-all {
  display: block;
  text-align: center;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.notif-view-all:hover { background: var(--bg); }

/* ---- notifications side panel ("Ver tudo") — full history, 25/page
   infinite scroll via a self-replacing sentinel row (see
   publishing/_notifications_panel_page.html) ---- */
.side-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 20, 32, 0.3);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.side-panel-backdrop.is-open { opacity: 1; pointer-events: auto; }
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(14, 20, 32, 0.12);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 50;
  overflow-y: auto;
}
.side-panel.is-open { transform: translateX(0); }
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.side-panel-header h2 { margin: 0; font-size: 1.05rem; }
.side-panel-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.side-panel-close:hover { background: var(--bg); color: var(--ink); }
.notif-panel-list { list-style: none; margin: 0; padding: 0; }
.notif-panel-item { border-bottom: 1px solid var(--line); }
.notif-panel-item a {
  display: block;
  padding: 14px 20px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}
.notif-panel-item a:hover { background: var(--bg); }
.notif-panel-item.is-unread { font-weight: 600; }
.notif-panel-sentinel { height: 1px; }

/* ---- topbar (sits above main.page, holds notifications + user menu) ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---- user menu (topbar, avatar dropdown) ----
   Same <details>/<summary> shape as .notif-dropdown above, just opening
   below-and-left instead of below-and-right, since this sits at the far
   right edge of the topbar. */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex;
  cursor: pointer;
  list-style: none;
}
.user-menu-trigger::-webkit-details-marker { display: none; }
.user-avatar-img, .user-avatar-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.user-avatar-img { object-fit: cover; }
.user-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(14, 20, 32, 0.12);
  z-index: 20;
  overflow: hidden;
}
.user-menu-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.user-menu-header strong { font-size: 0.92rem; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--bg); }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 24px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.96rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  width: 100%;
}
.btn-primary { background: var(--alarm); color: #fff; }
.btn-primary:hover { background: #e6371c; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink); }

/* ---- messages ---- */
.messages { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.messages li {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--safe-soft);
  color: #00754F;
}
.messages li.error { background: var(--alarm-soft); color: #B8290F; }

/* ---- auth pages (login, password reset, ...) ---- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.auth-nav {
  padding: 24px;
}
.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 1px 2px rgba(14, 20, 32, 0.04), 0 12px 32px -18px rgba(14, 20, 32, 0.18);
}
.auth-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.auth-card h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
  font-weight: 700;
}
.auth-subtitle {
  color: var(--muted);
  font-size: 0.94rem;
  margin: 0 0 28px;
}

.form-errors {
  background: var(--alarm-soft);
  color: #B8290F;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.88rem;
  margin-bottom: 20px;
  list-style: none;
}
.form-errors li + li { margin-top: 4px; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.96rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  transition: border-color 0.15s ease;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}
.field input[type="file"] {
  padding: 9px 13px;
  cursor: pointer;
  background: var(--surface);
}
.field input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}
.field .post-meta { margin: 6px 0 0; }
.field-errors {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  color: var(--alarm);
  font-size: 0.82rem;
}

.auth-footer-link {
  text-align: center;
  margin-top: 22px;
  font-size: 0.88rem;
  color: var(--muted);
}
.auth-footer-link a { color: var(--ink); font-weight: 500; text-decoration: underline; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 22px; border-radius: 12px; }
}

/* ---- app pages: page head, cards, badges, empty states ---- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.page-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.page-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0; font-weight: 700; }
.page-head .btn { width: auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty-state p { margin: 0 0 18px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
  background: var(--line);
  color: var(--ink);
  white-space: nowrap;
}
.badge-owner, .badge-admin { background: var(--ink); color: var(--bg); }
.badge-manager { background: var(--safe-soft); color: #00754F; }
.badge-analyst, .badge-client_viewer { background: var(--line); color: var(--muted); }

/* Generic status badges — reused across Post/Campaign/AdSet/StopLoss/
   compliance/media-generation status displays; no per-feature classes. */
.badge-safe { background: var(--safe-soft); color: #00754F; }
.badge-alarm { background: var(--alarm-soft); color: #B8290F; }

/* Inline SVG icons (apps.core.templatetags.icons) — sized to the text
   around them via em units so one icon size works at any font-size. */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
}
.icon-lg { width: 1.4em; height: 1.4em; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ---- compact workspace switcher (nav) ---- */
.workspace-select-wrap { position: relative; display: inline-flex; align-items: center; }
.workspace-select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 7px 30px 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 180px;
  text-overflow: ellipsis;
}
.workspace-select:hover { border-color: var(--ink); }
.workspace-select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

/* ---- workspace grid (full switcher page) ---- */
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.workspace-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 22px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.workspace-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.workspace-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.workspace-card h3 { margin: 0; font-size: 1.05rem; }
.workspace-card .plan {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.workspace-card-cta {
  font-size: 0.86rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.workspace-card:hover .workspace-card-cta { color: var(--ink); }

/* ---- members list: table on desktop, stacked cards on mobile ---- */
.members-list { width: 100%; border-collapse: collapse; }
.members-list th {
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.members-list td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.members-list tr:last-child td { border-bottom: none; }
.member-identity { display: flex; align-items: center; gap: 12px; }
.member-identity .email { font-weight: 500; }
.member-identity .joined-mobile { display: none; font-size: 0.82rem; color: var(--muted); }

@media (max-width: 640px) {
  .members-list thead { display: none; }
  .members-list, .members-list tbody, .members-list tr, .members-list td { display: block; width: 100%; }
  .members-list tr { padding: 14px 20px; border-bottom: 1px solid var(--line); }
  .members-list td { padding: 0; border-bottom: none; }
  .members-list td.col-role { margin-top: 10px; padding-left: 48px; }
  .members-list td.col-joined { display: none; }
  .member-identity .joined-mobile { display: block; margin-top: 2px; }
}

/* Publishing — date-grouped post list (Milestone 2) */
.post-day-group { margin-bottom: 28px; }
.post-day-group h3 {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 10px;
}
.post-list { list-style: none; margin: 0; padding: 0; }
.post-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.post-row:last-child { border-bottom: none; }
.post-thumb, .post-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.post-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.76rem;
}
/* Single (non-carousel) post media on the detail page — sized like an
   actual phone screen instead of stretching to fill whatever the card's
   width happens to be. 9:16 for story/reel formats (always vertical on
   Instagram), 1:1 for regular feed image/video. */
.post-detail-media-frame {
  width: 260px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  margin: 16px 0;
}
.post-detail-media-frame.is-story { aspect-ratio: 9 / 16; }
.post-detail-media-frame img,
.post-detail-media-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-main { flex: 1; min-width: 200px; }
.post-caption {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 4px;
}
.post-meta { font-size: 0.82rem; color: var(--muted); }
.post-actions { display: flex; gap: 8px; }
.upload-progress { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.upload-progress.is-done { color: #00754F; }
.upload-progress.is-error { color: #B8290F; }

/* Composer: form + live preview side by side */
.composer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .composer-layout { grid-template-columns: 1fr; }
}
.composer-form-card { padding: 32px; }
.composer-preview { position: sticky; top: 24px; }
.composer-preview-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}
.composer-preview-phone {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.composer-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.86rem;
}
.composer-preview-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}
.composer-preview-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  overflow: hidden;
}
.composer-preview-media.is-story { aspect-ratio: 9 / 16; }
.composer-preview-media img,
.composer-preview-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.composer-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.composer-preview-caption {
  padding: 10px 12px;
  margin: 0;
  font-size: 0.86rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dashboard KPI tiles (Milestone 6) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.kpi-tile { padding: 20px; }
.kpi-value { font-size: 2rem; font-weight: 600; display: block; }
.kpi-label { font-size: 0.82rem; color: var(--muted); }
.kpi-tile.is-alert { background: var(--alarm-soft); }
.kpi-tile.is-alert .kpi-value { color: var(--alarm); }

/* AI Studio (Milestone 5) */
.copy-variant { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.copy-variant:last-child { border-bottom: none; }
.copy-variant h4 { margin: 4px 0; }
.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.media-card { padding: 14px; }
.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: cover;
  background: var(--line);
  margin-bottom: 10px;
}
.media-card .prompt-excerpt {
  font-size: 0.86rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 8px;
}

/* Instagram analytics dashboard — trend chart is plain CSS bars (no JS
   charting library, no external request), value scaled server-side via
   Django's {% widthratio %} against the batch's own max. */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 12px 4px 0;
}
.trend-bar {
  flex: 1;
  min-height: 2px;
  background: var(--ink);
  border-radius: 3px 3px 0 0;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.trend-bar:hover { opacity: 1; }
.trend-chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px 4px 0;
}
.data-confidence {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 24px;
}
.stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.demo-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.demo-bar-label { width: 120px; flex-shrink: 0; font-size: 0.84rem; color: var(--muted); }
.demo-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}
.demo-bar-fill { height: 100%; background: var(--ink); border-radius: 5px; }
.demo-bar-value { width: 44px; flex-shrink: 0; text-align: right; font-size: 0.84rem; }

.sync-progress-track {
  position: relative;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 10px;
}
.sync-progress-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 4px;
  transition: width 0.5s ease;
}
.sync-progress-fill.is-indeterminate {
  position: absolute;
  top: 0;
  left: 0;
  width: 30%;
  animation: sync-progress-slide 1.2s ease-in-out infinite;
}
@keyframes sync-progress-slide {
  0% { left: -30%; }
  100% { left: 100%; }
}
