:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #172033;
  background: #f3f6fb;
  --navy: #102a56;
  --blue: #1769aa;
  --blue-soft: #e9f3fb;
  --line: #dce3ef;
  --muted: #6d788a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: #f3f6fb; }
body.modal-open { overflow: hidden; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.45rem; }
h2 { margin-bottom: 0; font-size: 1.55rem; }
h3 { margin-bottom: 1rem; font-size: 1.15rem; }
h4 { margin-bottom: .65rem; }

.topbar {
  min-height: 82px; display: flex; justify-content: space-between; align-items: center; gap: 2rem;
  padding: 1rem 2rem; color: white; background: linear-gradient(120deg, #0d244b, #1769aa);
  box-shadow: 0 4px 18px rgba(17, 45, 85, .22);
}
.brand { display: flex; align-items: center; gap: .9rem; }
.brand-mark { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 13px; background: rgba(255,255,255,.14); font-weight: 800; letter-spacing: .06em; }
.brand p { margin: .15rem 0 0; color: #cbe8ff; font-size: .82rem; }
.session { display: flex; align-items: center; gap: 1rem; }
.session-user { margin: 0; color: #d8edff; font-size: .82rem; }
.session-user strong { color: white; }
.session-actions { display: flex; gap: .45rem; }
.session-actions button { color: white; background: rgba(255,255,255,.16); }
.session-actions button:hover { background: rgba(255,255,255,.26); }

.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(140deg, #0d244b, #1769aa); }
.login-shell { width: min(420px, calc(100vw - 2rem)); padding: 1rem; }
.login-card { padding: 1.9rem; background: white; border-radius: .9rem; box-shadow: 0 26px 70px rgba(6, 21, 46, .4); }
.login-brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.6rem; }
.login-brand .brand-mark { color: white; background: var(--navy); }
.login-brand p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.login-card .form-actions button { width: 100%; }
.login-message { margin: 1rem 0 0; padding: .7rem .85rem; border-radius: .55rem; color: #8d1d1d; background: #fee2e2; font-size: .86rem; }
.login-note { margin: 1.4rem 0 0; color: var(--muted); font-size: .76rem; text-align: center; }

.app-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 82px); }
.sidebar { display: flex; flex-direction: column; justify-content: space-between; padding: 1.4rem .9rem; background: #fff; border-right: 1px solid var(--line); }
.sidebar nav { display: grid; gap: .35rem; }
.nav-item { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .8rem .9rem; color: #455268; background: transparent; text-align: left; }
.nav-item span { color: #9aa6b7; font-size: .7rem; font-weight: 700; }
.nav-item:hover { color: var(--blue); background: #f2f7fb; }
.nav-item.active { color: var(--blue); background: var(--blue-soft); box-shadow: inset 3px 0 var(--blue); }
.nav-item.active span { color: var(--blue); }
.sidebar-note { margin: 2rem .45rem .4rem; color: #7b8798; font-size: .75rem; line-height: 1.5; }

main { min-width: 0; max-width: 1500px; width: 100%; padding: 1.6rem 2rem 3rem; }
.content-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.eyebrow { color: var(--blue); font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
.view[hidden] { display: none; }
.page-intro { margin-bottom: 1rem; color: var(--muted); }
.subnav { display: flex; gap: .5rem; margin-bottom: 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.subnav button.active { color: white; background: var(--blue); }
.registration-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.registration-heading p { margin: 0; }
.registration-tabs { flex-wrap: wrap; }
.registration-list-panel { margin-top: 0; }

#message { position: sticky; top: .5rem; z-index: 20; min-height: 2.5rem; padding: .7rem 1rem; margin-bottom: 1rem; border-radius: .55rem; box-shadow: 0 4px 14px rgba(25,50,90,.12); }
#message:empty { display: none; }
#message.ok { color: #0b5b35; background: #dcfce7; }
#message.error { color: #8d1d1d; background: #fee2e2; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.cards article { display: flex; flex-direction: column; gap: .35rem; padding: 1.15rem 1.25rem; background: white; border: 1px solid var(--line); border-radius: .75rem; box-shadow: 0 5px 18px rgba(25,50,90,.04); }
.cards strong { font-size: 2rem; color: var(--blue); }
.cards span { color: var(--muted); font-size: .82rem; }
.cards .danger-card strong { color: #b22b2b; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.overview-grid { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); }
.registration-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.registration-detail { grid-template-columns: minmax(280px, .38fr) minmax(0, 1fr); align-items: start; }
.releases-layout { grid-template-columns: minmax(280px, .42fr) minmax(0, 1fr); align-items: start; }
.script-editor-panel { max-width: 1050px; }
.panel { min-width: 0; padding: 1.25rem; margin-bottom: 1rem; background: white; border: 1px solid var(--line); border-radius: .75rem; box-shadow: 0 5px 18px rgba(25,50,90,.04); }
.form-card { align-self: start; }
.management-panel { margin-top: 1rem; }
.welcome-panel { padding: 1.5rem; }
.status-panel { color: white; background: linear-gradient(145deg, #12315f, #1769aa); border: 0; }
.status-panel .eyebrow { color: #75d4ff; }
.status-panel p { color: #d7ebfa; line-height: 1.6; }

.steps { display: grid; gap: .7rem; padding: 0; margin: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: .75rem; color: #4e5b6e; }
.steps li span { display: grid; place-items: center; flex: 0 0 28px; height: 28px; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-size: .75rem; font-weight: 800; }

form { display: grid; gap: .8rem; }
label { display: grid; gap: .3rem; color: #445066; font-size: .82rem; font-weight: 600; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: .68rem .72rem; color: #172033; background: white; border: 1px solid #bfc9d9; border-radius: .45rem; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
.sql-editor { min-height: 260px; resize: vertical; font-family: Consolas, "Courier New", monospace; font-size: .82rem; line-height: 1.45; }
button { padding: .68rem .95rem; color: white; background: var(--blue); border: 0; border-radius: .45rem; cursor: pointer; font-weight: 650; }
button:hover { filter: brightness(.96); }
button.secondary { color: var(--blue); background: var(--blue-soft); }
button.danger { color: #8d1d1d; background: #fee2e2; }
button:disabled { opacity: .5; cursor: not-allowed; }
.form-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-actions, .row-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; padding: 0; font-size: 1rem; }
td.row-actions { min-width: 118px; }
.client-picker-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.client-picker-title h4 { margin: 0; }
.check { display: flex; align-items: center; gap: .45rem; }
.check input { width: auto; }

.target-section { padding: .9rem; border: 1px solid #e3e8f0; border-radius: .6rem; background: #fafcff; }
.target-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .65rem; }
.target-title h4 { margin: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.choice-grid label { display: flex; align-items: start; gap: .55rem; padding: .65rem; background: white; border: 1px solid var(--line); border-radius: .45rem; }
.choice-grid label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.choice-grid input { width: auto; margin-top: .2rem; }
.choice-grid .choice-disabled { opacity: .58; background: #f1f3f6; cursor: not-allowed; }
.choice-grid.single-column { grid-template-columns: 1fr; max-height: 330px; overflow-y: auto; }
.script-editor-panel #scriptClientChoices { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: 320px; overflow-y: auto; }

.release-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.release { padding: .9rem; border: 1px solid var(--line); border-radius: .55rem; }
.release header { display: flex; justify-content: space-between; gap: 1rem; padding: 0; color: inherit; background: none; box-shadow: none; }
.release-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.badge { display: inline-block; padding: .2rem .48rem; border-radius: 1rem; background: var(--blue-soft); font-size: .72rem; }
.secret-output { white-space: pre-wrap; overflow-wrap: anywhere; padding: .8rem; background: #fff7d6; border-radius: .45rem; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; background: rgba(10, 27, 55, .58); }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.25rem; background: white; border-radius: .8rem; box-shadow: 0 24px 70px rgba(8, 25, 52, .35); }
.modal-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal-header h3 { margin: .2rem 0 0; }
.modal-close { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; padding: 0; font-size: 1.4rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem; text-align: left; border-bottom: 1px solid #e5e9f0; vertical-align: top; }
th { color: #566174; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.execution-detail { min-width: 220px; max-width: 420px; overflow-wrap: anywhere; }
.history-filters { display: grid; grid-template-columns: minmax(220px, 1fr) 150px 150px auto auto; align-items: end; gap: .7rem; padding: .9rem; margin-bottom: 1rem; background: #f8fafc; border: 1px solid var(--line); border-radius: .6rem; }
.catalog-filters { display: grid; grid-template-columns: minmax(260px, 1fr) 150px 190px auto; align-items: end; gap: .7rem; padding: .9rem; margin-bottom: 1rem; background: #f8fafc; border: 1px solid var(--line); border-radius: .6rem; }
.client-results { min-width: 260px; }
.execution-client { display: grid; grid-template-columns: auto 1fr; gap: 0 .35rem; padding: .25rem 0; }
.execution-client small { grid-column: 1 / -1; color: var(--muted); }
.execution-client.client-success strong { color: #087443; }
.execution-client.client-failed strong { color: #c51f2e; }
.execution-client.client-pending strong { color: #a56700; }
.client-success { color: #087443; }
.client-failed { color: #c51f2e; }
.client-pending { color: #a56700; }
.record-id { display: block; margin-top: .25rem; overflow-wrap: anywhere; }
.agent-help { margin-top: 1rem; padding: .75rem; background: #f8fafc; border: 1px solid var(--line); border-radius: .5rem; }
.agent-help summary { color: var(--blue); cursor: pointer; font-weight: 700; }
.agent-help p { margin: .7rem 0; line-height: 1.45; }
.agent-help pre { overflow-x: auto; padding: .7rem; background: #102a56; color: #e8f3ff; border-radius: .4rem; font-size: .75rem; }
td input[type="text"], td input:not([type]) { min-width: 180px; padding: .48rem .55rem; }
td input[type="checkbox"] { width: auto; }
.node-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.node-list article { padding: .7rem .85rem; border: 1px solid var(--line); border-radius: .45rem; }
.muted { color: var(--muted); font-size: .8rem; font-weight: 400; }

@media (max-width: 1050px) {
  .registration-grid { grid-template-columns: 1fr 1fr; }
  .release-list { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .session { flex-wrap: wrap; justify-content: space-between; }
  .app-shell { display: block; }
  .sidebar { padding: .65rem; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; min-width: max-content; }
  .nav-item { width: auto; }
  .sidebar-note { display: none; }
  main { padding: 1.2rem; }
  .registration-heading { align-items: stretch; flex-direction: column; }
  .registration-heading button { align-self: start; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid, .overview-grid, .registration-grid, .releases-layout, .form-columns, .choice-grid { grid-template-columns: 1fr; }
  .script-editor-panel #scriptClientChoices { grid-template-columns: 1fr; }
  .registration-detail, .history-filters, .catalog-filters { grid-template-columns: 1fr; }
}
