:root {
  color-scheme: light dark;
  --canvas: #f1f3ef;
  --surface: #fbfcfa;
  --surface-muted: #e8ece8;
  --surface-strong: #dce3dd;
  --text: #17201b;
  --text-muted: #5f6d65;
  --border: #cdd6cf;
  --accent: #176b4d;
  --accent-hover: #10583e;
  --accent-soft: #dceee6;
  --danger: #a33d3d;
  --warning: #8a5a00;
  --focus: #27785b;
  --sidebar: #17201b;
  --sidebar-text: #e9eee9;
  --sidebar-muted: #a8b5ac;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #121713;
    --surface: #1a211c;
    --surface-muted: #222b25;
    --surface-strong: #2b362f;
    --text: #edf2ed;
    --text-muted: #a7b3aa;
    --border: #344239;
    --accent: #62b88f;
    --accent-hover: #7bc99f;
    --accent-soft: #203c30;
    --danger: #e08080;
    --warning: #e2ad4d;
    --focus: #8ad3ad;
    --sidebar: #0c110e;
  }
}

* { box-sizing: border-box; }
html { font-family: var(--sans); background: var(--canvas); color: var(--text); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button, .button, input, textarea, select { min-height: 44px; }
code, pre { font-family: var(--mono); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: var(--sidebar-text); padding: 24px 18px; display: flex; flex-direction: column; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 720; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #6ea98b; color: #94d1b2; font-family: var(--mono); font-size: 15px; }
.nav-list { margin-top: 52px; display: grid; gap: 4px; }
.nav-list a { padding: 11px 12px; border-radius: 6px; color: var(--sidebar-muted); text-decoration: none; font-size: 14px; }
.nav-list a:hover, .nav-list a:focus-visible { background: rgba(255,255,255,.07); color: var(--sidebar-text); }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,.12); display: grid; gap: 5px; font-size: 13px; }
.sidebar .eyebrow { color: var(--sidebar-muted); }
.sidebar .text-button { padding-left: 0; color: var(--sidebar-muted); }
.main { width: min(1180px, 100%); padding: 48px clamp(24px, 5vw, 72px) 80px; }

.page-header { display: flex; justify-content: space-between; gap: 32px; align-items: end; margin-bottom: 30px; }
.page-header h1 { margin: 3px 0 7px; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.045em; }
.eyebrow { display: block; margin: 0 0 7px; color: var(--text-muted); font-family: var(--mono); font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; }
.lede { max-width: 680px; margin: 0; color: var(--text-muted); font-size: 15px; line-height: 1.55; }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--text-muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--accent); }
.status-block { display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #27986a; box-shadow: 0 0 0 4px rgba(39,152,106,.12); }
.status-dot.large { width: 10px; height: 10px; }

.panel { margin: 0 0 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.compact-panel { padding-bottom: 22px; }
.panel-heading { min-height: 82px; padding: 20px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.panel-heading h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.018em; }
.panel-heading p { margin: 0; color: var(--text-muted); font-size: 13px; }
.count-badge { padding: 4px 8px; background: var(--surface-muted); border-radius: 6px; color: var(--text-muted); font: 12px var(--mono); }

.project-list { display: grid; }
.project-row { min-height: 92px; padding: 18px 22px; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(180px, 1fr) minmax(320px, 1fr) 24px; align-items: center; gap: 24px; text-decoration: none; }
.project-row:first-child { border-top: 0; }
.project-row:hover { background: var(--surface-muted); }
.project-row strong { display: block; margin-bottom: 5px; }
.project-row code { color: var(--text-muted); font-size: 12px; }
.row-metrics { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); }
.row-metrics div { border-left: 1px solid var(--border); padding-left: 18px; }
.row-metrics dt { color: var(--text-muted); font-size: 11px; }
.row-metrics dd { margin: 5px 0 0; font: 16px var(--mono); }
.row-arrow { color: var(--text-muted); font-size: 20px; }

.environment-nav { display: flex; gap: 6px; margin: -12px 0 20px; overflow-x: auto; }
.environment-nav a { flex: none; padding: 9px 12px; border: 1px solid transparent; border-radius: 6px; color: var(--text-muted); text-decoration: none; font-size: 13px; }
.environment-nav a span { margin-left: 5px; font: 11px var(--mono); opacity: .7; }
.environment-nav a.current { border-color: var(--border); background: var(--surface); color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--text-muted); font-size: 11px; font-weight: 650; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
th, td { height: 58px; padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-muted) 55%, transparent); }
.secret-key { color: var(--text); font-weight: 650; }
.masked { color: var(--text-muted); letter-spacing: .13em; }
.actions { text-align: right; }
.actions form { display: inline; }
.actor-type { display: block; color: var(--text-muted); font-size: 10px; text-transform: uppercase; }
.result { font-weight: 650; text-transform: capitalize; }
.result.success { color: var(--accent); }
.result.denied, .result.failure { color: var(--danger); }

.form-grid, .secret-form { padding: 20px 22px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 16px; align-items: start; }
.identity-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; border-top: 1px solid var(--border); padding-bottom: 2px; }
.oidc-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.secret-form { grid-template-columns: minmax(180px,.6fr) minmax(280px,1.4fr) auto; }
label { display: grid; gap: 7px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 6px; background: var(--canvas); color: var(--text); padding: 10px 12px; outline: none; }
textarea { resize: vertical; min-height: 86px; font-family: var(--mono); font-size: 13px; }
input:focus, textarea:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent); }
.grow { min-width: 0; }
.align-end { align-self: end; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; padding: 9px 14px; background: transparent; color: var(--text); cursor: pointer; font-weight: 650; text-decoration: none; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); }
.button.quiet { min-height: 34px; padding: 6px 10px; border-color: var(--border); color: var(--text-muted); font-size: 12px; }
.button.danger { color: var(--danger); }
.button.text-button { justify-content: start; min-height: 30px; font-size: 12px; }
.button.wide { width: 100%; }

.empty-state { padding: 52px 24px; text-align: center; color: var(--text-muted); }
.empty-state.small { padding: 24px; }
.empty-state h3 { margin: 8px 0 6px; color: var(--text); }
.empty-state p { margin: 0 auto; max-width: 480px; }
.empty-symbol { font: 22px var(--mono); }
.reveal-panel { padding: 26px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; background: var(--surface); display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.reveal-panel > div { min-width: 0; flex: 1; }
.reveal-panel pre { margin: 8px 0 0; padding: 18px; overflow-wrap: anywhere; white-space: pre-wrap; border-radius: 6px; background: var(--canvas); font-size: 14px; }
.reveal-panel pre.remasked { color: var(--text-muted); }
.notice { margin-top: 16px; padding: 13px 16px; border-radius: 6px; font-size: 13px; }
.notice.warning { border: 1px solid color-mix(in srgb, var(--warning) 38%, var(--border)); background: color-mix(in srgb, var(--warning) 8%, var(--surface)); color: var(--warning); }
.health-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; }
.fact-list { margin: 0; padding: 6px 22px 16px; }
.fact-list div { min-height: 52px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.fact-list div:last-child { border-bottom: 0; }
.fact-list dt { color: var(--text-muted); font-size: 13px; }
.fact-list dd { margin: 0; font-weight: 650; }
.warning-text { color: var(--warning); }
.error-panel { max-width: 620px; padding: 48px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.error-panel h1 { margin: 4px 0 14px; }
.error-panel p { margin-bottom: 28px; color: var(--text-muted); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 36%), var(--canvas); }
.login-card { width: min(470px,100%); padding: 46px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.login-brand { margin-bottom: 56px; }
.login-card h1 { margin: 6px 0 18px; font-size: clamp(34px, 7vw, 50px); line-height: 1.02; letter-spacing: -.05em; }
.login-card .lede { margin-bottom: 32px; }
.fine-print { margin: 18px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 20px; flex-direction: row; align-items: center; gap: 20px; }
  .nav-list { margin: 0; margin-left: auto; display: flex; }
  .sidebar-foot { display: none; }
  .main { padding-top: 34px; }
  .project-row { grid-template-columns: 1fr minmax(290px,1fr) 20px; }
  .identity-form, .oidc-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 767px) {
  .sidebar { align-items: flex-start; flex-wrap: wrap; }
  .nav-list { order: 2; width: 100%; overflow-x: auto; }
  .nav-list a { flex: none; }
  .main { padding: 30px 16px 64px; }
  .page-header { align-items: start; flex-direction: column; }
  .project-row { grid-template-columns: 1fr 18px; }
  .row-metrics { grid-column: 1/-1; order: 3; }
  .row-metrics div:first-child { border-left: 0; padding-left: 0; }
  .form-grid, .secret-form, .identity-form, .oidc-form, .health-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; }
  tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  td { min-height: 0; height: auto; padding: 4px 0; border: 0; }
  .actions { text-align: left; padding-top: 10px; }
  .reveal-panel { align-items: stretch; flex-direction: column; }
  .login-card { padding: 32px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
