:root {
  --ink: #17231f;
  --muted: #66716d;
  --paper: #f4f3ed;
  --panel: #fffefa;
  --line: #deddd5;
  --sidebar: #13221d;
  --sidebar-soft: #1d312a;
  --mint: #42d393;
  --mint-dark: #176f4d;
  --amber: #e3a82b;
  --red: #d85c4d;
  --blue: #4589ca;
  --shadow: 0 10px 35px rgba(23, 35, 31, .07);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: var(--mint-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1; letter-spacing: -.055em; }
h2 { margin-bottom: 8px; font-size: 1.15rem; letter-spacing: -.025em; }
small { display: block; color: var(--muted); line-height: 1.45; }
code { padding: 3px 6px; border-radius: 6px; background: #edeee8; font-size: .86rem; }

.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px 20px; background: var(--sidebar); color: #e8f0ec; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--mint); color: #10271f; font-weight: 900; box-shadow: inset 0 -4px 10px rgba(0,0,0,.12); }
.brand strong { display: block; font-size: 1.08rem; letter-spacing: -.02em; }
.brand small { color: #93aaa1; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 7px; margin-top: 46px; }
.nav-link { padding: 11px 13px; border-radius: 10px; color: #c8d6d0; font-size: .92rem; transition: .15s ease; }
.nav-link:hover { background: var(--sidebar-soft); color: #fff; text-decoration: none; transform: translateX(2px); }
.sidebar-foot { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 9px; margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.09); color: #8fa59c; font-size: .73rem; }
.sidebar-foot form { grid-column: 2; }
.environment-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px rgba(66,211,147,.1); }
.main { width: 100%; max-width: 1600px; padding: 44px clamp(24px, 4vw, 68px) 80px; overflow: hidden; }
.mobile-head { display: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.page-head > div:first-child { max-width: 850px; }
.lead { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.eyebrow { margin-bottom: 10px; color: var(--mint-dark); font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.title-line, .head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.title-line h1 { margin: 0; }
.head-actions form { margin: 0; }
.muted { color: var(--muted); }
.danger { color: var(--red) !important; }
.break-word { overflow-wrap: anywhere; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 750; font-size: .83rem; line-height: 1; text-decoration: none; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover { transform: translateY(-1px); text-decoration: none; }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-primary { background: var(--sidebar); color: #fff; box-shadow: 0 7px 18px rgba(19,34,29,.14); }
.button-primary:hover { background: #203c32; }
.button-secondary { border-color: #cad2cc; background: #fff; color: var(--ink); }
.button-secondary:hover { border-color: #9eaca5; }
.button-ghost { border-color: transparent; background: #eaeae4; color: var(--ink); }
.button-warning { background: #f6dfaa; color: #65460a; }
.button-danger { background: var(--red); color: #fff; }
.button-wide { width: 100%; }
.link-button { padding: 0; border: 0; background: none; color: var(--mint-dark); cursor: pointer; font: inherit; font-weight: 700; }
.sidebar .link-button { color: #b9c9c2; }

.flash, .notice { margin: 0 0 24px; padding: 14px 17px; border: 1px solid; border-radius: 12px; font-size: .9rem; line-height: 1.5; }
.flash-success { border-color: #aad9c2; background: #e3f5eb; color: #195d41; }
.flash-warning, .notice.warning { border-color: #e7c570; background: #fff5d9; color: #65460a; }
.flash-error, .notice.danger { border-color: #e5a79f; background: #fff0ed; color: #842b21; }
.notice strong { margin-right: 4px; }

.panel { margin-bottom: 24px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-head h2 { margin: 0; font-size: 1.35rem; }
.panel-head .eyebrow { margin-bottom: 5px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 24px; }
.panel-span-2 { min-width: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { min-height: 140px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.metric > span { display: block; color: var(--muted); font-size: .77rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.metric strong { display: block; margin: 13px 0 7px; font-size: 2.5rem; line-height: 1; letter-spacing: -.055em; }
.metric .metric-word { font-size: 1.7rem; }
.metric-alert { border-color: #e7aaa2; background: #fff8f6; }
.metric-alert strong { color: var(--red); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th { padding: 0 14px 11px; color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 14px; border-top: 1px solid #e8e8e1; vertical-align: top; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
td small { margin-top: 3px; max-width: 280px; }
.strong-link { color: var(--ink); font-weight: 800; }
.status { display: inline-flex; min-height: 24px; align-items: center; padding: 3px 9px; border-radius: 999px; background: #e9ebe7; color: #4f5b56; font-size: .66rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.status-active, .status-valid, .status-succeeded, .status-sent { background: #d9f4e7; color: #176844; }
.status-running, .status-queued, .status-pending { background: #dcecf9; color: #276591; }
.status-degraded, .status-warning, .status-retry, .status-paused { background: #fff0c7; color: #74500b; }
.status-failed, .status-invalid, .status-dead, .status-error { background: #fde2de; color: #922d23; }
.status-cancelled, .status-inactive, .status-unchecked, .status-skipped { background: #e9ebe7; color: #58625e; }
.status-deleting { background: #362f2d; color: #fff; }

.empty { grid-column: 1 / -1; padding: 48px 24px; text-align: center; color: var(--muted); }
.empty h2, .empty h3 { color: var(--ink); }
.empty.compact { padding: 18px; }
.worker-row { display: flex; align-items: flex-start; gap: 13px; padding: 12px 0; }
.worker-row strong { display: block; text-transform: capitalize; }
.pulse { width: 11px; height: 11px; margin-top: 4px; border-radius: 50%; background: #9da6a2; }
.pulse-active { background: var(--mint); box-shadow: 0 0 0 6px rgba(66,211,147,.13); }
.run-list { display: grid; }
.run-row { display: grid; grid-template-columns: 88px minmax(140px, 1fr) minmax(100px, .8fr) auto; align-items: center; gap: 15px; padding: 13px 0; border-top: 1px solid #e8e8e1; color: var(--ink); font-size: .83rem; }
.run-row:first-child { border-top: 0; }
.run-row:hover { text-decoration: none; }
.run-row time { color: var(--muted); text-align: right; }

.cards-grid, .profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.entity-card, .profile-card { position: relative; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.entity-top, .profile-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entity-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: #dff4e9; color: var(--mint-dark); font-weight: 900; }
.entity-card h2, .profile-card h2 { margin: 20px 0 4px; font-size: 1.35rem; }
.entity-handle, .profile-card > p { min-height: 42px; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.facts { display: grid; gap: 8px; margin: 20px 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid #e7e8e1; }
.facts dt { color: var(--muted); font-size: .75rem; }
.facts dd { margin: 0; text-align: right; font-size: .8rem; font-weight: 750; }
.facts.vertical > div { display: block; }
.facts.vertical dd { margin-top: 7px; text-align: left; }
.card-actions { display: flex; gap: 8px; margin-top: 18px; }
.disclosure { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.danger-zone-inline { margin-top: 18px; }
.inline-error { margin: 12px 0; padding: 10px; border-radius: 9px; background: #fff0ed; color: #842b21; font-size: .76rem; line-height: 1.4; }
.revision { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; }
.profile-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 20px 0; }
.profile-stat-row div { padding: 11px; border-radius: 11px; background: #f0f1eb; }
.profile-stat-row strong { display: block; font-size: 1.25rem; letter-spacing: -.04em; }
.profile-stat-row small { font-size: .66rem; text-transform: uppercase; }

.form-panel.narrow { max-width: 650px; }
.stack-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: #3f4a46; font-size: .78rem; font-weight: 750; }
label small { font-weight: 450; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #cfd3ce; border-radius: 9px; outline: none; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--mint-dark); box-shadow: 0 0 0 3px rgba(23,111,77,.12); }
input[type="checkbox"] { width: 18px; min-height: 18px; margin: 0; accent-color: var(--mint-dark); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.inline-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.inline-form select { width: auto; min-width: 130px; min-height: 36px; padding: 7px 9px; }

.wizard-form { display: grid; gap: 16px; padding-bottom: 86px; }
.wizard-step { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 18px; padding: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.step-number { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: #e8ebe5; color: #5a6661; font-family: ui-monospace, monospace; font-size: .74rem; font-weight: 850; }
.step-content > p { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.accent-step { border-color: #b1d9c6; background: #f6fff9; }
.accent-step .step-number { background: var(--mint); color: #113f2d; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.district-group { margin-top: 12px; }
.subregion-section { margin: 10px 0 0 18px; padding-left: 16px; border-left: 2px solid #d9ddd7; }
.subregion-section > p { margin: 0 0 9px; font-size: .78rem; }
.check-card, .big-toggle { display: flex; align-items: flex-start; gap: 11px; padding: 14px; border: 1px solid #d9ddd7; border-radius: 11px; background: #f9faf6; cursor: pointer; }
.check-card:has(input:checked), .big-toggle:has(input:checked) { border-color: #7fc8a5; background: #ecfbf3; box-shadow: inset 0 0 0 1px #7fc8a5; }
.check-card strong, .big-toggle strong { display: block; color: var(--ink); }
.toggle-line { display: flex; align-items: center; gap: 9px; align-self: end; min-height: 42px; padding: 11px; border-radius: 9px; background: #f2f3ed; }
.advanced { margin-top: 16px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; }
.advanced summary { cursor: pointer; font-size: .82rem; font-weight: 800; }
.advanced .field-grid { margin-top: 16px; }
.field-hint { display: block; margin: 4px 0 7px; color: var(--muted); font-size: .72rem; font-weight: 500; line-height: 1.35; }
.sticky-actions { position: fixed; z-index: 20; right: clamp(24px, 4vw, 68px); bottom: 18px; left: calc(244px + clamp(24px, 4vw, 68px)); display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: calc(1600px - 244px - clamp(48px, 8vw, 136px)); padding: 12px 16px; border: 1px solid rgba(222,221,213,.8); border-radius: 14px; background: rgba(255,254,250,.93); box-shadow: 0 14px 45px rgba(23,35,31,.16); backdrop-filter: blur(16px); }
.sticky-actions > span { color: var(--muted); font-size: .77rem; }
.sticky-actions > div { display: flex; gap: 8px; }

.profile-title { align-items: center; }
.profile-metrics { margin-top: 8px; }
.action-bar { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.action-bar h2 { margin-bottom: 4px; }
.action-bar p { margin: 0; color: var(--muted); font-size: .8rem; }
.source-summary { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-top: 1px solid #e8e8e1; }
.source-summary:first-of-type { border-top: 0; }
.source-summary > div:first-child { display: grid; grid-template-columns: 12px 1fr; align-items: center; column-gap: 9px; }
.source-summary > div:first-child small { grid-column: 2; }
.source-summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.source-summary dl div { min-width: 0; padding: 9px; border-radius: 9px; background: #f1f2ed; }
.source-summary dt { color: var(--muted); font-size: .68rem; }
.source-summary dd { margin: 4px 0 0; font-family: ui-monospace, monospace; font-size: .75rem; }
.source-off { opacity: .45; }
.source-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #9ca5a1; }
.source-dot.myhome { background: #2eb977; }
.source-dot.ss { background: #e66a9c; }
.source-dot.korter { background: #8b63d9; }
.tag { display: inline-flex; margin: 0 4px 4px 0; padding: 5px 8px; border-radius: 7px; background: #e8ebe5; font-size: .72rem; }
.danger-zone { border-color: #e5b2ab; box-shadow: none; }
.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 850; }
.danger-zone > div { margin-top: 18px; }

.source-run-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.source-run-grid article { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 14px; border-radius: 11px; background: #f1f2ed; }
.log-panel { background: #15231f; border-color: #15231f; color: #eaf1ed; }
.log-panel .eyebrow { color: var(--mint); }
.log-panel .panel-head { margin-bottom: 12px; }
.log-toolbar { display: flex; gap: 7px; margin-bottom: 13px; }
.chip { padding: 6px 9px; border: 1px solid #3b4a44; border-radius: 999px; background: transparent; color: #aebeb7; cursor: pointer; font-size: .65rem; font-weight: 800; }
.chip.active { border-color: var(--mint); background: rgba(66,211,147,.13); color: var(--mint); }
.live-indicator { color: #9dafA7; font-size: .72rem; }
.live-indicator.is-live { color: var(--mint); }
.live-indicator.is-live::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px rgba(66,211,147,.1); }
.log-stream { max-height: 640px; overflow: auto; border-top: 1px solid #33433d; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.log-line { display: grid; grid-template-columns: 72px 64px 95px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: .7rem; line-height: 1.5; }
.log-line time, .log-source { color: #85978f; }
.log-level { color: #9fb1a9; font-weight: 800; }
.log-line pre { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font: inherit; color: #dbe5e0; }
.log-WARNING .log-level { color: #f1c45e; }
.log-ERROR .log-level, .log-CRITICAL .log-level { color: #ff8173; }
.log-line[hidden] { display: none; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, #254e3e 0, #142720 36%, #0d1915 100%); }
.login-card { width: min(440px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: var(--panel); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login-brand { margin-bottom: 42px; color: var(--ink); }
.login-card h1 { font-size: 2.4rem; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid, .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 50; left: 0; transform: translateX(-105%); width: 260px; transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  body.menu-open .sidebar { transform: translateX(0); }
  .main { padding: 0 17px 72px; }
  .mobile-head { display: flex; align-items: center; justify-content: space-between; margin: 0 -17px 28px; padding: 14px 17px; background: var(--sidebar); color: #fff; }
  .mobile-head .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .menu-button { padding: 7px 10px; border: 1px solid #496057; border-radius: 8px; background: transparent; color: #d8e3de; }
  .page-head, .action-bar { display: grid; }
  .page-head .head-actions, .action-bar .head-actions { justify-content: flex-start; }
  .metric-grid, .cards-grid, .profile-grid, .content-grid { grid-template-columns: 1fr; }
  .run-row { grid-template-columns: 78px 1fr; }
  .run-row time { text-align: left; }
  .wizard-step { grid-template-columns: 1fr; padding: 19px; }
  .field-grid, .field-grid.three, .check-grid, .source-run-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .sticky-actions { right: 10px; bottom: 10px; left: 10px; display: grid; }
  .sticky-actions > div { justify-content: flex-end; }
  .source-summary { grid-template-columns: 1fr; }
  .source-summary dl { grid-template-columns: 1fr; }
  .log-line { grid-template-columns: 54px 52px minmax(0, 1fr); }
  .log-source { display: none; }
}

@media (max-width: 430px) {
  h1 { font-size: 2.1rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { min-height: 115px; padding: 15px; }
  .metric strong { font-size: 2rem; }
  .panel { padding: 18px; }
  .cards-grid, .profile-grid { grid-template-columns: 1fr; }
  .form-actions, .head-actions { align-items: stretch; }
  .head-actions .button, .head-actions form, .head-actions form .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
