:root {
  --c2p-ink: #172033;
  --c2p-muted: #6c778b;
  --c2p-sidebar: #111827;
  --c2p-sidebar-soft: #1f2937;
  --c2p-accent: #4f46e5;
  --c2p-accent-soft: #eef2ff;
  --c2p-bg: #f5f7fb;
  --c2p-border: #e3e8f0;
}

html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--c2p-bg);
  color: var(--c2p-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.btn-primary {
  --bs-btn-bg: var(--c2p-accent);
  --bs-btn-border-color: var(--c2p-accent);
  --bs-btn-hover-bg: #4338ca;
  --bs-btn-hover-border-color: #4338ca;
}

.login-view {
  min-height: 100vh;
  padding: 2rem 1rem;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(79, 70, 229, .2), transparent 30%),
    radial-gradient(circle at 85% 80%, rgba(15, 118, 110, .16), transparent 33%),
    linear-gradient(145deg, #f8fafc, #eef2ff);
}
.login-shell { width: min(100%, 460px); }
.login-card { border-radius: 1.25rem; }
.eyebrow {
  color: var(--c2p-accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-mark-lg { width: 58px; height: 58px; margin: 0 auto 1.25rem; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  z-index: 1030;
  flex-direction: column;
  background: linear-gradient(180deg, var(--c2p-sidebar), #0b1220);
  color: white;
}
.sidebar-brand { display: flex; align-items: center; gap: .85rem; padding: 1.35rem 1.25rem; }
.sidebar-nav { padding: .75rem; overflow-y: auto; }
.nav-section {
  padding: 1.25rem .8rem .5rem;
  color: rgba(255,255,255,.4);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .75rem .85rem;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  border-radius: .75rem;
  margin-bottom: .2rem;
  font-weight: 600;
  transition: .16s ease;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.07); }
.nav-item.active { color: white; background: rgba(99,102,241,.28); }
.nav-symbol { width: 1.35rem; text-align: center; font-size: 1.05rem; }
.sidebar-footer { margin-top: auto; padding: 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.mobile-menu { --bs-offcanvas-width: 285px; background: var(--c2p-sidebar); color: white; }

.main-area { min-height: 100vh; }
@media (min-width: 992px) { .main-area { margin-left: 270px; } }
.topbar {
  height: 70px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--c2p-border);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 1020;
}
.page-content { padding: 1.25rem; }
@media (min-width: 768px) { .page-content { padding: 2rem; } }
.page-header { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; }
.page-title { margin: 0; font-size: clamp(1.5rem, 2.2vw, 2rem); font-weight: 750; letter-spacing: -.03em; }
.page-subtitle { color: var(--c2p-muted); margin: .35rem 0 0; }

.metric-card, .panel-card {
  border: 1px solid var(--c2p-border);
  border-radius: 1rem;
  box-shadow: 0 8px 30px rgba(15,23,42,.045);
}
.metric-card .card-body { padding: 1.25rem; }
.metric-value { font-size: 2rem; font-weight: 750; letter-spacing: -.04em; }
.metric-label { color: var(--c2p-muted); font-size: .85rem; font-weight: 600; }
.metric-chip {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--c2p-accent-soft);
  color: var(--c2p-accent);
  font-weight: 800;
}

.status-notice {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
  border: 1px solid #cfd7ff;
  border-left: 4px solid var(--c2p-accent);
  border-radius: .85rem;
  background: #f8f9ff;
}
.status-notice-badge { flex: 0 0 auto; }
.status-notice-title { font-weight: 700; margin-bottom: .1rem; }
.status-notice-copy { color: #59647a; font-size: .9rem; }

.table-shell { overflow: hidden; }
.table-shell .table { margin-bottom: 0; }
.table-shell thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom-color: var(--c2p-border);
  white-space: nowrap;
}
.table-shell tbody td { vertical-align: middle; border-color: #edf0f5; }
.table-action { white-space: nowrap; text-align: right; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .58rem;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 750;
}
.status-Production { color: #065f46; background: #d1fae5; }
.status-Built { color: #1e40af; background: #dbeafe; }
.status-Demo { color: #92400e; background: #fef3c7; }
.status-Planned { color: #475569; background: #e2e8f0; }
.health-healthy { color: #065f46; background: #d1fae5; }
.health-warning { color: #92400e; background: #fef3c7; }
.health-unknown { color: #475569; background: #e2e8f0; }
.health-error { color: #991b1b; background: #fee2e2; }

.code-text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.empty-state { padding: 3rem 1.5rem; text-align: center; color: var(--c2p-muted); }
.loading-state { min-height: 240px; display: grid; place-items: center; }
.secret-box { background: #111827; color: #e5e7eb; padding: 1rem; border-radius: .8rem; word-break: break-all; }
.form-hint { color: var(--c2p-muted); font-size: .8rem; }

@media (max-width: 767.98px) {
  .page-header { flex-direction: column; }
  .page-header .btn { width: 100%; }
  .table-responsive { border-radius: 1rem; }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody, .mobile-card-table tr, .mobile-card-table td { display: block; width: 100%; }
  .mobile-card-table tr { padding: .85rem 1rem; border-bottom: 1px solid var(--c2p-border); }
  .mobile-card-table td { padding: .25rem 0; border: 0; }
  .mobile-card-table td::before { content: attr(data-label); display: block; color: var(--c2p-muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
  .mobile-card-table .table-action { text-align: left; padding-top: .7rem; }
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem 1.5rem;
}
.detail-label {
  color: var(--c2p-muted);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .07em;
  margin-bottom: .3rem;
  text-transform: uppercase;
}
.json-panel {
  max-height: 320px;
  overflow: auto;
  padding: 1rem;
  margin: 0;
  border-radius: .8rem;
  background: #111827;
  color: #e5e7eb;
  font: .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 575.98px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.text-capitalize { text-transform: capitalize; }

.asset-control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding: 1rem; border: 1px solid var(--c2p-border); border-radius: .85rem; background: #f8fafc; }
.finance-balance { margin-top: .8rem; font-size: clamp(1.15rem, 2.5vw, 1.65rem); font-weight: 800; word-break: break-all; }
.finance-total { font-size: clamp(1.3rem, 3vw, 2rem); font-weight: 850; word-break: break-all; }
@media (max-width: 575.98px) { .asset-control-grid { grid-template-columns: 1fr; } }


.environment-production { color: #065f46; background: #d1fae5; }
.environment-sandbox { color: #7c2d12; background: #ffedd5; }
.sandbox-admin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid #fdba74;
  border-left: 5px solid #ea580c;
  border-radius: .9rem;
  background: #fff7ed;
  color: #9a3412;
}
.sandbox-admin-banner strong { letter-spacing: .08em; }
.sandbox-admin-banner span { color: #7c2d12; font-size: .88rem; }
@media (max-width: 575.98px) { .sandbox-admin-banner { align-items: flex-start; flex-direction: column; } }


/* Release 0009 admin authority control plane */
.authority-owner {
  color: #5b21b6;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
}
.environment-all { color: #334155; background: #e2e8f0; }
.alert-owner {
  border: 1px solid #c4b5fd;
  border-left: 5px solid #7c3aed;
  background: #f5f3ff;
  color: #4c1d95;
}
.access-level {
  display: inline-flex;
  min-width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: .65rem;
  font-size: .75rem;
  font-weight: 850;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #e2e8f0;
  color: #334155;
}
.access-level-0 { background: #f1f5f9; color: #94a3b8; }
.access-level-1, .access-level-2 { background: #dbeafe; color: #1e40af; }
.access-level-3, .access-level-4 { background: #dcfce7; color: #166534; }
.access-level-5, .access-level-6 { background: #fef3c7; color: #92400e; }
.access-level-7, .access-level-8 { background: #fee2e2; color: #991b1b; }
.access-level-9 { background: #ede9fe; color: #5b21b6; }
.access-template-chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .6rem;
  border: 1px solid var(--c2p-border);
  border-radius: .75rem;
  background: #f8fafc;
  font-size: .78rem;
}
.access-capability-group {
  height: 100%;
  padding: 1rem;
  border: 1px solid var(--c2p-border);
  border-radius: .85rem;
  background: #fff;
}
.code-panel {
  max-height: 360px;
  overflow: auto;
  padding: 1rem;
  border-radius: .8rem;
  background: #111827;
  color: #e5e7eb;
  font: .76rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.access-matrix-sticky th:first-child,
.access-matrix-sticky td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
}
@media (max-width: 767.98px) {
  .access-level { min-width: 1.75rem; height: 1.75rem; }
  .access-template-chip { width: 100%; justify-content: space-between; }
}
.access-grant-cell {
  display: grid;
  gap: .35rem;
  min-width: 10.5rem;
}
.access-grant-cell .form-select:last-child {
  font-size: .72rem;
  color: #475569;
  background-color: #f8fafc;
}
.brand-runtime-logo { display:block; max-width:100%; max-height:100%; object-fit:contain; }
.platform-config-grid textarea { min-height: 9rem; }
.config-revision-card { border-left: 4px solid var(--bs-primary); }
.email-status-grid .detail-label { margin-bottom: .25rem; }

details > summary { cursor: pointer; }

/* Release 0047: shared Admin financial environment selector */
.admin-finance-environment {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .35rem .45rem .35rem .75rem;
  border: 1px solid var(--c2p-border);
  border-radius: .8rem;
  background: #f8fafc;
}
.admin-finance-environment-label {
  color: var(--c2p-muted);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.admin-finance-environment .btn {
  min-width: 4.5rem;
  font-weight: 700;
}
@media (max-width: 575.98px) {
  .topbar { padding-inline: .75rem; }
  .admin-finance-environment { padding-left: .4rem; gap: .35rem; }
  .admin-finance-environment-label { display: none; }
  .admin-finance-environment .btn { min-width: 3.9rem; padding-inline: .45rem; }
}
