:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #18212b;
  --muted: #66717e;
  --line: #dce2e8;
  --primary: #176b5b;
  --primary-dark: #0f5246;
  --danger: #b42318;
  --soft: #e8f3f0;
  --shadow: 0 12px 36px rgba(21, 35, 48, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 3vw, 2.3rem); letter-spacing: -.035em; }
h2 { margin-bottom: .35rem; font-size: 1.1rem; }
p { color: var(--muted); line-height: 1.55; }
code { padding: .12rem .32rem; border-radius: 5px; background: #eef1f4; font-size: .9em; }

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem clamp(1rem, 4vw, 4rem) 1.5rem;
  color: #fff;
  background: linear-gradient(125deg, #102f35, #176b5b 68%, #2c8875);
}
.eyebrow { margin-bottom: .35rem; color: inherit; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .78; }
nav { display: flex; gap: .35rem; }
nav a { padding: .65rem .85rem; border-radius: 8px; color: rgba(255,255,255,.75); text-decoration: none; font-weight: 700; font-size: .9rem; }
nav a:hover, nav a.active { color: #fff; background: rgba(255,255,255,.13); }

.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; width: min(1240px, calc(100% - 2rem)); margin: 1.5rem auto 4rem; }
.span-2 { grid-column: 1 / -1; }
.panel { padding: 1.3rem; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading p { margin-bottom: 0; }

form label { display: grid; gap: .4rem; color: #394653; font-size: .83rem; font-weight: 750; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: .72rem .78rem; border: 1px solid #cbd3da; border-radius: 8px; color: var(--text); background: #fff; outline: none; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,107,91,.12); }
input:disabled { background: #edf0f2; color: #707b85; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.stack { display: grid; gap: 1rem; }
.checkbox { display: flex; align-items: center; gap: .55rem; }
.checkbox input { width: auto; }
.actions { display: flex; gap: .65rem; }

button { padding: .68rem .95rem; border: 0; border-radius: 8px; color: #fff; background: var(--primary); cursor: pointer; font-weight: 750; }
button:hover { background: var(--primary-dark); }
button:disabled { cursor: progress; opacity: .55; }
button.secondary { color: var(--primary); background: var(--soft); }
button.secondary:hover { background: #d9ebe6; }
button.ghost { color: #475461; background: #edf0f2; }
button.ghost:hover { background: #dfe4e8; }
button.danger { color: var(--danger); background: #fff0ee; }
button.danger:hover { background: #ffe2de; }
button.small { padding: .48rem .65rem; font-size: .78rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .78rem .6rem; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: .85rem; }
th { border-top: 0; color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
td:last-child { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: .4rem; }
.badge { display: inline-flex; padding: .22rem .48rem; border-radius: 999px; font-size: .72rem; font-weight: 800; background: #edf0f2; }
.badge.ok { color: #0b684f; background: #dff4ed; }
.muted { color: var(--muted); }

.notice { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 10; max-width: min(430px, calc(100% - 2.5rem)); padding: .85rem 1rem; border-radius: 10px; color: #fff; background: #26333f; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.notice.visible { opacity: 1; transform: translateY(0); }
.notice.error { background: var(--danger); }

.login-page { display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at top, #217766, #102f35 70%); }
.login-card { width: min(430px, 100%); padding: 2rem; border-radius: 16px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.26); }
.login-card .eyebrow { color: var(--primary); }

.test-layout { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(0, 1.25fr); gap: 1.25rem; width: min(1240px, calc(100% - 2rem)); margin: 1.5rem auto 4rem; }
.output-panel { min-width: 0; }
pre { min-height: 420px; max-height: 70vh; overflow: auto; margin: 0; padding: 1rem; border-radius: 9px; color: #e6edf3; background: #101820; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 800px) {
  .topbar { align-items: start; flex-direction: column; gap: 1rem; }
  .page-grid, .test-layout { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .section-heading { align-items: start; }
}
