/* SenArch Relay Simulator. Base look taken from gateway-setup's style.css. */
:root {
    --brand: #14544C;
    --brand-dark: #092421;
    --ink: #101828;
    --ink-2: #475467;
    --ink-3: #667085;
    --line: #e5e7eb;
    --line-2: #cfd6df;
    --surface: #ffffff;
    --page: #f7f8f8;
    --good: #0ca30c;
    --warning: #fab219;
    --critical: #d03b3b;
    --idle: #98a2b3;
    /* Chart series, fixed order (validated categorical palette). */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #008300;
    --series-7: #6250d6;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
        'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--page);
    color: var(--ink);
    font-size: 15px;
}

code {
    font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
    font-size: 0.92em;
    background: #f2f4f7;
    padding: 1px 4px;
    border-radius: 4px;
}

a { color: var(--brand); }
h2 { margin: 0 0 0.5rem; font-size: 24px; line-height: 1.2; }
h3 { margin: 1.6rem 0 0.6rem; font-size: 17px; }
h4 { margin: 1rem 0 0.4rem; font-size: 14px; }
.muted { color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 13px; line-height: 1.45; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Top bar */
.top-bar { background-color: var(--brand); color: white; padding: 0 20px; min-height: 72px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.top-bar-inner { max-width: 1200px; width: 100%; min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; box-sizing: border-box; }
.page-editor .top-bar-inner, .page-editor .content { max-width: none; }
.brand-block { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-link, .brand-link:visited, .brand-link:hover { color: #ffffff; text-decoration: none; }
.brand-logo { display: block; width: 112px; height: 41px; object-fit: contain; object-position: left center; flex: 0 0 auto; }
.app-title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.app-version { margin-top: 3px; color: rgba(255, 255, 255, 0.74); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.top-nav { display: flex; gap: 6px; flex: 1; margin-left: 12px; flex-wrap: wrap; }
.top-nav a { color: rgba(255, 255, 255, 0.82); text-decoration: none; font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 7px; }
.top-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.top-nav a.active { background: rgba(255, 255, 255, 0.18); color: #fff; }
.logout-form { margin: 0; }
.logout-button { border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 7px; background: rgba(255, 255, 255, 0.1); color: #ffffff; cursor: pointer; font-size: 14px; font-weight: 700; padding: 9px 16px; white-space: nowrap; }
.logout-button:hover { background: #ffffff; color: var(--brand); }

.content { padding: 28px 20px; max-width: 1200px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.page-editor .content { padding: 14px 16px 24px; }

.card { padding: 1.5rem; background-color: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 28px rgba(16, 24, 40, 0.06); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head p { margin: 0; max-width: 640px; }
.prose { line-height: 1.55; }
.prose li { margin-bottom: 6px; }

/* Buttons and inputs */
.green-button { background-color: var(--brand); color: white; border: none; padding: 9px 15px; cursor: pointer; font-size: 14px; border-radius: 7px; font-weight: bold; }
.green-button:disabled { background-color: #ccc; cursor: not-allowed; }
.green-button:not(:disabled):hover { background-color: var(--brand-dark); }
.green-button.danger-button { background-color: #dc2626; }
.green-button.danger-button:not(:disabled):hover { background-color: #b91c1c; }
.ghost-button { border: 1px solid #b8c0cc; border-radius: 7px; background: #ffffff; color: #344054; cursor: pointer; font-size: 14px; font-weight: 600; padding: 8px 14px; }
.ghost-button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.ghost-button:disabled { color: #98a2b3; cursor: not-allowed; }
.ghost-button.small, .green-button.small { padding: 6px 10px; font-size: 13px; }
.ghost-button.danger { color: #b42318; border-color: #f0b8b3; }
.ghost-button.danger:hover:not(:disabled) { border-color: #b42318; color: #b42318; background: #fef3f2; }
.link-button { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input, select, textarea.input { height: 38px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: #ffffff; color: var(--ink); font-size: 14px; box-sizing: border-box; font-family: inherit; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 84, 76, 0.12); }
select { cursor: pointer; padding-right: 28px; }
button:focus-visible, a:focus-visible, .canvas:focus-visible, input[type=checkbox]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Login */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 70vh; }
.login-form { background-color: #ffffff; padding: 2rem; border-radius: 1rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); width: 100%; max-width: 400px; text-align: center; }
.login-form h2 { color: var(--brand); margin-bottom: 1.5rem; }
.login-form .input { width: 100%; height: 42px; margin-bottom: 1rem; }
.login-form .green-button { width: 100%; padding: 12px; }
.settings-error { margin: 0 0 1rem; color: #dc2626; font-weight: bold; padding: 10px 16px; border-radius: 8px; background-color: #fee; border: 2px solid #dc2626; }
.status-icon { font-weight: bold; margin-right: 8px; }

/* Toasts and modals */
.toast-container { position: fixed; right: 20px; bottom: 20px; z-index: 1200; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.toast { min-width: 240px; max-width: min(420px, calc(100vw - 40px)); border-radius: 8px; padding: 12px 14px; color: #ffffff; font-size: 14px; font-weight: 700; line-height: 1.35; box-shadow: 0 12px 26px rgba(16, 24, 40, 0.18); transition: opacity 0.18s ease, transform 0.18s ease; }
.toast-success { background: var(--brand); }
.toast-error { background: #dc2626; }
.toast-info { background: var(--ink); }
.toast-hide { opacity: 0; transform: translateY(6px); }
.modal-backdrop { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(16, 24, 40, 0.56); box-sizing: border-box; }
.modal-card { width: min(100%, 480px); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #ffffff; box-shadow: 0 22px 48px rgba(16, 24, 40, 0.24); padding: 22px; box-sizing: border-box; }
.modal-card.wide { width: min(100%, 680px); }
.modal-card h4 { margin: 16px 0 8px; font-size: 14px; }
.modal-card h3 { margin: 0 0 10px; font-size: 20px; }
.modal-description { margin: 0 0 14px; color: var(--ink-2); line-height: 1.45; }
.modal-error { min-height: 20px; margin: 8px 0 0; color: #dc2626; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* Tables */
.table-scroll { overflow-x: auto; }
.table-scroll.tall { max-height: calc(100vh - 330px); min-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.data-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.data-table th { background: #f3f4f6; color: #4a4a4a; font-size: 12px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.02em; position: sticky; top: 0; z-index: 1; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table th.group { text-align: center; border-left: 2px solid #fff; }
.data-table tr.too-large td { color: #98a2b3; }
.data-table tr.selected td { background: #e8f3f1; }
.data-table tr.clickable { cursor: pointer; }
.data-table tbody tr:hover td { background: #f8fafc; }
.data-table tr.selected:hover td { background: #dcedea; }
.data-table tr.group-start td { border-top: 2px solid var(--line-2); }

/* Scenario list */
.scenario-list { display: grid; gap: 10px; }
.scenario-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; flex-wrap: wrap; }
.scenario-row:hover { border-color: var(--brand); }
.scenario-row h3 { margin: 0 0 4px; font-size: 17px; }
.scenario-row h3 a { text-decoration: none; }
.scenario-row h3 a:hover { text-decoration: underline; }
.scenario-row p { margin: 0; }
.empty-state { padding: 28px; text-align: center; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--ink-2); }

/* Calculator */
.calc-form { display: flex; gap: 18px; flex-wrap: wrap; margin: 16px 0 6px; }
.calc-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; max-width: 300px; }
.calc-form .hint { font-weight: 400; }
.calc-form .input, .calc-form select { width: 180px; }

/* Editor */
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.editor-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 260px; }
.back-link { text-decoration: none; font-size: 22px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.back-link:hover { background: #e8f3f1; }
.name-input { font-size: 18px; font-weight: 700; flex: 1; max-width: 460px; height: 40px; }
.dirty-flag { color: #b54708; font-weight: 600; font-size: 13px; white-space: nowrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 12px; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--brand); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.count-pill { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 10px; background: #eaecf0; color: var(--ink-2); font-size: 12px; text-align: center; }
.count-pill.over { background: #fee4e2; color: #b42318; }
.count-pill.ok { background: #dcfae6; color: #067647; }
.count-pill.stale, .count-pill.near { background: #fef0c7; color: #93370d; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 12px; align-items: start; }
.main-pane { min-width: 0; }
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
#pane-results, #pane-compare { padding: 18px; }
#pane-sensors { padding: 12px; }
.canvas-toolbar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tool-group { display: flex; gap: 6px; align-items: center; }
.tool-group + .tool-group { padding-left: 14px; border-left: 1px solid var(--line); }
.palette-item { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed #98a2b3; border-radius: 7px; background: #fff; padding: 5px 10px; font-size: 13px; font-weight: 600; cursor: grab; touch-action: none; color: var(--ink); }
.palette-item:hover, .palette-item.active { border-color: var(--brand); border-style: solid; background: #e8f3f1; }
.tool { border: 1px solid var(--line-2); background: #fff; border-radius: 7px; padding: 5px 10px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); min-width: 32px; }
.tool:hover { border-color: var(--brand); color: var(--brand); }
.tool.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.canvas-wrap { position: relative; height: calc(100vh - 322px); min-height: 420px; overflow: hidden; border-radius: 0 0 8px 8px; background: #fbfcfc; }
.canvas { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; cursor: default; }
.canvas.tool-pan { cursor: grab; }
.canvas.panning { cursor: grabbing; }
.canvas.placing { cursor: crosshair; }
.canvas-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; pointer-events: none; }
.canvas-legend { position: absolute; left: 10px; bottom: 10px; background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 12px; color: var(--ink-2); display: flex; gap: 12px; flex-wrap: wrap; max-width: calc(100% - 20px); box-sizing: border-box; }
.canvas-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.drag-ghost { position: fixed; z-index: 2000; pointer-events: none; transform: translate(-50%, -50%); opacity: 0.85; }

/* Canvas marks */
.gw-shape { stroke: #fff; stroke-width: 2; cursor: pointer; }
.gw-label { font-weight: 700; fill: var(--ink); text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: #fbfcfc; stroke-linejoin: round; }
.gw-sub { font-weight: 600; fill: var(--ink-2); text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: #fbfcfc; stroke-linejoin: round; }
.gw-sub.bad { fill: #b42318; }
.gw-letter { font-weight: 800; fill: #fff; text-anchor: middle; pointer-events: none; }
.sel-ring { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3 2; pointer-events: none; }
.sensor { cursor: pointer; stroke: #fff; stroke-width: 1; }
.sensor.own { fill: #475467; }
.sensor.foreign { fill: #fff; stroke: #475467; stroke-width: 1.5; }
.sensor.unheard { fill: #b42318; }
.sensor.sel { stroke: var(--ink); stroke-width: 2.5; }
.range-sensor { fill: rgba(20, 84, 76, 0.05); stroke: rgba(20, 84, 76, 0.45); stroke-width: 1; pointer-events: none; }
.range-mesh { fill: none; stroke: rgba(71, 84, 103, 0.4); stroke-width: 1; stroke-dasharray: 2 5; pointer-events: none; }
.slink { stroke: #98a2b3; stroke-width: 1; opacity: 0.7; pointer-events: none; }
.slink.range { stroke-dasharray: 4 3; }
.slink.off { stroke: var(--critical); stroke-dasharray: 1 4; opacity: 0.8; }
.glink { stroke: var(--brand); stroke-width: 2.5; pointer-events: none; }
.glink.range { stroke-dasharray: 8 5; }
.glink.off { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 2 5; }
.gw-shape, .sel-ring, .sensor, .range-sensor, .range-mesh, .slink, .glink, .lasso { vector-effect: non-scaling-stroke; }
.lasso { fill: rgba(20, 84, 76, 0.08); stroke: var(--brand); stroke-width: 1; stroke-dasharray: 4 3; pointer-events: none; }

/* Inspector */
.inspector { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; max-height: calc(100vh - 250px); overflow-y: auto; box-sizing: border-box; position: sticky; top: 10px; }
.inspector h3 { margin: 0 0 4px; font-size: 16px; }
.inspector h4 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 12px; }
.inspector p { margin: 4px 0 8px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 13px; }
.field.with-apply { grid-template-columns: 18px minmax(0, 1fr) 160px; }
/* A select gets the full width under its label, so that no option is cut off. */
.field.stacked { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.field.stacked.with-apply { grid-template-columns: 18px minmax(0, 1fr); }
.field.stacked.with-apply > select { grid-column: 1 / -1; }
.field.indent { margin-left: 24px; }
.field input[type=checkbox] { justify-self: start; }
.field .field-hint { grid-column: 1 / -1; margin: -2px 0 2px; color: var(--ink-3); font-size: 12px; line-height: 1.4; }
.field .tech { color: var(--ink-3); font-size: 11px; font-family: source-code-pro, Menlo, Monaco, Consolas, monospace; white-space: nowrap; }
.interval { display: flex; gap: 6px; min-width: 0; }
.interval .input { flex: 1 1 0; min-width: 0; }
.interval select { flex: 0 0 74px; width: 74px; padding-left: 6px; padding-right: 18px; }
.field label { color: var(--ink); }
.field .input, .field select { width: 100%; height: 32px; font-size: 13px; }
.field.wide { grid-template-columns: 1fr; }
.field .unit { color: var(--ink-3); font-size: 12px; }
.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 13px; }
.field-note { color: var(--ink-3); font-size: 12px; line-height: 1.4; margin: -3px 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.active { background: var(--brand); color: #fff; }
.bind-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 5px; }
.bind-row select { height: 30px; font-size: 12px; min-width: 190px; }
.warn-list { margin: 6px 0; padding: 8px 10px 8px 26px; background: #fffaeb; border: 1px solid #fedf89; border-radius: 7px; font-size: 13px; color: #7a2e0e; }
.warn-list li { margin-bottom: 3px; }
.stat-line { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.stat-line b { font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: #dcfae6; color: #067647; }
.badge.near { background: #fef0c7; color: #93370d; }
.badge.over { background: #fee4e2; color: #b42318; }
.badge.idle { background: #f2f4f7; color: var(--ink-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.fix-list { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; line-height: 1.45; }
.fix-list li { margin-bottom: 5px; }
.warn-box { margin: 10px 0 6px; padding: 8px 10px; background: #fffaeb; border: 1px solid #fedf89; border-radius: 7px; font-size: 13px; line-height: 1.45; color: #7a2e0e; }
.warn-text { color: #93370d; }

/* Collapsible groups: "Advanced", link lists, result details */
details.adv { border-top: 1px solid var(--line); margin-top: 12px; }
details.adv > summary { cursor: pointer; padding: 10px 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-2); list-style-position: inside; }
details.adv > summary:hover { color: var(--brand); }
details.adv > .adv-body { padding-bottom: 4px; }
.changed-pill { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 10px; background: #fef0c7; color: #93370d; font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; }
.modal-card details.adv { margin-top: 16px; }

/* Step bar */
.steps { list-style: none; display: flex; gap: 6px; margin: 0 0 10px; padding: 0; flex-wrap: wrap; }
.steps li { flex: 1 1 170px; min-width: 0; }
.step { display: flex; align-items: center; gap: 10px; width: 100%; height: 100%; box-sizing: border-box; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 7px 12px; cursor: pointer; font: inherit; color: var(--ink-2); }
.step:hover { border-color: var(--brand); }
.step-mark { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: #eaecf0; color: var(--ink-2); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.step-text { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 1.3; }
.step-text b { font-size: 14px; color: var(--ink); }
.step-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.done .step-mark { background: #dcfae6; color: #067647; }
.step.warn .step-mark { background: #fef0c7; color: #93370d; }
.step.current { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(20, 84, 76, 0.14); }
.step.current .step-mark { background: var(--brand); color: #fff; }
.step.verdict-over .step-mark { background: #fee4e2; color: #b42318; }
.step.verdict-near .step-mark, .step.verdict-warn .step-mark { background: #fef0c7; color: #93370d; }
.step.verdict-ok .step-mark { background: #dcfae6; color: #067647; }

/* Cards to pick from: sensor presets, templates */
.pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pick-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 10px; }
.pick-card { position: relative; display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 10px 9px 32px; cursor: pointer; background: #fff; }
.pick-card:hover { border-color: var(--brand); }
.pick-card input { position: absolute; left: 9px; top: 11px; margin: 0; }
.pick-card:has(input:checked) { border-color: var(--brand); background: #e8f3f1; box-shadow: 0 0 0 1px var(--brand); }
.pick-title { font-weight: 700; font-size: 14px; }
.pick-sub { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.template-card svg { width: 100%; height: 74px; display: block; margin-bottom: 4px; }

/* Note on an empty canvas */
.canvas-intro { position: absolute; top: 10px; left: 10px; width: min(360px, calc(100% - 20px)); box-sizing: border-box; background: #fff; border: 1px solid var(--brand); border-radius: 8px; padding: 12px 34px 12px 14px; font-size: 13px; line-height: 1.45; box-shadow: 0 8px 22px rgba(16, 24, 40, 0.12); }
.canvas-intro p { margin: 0 0 8px; }
.intro-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-3); padding: 4px 6px; }
.intro-close:hover { color: var(--ink); }

/* Sensor list */
.list-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.list-toolbar .input { width: 280px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; }
.chip { display: inline-block; background: #eef2f6; border-radius: 5px; padding: 1px 6px; margin: 0 3px 3px 0; font-size: 12px; white-space: nowrap; }
.chip.forced { background: #d1e9e5; font-weight: 600; }

/* Results */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0 4px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.tile .tile-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-2); font-weight: 600; }
.tile .tile-value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .tile-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.verdict { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line); border-left-width: 6px; border-radius: 8px; padding: 14px 16px; }
.verdict h2 { margin: 0 0 4px; font-size: 22px; }
.verdict p { margin: 0; color: var(--ink-2); }
.verdict p + p { margin-top: 10px; }
.verdict-icon { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; background: #eaecf0; color: var(--ink-2); }
.verdict-ok { border-left-color: var(--good); background: #f6fef9; }
.verdict-ok .verdict-icon { background: #dcfae6; color: #067647; }
.verdict-near, .verdict-warn { border-left-color: var(--warning); background: #fffcf5; }
.verdict-near .verdict-icon, .verdict-warn .verdict-icon { background: #fef0c7; color: #93370d; }
.verdict-over { border-left-color: var(--critical); background: #fffbfa; }
.verdict-over .verdict-icon { background: #fee4e2; color: #b42318; }
.verdict-empty { border-left-color: var(--idle); background: #f9fafb; }
.note-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; line-height: 1.45; }
.note-list li { padding: 8px 12px; border-radius: 7px; background: #f2f4f7; color: var(--ink); }
.note-list li.note-law { background: #fef3f2; border: 1px solid #fecdca; }
.note-list li.note-warn { background: #fffaeb; border: 1px solid #fedf89; color: #7a2e0e; }
.gw-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 14px; align-items: start; }
.gw-card { border: 1px solid var(--line); border-top-width: 4px; border-radius: 8px; padding: 12px 14px; }
.gw-card.ok { border-top-color: var(--good); }
.gw-card.near { border-top-color: var(--warning); }
.gw-card.over { border-top-color: var(--critical); }
.gw-card.idle { border-top-color: var(--idle); }
.gw-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.gw-card h3 { margin: 0; font-size: 16px; }
.gw-card h4 { margin: 12px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-2); }
.gw-level { margin: 10px 0 2px; }
.gw-level b { font-size: 20px; font-variant-numeric: tabular-nums; }
.gw-cause { margin: 10px 0 0; font-size: 14px; line-height: 1.45; }
.gw-card-foot { margin: 10px 0 0; font-size: 13px; }
.gw-card .fix-list { font-size: 14px; }
.results-details { margin-top: 18px; }
.results-details > summary { font-size: 14px; }
.results-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.meter { position: relative; height: 8px; background: #eaecf0; border-radius: 4px; min-width: 90px; margin-top: 4px; overflow: hidden; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px 0 0 4px; }
.meter i.ok { background: var(--good); }
.meter i.near { background: var(--warning); }
.meter i.over { background: var(--critical); }
.meter b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.stack { display: flex; height: 14px; gap: 2px; min-width: 160px; }
.stack i { display: block; height: 100%; min-width: 2px; border-radius: 3px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 6px 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.chart-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; position: relative; }
.chart-card h4 { margin: 0 0 2px; font-size: 14px; }
.chart-card .hint { margin: 0 0 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--ink-3); }
.chart .grid line { stroke: #eaecf0; }
.chart .limit { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .limit-label { font-size: 11px; fill: var(--critical); font-weight: 600; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .end-label { font-size: 11px; font-weight: 600; fill: var(--ink-2); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; z-index: 5; line-height: 1.5; }
.chart-tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dominant { margin: 0; padding-left: 18px; line-height: 1.6; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.stale-note { background: #fffaeb; border: 1px solid #fedf89; color: #7a2e0e; border-radius: 7px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.better { color: #067647; font-weight: 700; }
.worse { color: #b42318; font-weight: 700; }

@media (max-width: 980px) {
    .workspace { grid-template-columns: 1fr; }
    .inspector { position: static; max-height: none; }
    .canvas-wrap { height: 60vh; }
}
@media (max-width: 620px) {
    .pick-grid, .pick-grid.three { grid-template-columns: 1fr; }
    .top-bar { padding: 10px 16px; }
    .top-bar-inner { flex-wrap: wrap; gap: 10px; }
    .top-nav { order: 3; flex-basis: 100%; margin-left: 0; }
    .content { padding: 16px; }
    .chart-grid { grid-template-columns: 1fr; }
    .tool-group + .tool-group { padding-left: 0; border-left: 0; }
}
