/* ═══════════════════════════════════════════════════════════════════════
   Piclo Shared Design System  —  piclo.css
   ─────────────────────────────────────────────────────────────────────
   The single source of truth for Piclo's visual design language.

   This file is loaded FIRST by every Piclo frontend surface. Surface-
   specific overrides go in a separate stylesheet loaded AFTER this one.

   Includes:
     • GT Walsheim font-face declarations
     • Piclo HSL colour tokens + light theme
     • Themes (Octopus, NESO, Piclo)
     • Reset + base typography
     • Topbar / sub-nav
     • Buttons, badges, tags, status pills
     • Cards (market-card, card, entity-card, kpi-card, revenue-card)
     • Tables, forms, modals
     • Builder sections, mode toggle, dashboard tabs, sub-tabs
     • Period picker, drag chart, direction toggle
     • Empty state, toast, hero
     • Mapbox overrides, scrollbars, responsive breakpoints
     • Utility classes (.flex, .mt-*, .mb-*, .text-*)

   Brand tokens are HSL-based so themes can re-tint cleanly.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Font Faces — GT Walsheim ─────────────────────────────────────── */
@font-face { font-family: 'GT Walsheim'; font-weight: 300; font-style: normal; font-display: swap; src: url('/shared/fonts/GT-Walsheim-Light-webfont.woff2') format('woff2'); }
@font-face { font-family: 'GT Walsheim'; font-weight: 400; font-style: normal; font-display: swap; src: url('/shared/fonts/GT-Walsheim-Regular-webfont.woff2') format('woff2'); }
@font-face { font-family: 'GT Walsheim'; font-weight: 500; font-style: normal; font-display: swap; src: url('/shared/fonts/GT-Walsheim-Medium-webfont.woff2') format('woff2'); }
@font-face { font-family: 'GT Walsheim'; font-weight: 700; font-style: normal; font-display: swap; src: url('/shared/fonts/GT-Walsheim-Bold-webfont.woff2') format('woff2'); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── CSS Variables — Piclo Light (default) ────────────────────────── */
:root {
  /* Piclo brand palette (from Flex tailwind config) */
  --navy: hsl(205, 67%, 24%);
  --navy-dark: hsl(206, 67%, 14%);
  --navy-light: hsl(206, 63%, 85%);
  --turquoise: hsl(176, 70%, 48%);
  --turquoise-dark: hsl(176, 70%, 41%);
  --turquoise-vibrant: hsl(176, 100%, 50%);

  /* Functional tokens */
  --primary: var(--turquoise);
  --primary-hover: var(--turquoise-dark);
  --bg: hsl(0, 0%, 100%);
  --bg-page: hsl(0, 0%, 98%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-card-hover: hsl(195, 43%, 97%);
  --bg-subtle: hsl(195, 43%, 95%);
  --text: var(--navy-dark);
  --text-secondary: hsl(205, 54%, 39%);
  --text-muted: hsl(196, 41%, 55%);
  --text-dim: hsl(196, 41%, 55%);
  --border: hsl(200, 33%, 93%);
  --border-light: hsl(194, 30%, 92%);
  --border-soft: hsl(194, 30%, 92%);
  --topbar-bg: var(--navy);
  --topbar-text: hsl(0, 0%, 100%);
  --topbar-border: hsl(205, 67%, 20%);
  --topbar-sub-bg: hsl(206, 67%, 18%);
  --badge-bg: hsla(176, 70%, 48%, 0.1);
  --badge-text: var(--turquoise-dark);
  --accent: var(--turquoise);
  --accent-soft: hsla(176, 70%, 48%, 0.08);
  --success: hsl(118, 70%, 38%);
  --success-bg: hsla(118, 70%, 38%, 0.08);
  --danger: hsl(356, 70%, 48%);
  --danger-bg: hsla(356, 70%, 48%, 0.08);
  --warning: hsl(29, 97%, 57%);
  --warning-bg: hsla(29, 97%, 57%, 0.08);
  --info: hsl(205, 67%, 45%);
  --info-bg: hsla(205, 67%, 45%, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px hsla(0, 0%, 0%, 0.06);
  --shadow-lg: 0 4px 16px hsla(0, 0%, 0%, 0.08);
  --shadow-light: 0 0.0625rem 0.186rem hsla(0, 0%, 0%, 0.08);
  --shadow-card: var(--shadow-light);
  --font: 'GT Walsheim', Helvetica, Arial, sans-serif;
  --transition: 258ms cubic-bezier(.5, 0, 0, 1.2);
  --transition-simple: 200ms ease;
}

/* ── Octopus Theme ────────────────────────────────────────────────── */
body.theme-octopus {
  --primary: #FF48D8;
  --primary-hover: #e040c0;
  --accent: #FF48D8;
  --accent-soft: hsla(316, 100%, 64%, 0.08);
  --badge-bg: hsla(316, 100%, 64%, 0.08);
  --badge-text: #c030a0;
  --topbar-bg: #250040;
  --topbar-border: #1a0030;
  --topbar-sub-bg: #1c002e;
}

/* ── NESO Theme ───────────────────────────────────────────────────── */
body.theme-neso {
  --primary: #7A3864;
  --primary-hover: #6a2e56;
  --accent: #7A3864;
  --accent-soft: hsla(316, 37%, 35%, 0.08);
  --badge-bg: hsla(316, 37%, 35%, 0.08);
  --badge-text: #7A3864;
  --topbar-bg: #3F0731;
  --topbar-border: #2d0523;
  --topbar-sub-bg: #2d0523;
}

/* ── Piclo Theme (explicit override, same as default) ─────────────── */
body.theme-piclo {
  --primary: var(--turquoise);
  --primary-hover: var(--turquoise-dark);
  --accent: var(--turquoise);
  --accent-soft: hsla(176, 70%, 48%, 0.08);
  --badge-bg: hsla(176, 70%, 48%, 0.1);
  --badge-text: var(--turquoise-dark);
  --topbar-bg: var(--navy);
  --topbar-border: hsl(205, 67%, 20%);
  --topbar-sub-bg: hsl(206, 67%, 18%);
}

html, body {
  min-height: 100vh;
  font-family: var(--font);
  font-weight: 400;
  font-size: 1rem;
  background: var(--bg-page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); }

/* ═══ Org Picker ═══ */
.org-picker-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: var(--bg-page);
  display: flex; align-items: center; justify-content: center;
}
.org-picker-card {
  max-width: 700px; width: 90%; text-align: center;
}
.picker-logo { height: 36px; margin-bottom: 24px; }
.org-picker-card h1 { font-size: 1.5rem; font-weight: 500; color: var(--navy); margin-bottom: 6px; }
.picker-subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 0.9375rem; }
.org-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.org-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 16px;
  cursor: pointer; transition: all var(--transition-simple); text-align: center;
  box-shadow: var(--shadow-light);
}
.org-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.org-card-logo { height: 28px; margin-bottom: 12px; }
.org-card-name { font-weight: 500; font-size: 0.9rem; margin-bottom: 4px; color: var(--navy); }
.org-card-id { font-size: 0.75rem; color: var(--text-muted); }

/* ═══ Topbar ═══ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-border);
  z-index: 2000; display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { height: 24px; width: auto; }
.brand-label { font-size: 0.8125rem; font-weight: 300; color: hsla(0,0%,100%,0.7); border-left: 1px solid hsla(0,0%,100%,0.2); padding-left: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-nav { display: flex; gap: 4px; align-items: center; }
.topbar-nav a {
  font-size: 0.8125rem; font-weight: 400; color: hsla(0,0%,100%,0.7);
  text-decoration: none; padding: 6px 12px; border-radius: 6px;
  border: 1px solid transparent; transition: all var(--transition-simple);
  cursor: pointer;
}
.topbar-nav a:hover { background: hsla(0,0%,100%,0.1); color: #fff; }
.topbar-nav a.active { color: #fff; border: 1px solid hsla(0,0%,100%,0.3); }

/* Nav Dropdown */
.nav-dropdown {
  position: relative;
  display: inline-flex;
}
.nav-dropdown-trigger {
  /* Mirrors .topbar-nav a styling so a <span> works as a hover-only trigger. */
  font-size: 0.8125rem;
  font-weight: 400;
  color: hsla(0,0%,100%,0.7);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all var(--transition-simple);
  cursor: default;
  user-select: none;
  display: inline-block;
}
.nav-dropdown:hover .nav-dropdown-trigger {
  background: hsla(0,0%,100%,0.1);
  color: #fff;
}
.nav-dropdown-trigger.active {
  color: #fff;
  border: 1px solid hsla(0,0%,100%,0.3);
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--navy-dark, hsl(206, 67%, 14%));
  border: 1px solid hsla(0,0%,100%,0.1);
  border-radius: 0 0 var(--radius-sm, 4px) var(--radius-sm, 4px);
  min-width: 200px;
  padding: 4px 0;
  z-index: 3000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.nav-dropdown:hover .nav-dropdown-menu {
  display: block;
}
.nav-dropdown-menu a {
  display: block;
  padding: 8px 16px;
  font-size: 0.8125rem;
  color: hsla(0,0%,100%,0.7);
  text-decoration: none;
  transition: all 0.15s ease;
  border: none;
  border-radius: 0;
}
.nav-dropdown-menu a:hover {
  background: hsla(0,0%,100%,0.1);
  color: #fff;
}
.nav-dropdown-menu a.active {
  color: var(--turquoise, hsl(176, 70%, 48%));
}

.org-indicator { display: flex; align-items: center; gap: 8px; }
.org-name-display { font-size: 0.8125rem; color: hsla(0,0%,100%,0.8); }

/* Org badge variant — for surfaces showing the active org as a pill */
.org-badge {
  display: flex; align-items: center; gap: 8px;
  background: hsla(0,0%,100%,0.08);
  border: 1px solid hsla(0,0%,100%,0.15);
  padding: 6px 12px; border-radius: 999px;
  color: hsla(0,0%,100%,0.9); font-size: 0.8125rem;
}
.org-dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; }
.role-tag {
  background: var(--primary); color: var(--navy-dark);
  font-size: 0.625rem; font-weight: 700; padding: 1px 6px; border-radius: 4px;
}

/* ═══ Sub-nav (secondary nav under the topbar) ═══ */
.sub-nav {
  position: sticky; top: 56px; z-index: 1900;
  background: var(--topbar-sub-bg);
  border-bottom: 1px solid var(--topbar-border);
  padding: 0;
}
.sub-nav .container, .sub-nav-inner {
  display: flex; gap: 0; max-width: 1400px; margin: 0 auto;
  padding: 0 1.25rem;
}
.sub-nav a {
  color: hsla(0,0%,100%,0.6);
  padding: 10px 14px; font-size: 0.8125rem; font-weight: 500;
  border-bottom: 2px solid transparent; transition: all var(--transition-simple);
}
.sub-nav a:hover { color: #fff; }
.sub-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ═══ WS Status ═══ */
.ws-status { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: hsla(0,0%,100%,0.5); }
.live-indicator { width: 7px; height: 7px; border-radius: 50%; background: hsla(0,0%,100%,0.3); }
.live-indicator.connected { background: hsl(118, 70%, 55%); box-shadow: 0 0 6px hsl(118, 70%, 55%); }

/* ═══ Layout ═══ */
.container { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
.main-content { margin-top: 56px; padding: 24px; max-width: 1400px; margin-left: auto; margin-right: auto; min-height: calc(100vh - 56px); }
.page-content { padding: 32px 24px; max-width: 1400px; margin-left: auto; margin-right: auto; }
.loading { padding: 60px 0; text-align: center; color: var(--text-dim); }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-head .h-left h1 { font-size: 1.625rem; margin-bottom: 4px; color: var(--navy); font-weight: 500; }
.page-head .h-left p { color: var(--text-dim); font-size: 0.875rem; max-width: 700px; }
.page-head .h-right { display: flex; gap: 8px; align-items: center; }

.section { margin-top: 32px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.section-header h2 { font-size: 1.25rem; font-weight: 500; color: var(--navy); }

/* ═══ Views ═══ */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ Buttons ═══ */
.btn {
  font-family: var(--font); font-size: 0.8125rem; font-weight: 500;
  border: none; border-radius: 6px; padding: 8px 16px;
  cursor: pointer; transition: all var(--transition-simple);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-subtle); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 6px 12px; border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg-subtle); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { font-size: 0.75rem; padding: 5px 12px; }
.btn-lg { font-size: 0.9375rem; padding: 12px 28px; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Back link */
.back-link {
  font-size: 0.8125rem; color: var(--text-secondary); text-decoration: none;
  cursor: pointer; transition: color var(--transition-simple); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px;
}
.back-link:hover { color: var(--primary); }
/* When used inside a breadcrumb row, drop the bottom margin so the row
   stays a single line. */
.breadcrumb .back-link { margin-bottom: 0; }

/* ═══ Dashboard Tabs ═══ */
.dash-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.dash-tab {
  font-family: var(--font); font-size: 0.8125rem; font-weight: 500;
  padding: 10px 18px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition-simple);
}
.dash-tab:hover { color: var(--text); }
.dash-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.dash-tab-panel { display: none; }
.dash-tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

/* ═══ Sub Tabs (pill-style) ═══ */
.sub-tabs {
  display: flex; background: var(--bg-subtle); border-radius: 8px;
  border: 1px solid var(--border); overflow: hidden; margin-bottom: 20px; margin-top: 16px;
}
.sub-tab {
  font-family: var(--font); font-size: 0.75rem; font-weight: 500;
  padding: 7px 14px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; transition: all var(--transition-simple);
}
.sub-tab.active { background: var(--primary); color: #fff; border-radius: 7px; }
.sub-tab:hover:not(.active) { color: var(--text); }
.subtab-content { display: none; }
.subtab-content.active { display: block; animation: fadeIn 0.2s ease; }

/* ═══ Tabs (in-page tabs, underline style) ═══ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px; font-size: 0.8125rem; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--transition-simple); background: transparent; border-top: none;
  border-left: none; border-right: none; font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

/* ═══ Cards ═══ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-light); margin-bottom: 16px;
}
.card h3 { font-size: 1.0625rem; font-weight: 500; margin-bottom: 8px; color: var(--navy); }
.card p { color: var(--text-muted); font-size: 0.875rem; }
.card.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }

/* ═══ Market Grid (cards for markets / surfaces with a grid of choices) ═══ */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.market-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 22px;
  cursor: pointer; transition: all var(--transition-simple);
  box-shadow: var(--shadow-light);
}
.market-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.market-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.market-card-header h3 { font-size: 0.9375rem; font-weight: 500; color: var(--navy); }
.market-card-desc { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.market-card-props { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8125rem; color: var(--text-secondary); }
.market-card-props .prop-label { color: var(--text-muted); font-size: 0.75rem; }

/* ═══ Entity Card (general-purpose clickable item card) ═══ */
.entity-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-light);
  border: 1px solid var(--border); cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.entity-card .ec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.entity-card .ec-title { font-size: 1rem; font-weight: 500; color: var(--navy); }
.entity-card .ec-desc { font-size: 0.8125rem; color: var(--text-muted); }
.entity-card .ec-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.entity-card .ec-stats { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border-light); }
.entity-card .ec-stat { font-size: 0.75rem; }
.entity-card .ec-stat .v { font-weight: 700; color: var(--text); display: block; font-size: 0.9375rem; }
.entity-card .ec-stat .l { color: var(--text-dim); }

/* ═══ KPI Cards ═══ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-light);
  border: 1px solid var(--border); text-align: center;
}
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--navy); }
.kpi-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-card.highlight { border-color: var(--primary); background: linear-gradient(135deg, var(--accent-soft), var(--bg-card)); }
.kpi-card.highlight .kpi-value { color: var(--primary-hover); }

/* ═══ Badges & Tags ═══ */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: 10px;
  background: var(--badge-bg); color: var(--badge-text);
  vertical-align: middle;
}
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-grey { background: var(--bg-subtle); color: var(--text-muted); }
.badge-warning { background: var(--warning-bg); color: hsl(29, 97%, 40%); }
.tag {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.6875rem; font-weight: 600; line-height: 1;
  vertical-align: middle;
}
.tag-blue   { background: var(--info-bg); color: var(--info); }
.tag-green  { background: var(--success-bg); color: var(--success); }
.tag-orange { background: var(--warning-bg); color: hsl(29, 97%, 40%); }
.tag-purple { background: hsla(270, 60%, 50%, 0.08); color: hsl(270, 60%, 45%); }
.tag-red    { background: var(--danger-bg); color: var(--danger); }
.tag-grey   { background: var(--bg-subtle); color: var(--text-muted); }

.role-badge {
  display: inline-block; font-size: 0.6875rem; font-weight: 500;
  padding: 2px 10px; border-radius: 10px;
}
.role-badge.owner { background: hsla(270, 60%, 50%, 0.08); color: hsl(270, 60%, 45%); }
.role-badge.qualified { background: var(--success-bg); color: var(--success); }
.role-badge.pending { background: var(--warning-bg); color: hsl(29, 97%, 40%); }
.role-badge.rejected { background: var(--danger-bg); color: var(--danger); }
.members-badge { font-size: 0.625rem; background: var(--danger); color: #fff; padding: 1px 6px; border-radius: 8px; margin-left: 4px; }
.live-orders-count { font-size: 0.625rem; background: var(--primary); color: #fff; padding: 1px 6px; border-radius: 8px; margin-left: 4px; }

/* Status pills — semantic state colours */
.status {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.6875rem; font-weight: 600; line-height: 1;
  vertical-align: middle;
}
.status-active,
.status-delivered,
.status-open,
.status-live       { background: var(--success-bg); color: var(--success); }
.status-partial,
.status-monitoring,
.status-pending    { background: var(--warning-bg); color: hsl(29, 97%, 40%); }
.status-contracted,
.status-matched    { background: var(--info-bg); color: var(--info); }
.status-qualified  { background: hsla(270, 60%, 50%, 0.08); color: hsl(270, 60%, 45%); }
.status-cancelled,
.status-closed,
.status-rejected   { background: var(--bg-subtle); color: var(--text-muted); }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  font-size: 0.6875rem; color: var(--text-muted); line-height: 1;
  vertical-align: middle;
}

/* ═══ Tables ═══ */
.table-wrap {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-light);
}
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
th {
  text-align: left; padding: 10px 16px; font-weight: 500;
  font-size: 0.6875rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); background: var(--bg-subtle);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }
table tr { cursor: pointer; transition: background var(--transition-simple); }

/* ═══ Detail Grid + Detail Row ═══ */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-light);
}
.detail-card .detail-label { font-size: 0.6875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; font-weight: 500; }
.detail-card .detail-value { font-size: 1rem; font-weight: 500; color: var(--navy); }

.detail-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--border-light); font-size: 0.8125rem; gap: 16px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .detail-label { color: var(--text-muted); }
.detail-row .detail-value { font-weight: 500; color: var(--text); text-align: right; word-break: break-word; }

/* ═══ Builder ═══ */
.builder-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.builder-topbar-left { display: flex; align-items: center; gap: 12px; }
.builder-topbar-right { display: flex; align-items: center; gap: 8px; }

/* No overflow:hidden here — it clips absolutely-positioned children like
   autofill dropdowns inside the section body. The border-radius is still
   respected on the header (which has its own bottom-border) and the body. */
.builder-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 16px;
  box-shadow: var(--shadow-light);
}
.builder-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light); cursor: pointer; user-select: none;
}
.builder-section-header h3 { font-size: 0.875rem; font-weight: 500; display: flex; align-items: center; gap: 8px; color: var(--navy); margin: 0; }
.builder-section-header .chevron { transition: transform var(--transition-simple); color: var(--text-muted); font-size: 0.75rem; }
.builder-section.collapsed .builder-section-body { display: none; }
.builder-section.collapsed .chevron { transform: rotate(-90deg); }
.builder-section-body { padding: 16px 20px; }

.builder-footer { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ═══ Mode Toggle ═══ */
.mode-toggle {
  display: inline-flex; background: var(--bg-subtle);
  border-radius: 8px; border: 1px solid var(--border); overflow: hidden; padding: 2px;
}
.mode-toggle button {
  font-family: var(--font); font-size: 0.75rem; font-weight: 500;
  padding: 5px 14px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; transition: all var(--transition-simple);
  border-radius: 6px;
}
.mode-toggle button.active { background: var(--primary); color: #fff; }

/* ═══ GSP Layout / Map containers ═══ */
.gsp-layout { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.map-container { width: 100%; height: 360px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.map-container.tall { height: 520px; }
.gsp-info { display: flex; flex-direction: column; gap: 12px; }
.gsp-detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
.gsp-detail-row:last-child { border-bottom: none; }
.gsp-detail-label { color: var(--text-muted); }
.gsp-detail-value { font-weight: 500; color: var(--navy); }

/* ═══ Drag Chart ═══ */
.drag-chart-wrap { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.drag-chart-wrap canvas { width: 100%; height: 300px; display: block; cursor: crosshair; }

/* ═══ Chart Controls ═══ */
.chart-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.batch-input { display: flex; align-items: center; gap: 8px; }
.batch-input label { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.batch-input input[type="number"] { width: 70px; padding: 5px 10px; }
.quick-prices { display: flex; flex-wrap: wrap; gap: 4px; }

/* ═══ Slider ═══ */
.slider-row { display: flex; align-items: center; gap: 16px; }
.slider-row input[type="range"] { flex: 1; -webkit-appearance: none; height: 6px; border-radius: 3px; background: var(--bg-subtle); outline: none; border: 1px solid var(--border); padding: 0; }
.slider-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); cursor: pointer; border: 2px solid #fff; box-shadow: var(--shadow); }
.slider-value { font-size: 1.25rem; font-weight: 700; color: var(--primary); min-width: 50px; }
.performance-layout { max-width: 600px; }

/* ═══ JSON Editor ═══ */
.json-editor {
  width: 100%; min-height: 320px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', ui-monospace, monospace;
  font-size: 0.8125rem; line-height: 1.5; padding: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-subtle); color: var(--text);
  resize: vertical; tab-size: 2;
}

/* ═══ Form Inputs ═══ */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 0.6875rem; font-weight: 500;
  color: var(--text-muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.help-text, .form-help { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 12px; }
.form-help { margin-top: 4px; margin-bottom: 0; }
input, select, textarea {
  font-family: var(--font); font-size: 0.8125rem; font-weight: 400;
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg); color: var(--text);
  transition: border-color var(--transition-simple); outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px hsla(176, 70%, 48%, 0.15);
}
input[type="checkbox"], input[type="radio"] { width: auto; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.checkbox-grid label {
  display: flex; align-items: center; gap: 8px; font-size: 0.8125rem;
  font-weight: 400; text-transform: none; letter-spacing: 0; cursor: pointer;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 0; transition: all 0.15s; color: var(--text);
}
.checkbox-grid label:hover { border-color: var(--primary); }
.checkbox-grid label.checked { border-color: var(--primary); background: var(--accent-soft); }
.checkbox-grid input[type="checkbox"] { width: auto; margin: 0; }

/* Filters bar */
.filters {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px;
  padding: 16px; background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-light); border: 1px solid var(--border); align-items: end;
}
.filters .form-group { margin-bottom: 0; min-width: 160px; }

/* ═══ Merit Order ═══ */
.merit-controls { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.merit-control-group { display: flex; align-items: center; gap: 8px; }
.merit-control-group label { font-size: 0.6875rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.gsp-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.gsp-tab {
  font-family: var(--font); font-size: 0.6875rem; font-weight: 500;
  padding: 4px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition-simple);
}
.gsp-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.gsp-tab:hover:not(.active) { border-color: var(--primary); }

/* ═══ Period Bar (compact strip) ═══ */
.period-bar { display: flex; flex-wrap: wrap; gap: 3px; margin: 12px 0; }
.period-slot {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 0.625rem; font-weight: 500; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-muted); cursor: pointer; transition: all var(--transition-simple);
}
.period-slot:hover { border-color: var(--primary); color: var(--text); }
.period-slot.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.period-slot.dispatched { background: hsla(270, 60%, 50%, 0.08); color: hsl(270, 60%, 45%); border-color: hsl(270, 60%, 65%); }

/* ═══ Period Picker (grid) — uses PicloUI.renderPeriodPicker ═══ */
.period-picker-grid {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px;
}
.period-pick {
  padding: 8px 4px; font-size: 0.6875rem; text-align: center;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer; user-select: none; transition: all .12s;
  color: var(--text-muted);
}
.period-pick:hover { border-color: var(--primary); color: var(--text); }
.period-pick.selected { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* ═══ Direction Toggle (buy / sell, up / down) ═══ */
.direction-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.direction-toggle button {
  flex: 1; background: transparent; border: none; padding: 8px 12px;
  color: var(--text-secondary); cursor: pointer; font-size: 0.8125rem;
  border-right: 1px solid var(--border);
}
.direction-toggle button:last-child { border-right: none; }
.direction-toggle button.active { background: var(--primary); color: #fff; }

/* ═══ Grid Layouts ═══ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.grid-auto-sm { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

/* ═══ Hero (page-level intro banner) ═══ */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff; padding: 56px 32px; border-radius: var(--radius-lg);
  margin-bottom: 32px;
}
.hero h1 { font-size: 2rem; font-weight: 700; margin-bottom: 10px; }
.hero p { font-size: 1.0625rem; color: hsla(0,0%,100%,0.75); max-width: 720px; line-height: 1.5; }
.hero .tag { margin-right: 6px; margin-top: 12px; }

/* ═══ Empty State ═══ */
.empty-state, .empty {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
}
.empty-state p, .empty p { font-size: 0.9375rem; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 1rem; font-weight: 500; }
.empty-state.flat, .empty.flat { background: transparent; border: none; padding: 48px 20px; }

/* ═══ Toast ═══ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--navy); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 400;
  box-shadow: var(--shadow-lg); z-index: 9999;
  opacity: 0; transform: translateY(20px);
  transition: all 0.25s ease;
  pointer-events: none; max-width: 360px;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 4px solid var(--primary); }
.toast.error   { border-left: 4px solid var(--danger); }

/* ═══ Order Card Mini ═══ */
.order-card-mini {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px;
  font-size: 0.8125rem; box-shadow: var(--shadow-light);
}

/* ═══ Modal ═══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: hsla(205, 67%, 24%, 0.45); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 50px 16px; overflow-y: auto;
}
.modal-overlay.active { display: flex; }
/* .modal does NOT cap its own height or set overflow — the surrounding
   .modal-overlay handles scrolling. Capping here would clip absolutely-
   positioned children (e.g. autofill dropdowns) inside .modal-body. */
.modal {
  background: var(--bg); border-radius: var(--radius-lg);
  width: 100%; max-width: 800px;
  box-shadow: 0 8px 32px hsla(0, 0%, 0%, 0.15);
  display: flex; flex-direction: column;
  margin-bottom: 60px;
}
.modal.wide { max-width: 1080px; }
.modal-header, .modal-head {  /* support both class names */
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.modal-header h2, .modal-header h3,
.modal-head h2, .modal-head h3 {
  font-size: 1rem; font-weight: 500; color: var(--navy); margin: 0;
}
.modal-close {
  font-size: 1.5rem; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
/* Modal body must NOT clip absolutely-positioned children (e.g. autofill
   dropdowns). The outer .modal-overlay handles overall scrolling, and
   .modal itself caps height + scrolls when needed. */
.modal-body { padding: 20px; overflow: visible; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ═══ Collapsible Sections (for schema display) ═══ */
details { margin-bottom: 8px; }
details summary {
  font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; padding: 6px 0;
}
details summary:hover { color: var(--primary); }
details pre {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-top: 6px;
  font-size: 0.75rem; overflow-x: auto; color: var(--text-secondary);
}

/* ═══ Sell-side layout (carried-over pattern) ═══ */
.sell-layout { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.sticky-panel { position: sticky; top: 96px; }
.cta-panel {
  background: linear-gradient(135deg, var(--navy), var(--navy-dark));
  color: #fff; border-radius: var(--radius-lg); padding: 24px;
}
.cta-panel h3 { color: var(--primary); margin-bottom: 8px; }
.cta-panel p { color: hsla(0,0%,100%,0.7); font-size: 0.875rem; margin-bottom: 16px; }
.cta-panel .form-group label { color: hsla(0,0%,100%,0.8); }
.cta-panel .form-group input,
.cta-panel .form-group textarea,
.cta-panel .form-group select {
  background: hsla(0,0%,100%,0.1); border-color: hsla(0,0%,100%,0.2); color: #fff;
}
.cta-panel .form-group input::placeholder { color: hsla(0,0%,100%,0.4); }

/* ═══ Mapbox Overrides ═══ */
.mapboxgl-ctrl-group { background: var(--bg) !important; border-radius: var(--radius) !important; box-shadow: var(--shadow) !important; }
.mapboxgl-ctrl-group button { background-color: transparent !important; border-color: var(--border) !important; }

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══ Utilities ═══ */
.text-muted { color: var(--text-dim); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.6875rem; }
.text-right { text-align: right; }
.mono { font-family: 'SF Mono', 'Fira Code', ui-monospace, Menlo, Monaco, monospace; font-size: 0.75rem; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-gap-8  { gap: 8px; }
.flex-gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { justify-content: space-between; }
.flex-center  { align-items: center; }

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .gsp-layout { grid-template-columns: 1fr; }
  .market-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .sell-layout { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .builder-topbar { flex-direction: column; align-items: flex-start; }
  .chart-controls { flex-direction: column; align-items: flex-start; }
  .period-picker-grid { grid-template-columns: repeat(8, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════════════
   Ex-Flex Market — extended patterns (live in the design system because
   they're reusable across any surface that exposes ex-flex / firmness /
   forecast-timeline UI)
   ═══════════════════════════════════════════════════════════════════════ */

/* Position-freeze explainer / callout */
.exflex-callout {
  background: linear-gradient(135deg, rgba(37,196,181,0.08), rgba(37,196,181,0.02));
  border: 1px solid rgba(37,196,181,0.3);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 0.875rem;
  color: var(--text);
}
.exflex-callout strong { color: var(--primary); display: block; margin-bottom: 4px; font-size: 0.875rem; }
.exflex-callout p { margin: 4px 0; color: var(--text-secondary); line-height: 1.5; }

/* Activation timeline banner */
.activation-timeline {
  display: flex; align-items: center; gap: 0;
  margin: 16px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.activation-timeline-track {
  flex: 1; height: 6px; background: var(--border-light); border-radius: 3px;
  position: relative; margin: 28px 12px;
}
.activation-timeline-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  background: linear-gradient(90deg, rgba(37,196,181,0.2), var(--primary));
  border-radius: 3px;
}
.activation-tick {
  position: absolute; top: -22px; transform: translateX(-50%);
  font-size: 0.6875rem; color: var(--text-muted); white-space: nowrap;
}
.activation-tick::after {
  content: ''; position: absolute; left: 50%; top: 18px;
  width: 1px; height: 8px; background: var(--text-muted);
}
.activation-label {
  font-size: 0.75rem; color: var(--text-secondary); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Stat grid */
.exflex-stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin: 16px 0;
}
.exflex-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.exflex-stat-label { font-size: 0.6875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; font-weight: 500; }
.exflex-stat-value { font-size: 1.4rem; font-weight: 600; color: var(--navy); }
.exflex-stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Forecast timeline canvas wrap */
.forecast-timeline-wrap {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-top: 12px;
}
.forecast-timeline-canvas { width: 100%; height: 420px; display: block; }

/* Firmness matrix canvas wrap */
.firmness-matrix-wrap {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-top: 12px;
}
.firmness-matrix-canvas { width: 100%; height: 460px; display: block; }

/* Legend rows */
.exflex-legend {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-top: 10px; font-size: 0.75rem; color: var(--text-secondary);
}
.exflex-legend-item { display: flex; align-items: center; gap: 6px; }
.exflex-legend-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Ex-Flex order form */
.exflex-form {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
}
.exflex-form .form-group.full { grid-column: 1 / -1; }
.exflex-form label { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 4px; display: block; font-weight: 500; }
.exflex-form input, .exflex-form select, .exflex-form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font-size: 0.875rem; box-sizing: border-box;
}
.exflex-form input[type="range"] { padding: 0; }
.exflex-slider-row { display: flex; align-items: center; gap: 10px; }
.exflex-slider-row input[type="range"] { flex: 1; }
.exflex-slider-value { font-weight: 600; color: var(--primary); min-width: 56px; text-align: right; font-size: 0.875rem; }
.exflex-help { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* Effective price live readout */
.effective-price-display {
  background: linear-gradient(135deg, var(--primary), rgba(37,196,181,0.7));
  color: #fff; padding: 14px 18px;
  border-radius: var(--radius);
  margin-top: 16px;
  font-size: 0.875rem;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.effective-price-display .ep-value { font-size: 1.5rem; font-weight: 600; }
.effective-price-display .ep-formula { font-size: 0.75rem; opacity: 0.9; }

/* Position freeze checkbox */
.position-freeze-row {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  margin: 8px 0;
}
.position-freeze-row input[type="checkbox"] { margin-top: 3px; }
.position-freeze-row .pf-text { font-size: 0.8125rem; color: var(--text); }
.position-freeze-row .pf-text strong { color: var(--primary); }

/* Merit-order Ex-Flex enhancements */
.merit-clear-controls {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; padding: 12px; margin-bottom: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.merit-clear-price {
  font-size: 0.875rem; color: var(--text-secondary);
}
.merit-clear-price strong { color: var(--primary); font-size: 1rem; }

/* Firmness pill */
.firmness-pill {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: 0.7rem; font-weight: 500;
  background: var(--bg-subtle); color: var(--text-secondary);
}
.firmness-pill.firm { background: rgba(46,204,113,0.15); color: #2ecc71; }
.firmness-pill.medium { background: rgba(241,196,15,0.15); color: #f39c12; }
.firmness-pill.non-firm { background: rgba(231,76,60,0.15); color: #e74c3c; }

@media (max-width: 700px) {
  .exflex-form { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Value-stacking revenue cards (Fluvius-style; generic enough to live
   in the design system — any surface explaining stacked revenue streams
   can reuse these)
   ═══════════════════════════════════════════════════════════════════════ */
.revenue-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.revenue-card {
  background: var(--bg-card); border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow-light); border-left: 4px solid var(--border);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
/* Stream colour accents — semantic for energy value-stack */
.revenue-card.tso       { border-left-color: hsl(255, 70%, 60%); }   /* TSO indigo */
.revenue-card.dso       { border-left-color: var(--primary); }       /* DSO turquoise */
.revenue-card.wholesale { border-left-color: hsl(40, 96%, 60%); }    /* Wholesale amber */
.revenue-card.btm       { border-left-color: hsl(14, 70%, 60%); }    /* BTM coral */
.revenue-card .stream-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.revenue-card .stream-label {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-dim);
}
.revenue-card .stream-value { font-size: 1.375rem; font-weight: 700; color: var(--navy); }
.revenue-card .stream-item {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 0.8125rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}
.revenue-card .stream-item:last-child { border-bottom: none; }
.revenue-card .stream-item .item-value { font-weight: 600; color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════
   Catalogue: Schema Builder
   Used to compose JSON-Schema-style field lists for components, contracts,
   and other configurable blueprints.
   ═══════════════════════════════════════════════════════════════════════ */
.schema-builder { display: flex; flex-direction: column; gap: 12px; }
.schema-builder .field-list { display: flex; flex-direction: column; gap: 10px; }
.schema-builder .field-empty {
  padding: 24px; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius); font-size: 0.875rem;
}
.field-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; transition: var(--transition-simple);
}
.field-card:hover { border-color: var(--primary); }
.field-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.field-card-header .field-name { font-weight: 500; color: var(--navy); font-size: 0.9375rem; }
.field-card-header .field-type-badge {
  font-size: 0.6875rem; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-subtle); color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600;
}
.field-card-header .field-controls { display: flex; gap: 4px; }
.field-card-header .field-controls button {
  border: none; background: transparent; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; color: var(--text-muted); font-size: 0.875rem;
}
.field-card-header .field-controls button:hover { background: var(--bg-subtle); color: var(--text); }
.field-card-header .field-controls .danger:hover { background: var(--danger-bg); color: var(--danger); }
.field-card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: 0.75rem; color: var(--text-muted); }
.field-card-meta .req { color: var(--danger); font-weight: 600; }
.field-card-options {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-light);
  display: none;
}
.field-card.expanded .field-card-options { display: block; }
.field-card-options .form-row { margin-bottom: 8px; }
.add-field-btn {
  align-self: flex-start; padding: 10px 16px; border: 1px dashed var(--border);
  background: transparent; color: var(--text-muted); border-radius: var(--radius);
  cursor: pointer; font-size: 0.875rem; font-weight: 500;
  transition: var(--transition-simple);
}
.add-field-btn:hover { border-color: var(--primary); color: var(--primary); border-style: solid; }
.field-type-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px;
}
.field-type-picker button {
  padding: 12px; border: 1px solid var(--border); background: var(--bg-card);
  border-radius: var(--radius); cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  transition: var(--transition-simple);
}
.field-type-picker button:hover { border-color: var(--primary); background: var(--bg-subtle); }
.field-type-picker .ft-name { font-size: 0.875rem; font-weight: 500; color: var(--navy); }
.field-type-picker .ft-desc { font-size: 0.75rem; color: var(--text-muted); }

.schema-preview {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; min-height: 100px;
}
.schema-preview .builder-section { background: var(--bg-card); margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   Catalogue: Workflow Builder
   Horizontal flow of connected nodes for state-machine-style components
   (qualification, clearing, settlement, dispatch).
   ═══════════════════════════════════════════════════════════════════════ */
.workflow-canvas {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; overflow-x: auto;
}
.workflow-row {
  display: flex; align-items: center; gap: 12px; min-height: 100px;
  flex-wrap: nowrap;
}
.workflow-node {
  flex: 0 0 auto; min-width: 160px; max-width: 220px;
  background: var(--bg-card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; position: relative;
  transition: var(--transition-simple);
}
.workflow-node:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.workflow-node.active { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.workflow-node.trigger { border-color: hsl(176, 70%, 48%); background: var(--accent-soft); }
.workflow-node.terminal { border-color: var(--success); background: var(--success-bg); }
.workflow-node.branch {
  border-color: hsl(40, 96%, 60%); background: hsl(40, 96%, 96%);
  border-radius: 50%; min-width: 80px; max-width: 100px; height: 80px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 0.75rem; padding: 6px;
}
.workflow-node-title {
  font-size: 0.875rem; font-weight: 500; color: var(--navy); margin-bottom: 4px;
}
.workflow-node-type {
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 6px;
}
.workflow-node-desc {
  font-size: 0.75rem; color: var(--text-muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.workflow-node-delete {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px; border-radius: 50%; border: none;
  background: var(--danger); color: #fff; font-size: 0.75rem; cursor: pointer;
  display: none; align-items: center; justify-content: center; line-height: 1;
}
.workflow-node:hover .workflow-node-delete { display: flex; }
.workflow-arrow {
  flex: 0 0 auto; width: 36px; height: 2px; background: var(--border);
  position: relative;
}
.workflow-arrow::after {
  content: ''; position: absolute; right: -1px; top: -4px;
  border-left: 8px solid var(--border); border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.add-step-btn {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  border: 1px dashed var(--border); background: var(--bg-card); cursor: pointer;
  color: var(--text-muted); font-size: 0.875rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition-simple);
}
.add-step-btn:hover { border-color: var(--primary); color: var(--primary); border-style: solid; }
.workflow-branch-group {
  display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
}

/* ═══════════════════════════════════════════════════════════════════════
   Catalogue: Autofill / search input
   ═══════════════════════════════════════════════════════════════════════ */
.autofill { position: relative; }
.autofill-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--font); font-size: 0.875rem;
}
.autofill-input:focus { outline: none; border-color: var(--primary); }
.autofill-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 5000;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 250px; overflow-y: auto; display: none;
}
.autofill-dropdown.open { display: block; }
.autofill-option {
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}
.autofill-option:last-child { border-bottom: none; }
.autofill-option:hover, .autofill-option.highlight { background: var(--bg-subtle); }
.autofill-option .opt-name { color: var(--navy); font-weight: 500; }
.autofill-option .opt-sub { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }
.autofill-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.autofill-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px;
  background: var(--accent-soft); color: var(--primary-hover); border-radius: 999px;
  font-size: 0.8125rem; font-weight: 500;
}
.autofill-chip button {
  border: none; background: transparent; cursor: pointer; color: inherit;
  font-size: 0.875rem; line-height: 1; padding: 0; opacity: 0.7;
}
.autofill-chip button:hover { opacity: 1; }

/* Catalogue grouping tabs (component type tabs) */
.cat-type-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* Catalogue filter bar — tabs on the left, search input on the right.
   Used on Markets and Products catalogue pages to combine a tab-based
   filter with a free-text search. The .cat-type-tabs inside loses its
   own bottom border so the wrapper owns the underline. */
.cat-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.cat-filter-bar .cat-type-tabs {
  border-bottom: none;
  margin-bottom: 0;
  flex: 1 1 auto;
}
.cat-filter-bar .cat-search {
  flex: 0 0 auto;
  margin-bottom: 6px;
}
.cat-search input[type="search"] {
  width: 260px;
  max-width: 100%;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition-simple);
}
.cat-search input[type="search"]::placeholder { color: var(--text-dim); }
.cat-search input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cat-type-tab {
  padding: 8px 14px; border: none; background: transparent; cursor: pointer;
  font-size: 0.8125rem; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: var(--transition-simple);
}
.cat-type-tab:hover { color: var(--text); }
.cat-type-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.cat-type-tab .count {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  background: var(--bg-subtle); font-size: 0.6875rem; color: var(--text-muted);
}
.cat-type-tab.active .count { background: var(--accent-soft); color: var(--primary-hover); }

/* ─────────────────────────────────────────────────────────────────
   Breadcrumbs — inline text trail at top of page content.
   Not a fixed bar. Sits in the normal flow above .page-head.
   ───────────────────────────────────────────────────────────────── */
.breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep {
  color: var(--border);
  margin: 0 2px;
}
.breadcrumb-section {
  /* Parent section label — not clickable. */
  color: var(--text-secondary);
  font-weight: 400;
  cursor: default;
}
.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
}
.breadcrumb-siblings {
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  display: flex;
  gap: 12px;
}
.breadcrumb-siblings a {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* ─────────────────────────────────────────────────────────────────
   Catalogue section grouping (Your / Default / Library)
   ───────────────────────────────────────────────────────────────── */
.cat-section { margin-bottom: 28px; }
.cat-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cat-section-head h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.cat-section-head .meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ────────────────────────────────────────────────────────────
   Component scope tag (Product vs Market) — small pill shown on
   each component card to indicate whether the component lives
   inside a Product or at the Market level.
   ──────────────────────────────────────────────────────────── */
.comp-scope-tag {
  font-size: 0.625rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
  white-space: nowrap;
}
.comp-scope-tag.product {
  background: hsla(176, 70%, 48%, 0.1);
  color: var(--turquoise-dark);
}
.comp-scope-tag.market {
  background: hsla(270, 60%, 50%, 0.08);
  color: hsl(270, 60%, 45%);
}

/* ────────────────────────────────────────────────────────────
   Component grouping (Product Components vs Market Components)
   — kept for backwards compatibility; the Components page no
   longer uses these groupings (tabs only). Other callers may
   still rely on the styles.
   ──────────────────────────────────────────────────────────── */
.comp-group { margin-bottom: 24px; }
.comp-group-head {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.comp-group-head h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px 0;
}
.comp-group-head p {
  margin: 0;
  font-size: 0.8125rem;
}

/* ────────────────────────────────────────────────────────────
   Chat / messaging panel — used by member messaging modals on
   market detail pages. Bubble layout with system / incoming /
   outgoing variants and a sticky input row at the bottom.
   ──────────────────────────────────────────────────────────── */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chat-msg { max-width: 80%; }
.chat-msg.system {
  align-self: center;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 6px 12px;
  border-radius: var(--radius);
}
.chat-msg.incoming { align-self: flex-start; }
.chat-msg.outgoing { align-self: flex-end; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.chat-msg.incoming .chat-bubble {
  background: var(--bg-subtle);
  color: var(--text);
}
.chat-msg.outgoing .chat-bubble {
  background: var(--primary);
  color: #fff;
}
.chat-sender {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.chat-time {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.chat-input-row input { flex: 1; }

/* Compact icon button for member rows (chat / email icons) */
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--primary);
  border-color: var(--primary);
}

/* Notifications / activity panel for market dashboard */
.activity-list {
  display: flex;
  flex-direction: column;
}
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 12px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-subtle); margin: 0 -12px; padding: 12px; border-radius: var(--radius); border-bottom-color: transparent; }
.activity-item .a-text { font-size: 0.875rem; color: var(--text); line-height: 1.4; }
.activity-item .a-time { font-size: 0.6875rem; color: var(--text-muted); white-space: nowrap; }

/* Pending filter button group on Members tab */
.filter-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.filter-tab {
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-light);
}
.filter-tab .badge { margin-left: 4px; }
