:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-2: #f6f9fc;
  --border: #d4deea;
  --text: #10233f;
  --muted: #62748d;
  --radius: 14px;
  --shadow: 0 12px 35px rgba(31, 52, 82, 0.08);
  --good: #0f9f69;
  --warn: #bc7410;
  --bad: #cc3d4a;
  --accent: #7c3aed;
  --accent-soft: #f0eafe;
}

html { background: var(--bg); }

body {
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.22);
  outline-offset: 2px;
}

.page {
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0 0 32px;
}

header.cp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.cp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
}

.cp-brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

header h1 {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.cp-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.cp-product-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn,
.logout-btn,
.btn,
.btn-outline,
.btn-danger {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: none;
  box-shadow: none;
}

.nav-btn,
.logout-btn,
.btn-outline {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
}

.nav-btn:hover,
.logout-btn:hover,
.btn-outline:hover { background: var(--panel-2); }

.btn {
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.btn:hover { transform: none; filter: brightness(0.97); }

.btn-danger {
  color: #ffffff;
  background: var(--bad);
  border: 1px solid var(--bad);
}

.btn:disabled,
.btn-outline:disabled,
.btn-danger:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.cp-header-session {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 4px;
}

.cp-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(145deg, var(--accent), #2563eb);
  font-size: 0.7rem;
  font-weight: 800;
}

.user-info {
  align-items: flex-start;
  gap: 1px;
  color: var(--text);
  font-size: 0.75rem;
}

.user-email-line { color: var(--muted); font-size: 0.68rem; }

.user-role-pill {
  margin: 2px 0 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

.cp-token-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--good);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.cp-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.cp-tab {
  position: relative;
  min-height: 51px;
  padding: 0 15px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.cp-tab.active { color: var(--text); }

.cp-tab.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

#cp-no-access-banner {
  max-width: 1600px;
  margin: 18px auto 0;
  padding: 0 24px;
}

#cp-no-access-banner .inner {
  color: #8b1d2c;
  background: #fff1f2;
  border-color: #fecdd3;
}

.cp-layout {
  display: block;
  max-width: 1600px;
  margin: 0 auto;
  padding: 22px 24px 0;
}

.cp-layout > aside { display: none; }

.cp-layout > main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  margin: 0;
  padding: 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.card + .card { margin-top: 0; }

#section-session {
  padding: 0;
  background: transparent;
  border: 0;
}

#section-system,
#section-users,
#section-raw { padding: 20px; }

.section-title {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.section-subtitle {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

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

.cp-page-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.45rem;
  letter-spacing: -0.025em;
}

.cp-page-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.cp-metric {
  min-width: 0;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cp-metric-label { color: var(--muted); font-size: 0.7rem; }

.cp-metric-value {
  overflow: hidden;
  margin-top: 6px;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-metric-context {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.cp-metric-context.good { color: var(--good); }

.cp-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: 14px;
}

.cp-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -18px -18px 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.cp-panel-head .section-subtitle { margin-bottom: 0; }

.cp-detail-list { display: grid; gap: 0; }

.cp-detail-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 45px;
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
}

.cp-detail-line:last-child { border-bottom: 0; }
.cp-detail-line span:first-child { color: var(--muted); }
.cp-detail-line strong { text-align: right; }

.cp-status-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.cp-status-card:last-child { border-bottom: 0; }

.cp-status-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  color: var(--good);
  background: #e9f8f2;
  font-size: 0.9rem;
  font-weight: 800;
}

.cp-status-icon.warn { color: var(--warn); background: #fff7e8; }
.cp-status-copy { min-width: 0; flex: 1; }
.cp-status-copy strong { display: block; font-size: 0.76rem; }
.cp-status-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.68rem; line-height: 1.35; }

.cp-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.pill {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}

.pill-dot { background: #94a3b8; }

.field-label {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.055em;
}

.field-group { margin-bottom: 12px; }

input,
select,
textarea {
  min-height: 42px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.78rem;
}

input[type="checkbox"] { min-height: auto; accent-color: var(--accent); }

textarea { min-height: 90px; }

.status-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.74rem;
}

.status-line.ok { color: var(--good); }
.status-line.error { color: var(--bad); }
.status-line.warn { color: var(--warn); }

.users-table {
  margin-top: 10px;
  color: var(--text);
  font-size: 0.74rem;
}

.users-table th,
.users-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
}

.users-table th {
  color: var(--muted);
  background: var(--panel-2);
  font-size: 0.65rem;
  letter-spacing: 0.045em;
}

.users-table tr:hover { background: #fafbff; }

.badge {
  min-height: 23px;
  padding: 0 8px;
  border: 0;
  font-size: 0.62rem;
  font-weight: 800;
}

.badge.green { color: #08764d; background: #e8f8f1; border: 0; }
.badge.red { color: #a32936; background: #fff0f1; border: 0; }

.user-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 14px;
  background: var(--panel-2);
  border-radius: 11px;
}

.user-detail-label,
.label-row-small { color: var(--muted); }
.user-detail-value { color: var(--text); }

#user-access-editor {
  border-color: #d8c7ff !important;
  background: #fbf9ff;
}

.raw-json {
  color: #dbeafe;
  background: #102039;
  border-color: #273d59;
  border-radius: 10px;
}

hr { border-top-color: var(--border) !important; }

@media (max-width: 1100px) {
  .cp-product-links { order: 3; width: 100%; }
  .cp-header-right { max-width: 65%; }
  .cp-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  header.cp-topbar { align-items: flex-start; }
  .cp-header-right { max-width: 58%; }
  .cp-overview-grid { grid-template-columns: 1fr; }
  .user-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  header.cp-topbar { display: block; padding: 15px; }
  .cp-header-right { justify-content: flex-start; max-width: none; margin-top: 14px; }
  .cp-product-links { justify-content: flex-start; }
  .cp-tabs { padding: 0 6px; }
  .cp-layout { padding: 15px 12px 0; }
  .cp-page-heading { align-items: flex-start; }
  .cp-metrics { gap: 8px; }
  .cp-metric { padding: 12px; }
  .cp-metric-value { font-size: 1.1rem; }
  .card { padding: 14px; }
  .cp-panel-head { margin: -14px -14px 14px; padding: 13px 14px; }
}
/* Ecosystem checkbox standard: control left, statement in its own column. */
.cp-check-group {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.cp-check-group-inline {
  grid-template-columns: repeat(auto-fit, minmax(78px, max-content));
  column-gap: 18px;
}

.cp-check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  column-gap: 12px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}

.cp-check-group .cp-check-row { margin: 0; }
.cp-check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
}
