:root {
  --fa-forest: #5D7770;
  --fa-salmon: #E5826D;
  --fa-cream: #F5EFE6;
  --fa-ink: #1F2A26;
  --fa-line: rgba(43, 43, 43, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: 'Outfit', system-ui, -apple-system, sans-serif; color: var(--fa-ink); background: var(--fa-cream); min-height: 100vh; }
body { display: flex; flex-direction: column; }
header { padding: 16px 32px; border-bottom: 1px solid var(--fa-line); display: flex; align-items: center; gap: 16px; background: white; }
.logo { font-weight: 600; font-size: 18px; color: var(--fa-forest); display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fa-salmon); }
nav { margin-left: auto; display: flex; gap: 16px; align-items: center; font-size: 14px; }
nav a { color: var(--fa-forest); text-decoration: none; }
nav a:hover { text-decoration: underline; }
main { flex: 1; padding: 32px; max-width: 1200px; width: 100%; margin: 0 auto; }
footer { padding: 16px 32px; font-size: 12px; color: var(--fa-forest); opacity: 0.5; text-align: center; }
h1 { font-weight: 600; font-size: 28px; color: var(--fa-forest); margin: 0 0 24px; }
h2 { font-weight: 600; font-size: 18px; color: var(--fa-forest); margin: 24px 0 12px; }
.card { background: white; border: 1px solid var(--fa-line); border-radius: 12px; padding: 20px; margin-bottom: 24px; }
.card.highlight { border-color: var(--fa-salmon); background: rgba(229, 130, 109, 0.05); }
.muted { color: var(--fa-forest); opacity: 0.7; font-size: 13px; }
form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; max-width: 640px; }
form label { font-size: 13px; color: var(--fa-forest); display: block; }
form label input { display: block; width: 100%; margin-top: 4px; padding: 8px 12px; border: 1px solid var(--fa-line); border-radius: 6px; font: inherit; background: white; }
form button { grid-column: span 2; justify-self: start; }
form.filters { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; max-width: none; margin-bottom: 16px; }
form.filters input { padding: 8px 12px; border: 1px solid var(--fa-line); border-radius: 6px; font: inherit; }
button.primary { font: inherit; font-weight: 500; background: var(--fa-forest); color: white; padding: 10px 20px; border: 0; border-radius: 6px; cursor: pointer; }
button.primary:hover { background: #4d6660; }
button.link { font: inherit; background: none; border: 0; color: var(--fa-forest); cursor: pointer; padding: 4px 8px; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: #b73a1f; }
a.link { color: var(--fa-forest); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; background: white; border: 1px solid var(--fa-line); border-radius: 8px; overflow: hidden; }
table.data th, table.data td { padding: 10px 14px; border-bottom: 1px solid var(--fa-line); text-align: left; vertical-align: top; }
table.data th { background: rgba(93, 119, 112, 0.08); color: var(--fa-forest); font-weight: 600; font-size: 13px; }
table.data tr:last-child td { border-bottom: 0; }
code { font-family: 'SF Mono', Consolas, monospace; font-size: 12px; background: rgba(93, 119, 112, 0.08); padding: 2px 6px; border-radius: 3px; }
pre { background: var(--fa-ink); color: white; padding: 16px; border-radius: 8px; overflow: auto; }
pre code { background: transparent; color: white; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge.active { background: rgba(168, 188, 161, 0.3); color: #2d4a35; }
.badge.revoked { background: rgba(229, 130, 109, 0.2); color: #8b2a17; }
.badge.cache { background: rgba(93, 119, 112, 0.15); color: var(--fa-forest); }
.flash { padding: 12px 16px; border-radius: 8px; background: rgba(168, 188, 161, 0.2); color: #2d4a35; margin-bottom: 16px; }

/* Scope checkbox UI on the key-issuance form */
fieldset.scopes { grid-column: span 2; border: 1px solid var(--fa-line); border-radius: 8px; padding: 16px 20px 20px; margin: 4px 0; background: rgba(93, 119, 112, 0.03); }
fieldset.scopes legend { padding: 0 8px; font-size: 13px; font-weight: 600; color: var(--fa-forest); }
.scope-group { margin-bottom: 16px; }
.scope-group:last-child { margin-bottom: 0; }
.scope-group h4 { margin: 8px 0 8px; font-size: 13px; font-weight: 600; color: var(--fa-forest); text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
label.scope-item { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 6px; cursor: pointer; transition: background 0.1s; }
label.scope-item:hover { background: rgba(93, 119, 112, 0.06); }
label.scope-item input[type="checkbox"] { margin-top: 2px; accent-color: var(--fa-forest); }
.scope-label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.scope-label code { font-size: 11px; align-self: flex-start; }
.scope-label strong { color: var(--fa-ink); font-weight: 600; }
.scope-label .muted { font-size: 12px; }
.scope-label .cost { font-size: 11px; color: var(--fa-salmon); font-weight: 500; }
.scope-badge { display: inline-block; padding: 2px 6px; margin: 1px 2px 1px 0; border-radius: 3px; font-family: 'SF Mono', Consolas, monospace; font-size: 11px; background: rgba(93, 119, 112, 0.1); color: var(--fa-forest); }

/* ---------------------------------------------------------------- Playground */

.playground { display: flex; flex-direction: column; gap: 16px; max-width: 1280px; }
.playground main { padding: 0; }
.pg-header h1 { margin-bottom: 4px; }
.pg-header p { margin: 0; }

/* Setup */
.pg-setup-grid { display: grid; grid-template-columns: 2fr 2fr 1.4fr; gap: 16px; align-items: end; }
.pg-setup-grid label { display: block; font-size: 13px; color: var(--fa-forest); }
.pg-setup-grid label input { display: block; width: 100%; margin-top: 4px; padding: 8px 12px; border: 1px solid var(--fa-line); border-radius: 6px; font: inherit; background: white; box-sizing: border-box; }
.pg-setup-actions { display: flex; gap: 12px; align-items: center; }
.pg-setup-hint { margin-top: 12px; }
.pg-status { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,0.06); color: var(--fa-forest); }
.pg-status-ok { background: rgba(168, 188, 161, 0.35); color: #2d4a35; }
.pg-status-warn { background: rgba(229, 130, 109, 0.2); color: #8b2a17; }
.pg-status-err { background: rgba(229, 109, 109, 0.25); color: #8b1717; }
.pg-status-neutral { background: rgba(0,0,0,0.06); color: var(--fa-forest); }

/* Stats strip */
.pg-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.pg-stat { background: white; border: 1px solid var(--fa-line); border-radius: 12px; padding: 14px 16px; text-align: center; }
.pg-stat-value { font-size: 24px; font-weight: 600; color: var(--fa-forest); line-height: 1.1; transition: color 0.3s; }
.pg-stat-value.pg-status-ok { color: #2d6a3a; }
.pg-stat-value.pg-status-warn { color: #b73a1f; }
.pg-stat-value.pg-status-err { color: #8b1717; }
.pg-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fa-forest); opacity: 0.65; margin-top: 4px; }

/* Tabs */
.pg-tabs-card { padding: 0; }
.pg-tabs { display: flex; gap: 4px; padding: 12px 12px 0; border-bottom: 1px solid var(--fa-line); }
.pg-tab { background: transparent; border: 0; padding: 10px 16px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit; font-size: 14px; color: var(--fa-forest); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pg-tab:hover { background: rgba(93, 119, 112, 0.06); }
.pg-tab.is-active { background: rgba(93, 119, 112, 0.08); border-bottom-color: var(--fa-salmon); font-weight: 500; }
.pg-tab-content { padding: 20px; }
.pg-tab-content h3 { margin: 0 0 4px; color: var(--fa-forest); font-size: 16px; }
.pg-tab-content > p { margin: 0 0 16px; }
.pg-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; max-width: none; }
.pg-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--fa-forest); flex: 0 1 auto; min-width: 140px; }
.pg-form input, .pg-form select, .pg-form textarea { padding: 8px 12px; border: 1px solid var(--fa-line); border-radius: 6px; font: inherit; background: white; min-width: 140px; }
.pg-form textarea { font-family: 'SF Mono', Consolas, monospace; font-size: 12px; min-width: 320px; }
.pg-form button.primary { padding: 9px 16px; font-size: 14px; }
.pg-form button.secondary { padding: 9px 12px; font: inherit; font-size: 13px; background: white; border: 1px solid var(--fa-line); border-radius: 6px; cursor: pointer; color: var(--fa-forest); }
.pg-form button.secondary:hover { background: rgba(93, 119, 112, 0.06); }

.pg-subtabs { display: flex; gap: 4px; margin: -8px 0 16px; border-bottom: 1px solid var(--fa-line); }
.pg-subtab { background: transparent; border: 0; padding: 8px 14px; border-radius: 6px 6px 0 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--fa-forest); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pg-subtab.is-active { background: rgba(229, 130, 109, 0.08); border-bottom-color: var(--fa-salmon); font-weight: 500; }

.pg-chips { margin-top: 14px; padding: 10px 12px; background: rgba(168, 188, 161, 0.12); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pg-chip { font: inherit; font-size: 12px; font-family: 'SF Mono', Consolas, monospace; padding: 4px 10px; background: white; border: 1px solid var(--fa-line); border-radius: 999px; cursor: pointer; color: var(--fa-forest); }
.pg-chip:hover { background: var(--fa-forest); color: white; border-color: var(--fa-forest); }

/* Request / response panels */
.pg-io { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pg-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pg-panel-head h3 { margin: 0; font-size: 14px; color: var(--fa-forest); text-transform: uppercase; letter-spacing: 0.04em; }
.pg-meta { display: flex; gap: 6px; }
.pg-meta-pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-family: 'SF Mono', Consolas, monospace; font-size: 11px; background: rgba(93, 119, 112, 0.1); color: var(--fa-forest); }
.pg-meta-pill.ok { background: rgba(168, 188, 161, 0.4); color: #2d4a35; }
.pg-meta-pill.err { background: rgba(229, 130, 109, 0.25); color: #8b2a17; }

.pg-code { background: #1F2A26; color: #E5E5DC; padding: 16px; border-radius: 8px; overflow: auto; max-height: 460px; font-family: 'SF Mono', Consolas, monospace; font-size: 12px; line-height: 1.5; margin: 0; white-space: pre; word-break: normal; }
.pg-code .pg-key { color: #A8BCA1; }
.pg-code .pg-str { color: #E5C8A8; }
.pg-code .pg-num { color: #C2A68D; }
.pg-code .pg-bool { color: #E5826D; font-weight: 500; }
.pg-code .pg-null { color: #888; font-style: italic; }

/* History */
.pg-history-card { padding-bottom: 4px; }
.pg-history { font-size: 13px; }
.pg-history th { font-size: 11px; }
.pg-history .pg-path { max-width: 380px; }
.pg-history .pg-empty td { padding: 24px; text-align: center; }
.pg-history .pg-row-err code { color: #8b2a17; }

/* Live tail */
.pg-livetail-card { padding-bottom: 4px; }
.pg-livetail { font-size: 12px; }
.pg-livetail th { font-size: 11px; }
.pg-livetail tr.pg-fresh { animation: pg-flash 1.6s ease-out; }
.pg-livetail .small { font-size: 11px; }
@keyframes pg-flash {
  0% { background: rgba(229, 130, 109, 0.25); }
  100% { background: transparent; }
}

.pg-livedot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fa-salmon); margin-left: 6px; vertical-align: middle; animation: pg-pulse 2s ease-in-out infinite; }
@keyframes pg-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Responsive: collapse two-col layout on narrow screens */
@media (max-width: 1100px) {
  .pg-io { grid-template-columns: 1fr; }
  .pg-stats { grid-template-columns: repeat(2, 1fr); }
  .pg-setup-grid { grid-template-columns: 1fr; }
}

/* ADMN-E07/E08 additions: portal and status pages */
.badge.ok   { background: rgba(168, 188, 161, 0.3); color: #2d4a35; }
.badge.warn { background: rgba(229, 130, 109, 0.2); color: #8b2a17; }
.card__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fa-forest); margin-bottom: 8px; }
.flash.error { background: rgba(229, 130, 109, 0.15); color: #8b2a17; border-color: rgba(229, 130, 109, 0.4); }
button.link { background: none; border: none; color: var(--fa-forest); padding: 0; cursor: pointer; text-decoration: underline; font-size: inherit; }
