:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #d7dde3;
  --text: #1d2b36;
  --muted: #5a6b7a;
  --accent: #0b5394;
  --accent-hover: #094578;
  --green: #1e7e34;
  --green-bg: #e6f4ea;
  --amber: #92600a;
  --amber-bg: #fdf3d7;
  --red: #b02a37;
  --red-bg: #fbeaec;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 1100px;
  padding: 24px 20px 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

header h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { margin: 0 0 20px; color: var(--muted); max-width: 70ch; }

nav[role="tablist"] {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

nav button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

nav button:hover { color: var(--text); }
nav button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.panel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 20px;
}
.panel.active { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(320px, 6fr); gap: 24px; }

@media (max-width: 860px) {
  .panel.active { grid-template-columns: 1fr; }
}

.panel h2 { margin: 0 0 4px; font-size: 17px; }
.op-desc { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 14px;
  padding: 12px 14px 14px;
}
legend { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.req { color: var(--red); font-weight: 700; }

input[type="text"], input[type="date"], input[type="number"], select, textarea {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

textarea.json {
  font-family: var(--mono);
  font-size: 12.5px;
  min-height: 260px;
  white-space: pre;
  resize: vertical;
}

.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.checkbox label { font-weight: 600; font-size: 13.5px; }

.measure-hint { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

button.submit {
  appearance: none;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 22px;
  cursor: pointer;
}
button.submit:hover { background: var(--accent-hover); }
button.submit:disabled { background: #9db3c6; cursor: default; }

button.link {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.results {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  background: #fafbfc;
  min-height: 200px;
  align-self: start;
}
.results h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.status-line { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.badge.idle { background: #e8ecf0; color: var(--muted); }
.badge.processing { background: var(--amber-bg); color: var(--amber); }
.badge.success { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.error { background: var(--red-bg); color: var(--red); }

.sub-id { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

.result-code {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  margin: 6px 0 2px;
}
.result-display { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--amber-bg);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

pre.raw {
  background: #10222f;
  color: #d5e3ee;
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  margin: 8px 0 0;
}

details.raw-wrap summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }

table.issues {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}
table.issues th, table.issues td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
table.issues th { background: #eef1f4; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.issues td.sev-error { color: var(--red); font-weight: 700; }
table.issues td.sev-warning { color: var(--amber); font-weight: 700; }
table.issues td code { font-family: var(--mono); font-size: 12px; }

#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#login-overlay[hidden] { display: none; }

.login-card {
  background: var(--panel);
  border-radius: 10px;
  padding: 28px 32px;
  width: min(360px, 90vw);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h2 { margin: 0; font-size: 18px; }
.login-card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.login-card input { font-size: 15px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; }
.login-error { color: var(--red); font-weight: 600; }

footer { margin-top: 22px; color: var(--muted); font-size: 13px; }
footer code { font-family: var(--mono); font-size: 12px; background: #e8ecf0; padding: 1px 5px; border-radius: 4px; }
