/* Space Group CP Portal — flat light theme (ported from the Customer Portal).
   Two colours only: ink #111827 (text, dark surfaces) and emerald #10B981 (accent).
   Everything else is white or a transparent tint of those two. Emerald is never used
   for text on white (2.5:1); it fills buttons and marks, and ink carries the text (17.7:1). */
:root {
  --ink: #111827;
  --brand: #10B981;
  --page: #F8F8F9;                     /* 3% ink on white */
  --surface: #FFFFFF;
  --muted: rgba(17, 24, 39, .8);       /* ≈ 9.5:1 on white */
  --line: rgba(17, 24, 39, .14);
  --line-strong: rgba(17, 24, 39, .28);
  --tint-ink: rgba(17, 24, 39, .05);
  --tint-brand: rgba(16, 185, 129, .12);
  --radius: 16px;
  color-scheme: light;
}

html { background: var(--page); }
body.sg-body { min-height: 100vh; color: var(--ink); background: var(--page); }
::selection { background: rgba(16, 185, 129, .3); color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.sg-layer { position: relative; }

/* ---------- Surfaces & text ---------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(17, 24, 39, .05);
}
.glass-hover { transition: border-color .2s ease, box-shadow .2s ease; }
.glass-hover:hover { border-color: var(--brand); box-shadow: 0 4px 14px -6px rgba(17, 24, 39, .18); }
.neon-border { border-top: 3px solid var(--brand); }
.text-ink, .text-gradient { color: var(--ink); }
.text-brand { color: var(--brand); }
.text-muted { color: var(--muted); }
.border-line { border-color: var(--line); }
.neon-text { color: var(--ink); font-weight: 700; }
a.neon-text { text-decoration: underline; text-decoration-color: var(--brand); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a.neon-text:hover { text-decoration-color: var(--ink); }

/* Dark areas (sidebar, login brand panel): white text, emerald accents. */
.sg-dark { background: var(--ink); color: #fff; }
.sg-dark .text-ink, .sg-dark .text-white { color: #fff; }
.sg-dark .text-gradient, .sg-dark .text-brand, .sg-dark .neon-text { color: var(--brand); }
.sg-dark .text-muted { color: rgba(255, 255, 255, .78); }
.sg-dark .glass { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); box-shadow: none; }
.sg-dark a.neon-text { text-decoration: none; }
.sg-dark a.neon-text:hover { color: #fff; }

/* ---------- Buttons & inputs (prefixed to outrank Tailwind's preflight on [type]) ---------- */
.sg-body .btn-neon {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.4rem; border-radius: 12px; font-weight: 700; color: var(--ink);
  background: var(--brand); border: 1px solid var(--brand);
  transition: background .2s, color .2s, border-color .2s, opacity .2s;
}
.sg-body .btn-neon:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.sg-body .btn-neon:focus-visible, .sg-body .btn-ghost:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sg-body .btn-neon:disabled { opacity: .6; cursor: wait; background: var(--brand); color: var(--ink); }
.sg-body .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1rem; border-radius: 12px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: border-color .2s, background .2s;
}
.sg-body .btn-ghost:hover { border-color: var(--ink); background: var(--tint-ink); }
.sg-body .btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
/* .sg-body .btn-ghost's (0,2,0) display:inline-flex beats Tailwind's md:hidden (0,1,0),
   so the mobile-only sidebar toggle needs its own higher-specificity override to stay hidden at md+. */
@media (min-width: 768px) {
  .sg-body #sidebar-open { display: none; }
}
.sg-input {
  width: 100%; padding: .75rem 1rem; border-radius: 12px; font-size: .9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: border-color .2s, box-shadow .2s;
}
.sg-input::placeholder { color: rgba(17, 24, 39, .5); }
.sg-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16, 185, 129, .25); }
select.sg-input {
  appearance: none; -webkit-appearance: none; padding-right: 2.5rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23111827' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9rem center; background-size: 1rem;
}
select.sg-input option { background: var(--surface); color: var(--ink); }
.sg-label { display: block; margin-bottom: .4rem; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }

/* ---------- Pills & badges ---------- */
.sg-pill, .sg-pill-demo {
  display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .8rem; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
}
.sg-pill { background: var(--tint-brand); border: 1px solid var(--brand); }
.sg-pill-demo { background: var(--surface); border: 1px dashed var(--ink); }
.sg-dark .sg-pill { color: #fff; background: rgba(16, 185, 129, .18); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.sg-badge {
  display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .7rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
  color: var(--ink); background: var(--tint-ink); border: 1px solid var(--line-strong);
}
.sg-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* Positive states in emerald, negative ones solid ink, everything else neutral. */
.sg-badge--green, .sg-badge--mint { background: var(--tint-brand); border-color: var(--brand); }
.sg-badge--green::before, .sg-badge--mint::before { background: var(--brand); }
.sg-badge--red { color: #fff; background: var(--ink); border-color: var(--ink); }

/* ---------- Shell ---------- */
/* Paints the sidebar column full height, so a page taller than the screen has no gap under the sticky sidebar. */
@media (min-width: 768px) {
  .sg-shell { background: linear-gradient(90deg, var(--ink) 18rem, transparent 18rem); }
}
.sg-sidebar { background: var(--ink); color: #fff; }
.sg-topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.sg-nav-link {
  position: relative; display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem;
  border-radius: 10px; font-size: .9rem; font-weight: 500; color: rgba(255, 255, 255, .8); transition: color .2s, background .2s;
}
.sg-nav-link:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.sg-nav-link.is-active { color: #fff; font-weight: 700; background: rgba(16, 185, 129, .18); }
.sg-nav-link.is-active::before {
  content: ""; position: absolute; left: -1rem; top: 20%; bottom: 20%; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand);
}
.sg-nav-link.is-active svg { color: var(--brand); }
.sg-avatar { display: grid; place-items: center; border-radius: 12px; font-weight: 800; color: var(--ink); background: var(--brand); }
.sg-banner { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border-radius: 12px; font-size: .875rem; font-weight: 600; color: var(--ink); }
.sg-banner--error { background: var(--tint-ink); border: 1px solid var(--line-strong); border-left: 4px solid var(--ink); }
.sg-banner--success { background: var(--tint-brand); border: 1px solid var(--brand); border-left: 4px solid var(--brand); }

/* ---------- Stat cards ---------- */
.stat-card { position: relative; overflow: hidden; padding: 1.35rem; }
.stat-icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center;
  color: var(--brand); background: var(--tint-brand);
}
/* tone-violet marks cancelled/inactive items: ink instead of emerald. */
.tone-violet.stat-icon, .tone-violet .stat-icon { color: var(--ink); background: var(--tint-ink); }
.sg-dark .stat-icon { background: rgba(16, 185, 129, .18); }

/* ---------- Table ---------- */
.sg-table { width: 100%; font-size: .875rem; border-collapse: separate; border-spacing: 0; }
.sg-table thead th {
  padding: .9rem 1rem; text-align: left; white-space: nowrap;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  background: var(--tint-ink); border-bottom: 1px solid var(--line);
}
.sg-table tbody td { padding: .85rem 1rem; color: var(--ink); white-space: nowrap; border-bottom: 1px solid var(--line); }
.sg-table tbody td:first-child { font-weight: 700; }
.sg-table tbody tr { cursor: pointer; transition: background .15s; }
.sg-table tbody tr:hover, .sg-table tbody tr:focus-visible { outline: none; background: var(--tint-brand); }
.sg-table tbody tr:hover td:first-child, .sg-table tbody tr:focus-visible td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.sg-table tbody tr:last-child td { border-bottom: 0; }
.sg-table tr[hidden] { display: none !important; }
.sg-table-wrap { position: relative; }
.sg-scroll-x { scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--tint-ink); }
.sg-scroll-x::-webkit-scrollbar { height: 8px; }
.sg-scroll-x::-webkit-scrollbar-track { background: var(--tint-ink); }
.sg-scroll-x::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.sg-scroll-x::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.sg-table-wrap::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 48px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--surface));
  opacity: 0; transition: opacity .2s ease;
}
.sg-table-wrap.is-overflowing::after { opacity: 1; }
@media (max-width: 767px) {
  .sg-table-wrap { background: transparent !important; border: 0 !important; box-shadow: none !important; }
  .sg-table thead { display: none; }
  .sg-table, .sg-table tbody { display: block; }
  .sg-table tbody tr { display: block; margin-bottom: .75rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  /* overflow-wrap: anywhere lets long unbroken values (emails) wrap instead of widening the card past a 320px screen. */
  .sg-table tbody td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .35rem 0; border: 0; white-space: normal; text-align: right; overflow-wrap: anywhere; }
  .sg-table tbody td::before { content: attr(data-label); flex-shrink: 0; text-align: left; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .sg-table tbody td:first-child { font-size: 1rem; padding-bottom: .6rem; margin-bottom: .3rem; border-bottom: 1px solid var(--line); }
  .sg-table tbody tr:hover td:first-child, .sg-table tbody tr:focus-visible td:first-child { box-shadow: none; }
}

/* ---------- Drawer ---------- */
.sg-drawer { background: var(--surface); border-left: 1px solid var(--line-strong); }
.sg-drawer-head { background: var(--tint-brand); border-bottom: 1px solid var(--line); }
.sg-body .sg-tab { flex: 1; padding: .85rem; font-size: .85rem; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; transition: color .2s, border-color .2s; }
.sg-body .sg-tab:hover { color: var(--ink); }
.sg-body .sg-tab.is-active { color: var(--ink); font-weight: 700; border-color: var(--brand); }
.sg-dt { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sg-dd { font-size: .9rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Entrance ---------- */
.sg-rise { animation: sg-rise .4s ease-out both; }
.sg-rise-1 { animation-delay: .04s; }
.sg-rise-2 { animation-delay: .08s; }
.sg-rise-3 { animation-delay: .12s; }
.sg-rise-4 { animation-delay: .16s; }
@keyframes sg-rise { from { opacity: 0; transform: translateY(8px); } }

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


/* ---------- Overview funnel ---------- */
/* One colour for every stage: the bar's width carries the count. */
.funnel-track { height: 10px; border-radius: 999px; background: var(--tint-ink); overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 999px; background: var(--brand); transition: width .6s ease-out; }
