/* ─────────────────────────────────────────────────────────────────────────
   BioMonie Portal — Design System
   Compact, professional, information-dense. Base 13 px.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  /* Surface */
  --bg:          #ebf3f7;
  --surface:     #ffffff;
  --surface-2:   #f3f7f9;
  --surface-3:   #f8fbfc;

  /* Borders */
  --line:        #dde8f0;
  --line-strong: #b9ced9;

  /* Text */
  --text:        #0f1e26;
  --muted:       #5a7a8a;
  --muted-2:     #7893a0;

  /* Public BioMonie brand palette */
  --brand:        #295c72;
  --brand-light:  #e7f0f4;
  --brand-strong: #1a3d4f;
  --brand-dark:   #0f1e26;
  --brand-mid:    #3a7a96;
  --accent:       #f5ff00;
  --accent-2:     #e2ff02;

  /* Semantic */
  --blue:         #2563eb;
  --blue-light:   #eef2ff;
  --amber:        #a96e0f;
  --amber-light:  #fef8e8;
  --red:          #c42519;
  --red-light:    #fff2f1;
  --green:        #18735d;
  --green-light:  #ecfaf6;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 30, 38, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 30, 38, 0.07), 0 1px 2px rgba(15, 30, 38, 0.04);
  --shadow:    0 4px 14px rgba(41, 92, 114, 0.09), 0 1px 3px rgba(15, 30, 38, 0.05);
  --shadow-lg: 0 20px 52px rgba(15, 30, 38, 0.2), 0 4px 12px rgba(41, 92, 114, 0.1);

  /* Geometry */
  --radius:    6px;
  --radius-sm: 4px;
  --sidebar:   216px;

  /* Typography */
  font-family: Sora, ui-sans-serif, system-ui, -apple-system,
               BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html {
  min-height: 100%;
  font-size: 13px;           /* compact, data-rich baseline */
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; }

svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex: 0 0 auto;
}

/* Custom scrollbar */
::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--line-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover{ background: var(--muted-2); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ─── PORTAL SHELL ───────────────────────────────────────────────────────── */

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.portal-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% -10%, rgba(245, 255, 0, 0.07), transparent 28%),
    var(--brand-dark);
  color: #c4d6de;
  border-right: 1px solid rgba(245, 255, 0, 0.1);
  scrollbar-width: none;
}
.portal-sidebar::-webkit-scrollbar { display: none; }

/* ─── BRAND / SIDEBAR HEADER ─────────────────────────────────────────────── */

.brand-block {
  padding: 15px 14px 12px;
  border-bottom: 1px solid rgba(245, 255, 0, 0.1);
}

.brand-mark,
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.brand-logo {
  display: block;
  width: 150px;
  height: 48px;
  object-fit: contain;
  object-position: left center;
}

.brand-mark small {
  margin: -8px 0 0 3px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.avatar {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand-light);
  color: var(--brand-strong);
  font-weight: 800;
  flex: 0 0 auto;
}

.avatar {
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
}

.user-chip strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ddeaf5;
}

.user-chip small {
  display: block;
  color: var(--muted-2);
  font-size: 0.73rem;
  margin-top: 1px;
}

/* ─── SIDE NAV ───────────────────────────────────────────────────────────── */

.side-nav {
  padding: 6px 10px 24px;
}

.nav-group {
  margin-top: 14px;
}

.nav-group h2 {
  margin: 0 6px 4px;
  color: #668392;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.nav-link {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius);
  color: #aac0ca;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background 80ms, color 80ms;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-link.active {
  background: rgba(245, 255, 0, 0.1);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ─── PORTAL MAIN ────────────────────────────────────────────────────────── */

.portal-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────── */

.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar-title span,
.eyebrow {
  display: block;
  color: var(--muted-2);
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.topbar-title strong {
  display: block;
  margin-top: 1px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.global-search {
  width: min(300px, 28vw);
  height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted-2);
  transition: border-color 120ms, background 120ms, box-shadow 120ms;
}

.global-search:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(41, 92, 114, 0.12);
}

.global-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.84rem;
}

.global-search input::placeholder { color: var(--muted-2); }

.user-chip {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px 0 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 80ms, background 80ms, color 80ms;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.mobile-menu { display: none; }

/* ─── CONTENT FRAME ──────────────────────────────────────────────────────── */

.content-frame {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
}

/* ─── PAGE HEADING ───────────────────────────────────────────────────────── */

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-heading h1 {
  margin: 3px 0 5px;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-heading p {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.heading-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */

.button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 80ms, border-color 80ms, color 80ms, box-shadow 80ms;
}

.button.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(41, 92, 114, 0.24);
}
.button.primary:hover {
  background: var(--brand-strong);
  box-shadow: 0 5px 15px rgba(41, 92, 114, 0.25);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.button.secondary:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.button.danger {
  background: var(--red);
  color: #fff;
}
.button.danger:hover { background: #a81f15; }

.button.compact {
  min-height: 26px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.button.wide { width: 100%; }

/* ─── METRIC GRID ────────────────────────────────────────────────────────── */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.metric-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.metric-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
}

.metric-icon:empty::after {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 3px;
  box-shadow: 5px 5px 0 -2px currentColor;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-card strong {
  display: block;
  margin: 3px 0 2px;
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.transaction-metrics {
  gap: 7px;
  margin-bottom: 9px;
}

.transaction-metrics .metric-card {
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.transaction-metrics .metric-icon {
  width: 28px;
  height: 28px;
}

.transaction-metrics .metric-icon svg {
  width: 15px;
  height: 15px;
}

.transaction-metrics .metric-card strong {
  margin: 1px 0;
  font-size: 1.02rem;
}

.transaction-metrics .metric-card span,
.transaction-metrics .metric-card small {
  font-size: 0.72rem;
}

/* Metric / badge tones */
.metric-card.info    .metric-icon, .badge.info    { background: var(--blue-light);  color: var(--blue);  }
.metric-card.success .metric-icon, .badge.success { background: var(--green-light); color: var(--green); }
.metric-card.warning .metric-icon, .badge.warning { background: var(--amber-light); color: var(--amber); }
.metric-card.danger  .metric-icon, .badge.danger  { background: var(--red-light);   color: var(--red);   }

/* ─── DASHBOARD / WORKSPACE GRIDS ────────────────────────────────────────── */

.dashboard-grid,
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.5fr);
  gap: 12px;
  margin-bottom: 12px;
}

/* ─── PANELS ─────────────────────────────────────────────────────────────── */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  margin-bottom: 12px;
}

.compact-panel {
  padding: 10px 16px;
}

.status-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-summary-list .badge {
  text-decoration: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 16px 9px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 2px 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.panel-body {
  padding: 14px 16px;
}

.sub-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.check-field {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.status-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ─── DETAIL GRID ────────────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.detail-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 2px 16px 14px;
}

.detail-list div {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child { border-bottom: 0; }

.detail-list dt {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

/* ─── DECISION FORM ──────────────────────────────────────────────────────── */

.decision-form {
  display: grid;
  gap: 10px;
  padding: 0 16px 14px;
}

/* ─── FILTER GRID ────────────────────────────────────────────────────────── */

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
  padding: 12px 16px;
}

.transaction-query-panel .panel-header {
  padding-top: 10px;
  padding-bottom: 0;
}

.transaction-query-panel .filter-grid {
  gap: 7px;
  padding: 8px 12px 10px;
}

.transaction-requery {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
}

.transaction-requery summary {
  color: var(--brand);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}

.transaction-requery .decision-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  padding: 10px 0 4px;
}

.transaction-requery .detail-list {
  margin-top: 8px;
}

.filter-actions {
  display: flex;
  align-items: end;
  gap: 7px;
  flex-wrap: wrap;
}

/* ─── DATE RANGE FORM ────────────────────────────────────────────────────── */

.date-range-form {
  display: flex;
  align-items: end;
  gap: 7px;
  flex-wrap: wrap;
}

.date-range-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.date-range-form input {
  min-height: 32px;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 9px;
  color: var(--text);
  background: var(--surface);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 120ms;
}

.date-range-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41, 92, 114, 0.12);
}

/* ─── INLINE FIELDS ──────────────────────────────────────────────────────── */

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 7px;
}

/* ─── ROW ACTIONS ────────────────────────────────────────────────────────── */

.row-action { min-width: 180px; }

.row-action summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.84rem;
}

.row-action form {
  display: grid;
  gap: 7px;
  min-width: 220px;
  margin-top: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

/* ─── CODE BLOCK ─────────────────────────────────────────────────────────── */

.code-block {
  min-height: 150px;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--brand-dark);
  color: #d6e6ed;
  font-size: 0.83rem;
  line-height: 1.65;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

/* ─── TABLE ACTIONS ──────────────────────────────────────────────────────── */

.table-actions { text-align: right; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.pager-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-subtitle {
  margin: 14px 0 0;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── SEGMENTED CONTROL ──────────────────────────────────────────────────── */

.segmented-control {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  gap: 1px;
}

.segmented-control button {
  min-width: 38px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 80ms, color 80ms, box-shadow 80ms;
}

.segmented-control button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ─── MINI CHART ─────────────────────────────────────────────────────────── */

.mini-chart {
  display: block;
  width: 100%;
  height: 220px;
  padding: 12px;
}

/* ─── QUEUE LIST ─────────────────────────────────────────────────────────── */

.queue-list { padding: 4px 8px; }

.queue-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: var(--radius);
  transition: background 80ms;
}

.queue-item:hover { background: var(--surface-2); }

.queue-item strong { display: block; font-size: 0.84rem; font-weight: 600; }
.queue-item small  { display: block; color: var(--muted); margin-top: 1px; font-size: 0.78rem; }
.queue-item b      { color: var(--muted); font-size: 0.8rem; font-weight: 600; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  flex: 0 0 auto;
}
.status-dot.warning { background: var(--amber); }
.status-dot.danger  { background: var(--red);   }
.status-dot.success { background: var(--green);  }

/* ─── PHASE BOARD ────────────────────────────────────────────────────────── */

.phase-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  padding: 10px 12px;
}

.phase-board article {
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.phase-index {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-strong);
  font-weight: 800;
  font-size: 0.75rem;
}

.phase-board small,
.note-panel p,
.callout span {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.82rem;
}

.text-link {
  color: var(--brand);
  font-weight: 600;
  font-size: 0.84rem;
}
.text-link:hover { color: var(--brand-strong); }

/* ─── DATA TABLE ─────────────────────────────────────────────────────────── */

.table-shell { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 8px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  white-space: nowrap;
}

.data-table th:first-child { border-radius: 0; }

.table-sort-button,
.sort-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-decoration: none;
  cursor: pointer;
}

.table-sort-button::after {
  content: " ↕";
  opacity: 0.45;
}

.data-table th[aria-sort="ascending"] .table-sort-button::after { content: " ↑"; opacity: 1; }
.data-table th[aria-sort="descending"] .table-sort-button::after { content: " ↓"; opacity: 1; }
.table-sort-button:hover,
.sort-link:hover { color: var(--brand); }

.transaction-table td {
  padding-top: 7px;
  padding-bottom: 7px;
}

.data-table td {
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.875rem;
}

.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr:hover td {
  background: var(--surface-2);
}

.data-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.data-table strong { font-weight: 600; }

.data-table code {
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  border: 1px solid var(--line);
}

/* ─── BADGES ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge.neutral {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ─── NOTE PANEL / CALLOUT ───────────────────────────────────────────────── */

.note-panel { padding-bottom: 14px; }

.note-panel p,
.callout {
  margin: 10px 16px 0;
}

.callout {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid #aad9d2;
  border-radius: var(--radius);
  background: #f0fbf8;
}

.callout strong { font-size: 0.84rem; font-weight: 600; }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(11, 22, 32, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-backdrop[hidden],
[hidden] { display: none !important; }

.modal-card {
  width: min(500px, 100%);
  border-radius: calc(var(--radius) + 1px);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-card.wide-modal {
  width: min(920px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
}

.modal-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.form-grid.single-column {
  grid-template-columns: 1fr;
}

.modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-card h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.modal-card p {
  margin: 0;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.875rem;
}

.modal-actions {
  justify-content: flex-end;
  padding: 0 16px 14px;
}

/* ─── AUTH ───────────────────────────────────────────────────────────────── */

.auth-surface {
  background:
    radial-gradient(circle at 12% 10%, rgba(245, 255, 0, 0.12), transparent 25%),
    linear-gradient(140deg, rgba(41, 92, 114, 0.2), transparent 42%),
    var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.62fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-card.compact {
  grid-template-columns: minmax(0, 1fr);
  width: min(440px, 100%);
}

.auth-visual {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
  padding: 34px;
  background:
    radial-gradient(ellipse 70% 60% at 80% 15%, rgba(245, 255, 0, 0.09), transparent 65%),
    linear-gradient(145deg, #0c1a22 0%, #1a3d4f 52%, #295c72 100%);
  color: #fff;
}

.auth-logo {
  width: min(310px, 84%);
  height: auto;
  margin: 0 0 auto;
}

.auth-visual h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.auth-visual p {
  max-width: 460px;
  margin: 0;
  color: #c0d3dc;
  line-height: 1.6;
  font-size: 0.9rem;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.auth-points span {
  padding: 5px 9px;
  border: 1px solid rgba(245, 255, 0, 0.24);
  border-radius: var(--radius);
  background: rgba(245, 255, 0, 0.08);
  color: #f7ff8c;
  font-size: 0.8rem;
  font-weight: 500;
}

.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 11px;
  padding: 34px;
}

/* ─── INLINE FILTER ──────────────────────────────────────────────────────── */

.inline-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.inline-filter input,
.inline-filter select {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 120ms;
}

.inline-filter input:focus,
.inline-filter select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41, 92, 114, 0.12);
}

.inline-filter input { width: min(260px, 50vw); }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */

.empty-state {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 0.84rem;
}

.empty-state strong {
  color: var(--text);
  font-weight: 600;
}

/* ─── AUTH FORM TYPOGRAPHY ───────────────────────────────────────────────── */

.auth-form h2,
.auth-form h1 {
  margin: 2px 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-form p,
.auth-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.85rem;
}

/* ─── FIELD ──────────────────────────────────────────────────────────────── */

.field {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.84rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
  font-size: 0.875rem;
}

.field textarea {
  width: 100%;
  min-height: 84px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41, 92, 114, 0.12);
}

/* ─── VALIDATION / ALERTS ────────────────────────────────────────────────── */

.validation-message,
.alert.danger { color: var(--red); }

.alert.warning { color: var(--amber); }
.alert.success { color: var(--green); }

.alert {
  padding: 9px 12px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.alert.danger  { border: 1px solid #f2aba2; background: var(--red-light);   }
.alert.warning { border: 1px solid #edcc8c; background: var(--amber-light); }
.alert.success { border: 1px solid #8ed9c8; background: var(--green-light); }

/* ─── UTILITIES ──────────────────────────────────────────────────────────── */

.text-danger { color: var(--red); }
.text-success { color: var(--green); }
.text-warning { color: var(--amber); }
.text-muted   { color: var(--muted); }

.empty-state.inset {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin: 14px 16px;
  padding: 14px;
  background: var(--surface-2);
}

/* ─── DATA FRESHNESS ─────────────────────────────────────────────────────── */

.data-freshness {
  margin: -2px 0 12px;
  color: var(--muted-2);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ─── RESPONSIVE BREAKPOINTS ─────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .metric-grid,
  .phase-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .workspace-grid,
  .detail-grid,
  .filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .portal-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar), 88vw);
    transform: translateX(-100%);
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 60;
  }

  body.sidebar-open .portal-sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.32);
  }

  .mobile-menu { display: inline-grid; }

  .global-search,
  .user-chip { display: none; }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-visual { min-height: 260px; padding: 28px; }
}

@media (max-width: 640px) {
  .content-frame  { padding: 14px; }
  .auth-form      { padding: 24px; }
  .topbar         { padding: 0 14px; }

  .metric-grid,
  .phase-board { grid-template-columns: minmax(0, 1fr); }

  .topbar-title strong { font-size: 0.88rem; }

  .detail-list div {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }
}

/* ─── TABLE WRAP (alias for table-shell) ─────────────────────────────────── */
.table-wrap { overflow-x: auto; }

/* ─── SECTION SUBTITLE (h3 inside panels) ───────────────────────────────── */
.section-subtitle {
  margin: 12px 16px 0;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

/* ─── TABLE FOOTER / PAGER ──────────────────────────────────────────────── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.pager-actions {
  display: flex;
  gap: 5px;
}

/* ─── FILTER BAR ─────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 7px;
  padding: 12px 16px;
}

.filter-bar .field {
  flex: 1;
  min-width: 118px;
  max-width: 200px;
  font-size: 0.78rem;
}

.filter-bar .field.wide { max-width: 260px; }

.filter-bar .field input,
.filter-bar .field select {
  min-height: 32px;
  font-size: 0.84rem;
}

.filter-bar > .button { flex: 0 0 auto; }

.filter-bar > details {
  flex: 0 0 auto;
  align-self: flex-end;
}

.filter-bar > details summary {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: border-color 80ms, color 80ms;
}

.filter-bar > details summary:hover { color: var(--text); border-color: var(--line-strong); }

.filter-bar > details[open] summary { color: var(--text); }

.filter-advanced {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: flex-end;
  padding: 9px 0 0;
}

.filter-advanced .field {
  flex: 1;
  min-width: 150px;
  max-width: 240px;
  font-size: 0.78rem;
}

.filter-advanced .field input { min-height: 32px; font-size: 0.84rem; }

/* When details is open, the summary stretches full-width and the advanced panel sits below the filter row */
.filter-bar > details[open] {
  flex-basis: 100%;
  border-top: 1px solid var(--line);
  padding-top: 9px;
  margin-top: 2px;
}

.filter-bar > details[open] summary {
  margin-bottom: 8px;
}

/* ─── PANEL TABS ─────────────────────────────────────────────────────────── */
.panel-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.panel-tabs::-webkit-scrollbar { display: none; }

.tab-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: color 80ms, border-color 80ms;
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab-button:hover { color: var(--text); }

.tab-button.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-button .badge {
  margin-left: 2px;
  pointer-events: none;
}

/* ─── DATE-RANGE FORM (polished datetime inputs) ─────────────────────────── */
.date-range-form .field-label {
  display: grid;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.date-range-form .field-label input[type="datetime-local"],
.date-range-form .field-label input[type="date"] {
  min-height: 32px;
  min-width: 168px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
  font: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}

.date-range-form .field-label input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41, 92, 114, 0.12);
}

/* Native datetime picker icon tint */
input[type="datetime-local"],
input[type="date"],
input[type="time"] { color-scheme: light; }

input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 0.8; }

/* ─── STAT GRID (transaction breakdown) ─────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.stat-cell {
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.stat-cell:last-child { border-right: 0; }

.stat-cell > span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-cell > strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-cell > small {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-cell.danger > strong  { color: var(--red);   }
.stat-cell.warning > strong { color: var(--amber); }
.stat-cell.success > strong { color: var(--green); }
.stat-cell.info    > strong { color: var(--blue);  }

/* ─── ONBOARDING FUNNEL ─────────────────────────────────────────────────── */
.funnel-list {
  padding: 12px 16px;
  display: grid;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 124px 1fr 50px;
  align-items: center;
  gap: 10px;
}

.funnel-row a {
  display: contents;
}

.funnel-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-bar-track {
  background: var(--surface-2);
  border-radius: 99px;
  height: 7px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--brand);
  min-width: 3px;
}

.funnel-bar.info    { background: var(--blue);  }
.funnel-bar.warning { background: var(--amber); }
.funnel-bar.danger  { background: var(--red);   }
.funnel-bar.success { background: var(--green); }

.funnel-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ─── CHART LEGEND ──────────────────────────────────────────────────────── */
.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px 10px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: 0 0 auto;
  background: var(--brand);
}

.legend-dot.muted { background: var(--line-strong); }

/* ─── BALANCE LIST (accounts summary) ──────────────────────────────────── */
.balance-list { display: grid; }

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
}

.balance-row:last-child { border-bottom: 0; }

.balance-label {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
}

.balance-value {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.balance-value.danger  { color: var(--red);   }
.balance-value.warning { color: var(--amber); }

/* ─── GUIDED SETUP ──────────────────────────────────────────────────────── */
.setup-wizard {
  max-width: 940px;
  margin: 0 auto;
}

.setup-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.setup-step {
  display: grid;
  grid-template-columns: 30px 1fr;
  column-gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: left;
}

.setup-step > span {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-weight: 700;
}

.setup-step strong { color: var(--text); font-size: 0.84rem; }
.setup-step small { margin-top: 2px; font-size: 0.73rem; }
.setup-step.active { border-color: var(--brand); background: var(--brand-light); }
.setup-step.active > span { background: var(--brand); color: #fff; }
.setup-step.complete > span { background: var(--green); color: #fff; }
.setup-step:disabled { cursor: default; opacity: 0.72; }

.setup-panel {
  min-height: 360px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.setup-heading { margin-bottom: 20px; }
.setup-heading h2 { margin: 4px 0 5px; font-size: 1.2rem; }
.setup-heading p,
.disclosure-copy { margin: 0; color: var(--muted); line-height: 1.55; }
.form-grid.comfortable { gap: 18px; }
.field > span em { color: var(--muted-2); font-style: normal; font-weight: 500; }
.field > small { color: var(--muted); font-size: 0.73rem; font-weight: 500; line-height: 1.4; }

.pricing-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0;
  padding: 0;
  border: 0;
}

.pricing-methods legend { margin-bottom: 8px; font-weight: 700; }
.pricing-choice { position: relative; display: block; cursor: pointer; }
.pricing-choice input { position: absolute; opacity: 0; pointer-events: none; }
.pricing-choice > span {
  min-height: 82px;
  display: flex;
  flex-direction: column;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 100ms, background 100ms, box-shadow 100ms;
}
.pricing-choice small { margin-top: 5px; color: var(--muted); font-size: 0.74rem; line-height: 1.4; }
.pricing-choice input:checked + span { border-color: var(--brand); background: var(--brand-light); box-shadow: 0 0 0 2px rgba(41, 92, 114, 0.1); }
.pricing-choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.charge-fields { padding: 15px; border-radius: 8px; background: var(--surface-2); }
.charge-fields > .field { max-width: 320px; }
.band-editor { display: grid; gap: 13px; }
.band-heading strong, .band-heading small { display: block; }
.band-heading small { margin-top: 3px; color: var(--muted); }
.inline-note { padding: 9px 11px; border-radius: var(--radius); background: var(--blue-light); color: var(--brand); font-size: 0.76rem; }

.advanced-disclosure {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.advanced-disclosure summary { padding: 13px 14px; cursor: pointer; color: var(--text); font-weight: 700; }
.advanced-disclosure summary span { color: var(--muted); font-weight: 500; }
.advanced-disclosure[open] summary { border-bottom: 1px solid var(--line); }
.advanced-disclosure .form-grid { padding: 14px; }
.advanced-disclosure .disclosure-copy { padding: 12px 14px 0; font-size: 0.8rem; }

.setup-review {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.setup-review > div { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.setup-review span, .setup-review strong, .setup-review small { display: block; }
.setup-review > div > span { color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.setup-review strong { margin-top: 7px; font-size: 0.92rem; }
.setup-review small { margin-top: 3px; color: var(--muted); }

.approval-note { display: flex; gap: 9px; margin: 16px 0; padding: 11px 13px; border: 1px solid #f1d9a8; border-radius: 8px; background: var(--amber-light); color: var(--amber); }
.approval-note span { color: var(--muted); }
.setup-actions { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 11px 0 2px; background: linear-gradient(transparent, var(--surface) 18%); }
.setup-counter { margin: 0 auto; color: var(--muted); font-size: 0.78rem; font-weight: 600; }

/* ─── COMMISSION WORKSPACE ──────────────────────────────────────────────── */
.commission-workspace { display: grid; gap: 16px; }
.commission-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border: 1px solid #cfe2eb;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--brand-light), var(--surface) 55%, var(--green-light));
}
.commission-hero h2 { margin: 4px 0 6px; }
.commission-hero p, .section-copy { margin: 0; color: var(--muted); line-height: 1.55; }
.commission-hero-stats { display: grid; grid-template-columns: repeat(3, minmax(86px, 1fr)); gap: 8px; }
.commission-hero-stats > div { padding: 11px 13px; border: 1px solid rgba(255,255,255,.9); border-radius: 8px; background: rgba(255,255,255,.78); }
.commission-hero-stats strong, .commission-hero-stats span { display: block; }
.commission-hero-stats strong { font-size: 1.25rem; color: var(--text); }
.commission-hero-stats span { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.commission-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.commission-flow > div { display: grid; grid-template-columns: 30px 1fr; column-gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.commission-flow > div > span { grid-row: span 2; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--brand); color: white; font-weight: 700; }
.commission-flow strong { font-size: .84rem; }
.commission-flow small { margin-top: 2px; color: var(--muted); }
.commission-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 14px; align-items: start; }
.commission-profile-cards, .commission-rule-grid { display: grid; gap: 10px; }
.commission-profile-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.commission-rule-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.commission-profile-card, .commission-rule-card { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.commission-profile-card.active { border-left: 3px solid var(--green); }
.commission-profile-card.inactive { opacity: .82; background: var(--surface-2); }
.commission-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.commission-card-heading strong, .commission-card-heading small { display: block; }
.commission-card-heading small { margin-top: 3px; color: var(--muted); }
.commission-card-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.commission-card-meta > div { min-width: 0; }
.commission-card-meta dt { color: var(--muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.commission-card-meta dd { margin: 4px 0 0; overflow-wrap: anywhere; font-size: .78rem; font-weight: 650; }
.commission-rate { font-size: 1.45rem; font-weight: 750; letter-spacing: -.03em; color: var(--brand-strong); }
.compact-disclosure { margin-top: 0; }
.compact-disclosure .form-grid, .commission-add-rule .form-grid { padding: 14px; }
.commission-rules-panel { display: grid; gap: 12px; }
.commission-add-rule { margin-top: 2px; }
.commission-add-rule .empty-state { margin: 14px; }
.button.danger-outline { border-color: #efc7c3; background: var(--surface); color: var(--red); }
.button.danger-outline:hover { background: var(--red-light); }

.configuration-form { max-width: 820px; margin: 0 auto; }
.configuration-key-preview {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.configuration-key-preview > span { color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.configuration-key-preview code { margin-top: 5px; color: var(--brand-strong); font-size: 0.88rem; font-weight: 700; }
.configuration-key-preview small { margin-top: 3px; color: var(--muted-2); font-size: 0.72rem; }
.secure-input { position: relative; display: flex; }
.field .secure-input input { padding-right: 62px; }
.secure-input button {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  min-width: 50px;
  border: 0;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.secure-input button:hover { background: var(--brand-light); }

@media (max-width: 700px) {
  .setup-progress, .pricing-methods, .setup-review { grid-template-columns: 1fr; }
  .setup-step small { display: none; }
  .setup-panel { min-height: 0; padding: 14px; }
  .commission-hero { align-items: stretch; flex-direction: column; }
  .commission-hero-stats, .commission-flow, .commission-profile-cards, .commission-rule-grid { grid-template-columns: 1fr; }
  .commission-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) and (min-width: 701px) {
  .commission-rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .commission-layout { grid-template-columns: 1fr; }
}

/* ─── METRIC ROW (two metric-grids side by side) ────────────────────────── */
.metric-row {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

/* ─── RESPONSIVE ADDITIONS ──────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .funnel-row { grid-template-columns: 100px 1fr 44px; }
}

@media (max-width: 920px) {
  .filter-bar .field { max-width: none; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel-row { grid-template-columns: 80px 1fr 38px; }
  .filter-bar .field { min-width: 100%; max-width: none; }
}
