:root {
  --ink: #20252b;
  --ink-soft: #555d68;
  --muted: #8b939d;
  --line: #e7e9ec;
  --line-strong: #d9dde2;
  --paper: #f7f8f9;
  --white: #fff;
  --blue: #5d7ea9;
  --blue-soft: #edf3fa;
  --orange: #c99552;
  --orange-soft: #fbf3e8;
  --green: #5d9975;
  --red: #bd6b6b;
  --shadow: 0 10px 30px rgba(32, 37, 43, .055);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
body.notice-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar { position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center; gap: 30px; padding: 0 max(28px, calc((100% - 1320px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; background: #fafbfc; color: var(--blue); font-size: 15px; }
.brand small, .brand strong { display: block; }
.brand small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.brand strong { margin-top: 1px; font-size: 14px; font-weight: 750; }
.top-nav { display: flex; align-items: center; gap: 3px; }
.nav-link { padding: 7px 12px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
.nav-link:hover, .nav-link:focus-visible, .nav-link.active { background: #f2f4f6; color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 13px; margin-left: auto; }
.health-link { color: var(--muted); font-size: 12px; }
.health-link:hover { color: var(--ink); }
.badge { padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fafbfc; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.ok { border-color: #d6e9dd; color: #4f8867; background: #f1f8f3; }
.badge.bad { border-color: #efd9d9; color: var(--red); background: #fff5f5; }
.profile-mark { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); background: #fafbfc; font-size: 11px; font-weight: 750; }

.shell { width: min(100% - 56px, 1320px); margin: 0 auto; padding: 38px 0 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 3px 23px; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.page-heading h1 { margin: 7px 0 4px; font-size: clamp(28px, 3.2vw, 40px); line-height: 1.08; letter-spacing: -.045em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.workspace-meta { display: inline-flex; align-items: center; gap: 7px; padding-bottom: 5px; color: var(--muted); font-size: 12px; }
.workspace-meta i { color: var(--green); }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.workspace-section, .query-panel, .routes-panel { scroll-margin-top: 88px; }

.overview-card { padding: 24px 27px 20px; }
.overview-topline, .card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.module-heading { display: flex; align-items: flex-start; gap: 11px; }
.module-icon { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--blue); background: var(--blue-soft); font-size: 14px; }
.module-icon.neutral { color: #7f8790; background: #f2f4f5; }
.module-icon.blue-soft { color: var(--blue); background: var(--blue-soft); }
.module-icon.orange-soft { color: var(--orange); background: var(--orange-soft); }
h2 { margin: 0; font-size: 17px; line-height: 1.25; letter-spacing: -.025em; }
.module-heading p, .card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.overview-controls { display: flex; align-items: center; gap: 17px; }
.select-compact, select, input, textarea { border: 1px solid var(--line-strong); border-radius: 8px; outline: none; color: var(--ink); background: #fff; transition: border-color .16s, box-shadow .16s, background .16s; }
.select-compact { min-width: 106px; padding: 7px 10px; font-size: 12px; }
select, input { min-height: 38px; padding: 8px 11px; }
input:focus, textarea:focus, select:focus { border-color: #9eb1ca; box-shadow: 0 0 0 3px rgba(93,126,169,.12); }
.text-switches { display: flex; gap: 3px; }
.text-switch, .text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.text-switch { padding: 7px 8px; border-bottom: 2px solid transparent; font-weight: 700; }
.text-switch:hover, .text-switch:focus-visible, .text-switch.active { border-bottom-color: var(--blue); color: var(--ink); }
.text-button { padding: 2px 0; font-weight: 700; }
.text-button:hover, .text-button:focus-visible { color: var(--blue); }
.text-button:disabled { cursor: not-allowed; opacity: .4; }
.icon-text-button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-lines { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 20px; color: var(--ink-soft); font-size: 12px; }
.status-line { display: inline-flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.status-dot.blue { background: #6d91bd; }
.status-dot.orange { background: #d4a05d; }
.heatmap-wrap { position: relative; margin-top: 17px; padding: 14px 16px 12px; border-top: 1px solid var(--line); background: #fcfcfd; }
.heatmap { display: grid; grid-template-columns: repeat(28, minmax(7px, 1fr)); grid-auto-rows: 11px; gap: 4px; min-height: 41px; }
.heat-cell { width: 100%; height: 100%; display: block; border-radius: 2px; background: #f0f1f2; }
.heatmap .level-0, .heatmap-legend .level-0 { background: #eff0f1; }
.heatmap .level-1, .heatmap-legend .level-1 { background: #f2d9d5; }
.heatmap .level-2, .heatmap-legend .level-2 { background: #d9e9d8; }
.heatmap .level-3, .heatmap-legend .level-3 { background: #9cc6a7; }
.heatmap .level-4, .heatmap-legend .level-4 { background: #4f8d68; }
.heatmap-legend { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.heatmap-legend .heat-cell { width: 11px; height: 11px; }

.workspace-grid, .secondary-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; }
.workspace-section > .workspace-grid { margin-top: 0; }
.work-card, .data-card { min-width: 0; padding: 24px 26px; }
.card-count { color: #c3c8ce; font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.form-stack { display: grid; gap: 15px; margin-top: 21px; }
.form-group { display: grid; gap: 7px; }
.field-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-soft); font-size: 12px; font-weight: 750; }
.field-hint { color: var(--muted); font-size: 11px; font-weight: 500; }
.inline-actions { display: inline-flex; gap: 12px; margin-left: auto; }
#credentials { width: 100%; min-height: 144px; resize: vertical; font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; }
#task-name { width: 100%; }
.domain-summary { min-height: 15px; color: var(--blue); font-size: 11px; }
.domain-summary.bad { color: var(--red); }
.check-stack { display: grid; gap: 10px; padding-top: 1px; }
.check-line { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 12px; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; margin: 0; accent-color: #6c8daf; }
.card-footer-action { display: block; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.primary-action, .dark-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border: 0; border-radius: 8px; padding: 10px 17px; color: #fff; background: #30353b; font-weight: 750; box-shadow: 0 5px 12px rgba(32,37,43,.12); transition: background .16s, transform .16s, box-shadow .16s; }
.primary-action { width: 100%; }
.primary-action:hover, .dark-button:hover { background: #171b1f; transform: translateY(-1px); box-shadow: 0 8px 16px rgba(32,37,43,.15); }
.action-status { min-width: 0; font-size: 11px; }
.card-footer-action .action-status { display: block; margin-top: 8px; }
.muted { color: var(--muted); }
.result-card { min-height: 100%; }
.compact-heading { align-items: flex-start; }
.empty-state { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; margin-top: 20px; border: 1px dashed #d9dde2; border-radius: 10px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink-soft); font-size: 13px; font-weight: 750; }
.empty-state > span:last-child { max-width: 250px; font-size: 11px; }
.empty-ring { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 5px; border: 1px dashed #aeb8c4; border-radius: 50%; color: #9aa7b4; font-size: 16px; }
.result-block { margin-top: 20px; }
.result-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.result-hint { color: var(--muted); font-weight: 500; }
.result-block textarea { width: 100%; min-height: 240px; resize: vertical; color: var(--ink); font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }

.secondary-grid { align-items: start; margin-top: 20px; }
.query-input { width: 100%; min-height: 92px; margin-top: 20px; resize: vertical; font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.query-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.inline-field { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.inline-field input { width: 72px; min-height: 34px; padding: 6px 8px; }
.dark-button { min-height: 36px; padding: 8px 13px; font-size: 12px; }
.query-results-wrap, .table-wrap { width: 100%; max-width: 100%; overflow: auto; margin-top: 17px; }
table { width: 100%; border-collapse: collapse; min-width: 690px; }
th, td { padding: 11px 9px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #fbfbfc; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
td { color: var(--ink-soft); font-size: 12px; }
.row-number { width: 35px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status { display: inline-flex; padding: 3px 7px; border-radius: 999px; color: var(--muted); background: #f1f2f3; font-size: 10px; font-weight: 750; }
.status.ready { color: #4f8866; background: #eff7f1; }
.status.bad, .query-error { color: var(--red); background: #fff2f2; }
.query-ok { color: #4f8866; }
.code-value { color: var(--ink); font: 750 13px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .07em; }
.route { display: block; max-width: 330px; overflow: hidden; color: var(--blue); text-overflow: ellipsis; white-space: nowrap; font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.route-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 20px; color: var(--muted); font-size: 11px; }
.route-summary strong { color: var(--ink); font-size: 16px; }
.route-summary .text-button { margin-left: auto; }
.empty { padding: 30px 14px; color: var(--muted); text-align: center; }

.notice-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(32,37,43,.28); }
.notice-dialog[hidden] { display: none; }
.notice-card { width: min(100%, 500px); padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 22px 70px rgba(32,37,43,.18); }
.notice-head, .notice-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice-card h2 { margin: 18px 0 10px; font-size: 21px; }
.notice-card p { color: var(--ink-soft); font-size: 13px; }
.notice-dismiss { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.notice-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 20px; color: var(--blue); font-size: 12px; font-weight: 700; }
.notice-actions { justify-content: flex-end; margin-top: 25px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; max-width: min(90vw, 480px); padding: 10px 15px; border-radius: 8px; color: #fff; background: #30353b; box-shadow: 0 10px 25px rgba(32,37,43,.18); opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9e5c5c; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .topbar { gap: 18px; padding: 0 20px; }
  .health-link { display: none; }
  .shell { width: min(100% - 36px, 700px); padding-top: 28px; }
  .overview-controls { align-items: flex-end; flex-direction: column; gap: 8px; }
  .workspace-grid, .secondary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { min-height: 62px; padding: 0 14px; }
  .top-nav { gap: 0; margin-left: auto; }
  .nav-link { padding: 6px 7px; font-size: 11px; }
  .top-actions { display: none; }
  .shell { width: min(100% - 24px, 520px); padding-top: 23px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-heading h1 { font-size: 30px; }
  .overview-card, .work-card, .data-card { padding: 19px 17px; }
  .overview-topline, .card-heading { flex-direction: column; }
  .overview-controls { width: 100%; align-items: stretch; flex-direction: row; justify-content: space-between; }
  .select-compact { min-width: 98px; }
  .heatmap-wrap { padding-inline: 4px; }
  .heatmap { grid-template-columns: repeat(14, minmax(8px, 1fr)); grid-auto-rows: 12px; }
  .card-count { display: none; }
  .route-summary .text-button { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
