:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-alt: #f8fafb;
  --line: #d8dee4;
  --line-strong: #b8c2cc;
  --text: #17212b;
  --muted: #66717d;
  --accent: #176b87;
  --accent-dark: #0f5268;
  --sidebar: #ffffff;
  --sidebar-active: #e8f2f6;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}
h1, h2 { margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 24px 0 18px;
}
.tab, .nav, .ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
}
.tab.active, .nav.active {
  background: var(--sidebar-active);
  border-color: #a8c8d5;
  color: var(--accent-dark);
}
.stack { display: grid; gap: 14px; }
label, .field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 107, 135, 0.12);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
}
.primary:hover { background: var(--accent-dark); }
.error-text { color: var(--danger); min-height: 20px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  background: var(--sidebar);
  color: var(--text);
  padding: 18px;
  border-right: 1px solid var(--line);
}
.brand { display: grid; gap: 4px; }
.brand strong { font-size: 16px; }
.brand span, .profile { color: var(--muted); font-size: 13px; }
nav { display: grid; align-content: start; gap: 8px; }
.nav {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: var(--text);
}
.nav.active {
  background: var(--sidebar-active);
  border-color: #c6dce5;
  color: var(--accent-dark);
}
.profile {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}
.profile .ghost { background: #fff; color: var(--text); border-color: var(--line); }

.content { padding: 24px 28px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.toast {
  min-height: 20px;
  color: var(--accent-dark);
  font-size: 13px;
  background: #eaf4f7;
  border: 1px solid #cfe4eb;
  border-radius: 6px;
  padding: 7px 10px;
}
.toast:empty { display: none; }
.view-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}
.wide { grid-column: 1 / -1; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 2px;
}
.panel-title span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.section-head, .actions, .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.actions { justify-content: flex-start; }
.inline-fields, .run-fields {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(260px, 1fr) minmax(320px, 1.2fr);
  gap: 14px;
}
.field-block { display: grid; gap: 7px; align-content: start; }
.check-grid {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}
.check-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: auto;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface-alt);
}
.check-item input {
  width: 14px;
  height: 14px;
  margin: 0;
}
.list, .runs { display: grid; gap: 10px; margin-top: 14px; }
.item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: var(--surface-alt);
}
.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.small { padding: 6px 9px; font-size: 12px; }
.danger { color: var(--danger); border-color: #f0b8b2; }
.status-ok { color: var(--ok); }
.status-error { color: var(--danger); }
.status-warn { color: var(--warn); }
.progress {
  width: 100%;
  height: 7px;
  background: #edf1f2;
  border-radius: 999px;
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.result-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 100px 100px 76px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
dialog {
  width: min(980px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.detail-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 12px;
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 65vh;
  overflow: auto;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
  }
  .view-grid, .inline-fields, .run-fields { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
}
