/* Global customer search in the topbar */
.global-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border-strong, #d2d0ce);
  border-radius: 999px; padding: 4px 12px; margin-left: 12px;
  min-width: 260px;
}
.global-search:focus-within { border-color: var(--color-primary, #0078d4); box-shadow: 0 0 0 1px var(--color-primary, #0078d4); }
.global-search-icon { font-size: 13px; opacity: .7; }
.global-search input {
  border: 0; outline: 0; background: transparent; font-size: 13px;
  color: var(--color-text); width: 100%; min-width: 0;
}
.search-source-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.search-score-bar {
  display: inline-block; height: 6px; border-radius: 3px;
  background: var(--color-primary, #0078d4); vertical-align: middle;
}

/* Sidebar version indicator (bottom of the nav) */
.sidebar-version {
  display: block; width: calc(100% - 16px); margin: 6px 8px 8px;
  padding: 5px 10px; border: 0; border-radius: var(--radius-md, 4px);
  background: transparent; color: var(--color-text-subtle, #8a8886);
  font: inherit; font-size: 11.5px; text-align: left; cursor: pointer;
}
.sidebar-version:hover { background: var(--color-surface-alt, #f3f2f1); color: var(--color-text); }

/* Version-history modal list */
.version-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.version-entry { border-left: 2px solid var(--color-border, #edebe9); padding-left: 12px; }
.version-entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.version-entry-num { font-weight: 700; font-size: 13px; color: var(--color-text); }
.version-entry-current {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px;
  background: var(--color-success-soft, #dff6dd); color: var(--color-success, #107c10);
}
.version-entry-summary { font-size: 13px; line-height: 1.5; color: var(--color-text-muted, #605e5c); }

/* Region chips — shared between Data Center pages and Maxio pages.
   Lifted out of per-template <style> so the Maxio common JS can render them
   anywhere they're injected. */
.dc-chip {
  font: inherit; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--color-border, #edebe9); background: transparent;
  color: var(--color-text, #201f1e); cursor: pointer; font-size: 12.5px;
  line-height: 1.4; transition: background 80ms, color 80ms, border-color 80ms;
}
.dc-chip:hover { background: var(--color-surface-alt, #f3f2f1); }
.dc-chip-active {
  background: var(--color-text, #201f1e);
  color: var(--color-bg, #faf9f8);
  border-color: var(--color-text, #201f1e);
}

/* "saved" badge next to blank-to-keep secret fields (token / password / API key) */
.saved-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 2px 8px; border-radius: 999px;
  background: var(--color-success-soft, #dff6dd);
  color: var(--color-success, #107c10);
  border: 1px solid var(--color-success, #107c10);
  vertical-align: middle;
}

/* Read-only reminder banner (top of every page) */
.readonly-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
  background: #fff4ce;            /* warn-soft */
  color: #6b5d18;                 /* darker amber for legibility */
  border-bottom: 1px solid #d8b945;
  font-size: 12.5px; line-height: 1.4;
}
.readonly-banner strong { color: #4a3f10; font-weight: 600; }
.readonly-banner-icon { font-size: 13px; }
.readonly-banner-detail { color: #6b5d18; }
.readonly-banner-detail em { font-style: normal; font-weight: 600; }

/* Fluent-inspired design tokens */
:root {
  --color-bg: #faf9f8;
  --color-surface: #ffffff;
  --color-surface-alt: #f3f2f1;
  --color-border: #edebe9;
  --color-border-strong: #d2d0ce;
  --color-text: #201f1e;
  --color-text-muted: #605e5c;
  --color-text-subtle: #8a8886;
  --color-primary: #0078d4;
  --color-primary-hover: #106ebe;
  --color-primary-pressed: #005a9e;
  --color-primary-soft: #deecf9;
  --color-danger: #a4262c;
  --color-danger-soft: #fde7e9;
  --color-success: #107c10;
  --color-success-soft: #dff6dd;
  --color-warn: #797673;
  --color-warn-soft: #fff4ce;
  --shadow-1: 0 1.6px 3.6px rgba(0,0,0,.08), 0 .3px .9px rgba(0,0,0,.06);
  --shadow-2: 0 6.4px 14.4px rgba(0,0,0,.10), 0 1.2px 3.6px rgba(0,0,0,.07);
  --shadow-modal: 0 25.6px 57.6px rgba(0,0,0,.18), 0 4.8px 14.4px rgba(0,0,0,.16);
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --topbar-height: 48px;
  --sidebar-width: 220px;
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
/* HTML `hidden` attribute must always win — any component class that sets
   display: flex/grid/inline-* would otherwise override the browser default. */
[hidden] { display: none !important; }
/* Tag pills — used in the List view for Type / Category / Partner cells */
.tag {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 4px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 18px;
  background: var(--color-surface-alt, #f3f2f1);
  color: var(--color-text, #201f1e);
  border: 1px solid var(--color-border, #edebe9);
  white-space: nowrap;
}
/* Sidebar section label (e.g. "Admin") */
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--color-text-subtle, #8a8886); padding: 10px 16px 4px; margin-top: 4px;
  border-top: 1px solid var(--color-border, #edebe9);
}

/* Sidebar sub-nav (List page BP quick-filters) */
.nav-subnav { display: flex; flex-direction: column; margin: 0 8px 8px 28px; }
.nav-sub-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 10px; border-radius: 4px;
  color: var(--color-text-muted, #605e5c);
  font-size: 12.5px; text-decoration: none;
}
.nav-sub-item:hover { background: var(--color-surface-alt, #f3f2f1); color: var(--color-text); }
.nav-sub-active { background: var(--color-primary-soft, #deecf9); color: #004578; }
.nav-sub-active:hover { background: var(--color-primary-soft, #deecf9); color: #004578; }
.nav-sub-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-sub-count { color: var(--color-text-subtle, #8a8886); font-size: 11px; flex-shrink: 0; }
.nav-sub-more { color: var(--color-primary, #0078d4); font-style: italic; }

/* Click-to-filter chips (Subscriptions BP + Owner) */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  background: var(--color-surface-alt, #f3f2f1);
  color: var(--color-text);
  border: 1px solid var(--color-border, #edebe9);
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s ease, color .1s ease, border-color .1s ease;
}
.chip:hover { border-color: var(--color-primary, #0078d4); }
.chip-active {
  background: var(--color-primary, #0078d4);
  color: #fff;
  border-color: var(--color-primary, #0078d4);
}
.chip-active:hover { background: var(--color-primary-hover, #106ebe); border-color: var(--color-primary-hover, #106ebe); }

.tag-type { background: var(--color-primary-soft, #deecf9); color: #004578; border-color: #c7e0f4; }
.tag-category { background: #fff4ce; color: #7e6900; border-color: #f6e8a0; }
.tag-partner { background: #e1f5e1; color: #0b6a0b; border-color: #c3e6c3; }

/* Opportunity row expansion (List view triangle) */
.opp-toggle {
  background: transparent; border: 0; cursor: pointer; padding: 2px 4px;
  font-size: 11px; color: var(--color-text-muted, #605e5c);
  line-height: 1; border-radius: 2px;
}
.opp-toggle:hover { background: var(--color-surface-alt, #f3f2f1); color: var(--color-text); }
.opp-toggle[aria-expanded="true"] { color: var(--color-primary); }
.opp-subrow > td { border-top: 0; }
.opp-table { width: 100%; }
.opp-table th, .opp-table td { padding: 6px 10px; }
/* Opportunity Status pill colors */
.opp-status-progress  { background: #deecf9; color: #004578; border-color: #c7e0f4; }
.opp-status-won       { background: #dff6dd; color: #0b6a0b; border-color: #c3e6c3; }
.opp-status-lost      { background: #fde7e9; color: #a4262c; border-color: #f3c6cb; }
.opp-status-suspended { background: #f3f2f1; color: #605e5c; border-color: #d2d0ce; }
.opp-status-abandoned { background: #f3f2f1; color: #797673; border-color: #d2d0ce; }

/* Activity spinner — used in the List view's progress modal */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--color-border-strong, #d2d0ce);
  border-top-color: var(--color-primary, #0078d4);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}
@keyframes spinner-rotate { to { transform: rotate(360deg); } }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
  font-size: 12.5px;
}

/* ===== Top bar ===== */
.app-topbar {
  height: var(--topbar-height);
  background: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-1);
}
.topbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 15px; letter-spacing: .2px;
  min-width: var(--sidebar-width);
}
.brand-mark {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, #ffffff 0%, #cfe4f7 100%);
  -webkit-mask: radial-gradient(circle at 50% 35%, #000 8px, transparent 9px) center/100% 100% no-repeat,
                radial-gradient(circle at 30% 70%, #000 4px, transparent 5px) center/100% 100% no-repeat,
                radial-gradient(circle at 70% 70%, #000 4px, transparent 5px) center/100% 100% no-repeat;
          mask:  radial-gradient(circle at 50% 35%, #000 8px, transparent 9px) center/100% 100% no-repeat,
                radial-gradient(circle at 30% 70%, #000 4px, transparent 5px) center/100% 100% no-repeat,
                radial-gradient(circle at 70% 70%, #000 4px, transparent 5px) center/100% 100% no-repeat;
  border-radius: 50%;
  background-color: #ffffff;
}
.brand-suffix { opacity: .8; font-weight: 400; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-actions { display: flex; align-items: center; gap: 12px; min-width: var(--sidebar-width); justify-content: flex-end; }
.topbar-link { color: rgba(255,255,255,.92); font-size: 13px; }
.topbar-link:hover { color: #fff; text-decoration: underline; }
.user-pill {
  font-size: 12px; padding: 4px 10px;
  background: rgba(255,255,255,.15); border-radius: 12px; color: #fff;
}

/* ===== Environment selector ===== */
.env-selector { position: relative; }
.env-button {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  padding: 6px 12px; border-radius: var(--radius-md);
  font-family: var(--font-family); font-size: 13px; cursor: pointer;
  min-width: 280px; height: 32px;
}
.env-button:hover { background: rgba(255,255,255,.20); }
.env-label { opacity: .75; }
.env-current { font-weight: 600; flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-caret { opacity: .8; }
.env-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  min-width: 320px; padding: 4px; z-index: 60;
}
.env-menu-list { max-height: 280px; overflow-y: auto; }
.env-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; gap: 8px;
}
.env-menu-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.env-menu-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-menu-meta { font-size: 11px; color: var(--color-text-subtle); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-menu-item:hover { background: var(--color-surface-alt); }
.env-menu-item.selected { background: var(--color-primary-soft); }
.env-menu-item .env-edit,
.env-menu-item .env-delete {
  background: transparent; border: 0; color: var(--color-text-subtle);
  cursor: pointer; padding: 2px 6px; border-radius: var(--radius-sm); font-size: 12px;
}
.env-menu-item .env-edit:hover   { background: var(--color-primary-soft); color: var(--color-primary); }
.env-menu-item .env-delete:hover { background: var(--color-danger-soft); color: var(--color-danger); }
.env-menu-empty { padding: 10px; color: var(--color-text-subtle); font-size: 13px; }
.env-menu-divider { height: 1px; background: var(--color-border); margin: 4px 0; }
.env-menu-add {
  width: 100%; text-align: left;
  background: transparent; border: 0;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-family: var(--font-family); font-size: 13px;
  color: var(--color-primary); cursor: pointer;
}
.env-menu-add:hover { background: var(--color-primary-soft); }

/* ===== Shell ===== */
.app-shell { display: flex; min-height: calc(100vh - var(--topbar-height)); }
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: var(--topbar-height); align-self: flex-start;
  height: calc(100vh - var(--topbar-height));
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--color-text); font-size: 14px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--color-surface-alt); text-decoration: none; }
.nav-item.active {
  background: var(--color-primary-soft);
  border-left-color: var(--color-primary);
  font-weight: 600;
}
.nav-icon { width: 18px; text-align: center; opacity: .8; }
.nav-spacer { flex: 1; }
.app-main {
  flex: 1; padding: 24px 32px;
  max-width: 100%; min-width: 0;
}

/* ===== Page header ===== */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.2px; }
.page-subtitle { color: var(--color-text-muted); margin: 0; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; }

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  margin-bottom: 20px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--color-border);
}
.card-header h2 { font-size: 16px; font-weight: 600; margin: 0; }
.card-body { padding: 18px; }
.card-subhead { font-size: 14px; font-weight: 600; margin: 0 0 12px; }

/* ===== Metric grid ===== */
.metric-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 20px;
}
.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
  display: flex; flex-direction: column;
}
.metric-label { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .4px; }
.metric-value { font-size: 28px; font-weight: 600; color: var(--color-text); margin-top: 4px; line-height: 1.1; }
.metric-suffix { font-size: 12px; color: var(--color-text-subtle); margin-top: 2px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; min-height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-family); font-size: 13.5px;
  cursor: pointer; transition: background .1s ease, border-color .1s ease;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--color-primary); color: #ffffff;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--color-primary-pressed); }
.btn-secondary {
  background: var(--color-surface); color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-alt); }
.btn-link {
  background: transparent; border: 0; color: var(--color-primary);
  padding: 4px 6px; min-height: 0;
}
.btn-link:hover:not(:disabled) { text-decoration: underline; }
.btn-link.btn-danger { color: var(--color-danger); }
.btn-block { width: 100%; }
.btn-icon { font-size: 14px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.field-hint { font-size: 12px; color: var(--color-text-muted); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline span { font-size: 13px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], textarea, select {
  font-family: var(--font-family); font-size: 13.5px;
  padding: 7px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  outline: none; transition: border-color .1s ease, box-shadow .1s ease;
  width: 100%;
}
textarea { resize: vertical; font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}
.form-grid { display: grid; gap: 12px; max-width: 560px; }
.field-row {
  display: grid; gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 0;
}
.field-row .field { margin-bottom: 12px; }
.field-locked,
.field-locked:focus {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  box-shadow: none;
  cursor: not-allowed;
}
.field-locked + .field-hint::before {
  content: '🔒 ';
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.inline-form { display: inline; }

/* ===== Flash ===== */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-md);
  font-size: 13px; border: 1px solid transparent;
}
.flash-success { background: var(--color-success-soft); color: var(--color-success); border-color: #b6e3b6; }
.flash-error   { background: var(--color-danger-soft);  color: var(--color-danger);  border-color: #f5c6cb; }
.flash-info    { background: var(--color-primary-soft); color: var(--color-primary); border-color: #b8d8f1; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th, .data-table td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.data-table th {
  font-weight: 600; font-size: 12px; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .3px;
  background: var(--color-surface-alt);
  position: sticky; top: 0;
}
.data-table tbody tr:hover { background: rgba(0,120,212,.04); }
.data-table tbody tr.empty-row td {
  text-align: center; color: var(--color-text-subtle); padding: 24px;
}
.data-table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.data-table .col-narrow { width: 1%; white-space: nowrap; }

/* ===== Misc ===== */
.muted { color: var(--color-text-muted); font-size: 13px; }
.small { font-size: 12px; }
.divider { border: 0; border-top: 1px solid var(--color-border); margin: 18px 0; }
.badge {
  display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600;
  border-radius: 10px; background: var(--color-surface-alt); color: var(--color-text-muted);
  vertical-align: middle;
}
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warn    { background: var(--color-warn-soft);    color: #8a6d00; }
.badge-danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }
.log-detail h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--color-text-muted); margin: 10px 0 4px; }
.log-detail pre {
  background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 10px; max-height: 320px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
}
details summary { cursor: pointer; color: var(--color-primary); font-size: 12.5px; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.32); backdrop-filter: blur(2px);
}
.modal-card {
  position: relative; background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 480px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  animation: modal-in .12s ease-out;
}
.modal-card-wide { width: 720px; }
/* env-modal is unusually wide — three connector columns + action row.
   max-width fills nearly the whole viewport on big screens, but caps at
   1200px so very-wide monitors don't stretch it beyond a comfortable read. */
.modal-card-xwide { width: 1200px; max-width: calc(100vw - 32px); }
.env-form-columns {
  display: grid;
  /* Maxio block holds two sub-blocks — give it 2 minmax shares. */
  grid-template-columns:
    minmax(280px, 1fr)
    minmax(260px, 1fr)
    minmax(560px, 2fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1024px) {
  /* Stack on narrower screens — each column reverts to full width. */
  .env-form-columns { grid-template-columns: 1fr; }
}
.env-form-columns fieldset { margin: 0; }
.env-form-columns .field { margin-bottom: 10px; }
.env-form-columns .field:last-child { margin-bottom: 0; }
.env-form-columns legend {
  font-size: 12px; font-weight: 700; color: var(--color-text);
  padding: 0 6px; letter-spacing: .03em;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--color-border);
}
.modal-header h2 { font-size: 16px; margin: 0; font-weight: 600; }
.modal-close {
  background: transparent; border: 0; font-size: 22px; line-height: 1;
  color: var(--color-text-muted); cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--color-surface-alt); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-error {
  padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--color-danger-soft); color: var(--color-danger);
  border: 1px solid #f5c6cb; font-size: 13px; margin-top: 8px;
}

/* ===== List view extras ===== */
.list-card .card-header { gap: 12px; flex-wrap: wrap; }
.update-fields {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.update-fields .field { margin: 0; }
.payload-preview { margin-top: 14px; }
.payload-preview pre {
  background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 10px;
  max-height: 220px; overflow: auto; font-size: 12px;
}

/* ===== MCP page ===== */
.security-box {
  background: #fff8e1;
  border: 1px solid #f7d774;
  border-left: 4px solid #d39e00;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-1);
}
.security-box h2 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
.security-box ul { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.security-box li { margin-bottom: 4px; }
.security-box code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 2px; }

.copy-box {
  display: flex; gap: 8px; align-items: stretch;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.copy-box code { flex: 1; word-break: break-all; font-size: 12.5px; align-self: center; }
.code-snippet {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
  white-space: pre-wrap;
  margin: 8px 0;
}
.connect-block { padding: 12px 4px 4px; }
.connect-block .field { margin-bottom: 10px; }

.revealed-token-card { border-color: var(--color-primary); }
.revealed-token-card .card-header { background: var(--color-primary-soft); border-bottom-color: var(--color-primary); }

.outbox-row {
  border: 1px solid var(--color-border);
  border-left: 4px solid #d39e00;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fffdf6;
}
.outbox-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.outbox-summary { font-size: 14px; margin: 6px 0 8px; }
.outbox-row pre {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 11.5px;
  overflow: auto;
  max-height: 260px;
}
.outbox-actions { display: flex; gap: 8px; margin-top: 10px; }

.row-revoked td { opacity: .55; }
.big-url-callout {
  background: var(--color-primary-soft);
  border: 1px solid #b8d8f1;
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.big-url-label { font-weight: 600; color: var(--color-text); margin-bottom: 8px; font-size: 14px; }
.big-url-row {
  display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px;
  background: #fff; border: 1px solid #b8d8f1; border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.big-url-row code {
  flex: 1; font-size: 15px; font-weight: 600; color: var(--color-primary-pressed);
  word-break: break-all; align-self: center; user-select: all;
}
.big-url-hint { line-height: 1.5; }

.warn-box {
  background: var(--color-warn-soft);
  border: 1px solid #f7d774;
  border-left: 4px solid #d39e00;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.warn-box code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 2px; }

.example-list { margin: 0; padding-left: 22px; line-height: 1.65; font-size: 13.5px; }

.rate-buttons {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 6px 0 14px;
}
.rate-limit-control {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  height: 36px;
}
.rate-limit-control .field-label { font-size: 12px; font-weight: 600; margin: 0; }
.rate-limit-control input { width: 84px; height: 24px; padding: 2px 6px; text-align: right; }
.rate-limit-control .field-hint { font-size: 12px; color: var(--color-text-muted); }
.progress-row {
  display: flex; gap: 12px; align-items: center; margin-top: 4px;
}
.progress-row progress {
  flex: 1; height: 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); overflow: hidden;
}
.progress-row progress::-webkit-progress-bar { background: var(--color-surface-alt); }
.progress-row progress::-webkit-progress-value {
  background: var(--color-primary); transition: width .15s ease;
}
.progress-row progress::-moz-progress-bar { background: var(--color-primary); }
.example-list li { margin-bottom: 6px; }

/* ===== Auth ===== */
.auth-body {
  min-height: 100vh; margin: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e3edf7 0%, #faf9f8 70%);
  padding: 24px;
}
.auth-card {
  width: 380px; max-width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 32px 28px;
}
.auth-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}
.auth-brand h1 {
  margin: 0; font-size: 20px; font-weight: 600;
}
.auth-subtitle { margin: 0 0 18px; color: var(--color-text-muted); font-size: 13px; }
.auth-form .field { margin-bottom: 14px; }
.auth-form .btn { margin-top: 4px; }
