:root {
  color-scheme: dark;
  --bg: #08110f;
  --surface: #101c18;
  --surface-2: #16241f;
  --surface-3: #1b2d26;
  --line: #2c433a;
  --text: #eef7f2;
  --muted: #a9bcb4;
  --green: #50e2a2;
  --green-dark: #143d2d;
  --gold: #e2b766;
  --red: #ff867c;
  --shadow: 0 18px 50px rgb(0 0 0 / 24%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 15% -10%, #153229 0, transparent 35%), var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3); color: var(--text); padding: .65rem .9rem; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--green); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.primary { background: var(--green); border-color: var(--green); color: #04120c; font-weight: 750; }
button.secondary { background: transparent; }
.hidden { display: none !important; }
.skip-link { position: fixed; left: 1rem; top: -4rem; background: var(--green); color: #04120c; padding: .6rem; z-index: 20; }
.skip-link:focus { top: 1rem; }

.topbar { position: sticky; top: 0; z-index: 10; padding: .85rem clamp(1rem, 3vw, 2.5rem) .7rem; background: rgb(8 17 15 / 94%); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand-row, .status-row, .brand, nav, .hero-actions, .section-heading { display: flex; align-items: center; }
.brand-row { justify-content: space-between; gap: 1rem; }
.brand { gap: .7rem; text-decoration: none; }
.brand strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); margin-top: .1rem; }
.brand-mark { display: grid; place-items: center; width: 2.35rem; aspect-ratio: 1; border-radius: 9px; color: #04120c; background: linear-gradient(135deg, #f7fff9, #9be7c1); font-weight: 850; }
nav { gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
nav a { color: var(--muted); font-size: .82rem; text-decoration: none; padding: .42rem .55rem; border-radius: 6px; }
nav a:hover { color: var(--text); background: var(--surface-2); }
.status-row { gap: .75rem; margin-top: .55rem; color: var(--muted); font-size: .74rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; border: 1px solid #38654f; background: var(--green-dark); color: var(--green); border-radius: 999px; padding: .2rem .55rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; font-size: .66rem; }
.badge.muted { color: var(--muted); border-color: var(--line); background: var(--surface-2); }
.badge.warning { color: var(--gold); border-color: #6c5329; background: #30250f; }
.badge.safe, .safe { color: var(--green); }

main { width: min(1500px, 100%); margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(145deg, rgb(22 36 31 / 96%), rgb(13 25 21 / 96%)); box-shadow: var(--shadow); }
.message { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid #6c5329; border-radius: 9px; background: #30250f; color: #f3d38e; }
.message.error { border-color: #743832; background: #321916; color: var(--red); }
.message.success { border-color: #38654f; background: var(--green-dark); color: var(--green); }
.hero { padding: clamp(1.2rem, 3vw, 2rem); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: center; }
.hero h1 { margin: .25rem 0 .55rem; max-width: 760px; font-size: clamp(1.35rem, 2.5vw, 2.15rem); line-height: 1.08; letter-spacing: -.035em; }
.hero p:not(.eyebrow) { max-width: 850px; margin: 0; color: var(--muted); line-height: 1.55; }
.hero-actions { gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.eyebrow, .workload-kicker { margin: 0; color: var(--green); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; margin: .85rem 0 2rem; }
.metric { padding: 1rem; box-shadow: none; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
.metric strong { display: block; margin: .5rem 0 .25rem; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.metric small { font-size: .72rem; }
.section-heading { justify-content: space-between; gap: 1.5rem; margin-bottom: .8rem; }
.section-heading h2 { margin: .15rem 0 0; font-size: 1.15rem; letter-spacing: -.02em; }
.section-heading > p { color: var(--muted); font-size: .82rem; max-width: 620px; margin: 0; }
.section-heading.compact { margin: 0 0 .75rem; }

.workload-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.workload-card { padding: 1rem; box-shadow: none; min-width: 0; }
.workload-card > header { display: flex; justify-content: space-between; gap: 1rem; min-height: 108px; }
.workload-title { font-size: 1.1rem; margin: .2rem 0; }
.workload-description { color: var(--muted); font-size: .78rem; line-height: 1.45; margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: .45rem; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.toggle input { accent-color: var(--green); width: 1rem; height: 1rem; }
.toggle.inline { align-self: end; min-height: 2.4rem; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: .85rem 0 0; padding: .85rem 0 0; }
fieldset:disabled { opacity: .82; }
.guardrail-note { margin: 0 0 .7rem; color: var(--muted); font-size: .72rem; line-height: 1.45; }
legend { padding: 0 .45rem 0 0; color: var(--gold); font-weight: 760; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
label > span { display: block; color: var(--muted); font-size: .7rem; margin-bottom: .28rem; }
input, select, textarea { width: 100%; color: var(--text); background: #091510; border: 1px solid var(--line); border-radius: 7px; padding: .55rem .6rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgb(80 226 162 / 25%); border-color: var(--green); }
.event-fields { border: 1px solid var(--line); background: rgb(8 17 15 / 45%); padding: .6rem; margin-top: .6rem; border-radius: 8px; }
.usage-row { display: flex; justify-content: space-between; gap: 1rem; margin-top: .7rem; padding-top: .65rem; border-top: 1px dashed var(--line); color: var(--muted); font-size: .72rem; }
.usage-row strong { color: var(--text); font-variant-numeric: tabular-nums; }

.cost-policy-card { margin-top: .85rem; padding: 1rem; box-shadow: none; }
.cost-policy-card > p { max-width: 980px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.cost-policy-card fieldset { margin-top: 1rem; }
.cost-policy-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(320px, 1.2fr); gap: 1.25rem; }
.fixed-policy > div:first-child { border-top: 0; }
.override-fields { display: grid; gap: .7rem; align-content: start; }
.override-fields .toggle { white-space: normal; }
.override-fields .quiet { margin: 0; }
.cost-warning { color: var(--gold) !important; }
.cost-blocked { color: var(--red) !important; }

.two-column { display: grid; grid-template-columns: 1.3fr 1fr; gap: .85rem; margin-top: .85rem; }
.deterministic-card, .safety-card, .history-panel { padding: 1rem; box-shadow: none; }
.deterministic-card > p, .quiet { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.automation-list { margin: 0; }
.automation-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--line); }
.automation-list dt { color: var(--muted); }
.automation-list dd { margin: 0; font-weight: 750; font-variant-numeric: tabular-nums; }
.lock { font-size: 1.3rem; }
.history-panel { margin-top: .85rem; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { text-align: left; color: var(--muted); font-size: .65rem; letter-spacing: .07em; text-transform: uppercase; }
th, td { padding: .65rem .5rem; border-top: 1px solid var(--line); vertical-align: top; }
td { font-variant-numeric: tabular-nums; }
td.empty { color: var(--muted); text-align: center; padding: 1.5rem; }

dialog { width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; color: var(--text); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(5px); }
.dialog-shell { padding: 1.1rem; }
.dialog-header, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-header h2 { margin: .15rem 0 0; }
.icon-button { border: 0; background: transparent; font-size: 1.6rem; padding: .2rem .5rem; }
.change-list { max-height: 310px; overflow: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 8px; }
.change { display: grid; grid-template-columns: minmax(120px, .8fr) 1fr auto 1fr; gap: .5rem; align-items: baseline; padding: .6rem; border-top: 1px solid var(--line); font-size: .75rem; }
.change:first-child { border-top: 0; }
.change-name { color: var(--muted); }
.change-old { color: var(--red); overflow-wrap: anywhere; }
.change-new { color: var(--green); overflow-wrap: anywhere; }
.reason-field { display: block; margin-top: .8rem; }
.reason-field em { color: var(--gold); font-style: normal; }
.dialog-actions { justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 1100px) {
  .workload-grid { grid-template-columns: 1fr; }
  .workload-card > header { min-height: auto; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .brand-row, .hero, .two-column { display: block; }
  nav { justify-content: flex-start; margin-top: .7rem; }
  .hero-actions { justify-content: flex-start; margin-top: 1rem; }
  .summary-grid, .field-grid, .cost-policy-grid { grid-template-columns: 1fr; }
  .change { grid-template-columns: 1fr; }
  .change-arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
