:root {
  --ink: #17262d;
  --muted: #657780;
  --line: #d9e3e7;
  --line-strong: #bdccd2;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --bg: #f1f5f6;
  --brand: #135d73;
  --brand-dark: #0c4355;
  --brand-soft: #e4f2f6;
  --ok: #217449;
  --ok-soft: #dff2e7;
  --warn: #916000;
  --warn-soft: #fff0c8;
  --danger: #a43939;
  --danger-soft: #f8dfdf;
  --shadow: 0 8px 26px rgba(24, 54, 65, 0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--brand); }
p { margin: 0 0 0.75rem; }
h1, h2, h3 { margin: 0; line-height: 1.18; }
h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.035em; }
h2 { font-size: 1.35rem; letter-spacing: -0.015em; }
h3 { font-size: 1.05rem; }
small { color: var(--muted); }

.topbar {
  min-height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 26px;
  background: #102f3b;
  color: white;
  box-shadow: 0 2px 12px rgba(9, 35, 45, 0.18);
}

.brand, .login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: #e9f7fa;
  color: var(--brand-dark);
  font-weight: 900;
}

.topbar nav { display: flex; align-self: stretch; align-items: center; gap: 4px; flex: 1; }
.topbar nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 11px;
  border-radius: 7px;
  color: #d7eaf0;
  text-decoration: none;
  white-space: nowrap;
}
.topbar nav a:hover, .topbar nav a.current { background: rgba(255,255,255,.1); color: white; }
.topbar nav a.current { box-shadow: inset 0 -2px #7cc2d4; }

.user-menu { display: flex; align-items: center; gap: 12px; }
.user-menu > span { display: grid; justify-items: end; line-height: 1.25; white-space: nowrap; }
.role-badge { color: #a9cad4; font-size: 11px; font-weight: 600; }
.card .role-badge { display: inline-block; padding: 3px 7px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 750; }

.container { max-width: 1440px; margin: 0 auto; padding: 34px; }
.container.narrow { max-width: 500px; padding-top: 10vh; }
.lead { max-width: 780px; margin: 9px 0 0; color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--brand); font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }

.page-title, .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}
.section-title { align-items: flex-start; margin-bottom: 18px; }
.section-title p { margin: 5px 0 0; }

.card, .metrics article, .help-grid article, .action-guide article, .glossary article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.card { padding: 24px; margin-bottom: 24px; }
.card .card { box-shadow: none; }
.login-card { padding: 36px; }
.login-brand { margin-bottom: 30px; color: var(--ink); }
.login-brand .brand-mark { background: var(--brand); color: white; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metrics article { padding: 20px; }
.metrics span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.metrics strong { display: block; margin: 4px 0; font-size: 29px; }
.metrics small { display: block; line-height: 1.35; }

.readiness-grid { display: grid; grid-template-columns: repeat(3, minmax(270px, 1fr)); gap: 16px; }
.readiness-card { padding: 18px; border: 1px solid var(--line); border-top: 4px solid var(--line-strong); border-radius: 11px; background: var(--surface-soft); }
.readiness-card.ready { border-top-color: var(--ok); }
.readiness-card.configured { border-top-color: var(--brand); }
.readiness-card.attention { border-top-color: #d39b22; }
.readiness-card.blocked { border-top-color: var(--danger); }
.readiness-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.readiness-badge { padding: 4px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: 10px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.ready .readiness-badge { background: var(--ok-soft); color: var(--ok); }
.attention .readiness-badge { background: var(--warn-soft); color: var(--warn); }
.blocked .readiness-badge { background: var(--danger-soft); color: var(--danger); }
.compact-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 16px 0; padding: 12px 0; border-block: 1px solid var(--line); }
.compact-stats div { padding: 0 8px; border-right: 1px solid var(--line); text-align: center; }
.compact-stats div:first-child { padding-left: 0; }
.compact-stats div:last-child { padding-right: 0; border: 0; }
.compact-stats dt { color: var(--muted); font-size: 10px; line-height: 1.25; }
.compact-stats dd { margin: 4px 0 0; font-size: 19px; font-weight: 800; }
.readiness-message strong, .readiness-action strong { display: block; color: var(--muted); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.readiness-message p { min-height: 42px; margin: 4px 0 12px; }
.readiness-action { padding: 10px 12px; border-radius: 8px; background: white; border: 1px solid var(--line); }
.readiness-action span { display: block; margin-top: 3px; }

.help-grid, .action-guide, .glossary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.help-grid article { display: flex; gap: 13px; padding: 17px; }
.help-grid article.warning { background: #fffaf0; border-color: #ecd8a8; }
.help-grid p, .action-guide p, .glossary p { margin: 4px 0 0; color: var(--muted); }
.help-number { display: grid; flex: 0 0 28px; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 850; }
.warning .help-number { background: var(--warn-soft); color: var(--warn); }
.action-guide article, .glossary article { padding: 17px 18px; }

.split { display: grid; grid-template-columns: minmax(310px, .78fr) minmax(540px, 1.5fr); gap: 22px; align-items: start; }
.content-grid { display: grid; grid-template-columns: minmax(500px, 1.4fr) minmax(260px, .6fr); gap: 22px; align-items: start; }
.sticky-card { position: sticky; top: 20px; }
.context-card { background: var(--surface-soft); }

.stack { display: grid; gap: 15px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 15px; align-items: end; }
.compact-form { grid-template-columns: minmax(230px, .8fr) minmax(300px, 1.2fr) minmax(170px, .5fr); }
label { display: grid; gap: 6px; color: #3f535c; font-size: 12px; font-weight: 700; }
.field-help { color: var(--muted); font-size: 11px; font-weight: 450; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font: inherit;
}
input:focus, select:focus { outline: 3px solid rgba(61, 145, 171, .2); border-color: #4d96ab; }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--brand);
  color: white;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--brand-dark); }
button.ghost, .button.ghost, .ghost { background: transparent; border-color: #9fb4bd; color: inherit; }
button.ghost:hover, .button.ghost:hover { background: rgba(19, 93, 115, .07); }
button.secondary { background: #e6f0f3; border-color: #c4d7dd; color: var(--brand-dark); }
button.secondary:hover { background: #d7e8ed; }
button.danger { background: var(--danger); }
button.danger:hover { background: #852d2d; }
button.danger-outline { background: white; border-color: #dba8a8; color: var(--danger); }
button.danger-outline:hover { background: var(--danger-soft); }
button.small, .button.small { min-height: 31px; padding: 5px 9px; font-size: 12px; }

.filters { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(160px, .35fr); gap: 12px; margin-bottom: 17px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.filters-wide { grid-template-columns: minmax(320px, 1fr) minmax(160px, .25fr); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
tbody tr:hover:not(.filter-empty) { background: #fafcfd; }
.table-link { font-weight: 800; text-decoration: none; }
.cell-note { display: block; margin-top: 3px; }
.message-cell { min-width: 320px; max-width: 660px; white-space: normal; overflow-wrap: anywhere; }
.progress-cell { min-width: 175px; }
.progress-block { display: grid; gap: 5px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 99px; background: #e5ecef; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.progress-copy { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; }
.progress-copy strong { color: var(--ink); }
.job-actions { display: flex; align-items: center; gap: 6px; }
.job-actions form { display: inline-flex; margin: 0; }
.failure-count { color: var(--danger); font-weight: 750; }

.status, .event-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 99px;
  background: #e7edf0;
  color: #435761;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.status.active, .status.completed, .status.ready, .event-badge.success { background: var(--ok-soft); color: var(--ok); }
.status.running, .status.queued, .status.leased, .status.uploading { background: var(--brand-soft); color: var(--brand); }
.status.awaiting-dataset, .status.cooldown, .status.paused, .status.completed-with-errors, .event-badge.warning { background: var(--warn-soft); color: var(--warn); }
.status.failed, .status.invalid, .status.cancelled, .status.disabled, .status.blocked, .event-badge.error { background: var(--danger-soft); color: var(--danger); }
.event-badge.neutral { background: #e7edf0; color: #435761; }

.credential-group { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.credential-group:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.credential-group-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.credential-group-title > span { color: var(--muted); font-size: 11px; }
.credential-list { display: grid; gap: 9px; }
.credential-row { display: grid; grid-template-columns: minmax(160px, 1fr) auto minmax(190px, 1fr) auto; align-items: center; gap: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.credential-row > div:first-child { display: grid; }
.credential-row > div:first-child span { color: var(--muted); font-size: 11px; }
.credential-row > div:nth-child(2) { display: grid; justify-items: start; gap: 5px; }
.credential-meta { display: grid; color: var(--muted); font-size: 11px; }

.processor-grid { display: grid; grid-template-columns: repeat(2, minmax(300px, 1fr)); gap: 14px; }
.rule-panel { padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.rule-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.rule-heading > div { display: grid; }
.rule-heading small { margin-top: 2px; }
.rule-form { grid-template-columns: 1.2fr .55fr .55fr; }
.rule-form .checkbox-field, .rule-form button { align-self: end; }
.checkbox-field { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.checkbox-field input, .weekday-picker input { width: auto; min-height: auto; margin: 0; }
.checkbox-field.fixed { color: var(--muted); }
.agreement-list { display: grid; gap: 12px; }
.agreement-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.agreement-panel[data-attention="true"] { border-left: 4px solid var(--danger); }
.agreement-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px; cursor: pointer; list-style-position: inside; }
.agreement-panel > summary > span:first-child { display: inline-grid; margin-left: 5px; }
.agreement-summary-state { display: flex; align-items: center; gap: 7px; }
.agreement-body { padding: 0 17px 17px; }
.readiness-explainer { padding: 14px; margin-bottom: 16px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); }
.readiness-explainer.blocked { background: var(--danger-soft); color: var(--danger); }
.readiness-explainer p { margin: 5px 0 0; }
.readiness-explainer ul { display: grid; gap: 8px; margin: 10px 0 0; padding-left: 20px; }
.readiness-explainer li span, .readiness-explainer li small { display: block; color: inherit; }
.readiness-explainer li small { opacity: .82; }
.agreement-form { display: grid; gap: 14px; }
.agreement-form fieldset { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 13px; margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.agreement-form legend { padding: 0 7px; color: var(--brand-dark); font-size: 12px; font-weight: 800; }
.weekday-picker { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; flex-wrap: wrap; }
.weekday-picker label { display: flex; align-items: center; gap: 5px; min-width: 58px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.schedule-copy { align-self: end; margin: 0; }
.form-actions { display: flex; justify-content: flex-end; }
.definition-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0; }
.definition-grid div { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.definition-grid dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.definition-grid dd { margin: 4px 0 0; font-weight: 700; }

.row-details { margin-top: 6px; max-width: 330px; color: var(--muted); font-size: 11px; white-space: normal; }
.row-details summary { cursor: pointer; color: var(--brand); font-weight: 700; }
.row-details p { margin: 5px 0 0; overflow-wrap: anywhere; }
.inline-warning { margin-top: 6px; max-width: 480px; color: var(--warn); font-size: 11px; white-space: normal; }
.inline-warning strong { display: block; margin-bottom: 4px; }

.flash, .error, .secret-reveal, .notice { padding: 14px 16px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 9px; }
.flash { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.flash.success { background: var(--ok-soft); border-color: #b9dfc8; color: var(--ok); }
.flash.warning, .notice.warning { background: var(--warn-soft); border-color: #ead398; color: #694600; }
.flash.error, .error { background: var(--danger-soft); border-color: #e8bcbc; color: var(--danger); }
.notice { display: flex; gap: 10px; background: var(--brand-soft); border-color: #bedde6; color: var(--brand-dark); }
.secret-reveal { background: var(--warn-soft); border-color: #e8cc6a; }
.secret-reveal code { display: block; margin: 9px 0; overflow-wrap: anywhere; font-size: 13px; }

.empty-state { padding: 26px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }
.empty-state p { margin-bottom: 11px; }
.plain-list { display: grid; gap: 9px; margin: 18px 0; padding-left: 20px; color: var(--muted); }
.form-note { margin-top: 20px; padding: 13px; border-radius: 8px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.form-note p { margin: 5px 0 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

@media (max-width: 1160px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 16px 22px; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .readiness-grid { grid-template-columns: repeat(2, minmax(270px, 1fr)); }
  .credential-row { grid-template-columns: minmax(150px, 1fr) auto; }
  .credential-meta { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .container { padding: 22px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .split, .content-grid, .form-grid, .compact-form { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .help-grid, .action-guide, .glossary { grid-template-columns: 1fr; }
  .processor-grid, .agreement-form fieldset, .definition-grid { grid-template-columns: 1fr; }
  .rule-form { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .page-title, .section-title { align-items: flex-start; flex-direction: column; }
  .readiness-grid, .metrics { grid-template-columns: 1fr; }
  .filters, .filters-wide { grid-template-columns: 1fr; }
  .user-menu > span { display: none; }
  .topbar { gap: 12px; }
  .topbar nav { margin-inline: -8px; }
  .credential-row { grid-template-columns: 1fr; }
  .credential-meta { grid-column: auto; }
  .job-actions { flex-wrap: wrap; }
  .agreement-panel > summary { align-items: flex-start; flex-direction: column; }
  .agreement-summary-state { flex-wrap: wrap; }
  h1 { font-size: 2rem; }
}
