/* =============================================================================
   Somia · Shared theme
   Dark mode chassis with neon green accent. JetBrains Mono everywhere.
   Imported by every page.
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ----------------------------------------------------------------------------
   Theme tokens
   Default = dark (Somia signature). Light mode lives under [data-theme="light"]
   on <html>. Somia.applyTheme() in auth.js sets that attribute on every page
   and persists the choice in localStorage.
   ---------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg:            #0a0a0a;
  --bg-elevated:   #141414;
  --bg-card:       #161616;
  --bg-input:      #1a1a1a;
  --bg-hover:      #1f1f1f;

  /* Brand */
  --accent:        #00E550;
  --accent-text:   #00E550;
  --accent-dim:    #00C846;
  --accent-bright: #00FF73;
  --accent-soft:   rgba(0, 229, 80, 0.12);
  --accent-line:   rgba(0, 229, 80, 0.30);

  /* Text */
  --text:          #f8f8f8;
  --text-muted:    #9090aa;
  --text-dim:      #5c5c70;

  /* Borders */
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* Status */
  --success:       #00E550;
  --warning:       #f5a623;
  --danger:        #e74c3c;
  --info:          #4f8ef7;

  /* Radius */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  /* Shadow */
  --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.40);
  --shadow:      0 4px 20px rgba(0, 0, 0, 0.40);
  --shadow-lg:   0 20px 60px rgba(0, 0, 0, 0.50);
  --shadow-glow: 0 4px 24px rgba(0, 229, 80, 0.18);

  /* Type */
  --font: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* Light theme - applied via <html data-theme="light"> */
:root[data-theme="light"] {
  --bg:            #fafaf8;
  --bg-elevated:   #ffffff;
  --bg-card:       #ffffff;
  --bg-input:      #f4f4f2;
  --bg-hover:      #f0f0ee;

  --accent:        #00B844;
  --accent-text:   #007a2c;
  --accent-dim:    #009638;
  --accent-bright: #00E550;
  --accent-soft:   rgba(0, 184, 68, 0.10);
  --accent-line:   rgba(0, 184, 68, 0.28);

  --text:          #1a1a1a;
  --text-muted:    #5c5c70;
  --text-dim:      #9090aa;

  --border:        rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.20);

  --warning:       #c97a08;
  --danger:        #c8392f;
  --info:          #2e6cd6;

  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:      0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg:   0 16px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 4px 16px rgba(0, 184, 68, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-bright); }

button { font-family: var(--font); cursor: pointer; }

input, textarea, select {
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

::placeholder { color: var(--text-dim); }
::selection { background: var(--accent-soft); color: var(--text); }

/* Compact location filter shown in page-head action rows. */
select.loc-filter {
  padding: 6px 10px;
  font-size: 12px;
  max-width: 220px;
}

/* ----------------------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #001b0a;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 14px 20px; font-size: 14px; }

/* ----------------------------------------------------------------------------
   Cards
   ---------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------------------
   Badges + chips
   ---------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.badge-warn   { background: rgba(245, 166, 35, 0.12); color: var(--warning); border-color: rgba(245, 166, 35, 0.3); }
.badge-danger { background: rgba(231, 76, 60, 0.12); color: var(--danger); border-color: rgba(231, 76, 60, 0.3); }

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.dot-warn   { background: var(--warning); }
.dot-danger { background: var(--danger); }

/* ----------------------------------------------------------------------------
   Tables
   ---------------------------------------------------------------------------- */
.tbl-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 520px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl .cell-wrap { white-space: normal; }

/* ----------------------------------------------------------------------------
   Form helpers
   ---------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .field select, .field textarea { width: 100%; }

.toggle {
  position: relative;
  display: inline-block;
  width: 38px; height: 22px;
}
.toggle input { display: none; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.toggle-track::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 160ms ease, background 160ms ease;
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(16px); background: #001b0a; }

/* ----------------------------------------------------------------------------
   Layout: app shell with sidebar
   ---------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sidebar .brand img { height: 22px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}
.sidebar .footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar .footer-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar .footer-actions a {
  display: block;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.sidebar .footer-actions a:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.sidebar .footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.sidebar .footer-meta .badge {
  font-size: 10px;
  padding: 2px 6px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 10px;
  column-gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.topbar .crumbs strong { color: var(--text); font-weight: 500; }
.topbar .actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ----------------------------------------------------------------------------
   Stat tiles (the splash-page metric cards)
   ---------------------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent-soft), transparent 60%);
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: none;
}
.stat:hover::after { opacity: 0.6; }
.stat .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat .delta { font-size: 12px; color: var(--accent-text); margin-top: 6px; }
.stat .delta.down { color: var(--danger); }

/* ----------------------------------------------------------------------------
   Chrome shapes
   ---------------------------------------------------------------------------- */
.glow-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
}

.kbd {
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-muted);
}

/* ----------------------------------------------------------------------------
   Alert / banner (used for Demo Mode notice across pages)
   ---------------------------------------------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-line);
  font-size: 12px;
  color: var(--accent-text);
}
.banner strong { color: var(--text); font-weight: 600; }

/* ----------------------------------------------------------------------------
   Auth shells (used by index.html and select-org.html)
   ---------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(0, 229, 80, 0.12), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.auth-card .brand img { height: 26px; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; background: var(--bg-input); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.tabs button {
  flex: 1;
  padding: 8px;
  font-size: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 6px;
  font-weight: 500;
}
.tabs button.active { background: var(--bg-elevated); color: var(--text); }

/* ----------------------------------------------------------------------------
   Utilities
   ---------------------------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono-tiny { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 22px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 22px; }
.spacer { flex: 1; }
.right { text-align: right; }
.center { text-align: center; }

/* ----------------------------------------------------------------------------
   Page sections (h2 anchors used across portal/app)
   ---------------------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  row-gap: 8px;
}
.page-head h1, .page-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-head .sub {
  font-size: 12px;
  color: var(--text-muted);
}
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------------------
   KPI strip + program impact tiles
   ---------------------------------------------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin-bottom: 8px;
}
.kpi .value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi .delta {
  font-size: 11px;
  color: var(--accent-text);
  margin-top: 8px;
}
.kpi .delta.muted { color: var(--text-muted); }
.kpi .live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0, 229, 80, 0.6);
  animation: pulse 1.6s ease-out infinite;
  margin-right: 6px;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 229, 80, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(0, 229, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 229, 80, 0); }
}

.impact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.impact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.impact-card .icon {
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--accent-text);
}
.impact-card .v {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.impact-card .h {
  font-size: 13px;
  font-weight: 600;
}
.impact-card .d {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ----------------------------------------------------------------------------
   Chart container - lets Chart.js render into a fixed-height canvas
   ---------------------------------------------------------------------------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
}
.chart-panel .h {
  font-size: 13px;
  font-weight: 600;
}
.chart-panel .sub {
  font-size: 11px;
  color: var(--text-muted);
}
.chart-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 180px;
}
.chart-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ----------------------------------------------------------------------------
   Integration cards (used in portal and admin)
   ---------------------------------------------------------------------------- */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.integration-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, background 120ms ease;
}
.integration-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.integration-logo {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}
.integration-meta { flex: 1; min-width: 0; }
.integration-meta .name { font-size: 13px; font-weight: 600; }
.integration-meta .note { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ----------------------------------------------------------------------------
   Member health rollup (8-cell aggregate grid)
   ---------------------------------------------------------------------------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.health-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.health-cell .v { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.health-cell .l { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ----------------------------------------------------------------------------
   Upsell panel (used by the member "At {Org}" container)
   Soft accent gradient + glow + top accent stripe so it pops against the
   regular .panel cards above and below it. Adapts to light + dark via the
   --accent-soft / --accent-line / --shadow-glow tokens.
   ---------------------------------------------------------------------------- */
.upsell-panel {
  position: relative;
  background:
    radial-gradient(ellipse at 0% 0%, var(--accent-soft), transparent 60%),
    radial-gradient(ellipse at 100% 100%, var(--accent-soft), transparent 70%),
    var(--bg-card);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}
.upsell-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.7;
  pointer-events: none;
}
.upsell-panel .panel-title { color: var(--text); }
.upsell-panel .panel-title .star {
  display: inline-block;
  color: var(--accent-text);
  margin-right: 6px;
  transform: translateY(-1px);
}
.upsell-panel .panel-sub { color: var(--text-muted); }

/* ----------------------------------------------------------------------------
   Activity item rows (member ledger, etc.)
   ---------------------------------------------------------------------------- */
.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .meta { flex: 1; min-width: 0; }
.activity-item .ago { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.delta-pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.delta-pill.earn   { background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.delta-pill.redeem { background: rgba(231,76,60,.10); color: var(--danger); border: 1px solid rgba(231,76,60,.3); }

/* Source attribution chip (rendered in ledger row .ago line) */
.source-chip {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 2px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.source-chip.source-venue   { background: var(--accent-soft); color: var(--accent-text); }
.source-chip.source-partner { background: rgba(155, 127, 245, 0.14); color: #b8a4ff; }
.source-chip.source-somia   { background: var(--bg-elevated);    color: var(--text-muted); border: 1px solid var(--border); }
:root[data-theme="light"] .source-chip.source-partner { color: #6f49d6; background: rgba(111, 73, 214, 0.10); }

/* ----------------------------------------------------------------------------
   Activity feed
   ---------------------------------------------------------------------------- */
.feed-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.feed-row:last-child { border-bottom: none; }
.feed-row .who { font-weight: 600; }
.feed-row .what { color: var(--text-muted); }
.feed-row .ago { margin-left: auto; font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ----------------------------------------------------------------------------
   Modal (used by portal member detail and app modals)
   ---------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  overflow: hidden;
}
.modal.open { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  margin: 4vh auto;
  max-width: 760px;
  width: calc(100% - 32px);
  max-height: 92vh;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
.modal-header {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 1;
}
.modal-header .title { font-size: 15px; font-weight: 600; }
.modal-header .sub { font-size: 12px; color: var(--text-muted); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--bg-hover); }
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ----------------------------------------------------------------------------
   Org picker (compact select used in admin section heads)
   ---------------------------------------------------------------------------- */
.org-picker {
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  min-width: 180px;
  background-position: right 8px center;
}

/* ----------------------------------------------------------------------------
   Row actions (edit/delete buttons in tbl rows)
   ---------------------------------------------------------------------------- */
.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
  justify-content: flex-end;
}
.row-actions .btn { padding: 4px 10px; font-size: 11px; }
.row-actions .btn-danger {
  border-color: rgba(231, 76, 60, 0.3);
  color: var(--danger);
}
.row-actions .btn-danger:hover { background: rgba(231, 76, 60, 0.1); }

/* ----------------------------------------------------------------------------
   Toast (used by admin saves, app modal confirmations, etc.)
   The element is auto-created by Somia.toast() the first time it's called.
   ---------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.92);
  opacity: 0;
  pointer-events: none;
  z-index: 80;
  max-width: 360px;
  transition: transform 200ms ease, opacity 200ms ease;
}
.toast.show {
  pointer-events: auto;
  animation: toast-bounce 480ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.toast.error { border-color: rgba(231, 76, 60, 0.4); color: var(--danger); }
@keyframes toast-bounce {
  0%   { transform: translateY(20px) scale(0.92); opacity: 0; }
  60%  { transform: translateY(-6px)  scale(1.04); opacity: 1; }
  80%  { transform: translateY(2px)   scale(0.99); }
  100% { transform: translateY(0)     scale(1);    opacity: 1; }
}

/* ----------------------------------------------------------------------------
   Theme toggle button (sun in dark mode, moon in light mode)
   ---------------------------------------------------------------------------- */
.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.theme-toggle:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.theme-toggle svg { width: 14px; height: 14px; display: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
:root[data-theme="light"]       .theme-toggle .icon-moon { display: block; }

/* ----------------------------------------------------------------------------
   Logo swap by theme. Each location includes both imgs; CSS shows the
   right one based on data-theme. Works inside .brand or anywhere else.
   ---------------------------------------------------------------------------- */
.logo-dark, .logo-light { display: none; }
:root:not([data-theme="light"]) .logo-dark  { display: block; }
:root[data-theme="light"]       .logo-light { display: block; }

/* ----------------------------------------------------------------------------
   Single-page router: only the active section-page renders. Others stay in DOM
   so anchor links and JS references keep working, they're just hidden.
   The router lives in auth.js as Somia.mountSinglePageRouter().
   ---------------------------------------------------------------------------- */
.section-page { display: none; }
.section-page.active { display: flex; flex-direction: column; gap: 14px; }

/* ----------------------------------------------------------------------------
   Sub-tab icons (Points view, etc) - small inline SVGs
   ---------------------------------------------------------------------------- */
.subtab-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ----------------------------------------------------------------------------
   Responsive
   Three breakpoints:
   - 1100px: hide non-essential bits in the topbar org switcher
   - 880px:  shrink sidebar to icons + tighten paddings
   - 760px:  flip sidebar to a horizontal nav strip across the top
   ---------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  /* When cramped, hide the secondary metadata next to the org switcher */
  .org-switcher .role-meta,
  .org-switcher .switch-link,
  .crumbs .role-meta { display: none; }
  .topbar .actions .btn .label-long { display: none; }
}
@media (max-width: 760px) {
  .switch-btn { padding: 4px 8px; font-size: 11px; }
}

@media (max-width: 880px) {
  .shell { grid-template-columns: 200px 1fr; }
  .content { padding: 18px; gap: 16px; }
  .panel { padding: 16px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 24px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand img { height: 22px; }

  /* Backdrop behind the drawer */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 55;
  }
  .sidebar-backdrop.show { display: block; }

  /* Hamburger toggle becomes visible */
  .menu-toggle { display: inline-grid !important; }

  /* Topbar layout for mobile */
  .topbar {
    flex-direction: row;
    align-items: center;
    padding: 12px 14px;
    position: sticky;
  }
  .topbar .crumbs { flex: 1; min-width: 0; gap: 6px; }
  .topbar .actions { gap: 8px; }

  .content { padding: 14px; gap: 14px; }
  .panel { padding: 14px; }
  .panel-header { flex-wrap: wrap; gap: 8px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 22px; }

  .auth-card { padding: 24px 20px; }
}

/* Hamburger toggle - hidden by default on desktop */
.menu-toggle {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.menu-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 480px) {
  .sidebar .brand img { height: 16px; }
  .stat .value { font-size: 20px; }
  .auth-card { padding: 20px 16px; border-radius: var(--radius); }
}
