/* ============================================================
   Reclop Dashboard — Studio theme (light SaaS, white cards, soft pastels)
   Design tokens first, then a small set of composable layout +
   component utilities so new tabs/cards drop in without new CSS.
   ============================================================ */
:root {
  /* Type — deliberate pairing: Space Grotesk (geometric, quirky digits) carries
     the brand + the numbers, which are a dashboard's real hero; Hanken Grotesk
     (humanist, warm) does the reading work. Tabular figures keep data aligned. */
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Surfaces */
  --bg: #eef0f3;            /* app backdrop behind the shell */
  --shell: #ffffff;         /* sidebar + main panel */
  --panel: #ffffff;         /* cards */
  --panel-alt: #f7f8fa;     /* inset / hover surfaces */
  --border: #ececef;
  --border-strong: #e1e2e7;

  /* Text — all tiers meet WCAG AA (>=4.5:1) on white while preserving hierarchy */
  --text: #1c2024;
  --muted: #5f646f;         /* ~5.6:1 */
  --faint: #6c717b;         /* ~4.6:1 — lightest label tier, still legible */

  /* Brand / accent */
  --accent: #8b7cf6;        /* lavender */
  --accent-soft: #f1edfd;   /* active pill */
  --accent-hover: #6f5de6;

  /* Pastels for charts / categories */
  --c-lavender: #b3a7f5;
  --c-pink: #f3aec1;
  --c-blue: #9ec1ee;
  --c-green: #a9d8c0;
  --c-amber: #efd9a3;

  /* Semantic */
  --pos-bg: #e8f6ee; --pos-fg: #2f9e5e;
  --neg-bg: #fdecec; --neg-fg: #d9534f;
  --error: #b91c1c;
  --success: #15803d;

  /* Geometry */
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --sidebar-w: 232px;
  --shadow: 0 1px 2px rgba(20, 24, 35, 0.04), 0 8px 24px rgba(20, 24, 35, 0.04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }

/* Numbers are data — keep digits monospaced-width wherever they're tabulated. */
.value, .chart-value, .metric .value, .table td.num, .mono, .donut .center strong,
.bar-head .pct, .legend-row .pct, .delta { font-variant-numeric: tabular-nums; }

/* Accessible focus floor — visible ring on every interactive element. */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   App shell — sidebar + main, scales to one rounded panel
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  width: 100%;
  background: var(--shell);
  transition: grid-template-columns 0.18s ease;
}

/* ---- Sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  min-width: 0;
}
.brand-mark {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 8px; font-size: 16px; font-weight: 700;
}
.sidebar-toggle {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border-strong);
  border-radius: 8px; color: var(--muted); cursor: pointer; padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-toggle:hover { background: var(--panel-alt); color: var(--text); }
.sidebar-toggle svg { width: 16px; height: 16px; transition: transform 0.18s ease; }
.nav-section {
  margin-top: 26px;
}
.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: var(--faint);
  padding: 0 8px 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--panel-alt); color: var(--text); }
.nav-item .ic { width: 18px; height: 18px; flex: none; color: var(--faint); transition: color 0.15s ease; }
.nav-item:hover .ic { color: var(--muted); }
.nav-item .label { white-space: nowrap; overflow: hidden; }
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-item.active .ic { color: var(--accent); }

/* Sign out — a leaving-action, tinted red only on hover so it stays quiet at rest. */
.nav-item.logout { margin-top: 4px; color: var(--faint); }
.nav-item.logout:hover { background: var(--neg-bg); color: var(--neg-fg); }
.nav-item.logout:hover .ic { color: var(--neg-fg); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px 2px;
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c-pink);
  color: #fff; font-size: 13px; font-weight: 600;
  display: grid; place-items: center; flex: none;
}
.user-chip .user-meta { line-height: 1.3; min-width: 0; }
.user-chip .user-meta strong { font-size: 13px; font-weight: 600; display: block; }
.user-chip .user-meta span { display: block; font-size: 12px; color: var(--muted); }

/* ---- Collapsed rail ---- */
html.sidebar-collapsed .app { grid-template-columns: 72px 1fr; }
html.sidebar-collapsed .sidebar { padding: 22px 12px; }
html.sidebar-collapsed .sidebar-head { flex-direction: column; gap: 14px; padding-bottom: 8px; }
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-item .label,
html.sidebar-collapsed .user-meta { display: none; }
html.sidebar-collapsed .nav-item { justify-content: center; padding: 9px; }
html.sidebar-collapsed .user-chip { justify-content: center; padding: 10px 0 2px; }
html.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* ---- Main ---- */
.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 34px 22px;
  border-bottom: 1px solid var(--border);
}
.topbar .eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em;
  color: var(--faint); margin-bottom: 7px;
}
.topbar h1 { margin: 0; font-family: var(--font-display); font-size: 27px; font-weight: 600; letter-spacing: -0.03em; }

.page { padding: 26px 34px 40px; }

/* ============================================================
   Layout utilities — responsive grids for scalable content
   ============================================================ */
.grid { display: grid; gap: 18px; }
.grid.cols-metric { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-2-1 { grid-template-columns: 2fr 1fr; }
.grid.cols-1-1 { grid-template-columns: 1fr 1fr; }
.grid + .grid { margin-top: 18px; }

@media (max-width: 1080px) {
  .grid.cols-2-1, .grid.cols-1-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app,
  html.sidebar-collapsed .app { grid-template-columns: 1fr; }
  .sidebar,
  html.sidebar-collapsed .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 4px; padding: 12px 16px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar-head { padding: 0; }
  .sidebar-toggle { display: none; }
  .nav-section { margin: 0 0 0 auto; display: flex; align-items: center; gap: 4px; }
  .nav-label { display: none; }
  /* Keep labels + Settings reachable on mobile even if collapsed was saved. */
  html.sidebar-collapsed .nav-item .label,
  html.sidebar-collapsed .brand-text { display: inline; }
  .sidebar-footer { margin: 0; padding: 0; border-top: none; display: flex; align-items: center; gap: 4px; }
  .user-chip { display: none; }
  .nav-item { margin: 0; }
  .topbar, .page { padding-left: 20px; padding-right: 20px; }
}

/* ============================================================
   Card primitive
   ============================================================ */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-tag { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; color: var(--faint); }

/* ---- Metric card ---- */
.metric .label { font-size: 13px; color: var(--muted); }
.metric .value {
  font-family: var(--font-display);
  font-size: 31px; font-weight: 600; letter-spacing: -0.025em;
  margin: 8px 0 12px;
}
.metric .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.delta {
  font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.delta.pos { background: var(--pos-bg); color: var(--pos-fg); }
.delta.neg { background: var(--neg-bg); color: var(--neg-fg); }
.spark { flex: none; }

/* ============================================================
   Charts (pure inline SVG — no JS dependency)
   ============================================================ */
.chart-value { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -0.025em; }
.chart-trend { font-size: 13px; font-weight: 600; color: var(--pos-fg); }
.area-chart { width: 100%; height: auto; display: block; }
.x-axis { display: flex; justify-content: space-between; margin-top: 10px; }
.x-axis span { font-size: 11px; color: var(--faint); }

/* Donut + legend */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { position: relative; flex: none; }
.donut .center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.donut .center strong { font-family: var(--font-display); font-size: 23px; font-weight: 600; display: block; letter-spacing: -0.02em; }
.donut .center span { font-size: 11px; color: var(--muted); }
.legend { flex: 1; display: flex; flex-direction: column; gap: 11px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-row .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row .name { color: var(--text); }
.legend-row .pct { margin-left: auto; color: var(--muted); font-weight: 500; }

/* Category bars */
.bar-row { margin-bottom: 16px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px; }
.bar-head .pct { color: var(--muted); font-weight: 600; }
.bar-track { height: 7px; border-radius: 999px; background: var(--panel-alt); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }

/* ============================================================
   Table
   ============================================================ */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  color: var(--faint); padding: 0 0 12px;
}
.table th.num, .table td.num { text-align: right; }
.table td { padding: 13px 0; border-top: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:first-child td { border-top: 1px solid var(--border); }
.prod { display: flex; align-items: center; gap: 12px; }
.prod .thumb { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.prod .name { font-weight: 600; }
.prod .cat { font-size: 12px; color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

/* ============================================================
   Empty state (placeholder tabs)
   ============================================================ */
.empty {
  display: grid; place-items: center;
  min-height: 420px;
  text-align: center;
}
.empty .glyph {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin: 0 auto 18px;
  font-size: 24px;
}
.empty h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.empty p { margin: 0; color: var(--muted); font-size: 14px; max-width: 360px; }

/* ============================================================
   CSV Formatter tool
   ============================================================ */
.tool-card { max-width: 640px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  padding: 40px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel-alt);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
/* Real input stays focusable for keyboard users, visually folded into the zone. */
.dropzone-input {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; overflow: hidden; clip: rect(0 0 0 0);
}
.dz-icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.dz-title { font-size: 15px; font-weight: 600; }
.dz-link { color: var(--accent); text-decoration: underline; }
.dz-sub { font-size: 12px; color: var(--muted); }
.dz-file {
  margin-top: 8px; padding: 5px 12px;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* optional output-name field — extension is fixed, shown as a suffix chip */
.field-name { margin-top: 20px; }
.field-label {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--text);
}
.field-hint {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.name-input {
  display: flex; align-items: stretch;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.name-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.name-input.is-disabled { background: var(--panel-alt); opacity: 0.55; }
.name-input .name-field {   /* scoped to override the global input[type=text] rule */
  display: block; flex: 1 1 auto; min-width: 0; width: auto; margin: 0;
  border: 0; outline: 0; background: transparent;
  padding: 11px 8px 11px 14px; font-size: 14px; color: var(--text); font-family: inherit;
}
.name-input .name-field::placeholder { color: var(--faint); }
.name-ext {
  display: flex; align-items: center; flex: none;
  padding: 0 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--panel-alt); border-left: 1px dashed var(--border-strong);
}

.tool-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin-top: 20px;
}
.cleanup-list { margin: 0; padding: 0; list-style: none; }
.cleanup-list li {
  font-size: 13px; color: var(--muted); padding-left: 18px; position: relative; line-height: 1.7;
}
.cleanup-list li::before {
  content: ""; position: absolute; left: 2px; top: 9px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* two-button actions (Begin Formatting / Download) */
.tool-actions { display: flex; gap: 10px; }
/* Secondary action (Download). Compound `.btn.btn-secondary` selector so it reliably beats the
   base `.btn` defined later in the file; text is pinned to --text (incl. hover) so it never
   washes out to white-on-near-white. */
.btn.btn-secondary {
  background: #fff; color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn.btn-secondary:hover:not([disabled]) {
  background: var(--panel-alt); color: var(--text); border-color: var(--muted);
}

/* status line with inline spinner */
.tool-status {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 2px 0; min-height: 18px; font-size: 13px; color: var(--muted);
}
.tool-status.ok { color: var(--pos-fg); }
.tool-status.err { color: var(--neg-fg); }
.tool-status.warn { color: #b07d13; }
.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

@media (max-width: 520px) {
  .tool-foot { flex-direction: column; align-items: stretch; }
  .tool-actions { width: 100%; }
  .tool-actions .btn { flex: 1; }
}

/* "How formatting works" help trigger */
.tool-foot-info { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.help-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 0; padding: 2px 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.help-btn:hover { color: var(--accent); }
.help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.help-q {
  display: grid; place-items: center; width: 18px; height: 18px; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; line-height: 1;
}

/* pipeline explanation modal */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: rgba(20, 24, 35, 0.42);
  opacity: 0; transition: opacity 0.18s ease;
}
/* class `display` overrides the UA `[hidden]{display:none}` — restore it, or the invisible
   fixed overlay captures every click and freezes the page. */
.modal-backdrop[hidden] { display: none; }
@supports (backdrop-filter: blur(2px)) { .modal-backdrop { backdrop-filter: blur(2px); } }
.modal-backdrop.is-open { opacity: 1; }
.modal {
  width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 26px 28px 24px;
  transform: translateY(8px) scale(0.99); transition: transform 0.18s ease;
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.modal-title { margin: 4px 0 0; font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.modal-close {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--panel-alt); border: 1px solid var(--border-strong); border-radius: 9px;
  color: var(--muted); cursor: pointer;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-close svg { width: 16px; height: 16px; }
.modal-lead { margin: 10px 0 18px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.pipeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.pipeline li { display: flex; gap: 12px; align-items: flex-start; }
.step-n {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; font-family: var(--font-display);
}
.step-body { font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.step-body strong { color: var(--text); font-weight: 600; }
.modal code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 5px; color: var(--text);
}
.modal-note {
  margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { transition: none; }
  .modal { transform: none; }
}

/* ============================================================
   Settings — left-rail tabs (Account / Shopify)
   ============================================================ */
.settings-card { max-width: 860px; padding: 0; overflow: hidden; }
.settings-layout { display: grid; grid-template-columns: 200px 1fr; }

.settings-nav {
  display: flex; flex-direction: column; gap: 3px;
  padding: 22px 14px;
  border-right: 1px solid var(--border);
  background: var(--panel-alt);
}
.settings-tab {
  display: flex; align-items: center; gap: 10px;
  appearance: none; background: transparent; border: none;
  width: 100%; text-align: left;
  padding: 9px 11px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.settings-tab .ic { width: 18px; height: 18px; flex: none; color: var(--faint); transition: color 0.15s ease; }
.settings-tab:hover { background: var(--panel); color: var(--text); }
.settings-tab:hover .ic { color: var(--muted); }
.settings-tab.active { background: var(--accent-soft); color: var(--text); }
.settings-tab.active .ic { color: var(--accent); }

.settings-body { padding: 26px 30px 30px; min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.tab-panel .panel-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* Shopify connection panel */
.conn-status { display: flex; align-items: center; gap: 9px; margin: 0 0 16px; font-size: 14px; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--border-strong); box-shadow: 0 0 0 3px var(--panel-alt);
}
.status-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--pos-bg); }

.oauth-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 22px; }
.inline-form { display: inline; margin: 0; }

.oauth-panel {
  background: var(--panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 24px;
}
.oauth-panel strong { font-size: 14px; }
.oauth-panel p { margin: 4px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.redirect-url {
  width: 100%; padding: 9px 11px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
}

/* Button variants used by the Shopify panel */
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: var(--panel-alt); }
.btn.ghost.danger { color: var(--neg-fg); border-color: var(--neg-bg); }
.btn.ghost.danger:hover { background: var(--neg-bg); }
.btn.disabled { background: var(--border-strong); color: var(--faint); cursor: not-allowed; pointer-events: none; }

@media (max-width: 720px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav {
    flex-direction: row; gap: 6px; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .settings-tab { width: auto; }
}

/* ============================================================
   Forms / buttons (settings + login)
   ============================================================ */
.btn, button[type="submit"] {
  display: inline-block;
  background: var(--accent);
  color: #fff; border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover, button[type="submit"]:hover { background: var(--accent-hover); }
.muted { color: var(--muted); }

.settings-form { max-width: 520px; }
label { display: block; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
input[type="text"], input[type="password"] {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff;
}
input:focus { outline: none; border-color: var(--accent); }
.settings-form small { display: block; margin-top: 4px; font-weight: 400; }
.error { color: var(--error); font-size: 14px; }
.success { color: var(--success); font-size: 14px; }

/* ============================================================
   Login (standalone)
   ============================================================ */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  width: 340px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.auth-card .subtitle { margin: 4px 0 20px; color: var(--muted); font-size: 14px; }
.auth-card button { width: 100%; margin-top: 8px; }

/* ============================================================
   Daily Report tab (scoped .dr-* — additive, no existing selector touched)
   ============================================================ */
.dr-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.dr-when .dr-date {
  font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em;
}
.dr-when .dr-sub { margin-top: 3px; color: var(--muted); font-size: 13px; }
.card.metric.secondary .value { font-size: 22px; }
.dr-cur { font-size: 0.62em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.prod .name .dr-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-right: 9px; border-radius: 6px;
  background: var(--panel-alt); color: var(--faint);
  font-size: 11px; font-weight: 700; vertical-align: middle;
}
.dr-foot { margin-top: 14px; font-size: 12px; }
.dr-state { text-align: center; padding: 44px 22px; }
.dr-state h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.dr-state p { margin: 0 auto 18px; max-width: 420px; }
.dr-meta { margin: 2px 0 16px; color: var(--muted); font-size: 13px; }

/* ============================================================
   SNS Content Studio (scoped .sns-* — additive, own sub-brand)
   The social studio gets a lavender->pink signature to set it apart
   from the analytics tabs, layered on the existing tokens.
   ============================================================ */
:root { --sns-grad: linear-gradient(92deg, var(--accent) 0%, var(--c-pink) 100%); }

/* ---- Horizontal child sub-nav (Products / Generate / History / Settings) ---- */
.sns-subnav {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 5px; margin-bottom: 24px;
  background: var(--panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius); width: fit-content; max-width: 100%;
}
.sns-tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.sns-tab .ic { width: 17px; height: 17px; flex: none; color: var(--faint); transition: color 0.15s ease; }
.sns-tab:hover { color: var(--text); background: var(--panel); }
.sns-tab:hover .ic { color: var(--muted); }
.sns-tab.active { color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
.sns-tab.active .ic { color: var(--accent); }
/* signature gradient underline on the active child */
.sns-tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px;
  border-radius: 2px; background: var(--sns-grad);
}
@media (max-width: 560px) {
  .sns-subnav { width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .sns-tab { flex: none; }
}

/* ---- Products: intake + gallery ---- */
.sns-intake { max-width: none; }
.sns-import-open svg { margin-right: 2px; vertical-align: -3px; }

.sns-selbar {
  display: flex; align-items: center; gap: 16px;
  margin: 18px 0 4px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.sns-selall { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.sns-selcount { font-size: 13px; font-weight: 600; color: var(--text); }
.sns-del-selected { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; }
.sns-gen-btn { margin-left: auto; }
.sns-gen-btn:not([disabled]) { background: var(--sns-grad); }
.sns-gen-btn:not([disabled]):hover { filter: brightness(0.96); }

.sns-grid {
  display: grid; gap: 16px; margin-top: 20px;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.sns-product {
  position: relative;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease, outline-color 0.15s ease;
  outline: 2px solid transparent; outline-offset: -2px;
}
.sns-product:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20,24,35,0.05), 0 14px 30px rgba(20,24,35,0.08); }
.sns-product.selected { outline-color: var(--accent); }
.sns-thumb {
  position: relative; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: none;
  background: var(--panel-alt); display: grid; place-items: center; overflow: hidden;
  cursor: pointer; font: inherit; color: inherit;
}
.sns-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s ease; }
.sns-product:hover .sns-thumb img { transform: scale(1.03); }
.sns-noimg { font-size: 12px; color: var(--faint); }
/* click affordance — an expand glyph fades in over the image on hover */
.sns-thumb-hint {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  background: rgba(20, 24, 35, 0.28); opacity: 0; transition: opacity 0.15s ease; pointer-events: none;
}
.sns-thumb:hover .sns-thumb-hint, .sns-thumb:focus-visible .sns-thumb-hint { opacity: 1; }
/* "N photos" badge (matches the import picker's count pill) */
.sns-photos {
  position: absolute; bottom: 8px; right: 8px; z-index: 1;
  padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  color: #fff; background: rgba(20, 24, 35, 0.6); backdrop-filter: blur(2px);
}

/* ---- Image lightbox / carousel ---- */
.sns-lightbox { max-width: 860px; }
.sns-lb-stage { position: relative; display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.sns-lb-hero {
  flex: 1 1 auto; min-width: 0; height: 62vh; max-height: 620px;
  display: grid; place-items: center; background: #14151a; border-radius: var(--radius); overflow: hidden;
}
.sns-lb-hero img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.sns-lb-hero .tool-status { color: #cfd2da; }
.sns-lb-arrow {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  box-shadow: var(--shadow); transition: background 0.15s ease, color 0.15s ease;
}
.sns-lb-arrow:hover { background: var(--accent-soft); color: var(--accent-hover); }
.sns-lb-arrow svg { width: 20px; height: 20px; }
.sns-lb-foot { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.sns-lb-counter { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sns-lb-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px; }
.sns-lb-thumb {
  flex: none; width: 60px; height: 60px; padding: 0; cursor: pointer; overflow: hidden;
  border-radius: 8px; border: 2px solid transparent; background: var(--panel-alt);
  transition: border-color 0.15s ease;
}
.sns-lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sns-lb-thumb:hover { border-color: var(--border-strong); }
.sns-lb-thumb.active { border-color: var(--accent); }
@media (max-width: 560px) {
  .sns-lb-hero { height: 48vh; }
  .sns-lb-arrow { width: 34px; height: 34px; }
}
.sns-meta { padding: 10px 12px 12px; }
.sns-meta .pname {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sns-meta .src {
  display: inline-block; margin-top: 6px; padding: 2px 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: 999px; background: var(--panel-alt); color: var(--faint);
}
.sns-meta .src-shopify { background: var(--accent-soft); color: var(--accent-hover); }
.sns-meta .src-upload { background: #fbeef3; color: #b26689; }

/* selection checkbox (top-left) + delete (top-right) overlays */
.sns-select { position: absolute; top: 8px; left: 8px; margin: 0; cursor: pointer; z-index: 2; }
.sns-select input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.sns-check-box {
  display: block; width: 20px; height: 20px; border-radius: 6px;
  background: rgba(255,255,255,0.92); border: 1.5px solid var(--border-strong);
  box-shadow: 0 1px 3px rgba(20,24,35,0.14); transition: background 0.15s ease, border-color 0.15s ease;
}
.sns-select input:checked + .sns-check-box {
  background: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 14px; background-position: center; background-repeat: no-repeat;
}
.sns-select input:focus-visible + .sns-check-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.sns-del {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 26px; height: 26px; display: grid; place-items: center;
  border: none; border-radius: 7px; cursor: pointer;
  background: rgba(255,255,255,0.92); color: var(--muted);
  box-shadow: 0 1px 3px rgba(20,24,35,0.14);
  opacity: 0; transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.sns-del svg { width: 15px; height: 15px; }
.sns-product:hover .sns-del, .sns-del:focus-visible { opacity: 1; }
.sns-del:hover { background: var(--neg-bg); color: var(--neg-fg); }
.sns-del[disabled] { opacity: 0.4; cursor: default; }

/* empty state for the gallery */
.sns-empty { text-align: center; padding: 48px 22px; }
.sns-empty .glyph {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  display: grid; place-items: center; color: var(--accent); background: var(--accent-soft);
}
.sns-empty h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.sns-empty p { margin: 0 auto; max-width: 380px; color: var(--muted); font-size: 14px; }

/* ---- Import-from-Shopify modal body ---- */
.sns-import-search {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 4px;
  padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sns-import-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sns-import-search svg { width: 16px; height: 16px; flex: none; color: var(--faint); }
.sns-import-search input {
  flex: 1 1 auto; min-width: 0; width: auto; margin: 0;
  border: 0; outline: 0; background: transparent;
  padding: 10px 0; font-size: 14px; color: var(--text); font-family: inherit;
}
.sns-import-search input::placeholder { color: var(--faint); }
.sns-import-body { max-height: 52vh; overflow-y: auto; margin: 6px 0 2px; }
.sns-import-empty { color: var(--muted); font-size: 14px; line-height: 1.6; }
.sns-import-empty a { color: var(--accent); text-decoration: underline; }
.sns-catalog { list-style: none; margin: 0; padding: 0; }
.sns-cat-row { border-top: 1px solid var(--border); }
.sns-cat-row:first-child { border-top: none; }
.sns-cat-row label { display: flex; align-items: center; gap: 12px; margin: 0; padding: 9px 4px; cursor: pointer; font-weight: 500; }
.sns-cat-check { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.sns-cat-thumb { flex: none; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; background: var(--panel-alt); display: grid; place-items: center; }
.sns-cat-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sns-cat-thumb .sns-noimg { font-size: 14px; }
.sns-cat-title { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sns-cat-count {
  margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  background: var(--accent-soft); color: var(--accent-hover); vertical-align: 1px;
}
.sns-import-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.sns-import-foot .btn { margin-left: auto; }

/* ---- Generate / History stage placeholders ---- */
.sns-stage { max-width: 620px; text-align: center; padding: 34px 30px 30px; }
.sns-stage-badge {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 18px;
  display: grid; place-items: center; color: #fff;
  background: var(--sns-grad); box-shadow: 0 8px 22px rgba(139,124,246,0.28);
}
.sns-stage-title { margin: 0 0 8px; font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.sns-stage-lead { margin: 0 auto 22px; max-width: 440px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.sns-pipeline { list-style: none; margin: 0 auto 22px; padding: 0; max-width: 420px; text-align: left; display: flex; flex-direction: column; gap: 12px; }
.sns-pipeline li { display: flex; align-items: flex-start; gap: 12px; }
.sns-step-n {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
}
.sns-pipeline li div { display: flex; flex-direction: column; }
.sns-pipeline strong { font-size: 14px; font-weight: 600; color: var(--text); }
.sns-pipeline span { font-size: 13px; color: var(--muted); }
.sns-stage-note {
  margin: 0; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--panel-alt); color: var(--muted); font-size: 13px;
}
.sns-stage-note a { color: var(--accent); text-decoration: underline; }

/* ---- SNS settings ---- */
.sns-settings { max-width: 620px; display: flex; flex-direction: column; gap: 18px; }
.sns-set-card .settings-form { max-width: none; margin-top: 4px; }
.sns-set-card .conn-status { margin: 0; font-size: 13px; }
.sns-saved { margin: 0 0 2px; }

/* ---- Generate wizard (scoped .sns-gen-*) ---- */
.sns-gen { display: flex; flex-direction: column; gap: 18px; }
.sns-gen-config { max-width: 760px; display: flex; flex-direction: column; gap: 24px; }
.sns-gen-step { display: flex; flex-direction: column; }
.sns-gen-step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.sns-gen-step-head h3 { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.sns-gen-n {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  background: var(--sns-grad); color: #fff; font-family: var(--font-display); font-size: 12px; font-weight: 700;
}
.sns-gen-hint { margin: 0 0 12px 32px; font-size: 13px; color: var(--muted); }

/* Step 1 — product picker (horizontal scroll of option cards) */
.sns-gen-products { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 8px; margin-left: 32px; }
.sns-gen-product {
  flex: none; width: 120px; display: flex; flex-direction: column; gap: 6px; padding: 0; cursor: pointer;
  background: none; border: none; text-align: left; font-family: inherit;
}
.sns-gen-thumb {
  width: 120px; height: 120px; border-radius: var(--radius); overflow: hidden;
  background: var(--panel-alt); display: grid; place-items: center;
  border: 2px solid var(--border); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sns-gen-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sns-gen-product:hover .sns-gen-thumb { border-color: var(--border-strong); }
.sns-gen-product.selected .sns-gen-thumb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sns-gen-pname {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}

/* Step 2 — segmented type control */
.sns-seg {
  display: inline-flex; gap: 4px; margin-left: 32px; padding: 4px;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); width: fit-content;
}
.sns-seg-opt {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border: none; border-radius: 7px;
  background: transparent; color: var(--muted); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.sns-seg-opt.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.sns-seg-opt.active svg { color: var(--accent); }
.sns-seg-opt.disabled { opacity: 0.6; cursor: not-allowed; }
.sns-soon {
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 999px; background: var(--c-pink); color: #fff;
}

/* Step 3 — options */
.sns-gen-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 16px; margin-left: 32px; }
.sns-gen-field { display: block; margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
/* author display:block above beats the UA [hidden] rule — restore hiding for toggled fields */
.sns-gen-field[hidden] { display: none; }
.sns-gen-select {
  display: block; width: 100%; margin-top: 7px; padding: 9px 11px; font-size: 14px; font-family: inherit;
  color: var(--text); background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.sns-gen-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sns-gen-concept-desc { margin: 10px 0 0 32px; font-size: 13px; color: var(--muted); }

/* Step 3 — reference image picker */
.sns-gen-refs {
  display: grid; gap: 10px; margin-left: 32px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
.sns-gen-refs .tool-status { grid-column: 1 / -1; }
.sns-gen-ref {
  position: relative; aspect-ratio: 1 / 1; margin: 0; cursor: pointer;
  border-radius: var(--radius-sm); overflow: hidden; background: var(--panel-alt);
  border: 2px solid var(--border); transition: border-color 0.15s ease;
}
.sns-gen-ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sns-gen-ref:hover { border-color: var(--border-strong); }
.sns-gen-ref.selected { border-color: var(--accent); }
.sns-gen-refcheck { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sns-gen-refcheck-box {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 6px;
  background: rgba(255,255,255,0.92); border: 1.5px solid var(--border-strong);
  box-shadow: 0 1px 3px rgba(20,24,35,0.14); transition: background 0.15s ease, border-color 0.15s ease;
}
.sns-gen-refcheck:checked + img + .sns-gen-refcheck-box {
  background: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 13px; background-position: center; background-repeat: no-repeat;
}
.sns-gen-refcheck:focus-visible + img + .sns-gen-refcheck-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.sns-gen-ref.selected::after {
  content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--accent); pointer-events: none;
}

/* CTA row */
.sns-gen-cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sns-gen-mock {
  font-size: 12px; font-weight: 600; color: var(--accent-hover);
  padding: 5px 11px; border-radius: 999px; background: var(--accent-soft);
}
.sns-gen-cta .sns-gen-btn { margin-left: auto; }

/* Results */
.sns-gen-grid { margin-top: 4px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.sns-gen-slot {
  position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden;
  background: var(--panel-alt); border: 1px solid var(--border);
  display: grid; place-items: center;
}
.sns-gen-slot img,
.sns-gen-slot video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.sns-gen-slot.is-video { aspect-ratio: 9 / 16; }
.sns-gen-grid.has-video { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sns-gen-slot img { cursor: zoom-in; }
.sns-gen-histlink { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.sns-gen-histlink:hover { color: var(--accent-hover); }
.sns-hist-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.sns-hist-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.sns-hist-media { position: relative; aspect-ratio: 4 / 5; background: #14151a; display: grid; place-items: center; overflow: hidden; }
.sns-hist-media video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.sns-hist-thumb { position: relative; width: 100%; height: 100%; padding: 0; border: none; background: none; cursor: zoom-in; }
.sns-hist-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sns-hist-blank { color: var(--faint); font-size: 13px; }
.sns-hist-card .sns-gen-tag { top: 8px; left: 8px; right: auto; }
.sns-hist-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.sns-hist-concept { margin-right: auto; font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Status is display-only now (posting happens via the Post button + modal). */
.sns-hist-status {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--panel-alt); border-radius: 999px;
  padding: 4px 10px; font-size: 11px; font-weight: 600; color: var(--muted);
}
.sns-hist-status.posted { background: var(--pos-bg); border-color: var(--pos-bg); color: var(--pos-fg); }
.sns-hist-status.review { background: #fff4e0; border-color: #fbe0b0; color: #b07d13; }
.sns-hist-status.review .status-dot { background: #e0a020; }
.sns-hist-actions { flex: none; display: inline-flex; align-items: center; gap: 8px; }
.sns-hist-approve, .sns-hist-regen {
  flex: none; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font-size: 11px; font-weight: 700; font-family: inherit; transition: background 0.15s ease, color 0.15s ease;
}
.sns-hist-approve { border: none; background: var(--accent); color: #fff; }
.sns-hist-approve:hover { background: var(--accent-hover); }
.sns-hist-approve[disabled] { opacity: 0.5; cursor: default; }
.sns-hist-regen { border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); }
.sns-hist-regen:hover { background: var(--panel-alt); }
.sns-hist-regen[disabled] { opacity: 0.6; cursor: default; }
.sns-hist-post {
  flex: none; padding: 5px 13px; border: none; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; font-family: inherit;
  transition: background 0.15s ease;
}
.sns-hist-post:hover { background: var(--accent-hover); }
.sns-hist-del { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: none; border-radius: 7px; background: var(--panel-alt); color: var(--muted); cursor: pointer; }
.sns-hist-del:hover { background: var(--neg-bg); color: var(--neg-fg); }
.sns-hist-del[disabled] { opacity: 0.4; cursor: default; }
.sns-hist-channels { padding: 0 12px 11px; font-size: 11px; font-weight: 600; color: var(--muted); }

/* ---- Post modal (compose + confirm) ---- */
.sns-post { max-width: 460px; }
.sns-post-media {
  border-radius: var(--radius); overflow: hidden; background: #14151a;
  display: grid; place-items: center; max-height: 46vh; margin-bottom: 4px;
}
.sns-post-media:empty { display: none; }
.sns-post-media img, .sns-post-media video {
  max-width: 100%; max-height: 46vh; object-fit: contain; display: block; background: #000;
}
.sns-post-field { margin-top: 16px; }
.sns-post-label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sns-post-channels { display: flex; flex-wrap: wrap; gap: 8px; }
.sns-chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sns-chip:hover { border-color: var(--muted); }
.sns-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.sns-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sns-post-caption {
  display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; line-height: 1.5; color: var(--text); background: var(--panel);
}
.sns-post-caption:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.sns-post-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* caption studio (generate + variant picker) inside the post modal */
.sns-studio-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sns-studio-select {
  flex: 0 1 auto; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.sns-studio-gen { flex: none; margin-left: auto; }
.sns-studio-hint { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 16px; font-size: 12px; color: var(--muted); }
.sns-studio-hint.err { color: var(--neg-fg); }
.sns-post-variants { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.sns-var-card {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 13px; background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sns-var-card.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.sns-var-rationale { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-hover); margin-bottom: 6px; }
.sns-var-caption { font-size: 13px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }
.sns-var-tags { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--accent-hover); word-break: break-word; }
.sns-var-extras { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 11px; line-height: 1.5; color: var(--muted); }
.sns-var-use { margin-top: 10px; padding: 5px 12px; font-size: 12px; }
.sns-post-confirm-back { z-index: 60; }
.sns-post-confirm { max-width: 420px; }
.sns-pcf-caption {
  margin-top: 8px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--panel-alt); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.5; color: var(--muted); white-space: pre-wrap;
  max-height: 30vh; overflow-y: auto;
}
.sns-gen-tag {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: #fff; background: var(--sns-grad);
}
.sns-gen-slot.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.sns-gen-slot-n { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--border-strong); }
.sns-gen-slot.error { border-color: var(--neg-bg); }
.sns-gen-slot-msg { font-size: 12px; font-weight: 600; color: var(--neg-fg); }
/* shimmer while a slot is pending */
.sns-gen-slot.shimmer {
  background: linear-gradient(100deg, var(--panel-alt) 30%, #eef0f3 50%, var(--panel-alt) 70%);
  background-size: 200% 100%; animation: sns-shimmer 1.3s linear infinite;
}
@keyframes sns-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sns-gen-slot.shimmer { animation: none; } }
.sns-gen-slot .sns-select { position: absolute; top: 8px; left: 8px; margin: 0; cursor: pointer; z-index: 2; }
.sns-gen-slot .sns-select input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }

/* Selection → post bar */
.sns-gen-selbar {
  position: sticky; bottom: 16px;
  display: flex; align-items: center; gap: 16px; padding: 12px 18px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.sns-gen-selcount { font-size: 14px; font-weight: 600; color: var(--text); }
.sns-gen-selbar .sns-gen-btn { margin-left: auto; }

@media (max-width: 560px) {
  .sns-gen-hint, .sns-gen-products, .sns-seg, .sns-gen-fields, .sns-gen-concept-desc, .sns-gen-refs { margin-left: 0; }
  .sns-gen-fields { grid-template-columns: 1fr; }
}

/* ============================================================
   Overview time-range toggle (segmented pills)
   ============================================================ */
.range-pills {
  display: inline-flex; gap: 4px; margin-bottom: 18px; padding: 4px;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 999px;
}
.range-pill {
  padding: 6px 14px; border-radius: 999px; text-decoration: none;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.range-pill:hover { color: var(--text); }
.range-pill.active { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   Generic child sub-nav (Overview: Summary / Yesterday). Neutral analytics
   variant of the SNS sub-nav — accent underline instead of the SNS gradient.
   ============================================================ */
.subnav {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 5px; margin-bottom: 24px;
  background: var(--panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius); width: fit-content; max-width: 100%;
}
.subtab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.subtab .ic { width: 17px; height: 17px; flex: none; color: var(--faint); transition: color 0.15s ease; }
.subtab:hover { color: var(--text); background: var(--panel); }
.subtab:hover .ic { color: var(--muted); }
.subtab.active { color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
.subtab.active .ic { color: var(--accent); }
.subtab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px;
  border-radius: 2px; background: var(--accent);
}

/* ============================================================
   Overview — interactive charts + BI cards (scoped .ov-*, additive).
   ECharts renders into .ov-chart nodes; everything else is static
   markup styled from the existing tokens. No new color system.
   ============================================================ */
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1080px) {
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .grid.cols-3 { grid-template-columns: 1fr; }
}

.ov-chart { width: 100%; }

/* Sparkline tucked beside each KPI delta */
.metric-spark { display: inline-block; width: 78px; height: 30px; flex: none; }

/* Trend metric toggle (Revenue / Orders / Units) */
.ov-toggle {
  display: inline-flex; gap: 3px; padding: 3px; flex: none;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 999px;
}
.ov-toggle-opt {
  border: none; background: transparent; padding: 6px 13px; border-radius: 999px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ov-toggle-opt:hover { color: var(--text); }
.ov-toggle-opt.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }

/* Sales composition */
.ov-comp .card-head { align-items: center; }
.ov-rates { display: flex; gap: 22px; flex-wrap: wrap; }
.ov-rate { display: flex; flex-direction: column; align-items: flex-end; }
.ov-rate-val { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ov-rate-lbl { font-size: 11px; color: var(--faint); }
.comp-bar {
  display: flex; height: 15px; gap: 2px; border-radius: 999px; overflow: hidden;
  background: var(--panel-alt);
}
.comp-seg { height: 100%; transition: filter 0.15s ease; }
.comp-seg:hover { filter: brightness(0.95); }
.comp-legend { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 15px; }
.comp-key { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.comp-key .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.comp-key .name { color: var(--text); font-weight: 600; }
.comp-key .val { color: var(--text); font-variant-numeric: tabular-nums; }
.comp-key .pct { color: var(--muted); }

/* Product list with thumbnails */
.prod-list { list-style: none; margin: 0; padding: 0; }
.prod-item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.prod-item:first-child { border-top: none; padding-top: 2px; }
.prod-thumb { width: 38px; height: 38px; border-radius: 9px; flex: none; object-fit: cover; background: var(--panel-alt); }
.mono-thumb { display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.prod-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-units { color: var(--muted); font-weight: 600; font-size: 14px; flex: none; }

.ov-legend-inline { margin-top: 14px; }

/* Live badge on the fulfillment card */
.ov-live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--pos-fg); background: var(--pos-bg); padding: 3px 9px; border-radius: 999px;
}
.ov-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pos-fg); }

.fulfil { display: flex; align-items: center; gap: 16px; }
.fulfil #ov-fulfil { width: 150px; flex: none; }
.fulfil-legend { flex: 1; }
.fulfil-empty { text-align: center; padding: 12px 8px 4px; }
.fulfil-empty .btn { margin-top: 12px; }
@media (max-width: 420px) {
  .fulfil { flex-direction: column; }
  .fulfil #ov-fulfil { width: 100%; }
}

/* ============================================================
   Yesterday flash report (scoped .dr-* — reuses .ov-*/.comp-*/.prod-*)
   ============================================================ */
/* Neutral delta (no baseline to compare against) */
.delta.flat { background: var(--panel-alt); color: var(--muted); }

/* Hero recap — net revenue as the thesis + two comparison deltas */
.dr-hero { display: flex; flex-direction: column; justify-content: center; }
.dr-hero-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.dr-hero-value {
  font-family: var(--font-display); font-size: 44px; font-weight: 700;
  letter-spacing: -0.03em; margin: 10px 0 18px; font-variant-numeric: tabular-nums;
}
.dr-hero-value .dr-cur { font-size: 0.5em; }
.dr-cmp { display: flex; gap: 26px; flex-wrap: wrap; }
.dr-cmp-item { display: flex; align-items: center; gap: 8px; }
.dr-cmp-lbl { font-size: 12px; color: var(--muted); }

/* Composition mini-card (1fr side of the hero row) */
.dr-comp-mini .comp-legend { gap: 8px 16px; margin-top: 12px; }
.dr-rates { margin-top: 15px; justify-content: flex-start; gap: 26px; }

/* KPI band footnote under each delta */
.metric .foot .dr-foot-note { font-size: 11px; color: var(--faint); }

/* Customer + hourly helper copy */
.dr-cust-note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.dr-cust-note strong { color: var(--text); }
.dr-hourly-empty { padding: 22px 4px; }

/* Rank badge inside the thumbnail product list */
.prod-item .dr-rank {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--panel-alt); color: var(--faint); font-size: 11px; font-weight: 700;
}
