:root {
  --ink: #17202a;
  --muted: #657082;
  --line: #dfe3e8;
  --soft: #f5f6f8;
  --purple: #4d148c;
  --purple-dark: #36105f;
  --orange: #ff6200;
  --green: #16794a;
  --red: #b42318;
  --amber: #9a6700;
  --shadow: 0 12px 32px rgb(28 22 35 / 8%);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #fafafa; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .7rem; font-size: clamp(2rem, 4vw, 3.75rem); line-height: 1.04; letter-spacing: -.04em; }
h2 { margin-bottom: .45rem; letter-spacing: -.02em; }
small { display: block; color: var(--muted); }
label { display: grid; gap: .45rem; color: #3d4654; font-size: .88rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd1d8; border-radius: .55rem; padding: .72rem .8rem; background: white; color: var(--ink); font: inherit; font-weight: 500; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(77 20 140 / 15%); border-color: var(--purple); }
button { font: inherit; }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: 1rem max(1.25rem, calc((100vw - 1180px) / 2)); background: white; border-bottom: 1px solid var(--line); }
.site-header nav { display: flex; align-items: center; gap: 1.4rem; font-weight: 700; font-size: .92rem; }
.brand { display: flex; align-items: center; gap: .8rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: .7rem; color: white; background: linear-gradient(135deg, var(--purple) 0 65%, var(--orange) 65%); font-size: .8rem; font-weight: 900; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand small { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; }
.demo-banner { padding: .48rem 1rem; color: #5b3b00; background: #fff1c2; text-align: center; font-size: .8rem; font-weight: 800; letter-spacing: .02em; }
.page-shell { width: min(1180px, calc(100% - 2.5rem)); margin: 0 auto; padding: 3rem 0 5rem; }
footer { padding: 1.5rem; color: var(--muted); background: white; border-top: 1px solid var(--line); text-align: center; font-size: .82rem; }

.hero, .country-hero, .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2.2rem; }
.hero { padding: 2.5rem; color: white; background: linear-gradient(125deg, var(--purple-dark), var(--purple) 72%, #6f2aaa); border-radius: 1rem; box-shadow: var(--shadow); }
.hero p { max-width: 62ch; color: rgb(255 255 255 / 78%); }
.hero .eyebrow { color: #ffb888; }
.hero .button { background: var(--orange); }
.eyebrow { margin-bottom: .5rem; color: var(--purple); font-size: .76rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.breadcrumbs { display: flex; gap: .55rem; margin-bottom: 1.5rem; color: var(--muted); font-size: .86rem; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.6rem; padding: .65rem 1rem; border: 0; border-radius: .55rem; color: white; background: var(--purple); cursor: pointer; font-weight: 800; }
.button:hover { background: var(--purple-dark); text-decoration: none; }
.button-secondary { color: var(--purple); background: #f0e9f7; }
.button-secondary:hover { background: #e6d8f2; }
.hero-actions, .card-actions, .form-actions { display: flex; align-items: center; gap: .75rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.metric { padding: 1.35rem; background: white; border: 1px solid var(--line); border-radius: .8rem; }
.metric strong { display: block; font-size: 2rem; line-height: 1; }
.metric span { color: var(--muted); font-size: .82rem; }
.panel { margin-bottom: 1.25rem; padding: 1.5rem; background: white; border: 1px solid var(--line); border-radius: .8rem; box-shadow: 0 5px 20px rgb(24 20 33 / 4%); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.2rem; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading > span { color: var(--muted); font-size: .82rem; }
.filter-grid, .form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 1rem; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.span-2 { grid-column: span 2; }
.country-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.country-card { padding: 1.4rem; background: white; border: 1px solid var(--line); border-radius: .8rem; box-shadow: 0 5px 20px rgb(24 20 33 / 4%); }
.country-card h2 { margin: 1rem 0 .7rem; }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.country-code { color: var(--muted); font-size: .8rem; font-weight: 900; letter-spacing: .15em; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: 1rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mini-stats div { display: grid; }
.mini-stats dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.mini-stats dd { margin: 0; font-size: 1.25rem; font-weight: 900; }
.card-actions { justify-content: end; padding-top: 1rem; }

.badge { display: inline-flex; align-items: center; padding: .24rem .5rem; border-radius: 999px; font-size: .7rem; font-weight: 900; letter-spacing: .04em; }
.badge-neutral { color: #374151; background: #e5e7eb; }
.badge-plain { color: #4b5563; background: #f3f4f6; }
.badge-blue { color: #174ea6; background: #e8f0fe; }
.badge-violet { color: #5b21b6; background: #ede9fe; }
.badge-green { color: var(--green); background: #dcfce7; }
.badge-red { color: var(--red); background: #fee4e2; }
.badge-amber { color: var(--amber); background: #fef0c7; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .8rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--soft); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
td a[href^="http"] { display: inline-block; max-width: 42rem; overflow-wrap: anywhere; }
.stack { display: grid; gap: 1.25rem; }
.form-section { margin-bottom: 0; }
.capability-editor-list { display: grid; gap: .7rem; }
.capability-editor { display: grid; grid-template-columns: minmax(12rem, 1.3fr) minmax(9rem, .7fr) minmax(8rem, .6fr) minmax(14rem, 1fr) auto; gap: 1rem; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.capability-editor .checkbox { padding-top: 1.45rem; }
.module-editor-list { display: grid; gap: .7rem; }
.module-editor { display: grid; grid-template-columns: 1fr minmax(12rem, 18rem); gap: 1rem; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.migration-fields { margin-top: 1.4rem; }
.checkbox { display: flex; align-items: center; gap: .65rem; padding-top: 1.7rem; }
.checkbox input { width: auto; }
.form-actions { justify-content: end; }
.endpoint-list { display: grid; gap: .7rem; min-width: 22rem; margin: 0; padding: 0; list-style: none; }
.endpoint-list li { display: grid; grid-template-columns: auto auto minmax(14rem, 1fr); align-items: start; gap: .4rem; }
.endpoint-list a { overflow-wrap: anywhere; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; padding: 1rem 1.2rem; border: 1px solid #fda29b; border-radius: .65rem; background: #fff5f4; }
.button-danger { background: var(--red); }
.button-danger:hover { background: #7a271a; }
.notice, .error-box { margin-bottom: 1.25rem; padding: 1rem 1.2rem; border-radius: .65rem; }
.notice { color: #14532d; background: #dcfce7; border: 1px solid #86efac; }
.error-box { color: #7a271a; background: #fee4e2; border: 1px solid #fda29b; }
.error-box ul { margin-bottom: 0; }
.empty-state { grid-column: 1 / -1; padding: 4rem 2rem; background: white; border: 1px dashed #b9c0c9; border-radius: .8rem; text-align: center; }

.explorer-grid { display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; align-items: start; gap: 1rem; }
.explorer-grid form { display: grid; gap: 1rem; }
.response-panel { min-width: 0; }
.endpoint-line { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: .75rem; background: var(--soft); border-radius: .5rem; }
.endpoint-line code { overflow-wrap: anywhere; }
pre { min-height: 28rem; max-height: 55rem; margin: 0; padding: 1rem; overflow: auto; color: #e6edf3; background: #0d1117; border-radius: .6rem; font: .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

@media (max-width: 850px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .site-header nav { flex-wrap: wrap; }
  .hero, .country-hero, .page-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .country-grid, .explorer-grid { grid-template-columns: 1fr; }
  .filter-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .capability-editor { grid-template-columns: 1fr 1fr; }
  .capability-editor > :first-child, .capability-editor > :nth-child(4) { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 1.25rem, 1180px); padding-top: 1.5rem; }
  .hero, .panel { padding: 1.1rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .country-grid { grid-template-columns: 1fr; }
  .capability-editor, .module-editor { grid-template-columns: 1fr; }
  .capability-editor > :first-child, .capability-editor > :nth-child(4) { grid-column: auto; }
  .endpoint-list { min-width: 16rem; }
  .endpoint-list li { grid-template-columns: auto auto; }
  .endpoint-list a { grid-column: 1 / -1; }
  .danger-zone { align-items: stretch; flex-direction: column; }
}

.capability-card { display: flex; flex-direction: column; }
.capability-card .card-description { flex: 1; color: var(--muted); }
.capability-card .mini-stats { margin-top: 1rem; }
.capability-filter-grid { grid-template-columns: 2fr 1fr 1fr auto; }

@media (max-width: 850px) {
  .capability-filter-grid { grid-template-columns: 1fr; }
}

textarea { resize: vertical; }
input[readonly], select:disabled { color: var(--muted); background: var(--soft); }
.danger-zone label { min-width: 12rem; }
.danger-zone-disabled { color: var(--ink); border-color: var(--line); background: var(--soft); }

@media (max-width: 560px) {
  .danger-zone label { min-width: 0; }
}
