:root {
  --navy: #091f2c;
  --deep: #06141d;
  --cyan: #0095c8;
  --bright: #2ed4ff;
  --paper: #f4f9fb;
  --ink: #102b39;
  --muted: #607984;
  --line: #dbe6ec;
  --white: #fff;
  --danger: #a4382f;
  --danger-bg: #fbe1db;
  --good: #1e6b48;
  --good-bg: #dff3e8;
  --warning: #7a5300;
  --warning-bg: #fff1cc;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 4px; }
:focus-visible { outline: 3px solid var(--cyan); }
button { cursor: pointer; }
a { color: var(--cyan); }
code, pre, .script { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

header {
  background: var(--deep);
  color: white;
  padding: 18px 3%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid #24414f;
}
.brand { font-size: 23px; font-weight: 750; letter-spacing: -1px; }
.brand span { color: var(--bright); }
.brand small { display: block; font-size: 10px; letter-spacing: 2px; color: #90abb9; font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.identity { font-size: 12px; color: #bdd2dd; }
.header-logout { color: white; border-color: #496371; }
.header-logout:hover { background: #ffffff12; }

nav {
  background: var(--navy);
  display: flex;
  padding: 0 3%;
  gap: 6px;
  overflow: auto;
}
nav a {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: #a9bfca;
  padding: 16px 19px;
  white-space: nowrap;
  text-decoration: none;
}
nav a.active { color: var(--bright); border-color: var(--bright); }
nav a:hover { background: #ffffff08; }

main { max-width: 1500px; margin: auto; padding: 30px 3% 60px; }
h1 { font-size: 29px; letter-spacing: -.8px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 16px; }
p { margin: 5px 0 16px; }
small, .muted { color: var(--muted); }
.eyebrow { color: var(--cyan); font-size: 10px; letter-spacing: 2px; font-weight: 750; text-transform: uppercase; margin-bottom: 6px; }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 25px; }
.heading h1, .heading p { max-width: 900px; }
.heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; text-align: right; }
.summary { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: -8px 0 16px; }

.button {
  background: white;
  color: var(--ink);
  border: 1px solid #c7d9e2;
  border-radius: 7px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.button:hover:not(:disabled) { border-color: var(--cyan); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--cyan); color: white; border-color: var(--cyan); }
.primary:hover:not(:disabled) { background: #0085b3; }
.quiet { background: transparent; }
.danger { color: var(--danger); border-color: #e3b7b1; }
.danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }
.link { background: none; border: 0; color: var(--cyan); padding: 0; text-decoration: underline; font-weight: 600; }
.back { margin-bottom: 10px; }

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 21px;
  margin-bottom: 22px;
}
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.card-heading h2 { margin: 0; }
.note {
  background: #eef7fb;
  border-left: 3px solid var(--cyan);
  color: #376071;
  padding: 11px 13px;
  font-size: 12px;
  margin: 12px 0;
}
.warning-text { color: var(--warning); }
.error, .field-error {
  background: var(--danger-bg);
  color: #7d2b24;
  border-left: 3px solid var(--danger);
  padding: 9px 12px;
  font-size: 12px;
  margin: 10px 0;
}
.field-error { margin: 6px 0 0; }
.page-alert { margin-bottom: 18px; }

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
}
.toolbar input { flex: 1; min-width: 220px; }
.toolbar input, .toolbar select { margin: 0; width: auto; }

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #c7d9e2;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  margin: 5px 0 12px;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; margin: 0 7px 0 0; }
input[readonly], textarea[readonly] { background: #f5f9fb; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field { display: block; font-weight: 600; font-size: 12px; color: #3c5966; }
.field input, .field select, .field textarea { font-weight: 400; }
.wide { grid-column: 1 / -1; }
.check-line { font-size: 13px; margin: 8px 0 14px; }
.check-line label { display: inline-flex; align-items: center; }

.table-wrap {
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-top: 0;
}
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); background: #f7fbfd; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; }
td code, td .script-excerpt { white-space: pre-wrap; overflow-wrap: anywhere; }
td .script-excerpt { display: block; max-width: 440px; color: #36515f; font-size: 12px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 26px; }
.empty { padding: 28px; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 0; font-size: 12px; color: var(--muted); }
.pagination-controls { display: flex; align-items: center; gap: 9px; }
.page-number { min-width: 22px; text-align: center; font-weight: 700; color: var(--ink); }

.tag {
  display: inline-block;
  background: #eaf4f8;
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11px;
  color: #315b6c;
  margin: 1px 2px;
  white-space: nowrap;
}
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warning { background: var(--warning-bg); color: var(--warning); }
.tag.danger { background: var(--danger-bg); color: var(--danger); }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 22px; align-items: start; }
.editor-layout > div > .card, .editor-layout > aside > .card { margin-bottom: 18px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 18px; }
.steps span { border: 1px solid var(--line); background: white; border-radius: 6px; padding: 5px 9px; font-size: 11px; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 15px; }
.actions small { margin-right: auto; }
.selector { border: 1px solid var(--line); border-radius: 8px; padding: 9px; background: #fbfdfe; }
.selector input[type="search"] { margin: 0 0 8px; }
.selector-results { max-height: 210px; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px 0; }
.selector-result { display: flex; align-items: center; padding: 4px 3px; font-size: 12px; }
.selector-result label { display: flex; align-items: center; gap: 7px; width: 100%; cursor: pointer; }
.selector-pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 7px 0; font-size: 11px; color: var(--muted); }
.selector-pagination .button { padding: 4px 8px; font-size: 11px; }
.selected { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 7px; }
.selected-item { display: inline-flex; align-items: center; gap: 5px; background: #eaf4f8; border-radius: 15px; padding: 3px 5px 3px 9px; font-size: 11px; }
.selected-item button { border: 0; background: transparent; color: #315b6c; padding: 0 3px; font-size: 14px; line-height: 1; }

.terminal {
  background: var(--deep);
  color: #d9f5ff;
  border-radius: 7px;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  margin: 8px 0 14px;
}
.output-block { margin-top: 4px; max-height: 280px; overflow: auto; }
.kv { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 12px; }
.kv:last-of-type { border-bottom: 0; }
.secret-panel { background: var(--warning-bg); border: 1px solid #e8ce8e; border-radius: 8px; padding: 13px; margin-top: 14px; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 23px; }
.metric { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 21px; }
.metric .value { display: block; font-size: 34px; letter-spacing: -1px; font-weight: 700; margin: 8px 0; }
.metric small { display: block; margin-bottom: 9px; }
.health-bar { height: 7px; background: var(--danger-bg); border-radius: 5px; overflow: hidden; margin: 12px 0 0; }
.health-bar span { display: block; height: 100%; width: 0; background: var(--cyan); transition: width .25s ease; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 22px; align-items: start; }
.dashboard-grid > * { min-width: 0; }
.alert-item { padding: 15px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; }
.alert-item p { font-size: 12px; margin: 5px 0 7px; color: var(--muted); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.dashboard-footnote { font-size: 11px; color: var(--muted); margin-top: 14px; }

.login-body { min-height: 100vh; background: radial-gradient(circle at 20% 10%, #163d50, var(--deep) 65%); display: grid; place-items: center; }
.login-shell { width: min(440px, 92vw); padding: 30px 0; }
.login-card { background: white; border-radius: 13px; padding: 30px; box-shadow: 0 20px 60px #00101866; }
.login-brand { color: var(--ink); margin-bottom: 28px; }
.login-brand small { color: var(--muted); }
.login-actions { justify-content: stretch; }
.login-actions .button { width: 100%; }
.login-card h1 { margin-bottom: 4px; }

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(440px, calc(100vw - 44px));
  background: var(--navy);
  color: white;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 8px 30px #00101855;
}
#toast.error-toast { background: #7d2b24; }
#toast.success-toast { background: #175f43; }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .editor-layout, .two-column { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  header { padding: 14px 16px; }
  nav { padding: 0 10px; }
  nav a { padding: 14px 12px; }
  main { padding: 24px 16px 50px; }
  .heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { justify-content: flex-start; text-align: left; }
  .fields { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .identity { display: none; }
  .card { padding: 18px; }
  .toolbar input { min-width: 100%; }
  .pagination { flex-wrap: wrap; }
  .actions { flex-wrap: wrap; }
  .actions small { width: 100%; }
  th, td { padding: 12px; }
  .login-card { padding: 22px; }
}
