/* ============================================================================
   CrossPromo developer dashboard — shared app shell + design system.
   Single source of truth for tokens, the left-sidebar shell, and the common
   component library every authenticated page (Overview, Promoters, Settings)
   is built from. Page-specific styling stays inline in each page and, because
   this file loads first, always wins over these defaults.
   ========================================================================== */

:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #171b25;
  --well: #0d1017;
  --border: #262b38;
  --border-soft: #1d2230;
  --text: #f2f4f9;
  --muted: #8b93a7;
  --faint: #5b6274;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-text: #b6b8f8;
  --accent-soft: rgba(99, 102, 241, .14);
  --signal: #34d399;
  --amber: #fbbf24;
  --danger: #f87171;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 250px;
  --content-max: 960px;
  --radius: 14px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-y: scroll; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, .cp-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- shell layout ---------- */
.cp-skip {
  position: absolute; left: 12px; top: -48px; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  transition: top .15s ease;
}
.cp-skip:focus { top: 12px; }

.cp-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--panel), #0f1219);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 20px 16px 18px;
  z-index: 40;
}
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 34px clamp(20px, 4vw, 48px) 90px;
}
.page { max-width: var(--content-max); margin: 0 auto; }

/* ---------- sidebar: brand ---------- */
.cp-brand {
  display: flex; align-items: center; gap: 11px;
  text-decoration: none; color: inherit;
  padding: 4px 8px 0;
}
.cp-brand:hover { opacity: .9; }
.cp-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
}
.cp-brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

/* ---------- sidebar: app identity card ---------- */
.cp-identity {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 11px 12px; margin: 18px 4px 6px;
}
.cp-identity img {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  border: 1px solid var(--border); background: var(--well);
}
.cp-identity .cp-id-fallback {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  border: 1px solid var(--border); background: var(--well);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 16px;
}
.cp-identity .cp-id-meta { min-width: 0; flex: 1; }
.cp-identity .cp-id-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cp-identity .cp-id-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px;
}
.cp-identity .cp-id-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none;
}
.cp-identity.is-live .cp-id-dot { background: var(--signal); box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.cp-identity.is-live .cp-id-status { color: var(--signal); }
.cp-identity.is-testing .cp-id-dot { background: var(--accent-text); box-shadow: 0 0 0 3px rgba(99, 102, 241, .16); }
.cp-identity.is-testing .cp-id-status { color: var(--accent-text); }

/* ---------- sidebar: navigation ---------- */
.cp-nav-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
  color: var(--faint); text-transform: uppercase;
  padding: 18px 12px 8px;
}
.cp-nav { display: flex; flex-direction: column; gap: 2px; }
.cp-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); font-size: 13.5px; font-weight: 600;
  text-decoration: none; position: relative;
  transition: background .12s ease, color .12s ease;
}
.cp-nav a svg { width: 18px; height: 18px; flex: none; stroke-width: 1.8; }
.cp-nav a:hover { color: var(--text); background: var(--panel-2); }
.cp-nav a.is-active {
  color: var(--text);
  background: linear-gradient(90deg, var(--accent-soft), rgba(99, 102, 241, .04));
}
.cp-nav a.is-active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.cp-nav a.is-active svg { color: var(--accent-text); }

/* ---------- sidebar: account footer ---------- */
.cp-foot { margin-top: auto; padding-top: 14px; }
.cp-foot-account {
  font-size: 12px; color: var(--faint); padding: 0 12px 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cp-signout {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: 10px; text-align: left;
}
.cp-signout svg { width: 17px; height: 17px; flex: none; stroke-width: 1.8; }
.cp-signout:hover { color: var(--text); background: var(--panel-2); }

/* ---------- mobile top bar + drawer ---------- */
/* 3-column grid (menu | identity | spacer) so the identity block is truly
   centered regardless of the menu button's width. */
.cp-topbar {
  display: none;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.cp-menu {
  grid-column: 1;
  display: flex;
  align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); cursor: pointer;
  font-size: 18px;
}
.cp-topbar-id {
  grid-column: 2; justify-self: center;
  display: flex; align-items: center; gap: 8px;
  min-width: 0; max-width: 100%;
}
.cp-topbar-id img {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  border: 1px solid var(--border); background: var(--well);
}
.cp-topbar-id .cp-topbar-fallback {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  border: 1px solid var(--border); background: var(--well);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 12px;
}
.cp-topbar-id span.cp-topbar-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cp-scrim {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(4, 6, 10, .62); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}

@media (max-width: 860px) {
  .cp-sidebar {
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, .5);
    width: min(280px, 84vw);
  }
  .app-main { margin-left: 0; padding-top: 22px; }
  .cp-topbar { display: grid; }
  body.cp-nav-open .cp-sidebar { transform: translateX(0); }
  body.cp-nav-open .cp-scrim { opacity: 1; pointer-events: auto; }
}

/* ============================================================================
   Shared component library
   ========================================================================== */

/* ---------- page head ---------- */
.page-head { margin-bottom: 26px; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .18em;
  color: var(--faint); text-transform: uppercase;
}
.page-head h1 { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin-top: 7px; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 7px; max-width: 62ch; }

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.card > .eyebrow { display: block; margin-bottom: 16px; }

/* ---------- stat tiles ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.stat {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat b {
  display: block; font-family: var(--mono); font-size: 26px; font-weight: 600;
  color: var(--text); letter-spacing: -0.01em; line-height: 1.1;
}
.stat span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ---------- chips ---------- */
.status-chip {
  flex: none; font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: .04em; padding: 4px 11px; border-radius: 99px;
  color: var(--amber); border: 1px solid rgba(251, 191, 36, .35);
}
.status-chip.live { color: var(--signal); border-color: rgba(52, 211, 153, .35); }
.status-chip.testing { color: var(--accent-text); border-color: rgba(99, 102, 241, .45); }

/* ---------- key / mono value box ---------- */
.keybox {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  background: var(--well); border: 1px solid var(--border-soft);
  border-radius: 9px; padding: 10px 10px 10px 14px;
}
.keybox code {
  font-family: var(--mono); font-size: 13px; color: var(--accent-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}

/* ---------- buttons ---------- */
.btn {
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 14px;
  padding: 11px 20px; border-radius: 10px;
}
.btn:hover { background: #7477f0; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-ghost {
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 600;
  border-radius: 7px; padding: 7px 13px; cursor: pointer; flex: none;
  font-family: inherit;
}
.btn-ghost:hover { color: var(--text); }

/* ---------- empty / degraded state ---------- */
.empty {
  text-align: center; padding: 46px 24px;
  background: var(--panel); border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}
.empty .empty-icon {
  width: 46px; height: 46px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent-text);
}
.empty h2 { font-size: 16px; font-weight: 700; }
.empty p { color: var(--muted); font-size: 13.5px; margin-top: 7px; max-width: 46ch; margin-inline: auto; }

/* ---------- footer ---------- */
.page-footer { margin-top: 46px; text-align: center; font-size: 12px; color: var(--faint); }
.page-footer a { color: var(--muted); }
