:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #69736d;
  --line: #dfe5e0;
  --primary: #1f6b4f;
  --primary-dark: #14533c;
  --soft-green: #e7f3ec;
  --danger: #b83b3b;
  --soft-danger: #fbeaea;
  --shadow: 0 8px 30px rgba(24, 45, 34, 0.06);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.topbar { height: 68px; padding: 0 max(24px, calc((100vw - 1240px) / 2)); display: flex; align-items: center; gap: 30px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; display: inline-grid; place-items: center; color: white; background: var(--primary); border-radius: 9px; font-size: 19px; }
nav { display: flex; gap: 4px; flex: 1; }
.nav-link { padding: 9px 11px; border-radius: 8px; color: var(--muted); font-weight: 550; }
.nav-link:hover, .nav-link.active { background: var(--soft-green); color: var(--primary-dark); }

.container { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
h1 { margin: 3px 0 6px; font-size: clamp(26px, 3vw, 36px); line-height: 1.15; letter-spacing: -0.035em; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 22px 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }
p { margin: 4px 0; color: var(--muted); }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.muted, .subtle { color: var(--muted); }
.subtle { display: inline-block; margin-top: 5px; max-width: 440px; overflow: hidden; text-overflow: ellipsis; }
.nowrap { white-space: nowrap; }
.break-all { word-break: break-all; }

.button { border: 1px solid var(--line); border-radius: 9px; padding: 10px 15px; display: inline-flex; justify-content: center; align-items: center; cursor: pointer; font-weight: 650; background: white; color: var(--ink); white-space: nowrap; }
.button:hover { border-color: #bcc8c0; }
.button.primary { background: var(--primary); color: white; border-color: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; }
.button.small { padding: 7px 10px; font-size: 12px; }
.button.wide { width: 100%; }
.text-link, .link-button { color: var(--primary); font-weight: 650; }
.link-button { padding: 0; border: 0; background: none; cursor: pointer; }
.danger-text { color: var(--danger); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.stat-card span { color: var(--muted); font-weight: 550; }
.stat-card strong { display: block; margin-top: 12px; font-size: 30px; letter-spacing: -.04em; }
.stat-card:hover { border-color: #b8cbbf; transform: translateY(-1px); }
.danger-card strong { color: var(--danger); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { min-height: 66px; padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-heading p { font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 16px; color: var(--muted); background: #fafbfa; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfcfb; }
code { padding: 2px 5px; background: #f0f3f1; border-radius: 4px; color: #3b4841; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; white-space: nowrap; }
.location-copy { display: flex; align-items: center; gap: 6px; }
.icon-button { width: 28px; height: 28px; display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { border-color: var(--line); background: var(--soft-green); color: var(--primary); }
.icon-button.danger-icon:hover { border-color: #efc5c5; background: var(--soft-danger); color: var(--danger); }
.icon-button.copied { background: var(--soft-green); color: var(--primary); }
.icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.clipboard-fallback { position: fixed; left: -9999px; top: 0; opacity: 0; }
.clipboard-toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; padding: 12px 16px; border-radius: 9px; color: white; background: var(--ink); box-shadow: 0 10px 35px rgba(23, 32, 27, .22); font-weight: 650; opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; pointer-events: none; }
.clipboard-toast.visible { opacity: 1; transform: translateY(0); }
.clipboard-toast.success { background: var(--primary-dark); }
.clipboard-toast.error { background: var(--danger); }
.route-arrow { padding: 0 8px; color: #9aa39e; }
.empty { padding: 38px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge.success { background: var(--soft-green); color: var(--primary-dark); }
.badge.danger { background: var(--soft-danger); color: var(--danger); }
.badge.info { margin-left: 4px; background: #eaf0fb; color: #3e6094; }
.muted-badge { background: #eff1f0; color: var(--muted); }

.narrow { max-width: 680px; margin: 0 auto; }
.subscription-form-page { max-width: 1100px; margin: 0 auto; }
.form-panel { padding: 24px; }
.stack { display: grid; gap: 20px; }
.field { display: grid; gap: 7px; }
.field label { font-weight: 650; }
.field input, .field select, .field textarea, .filters select { width: 100%; padding: 11px 12px; border: 1px solid #cbd3ce; border-radius: 8px; color: var(--ink); background: white; outline: none; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filters select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 107, 79, .12); }
.field small, .check-field small { color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 10px; }
.check-field { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.check-field input { margin-top: 3px; }
.check-field span { display: grid; gap: 3px; }
.filters { display: flex; gap: 10px; align-items: center; margin: -8px 0 18px; }
.filters select { width: auto; min-width: 190px; padding: 9px 11px; }

.flash { margin-bottom: 18px; padding: 12px 15px; border-radius: 9px; border: 1px solid; }
.flash.notice { color: var(--primary-dark); background: var(--soft-green); border-color: #c6e0d0; }
.flash.alert, .error-box { color: #892c2c; background: var(--soft-danger); border-color: #efcaca; }
.error-box { padding: 13px 15px; border: 1px solid; border-radius: 8px; }
.error-box ul { margin: 8px 0 0; padding-left: 20px; }

.details-grid { display: grid; grid-template-columns: 1fr 1fr .6fr; gap: 14px; margin-bottom: 18px; }
.detail-card { padding: 18px; display: grid; gap: 6px; }
.detail-card > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.detail-card strong { font-size: 17px; }
.detail-card code { overflow-wrap: anywhere; }
.exchange-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.exchange-grid .panel { padding: 0 20px 20px; min-width: 0; }
.exchange-grid .panel-heading { margin: 0 -20px; }
pre { max-height: 460px; overflow: auto; margin: 0; padding: 14px; border-radius: 8px; background: #17201b; color: #e7eee9; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 "SFMono-Regular", Consolas, monospace; }
.headers-list { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.headers-list > div { display: grid; grid-template-columns: minmax(130px, .7fr) 1.5fr; border-top: 1px solid var(--line); }
.headers-list > div:first-child { border-top: 0; }
.headers-list dt, .headers-list dd { margin: 0; padding: 9px 11px; overflow-wrap: anywhere; }
.headers-list dt { background: #f5f7f5; color: #3b4841; font: 600 12px/1.45 "SFMono-Regular", Consolas, monospace; }
.headers-list dd { border-left: 1px solid var(--line); color: var(--ink); font: 12px/1.45 "SFMono-Regular", Consolas, monospace; }
.empty-headers { padding: 12px; border: 1px dashed var(--line); border-radius: 8px; }
.form-hint { padding: 12px 14px; border-radius: 8px; background: var(--soft-green); color: var(--primary-dark); }
.curl-panel { margin-bottom: 18px; }
.curl-panel pre { margin: 18px 20px 20px; }
.conditional-routes { display: grid; gap: 14px; padding-top: 4px; border-top: 1px solid var(--line); }
.conditional-routes-heading, .conditional-route-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.conditional-routes-heading { padding-top: 18px; }
.conditional-routes-actions { display: flex; align-items: center; gap: 8px; }
.conditional-routes-list, .conditions, .conditions-list { display: grid; gap: 12px; }
.conditional-route-card { display: grid; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfa; }
.conditional-route-card.dragging { opacity: .55; border-color: var(--primary); }
.conditional-route-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drag-handle { padding: 4px 8px; border: 0; background: transparent; color: var(--muted); cursor: grab; font-size: 20px; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.conditional-route-heading strong { flex: 1; }
.condition-row { display: grid; grid-template-columns: .7fr 1.35fr .8fr 1fr 30px; gap: 8px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.condition-row .field { gap: 4px; }
.condition-row label { font-size: 11px; }
.condition-remove { margin-bottom: 7px; color: var(--danger); font-size: 20px; }
.jsonpath-modal { width: min(880px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; overflow: auto; border: 0; border-radius: 14px; color: var(--ink); background: var(--panel); box-shadow: 0 24px 80px rgba(23, 32, 27, .28); }
.jsonpath-modal::backdrop { background: rgba(23, 32, 27, .5); backdrop-filter: blur(2px); }
.jsonpath-modal-content { display: grid; gap: 18px; padding: 24px; }
.jsonpath-modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.jsonpath-modal-heading h2 { margin-top: 3px; font-size: 24px; }
.modal-close { color: var(--ink); font-size: 22px; }
.jsonpath-cheat-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 18px; min-width: 0; }
.jsonpath-cheat-grid section { min-width: 0; }
.jsonpath-cheat-grid h3 { margin-top: 0; }
.jsonpath-cheat-grid pre { max-height: none; }
.jsonpath-examples { margin: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.jsonpath-examples > div { display: grid; grid-template-columns: minmax(170px, .8fr) 1.2fr; border-top: 1px solid var(--line); }
.jsonpath-examples > div:first-child { border-top: 0; }
.jsonpath-examples dt, .jsonpath-examples dd { margin: 0; padding: 10px 12px; }
.jsonpath-examples dt { background: #f5f7f5; }
.jsonpath-examples dd { border-left: 1px solid var(--line); color: var(--muted); }

.auth-page { min-height: 100vh; background: radial-gradient(circle at 50% 0%, #e6f1ea, var(--bg) 45%); }
.auth-container { min-height: 100vh; display: grid; place-items: center; padding: 30px 0; }
.auth-card { width: min(420px, 100%); padding: 34px; background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 20px 60px rgba(24, 45, 34, .1); }
.auth-brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 28px; }
.auth-card > p { margin-bottom: 24px; }

@media (max-width: 900px) {
  .topbar { height: auto; padding: 12px 20px; flex-wrap: wrap; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .exchange-grid, .details-grid, .conditional-route-settings, .jsonpath-cheat-grid { grid-template-columns: 1fr; }
  .condition-row { grid-template-columns: 1fr 1fr; }
  .condition-remove { margin: 0; }
}
@media (max-width: 560px) {
  .container { width: min(100% - 24px, 1240px); padding-top: 28px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  .filters { align-items: stretch; flex-direction: column; }
  .filters select { width: 100%; }
  .conditional-routes-heading { align-items: flex-start; flex-direction: column; }
  .conditional-routes-actions { width: 100%; flex-wrap: wrap; }
  .jsonpath-modal-content { padding: 18px; }
  .jsonpath-examples > div { grid-template-columns: 1fr; }
  .jsonpath-examples dd { border-top: 1px solid var(--line); border-left: 0; }
}
