:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657089;
  --line: #dce3ef;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --danger: #b42318;
  --ok: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sidebar {
  padding: 24px;
  background: #0f172a;
  color: white;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  font-weight: 800;
}

.brand small {
  display: block;
  color: #aeb9d0;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #d8e1f4;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

main {
  padding: 28px;
  display: grid;
  gap: 20px;
}

.topbar,
.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
}

h1,
h2,
p {
  margin-top: 0;
}

p,
small,
.card span {
  color: var(--muted);
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid.cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.history-item strong {
  font-size: 14px;
}

.history-item time {
  color: var(--muted);
  white-space: nowrap;
}

.history-item p {
  margin: 0;
  color: var(--text);
}

.history-details {
  margin-top: 10px;
}

.history-details pre {
  margin: 8px 0 0;
  font-size: 12px;
  overflow: auto;
}

.history-actions {
  margin-top: 8px;
}

.topbar .active-switcher {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.topbar .active-switcher select {
  min-width: 220px;
}

.health-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

#activeProfileHealth.health-ok {
  color: #6ee7a0;
}

#activeProfileHealth.health-warn {
  color: #fbbf24;
}

.health-inline pre {
  margin-top: 12px;
  font-size: 12px;
}

.history-empty {
  color: var(--muted);
}

.card {
  padding: 18px;
}

.card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  padding: 22px;
}

.panel-header {
  margin-bottom: 16px;
}

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

.inline-form {
  display: grid;
  gap: 10px;
  align-content: start;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.profile-list {
  display: grid;
  gap: 12px;
}

.profile {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.profile-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

pre {
  overflow: auto;
  background: #0b1020;
  color: #dce7ff;
  padding: 16px;
  border-radius: 14px;
  min-height: 80px;
}

.status {
  min-height: 20px;
}

.ok {
  color: var(--ok);
}

.error {
  color: var(--danger);
}

.setup-wizard.hidden,
.setup-nav.hidden,
.setup-panel.hidden,
.setup-field.hidden,
.setup-secret.hidden,
.hidden {
  display: none;
}

.setup-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0 0 20px;
  list-style: none;
}

.setup-steps li {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.setup-steps li.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.setup-steps li.done {
  color: var(--ok);
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.setup-panels label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.setup-secret {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  white-space: pre-wrap;
  word-break: break-all;
}

.setup-default-org {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}

.setup-or {
  margin: 0.75rem 0;
  color: rgba(15, 23, 42, 0.55);
  font-size: 0.9rem;
}

#setupHealthResult.health-ok {
  background: #ecfdf5;
  border-color: #86efac;
}

#setupHealthResult.health-warn {
  background: #fff7ed;
  border-color: #fdba74;
}

@media (max-width: 1000px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

.profile-field {
  display: grid;
  gap: 6px;
}

.profile-field.hidden {
  display: none;
}

.history-artifact {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.history-screenshot {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.history-warning {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.policies-table table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 0.92rem;
}

.policies-table th,
.policies-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.usage-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.usage-breakdown-grid ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.audit-table table,
.billing-alerts table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.billing-limits table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.billing-limits th,
.billing-limits td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

.audit-table th,
.audit-table td,
.billing-alerts th,
.billing-alerts td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.audit-table td small,
.billing-alerts td small {
  color: var(--muted);
}

.principal-edit-form {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.principal-edit-form.hidden {
  display: none;
}

.nav-hidden {
  display: none !important;
}

.panel-hidden {
  display: none !important;
}
