/* ══════════════════════════════════════════════════════════════════════
   /demo — in-browser imitation of the desktop app shell.
   Colours come from the md3.css tokens only (same palette as the app).
   ══════════════════════════════════════════════════════════════════════ */

.dm-body {
    margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
    background: var(--md-surface); color: var(--md-on-surface);
    font-family: var(--md-font); font-size: 14px; line-height: 1.4;
}
.dm-body *, .dm-body *::before, .dm-body *::after { box-sizing: border-box; }
.dm-body button, .dm-body select, .dm-body input { font: inherit; color: inherit; }
.dm-body h1, .dm-body h2, .dm-body h3, .dm-body p { margin: 0; }
.dm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dm-muted { color: var(--md-on-surface-variant); }
.dm-small { font-size: 13px; }
.dm-push { margin-left: auto; }
.dm-row { display: flex; flex-wrap: wrap; gap: 8px; }
.dm-row-end { justify-content: flex-end; }
.dm-body [hidden] { display: none !important; }

/* ── Site strip ─────────────────────────────────────────────────────── */
.dm-strip {
    flex: none; display: flex; align-items: center; gap: 16px; padding: 8px 16px;
    background: var(--md-primary-container); color: var(--md-on-primary-container);
    border-bottom: 1px solid var(--md-outline-variant);
}
.dm-strip-back { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; font-weight: 500; white-space: nowrap; }
.dm-strip-back:hover { text-decoration: underline; color: inherit; }
.dm-strip-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dm-strip-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: center; text-align: center; }
.dm-strip-link { flex: none; color: inherit; text-decoration: underline; white-space: nowrap; }
.dm-strip-link:hover { color: inherit; }
.dm-strip-cta {
    flex: none; padding: 6px 16px; border-radius: var(--md-r-full); white-space: nowrap;
    background: var(--md-primary); color: var(--md-on-primary); font-weight: 600; text-decoration: none;
}
.dm-strip-cta:hover { background: var(--md-primary-strong); color: var(--md-on-primary); text-decoration: none; }

/* ── App frame ──────────────────────────────────────────────────────── */
.dm-app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dm-head {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 10px 16px; background: var(--md-surface-container-low); border-bottom: 1px solid var(--md-outline-variant);
}
.dm-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dm-logo { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--md-r-xs); background: var(--md-secondary-container); color: var(--md-link); }
.dm-logo svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.dm-brand-name { font-size: 21px; font-weight: 300; white-space: nowrap; }
.dm-brand-name b { font-weight: 700; }
.dm-brand-sub { padding-left: 12px; border-left: 1px solid var(--md-outline-variant); font-size: 16px; font-weight: 500; }
.dm-badge { padding: 2px 10px; border-radius: var(--md-r-full); background: var(--md-warning-container); color: var(--md-on-warning-container); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.dm-head-right { display: flex; align-items: center; gap: 4px; }
.dm-head-btn { background: none; border: 0; padding: 6px 10px; border-radius: var(--md-r-xs); cursor: pointer; }
.dm-head-btn:hover { background: var(--md-surface-container-highest); }
.dm-head-tag { margin-left: 12px; text-align: right; font-size: 12px; color: var(--md-on-surface-variant); }

.dm-main { flex: 1; min-height: 0; display: flex; }

/* ── Rail ───────────────────────────────────────────────────────────── */
.dm-rail {
    flex: none; width: 176px; padding: 10px 7px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
    background: var(--md-surface-container-low); border-right: 1px solid var(--md-outline-variant);
}
.dm-rail hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--md-outline-variant); }
.dm-nav {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 10px; text-align: left;
    background: none; border: 0; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.dm-nav:hover { background: var(--md-surface-container-highest); }
.dm-nav.is-active { background: var(--md-primary); color: var(--md-on-primary); font-weight: 600; }
.dm-nav svg, .dm-search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dm-nav i, .dm-search i { display: inline-flex; }
.dm-rail-foot { margin-top: auto; padding: 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--md-on-surface-variant); }
.dm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--md-warning); display: inline-block; }
.dm-dot-idle { background: var(--md-secondary); }

/* ── Work area ──────────────────────────────────────────────────────── */
.dm-work { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.dm-vehicle {
    flex: none; display: flex; align-items: flex-end; gap: 14px; padding: 10px 14px;
    border-bottom: 1px solid var(--md-outline-variant);
}
.dm-vf { display: flex; flex-direction: column; gap: 3px; margin: 0; width: 240px; min-width: 0; font-size: 12px; color: var(--md-on-surface-variant); }
.dm-vf-file { flex: 1; width: auto; }
.dm-vf output {
    display: block; padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: var(--md-surface-container); border: 1px solid var(--md-outline-variant); border-radius: 4px;
    font-size: 14px; color: var(--md-on-surface);
}
.dm-sopsbox { flex: none; padding: 6px 12px; background: var(--md-surface-container); border: 1px solid var(--md-outline-variant); border-radius: 4px; font-size: 12px; color: var(--md-on-surface-variant); }
.dm-sopsbox code { color: var(--md-on-surface); font-size: 12.5px; background: none; padding: 0; }

.dm-view { flex: 1; min-height: 0; }
.dm-loading { padding: 40px 20px; text-align: center; color: var(--md-on-surface-variant); }

/* ── Home ───────────────────────────────────────────────────────────── */
.dm-home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.dm-card { padding: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; background: var(--md-surface-container); border: 1px solid var(--md-outline-variant); border-radius: 6px; }
.dm-card h3 { font-size: 17px; font-weight: 600; }

.dm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
    background: var(--md-surface-container); color: var(--md-on-surface); border: 1px solid var(--md-outline-variant); border-radius: 4px;
}
.dm-btn:hover { background: var(--md-surface-container-highest); color: var(--md-on-surface); text-decoration: none; }
.dm-btn-primary { background: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); font-weight: 600; }
.dm-btn-primary:hover { background: var(--md-primary-strong); border-color: var(--md-primary-strong); color: var(--md-on-primary); }
.dm-btn-sm { padding: 4px 10px; font-size: 13px; font-weight: 400; }
.dm-btn:disabled { opacity: .5; cursor: default; }

/* ── Parameters workbench ───────────────────────────────────────────── */
.dm-params { display: grid; grid-template-columns: 262px minmax(0, 1fr) 344px; gap: 10px; padding: 12px 14px; }
.dm-panel { min-height: 0; display: flex; flex-direction: column; background: var(--md-surface-container); border: 1px solid var(--md-outline-variant); border-radius: 6px; overflow: hidden; }
.dm-panel-h { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 40px; font-weight: 600; background: var(--md-surface-container-high); }
.dm-count { font-weight: 400; font-size: 12px; color: var(--md-on-surface-variant); }

.dm-tree { flex: 1; overflow-y: auto; padding: 4px; }
.dm-tree-select { display: none; }
.dm-tree-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 8px; text-align: left; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.dm-tree-item:hover { background: var(--md-surface-container-highest); }
.dm-tree-item.is-active { background: var(--md-primary); color: var(--md-on-primary); }
.dm-tree-item small { font-size: 11px; opacity: .75; }
.dm-tree-item.is-child { padding-left: 28px; }
.dm-tree-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-tree-label { padding: 6px 8px 2px; font-size: 13px; color: var(--md-on-surface-variant); }

.dm-notice { flex: none; margin: 8px 10px 0 !important; padding: 7px 10px; border-radius: 4px; font-size: 13px; background: var(--md-warning-container); color: var(--md-on-warning-container); }
.dm-notice a { color: inherit; font-weight: 600; text-decoration: underline; }
.dm-toolbar { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
.dm-search { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: var(--md-surface); border: 1px solid var(--md-outline-variant); border-radius: 4px; color: var(--md-on-surface-variant); }
.dm-search:focus-within { border-color: var(--md-primary); }
.dm-search input { flex: 1; min-width: 0; padding: 7px 0; background: none; border: 0; outline: 0; color: var(--md-on-surface); }
.dm-check { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; cursor: pointer; }

.dm-table-wrap { flex: 1; overflow-y: auto; }
.dm-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dm-table th { position: sticky; top: 0; z-index: 1; padding: 7px 10px; text-align: left; font-weight: 600; background: var(--md-surface-container-high); border-right: 1px solid var(--md-outline-variant); }
.dm-table th:nth-child(2) { width: 31%; }
.dm-table th:nth-child(3) { width: 104px; }
.dm-table td { padding: 3px 10px; height: 31px; border-bottom: 1px solid var(--md-outline-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-table tbody tr { cursor: pointer; }
.dm-table tbody tr:hover { background: var(--md-surface-container-highest); }
.dm-table tbody tr.is-selected { background: var(--md-primary-strong); color: var(--md-on-primary); }
.dm-table select, .dm-details select {
    width: 100%; padding: 3px 6px; background: var(--md-surface); color: var(--md-on-surface);
    border: 1px solid var(--md-outline-variant); border-radius: 3px;
}
.dm-mod { color: var(--md-warning); font-weight: 600; }
tr.is-selected .dm-mod { color: var(--md-on-warning-container); }
.dm-empty { padding: 24px; text-align: center; color: var(--md-on-surface-variant); }

.dm-details-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dm-details-close { display: none; margin-left: auto; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; }
.dm-dl { display: grid; grid-template-columns: 92px 1fr; gap: 6px 8px; margin: 0; }
.dm-dl dt { font-weight: 400; font-size: 12px; color: var(--md-on-surface-variant); padding-top: 2px; }
.dm-dl dd { margin: 0; overflow-wrap: anywhere; }
.dm-details select { padding: 7px 8px; }
.dm-allowed { margin: 0; padding-left: 18px; font-size: 13px; }
.dm-details-actions { flex: none; display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--md-outline-variant); }
.dm-details-actions .dm-btn { flex: 1; }

/* ── Other screens (home, XML, VCI screens, remote jobs) ────────────── */
.dm-page { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.dm-page > * { flex: none; }
.dm-page h2 { font-size: 22px; font-weight: 600; }
.dm-page-fill > .dm-fill { flex: 1; min-height: 220px; }
.dm-page > .dm-muted { max-width: 1100px; }
.dm-caps { text-transform: uppercase; letter-spacing: .04em; }
.dm-row-mid { align-items: center; gap: 10px 14px; }
.dm-inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.dm-page select, .dm-page input[type="search"], .dm-page input[type="number"], .dm-page input[type="text"] {
    padding: 6px 8px; background: var(--md-surface); color: var(--md-on-surface);
    border: 1px solid var(--md-outline-variant); border-radius: 4px;
}
.dm-notice-inline { margin: 0 !important; max-width: 1100px; }
.dm-card-wide { max-width: 760px; }
.dm-card-full { align-items: stretch; }
.dm-card-info { background: var(--md-secondary-container); }
.dm-bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.dm-field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.dm-result { padding: 8px 10px; border-radius: 4px; background: var(--md-secondary-container); }
.dm-dl-wide { grid-template-columns: minmax(0, 250px) 1fr; }
.dm-dl-wide dt { font-size: 14px; }
.dm-dl-wide dd { font-weight: 600; }

.dm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 1100px; }
.dm-stat { gap: 4px; }
.dm-stat-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--md-on-surface-variant); }
.dm-stat-n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.dm-stat-ok { color: var(--md-success); margin-right: 6px; }
.dm-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 1100px; }
.dm-tiles-3 { grid-template-columns: repeat(3, 1fr); max-width: 760px; }
.dm-tile {
    display: flex; flex-direction: column; gap: 2px; padding: 18px; text-align: left; cursor: pointer;
    background: var(--md-surface-container); border: 1px solid var(--md-outline-variant); border-radius: 6px;
}
.dm-tile b { font-size: 18px; }
.dm-tile span { font-size: 13px; opacity: .85; }
.dm-tile:hover { background: var(--md-surface-container-highest); }
.dm-tile-primary { background: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); }
.dm-tile-primary:hover { background: var(--md-primary-strong); }
.dm-tiles-3 .dm-tile { align-items: center; text-align: center; padding: 26px 12px; }
.dm-home-grid { max-width: 1100px; margin-top: 0; }
.dm-page > .dm-card { max-width: 1100px; }
.dm-page > .dm-card.dm-card-wide { max-width: 760px; }
.dm-page > .dm-card.dm-card-full { max-width: none; }

.dm-xml { flex: 1; min-height: 0; margin: 0; padding: 12px 14px; overflow: auto; font-family: var(--md-font-mono, Consolas, Menlo, monospace); font-size: 13px; line-height: 1.5; color: var(--md-on-surface); background: none; white-space: pre; }
.dm-xml mark { padding: 0; background: var(--md-warning-container); color: var(--md-on-warning-container); }
.dm-xml mark.is-current { background: var(--md-warning); color: var(--md-surface); }

.dm-grid { table-layout: auto; min-width: 720px; }
.dm-grid th:nth-child(n) { width: auto; }
.dm-grid tbody tr { cursor: default; }
.dm-grid td input { width: 100%; min-width: 120px; padding: 2px 6px !important; }
.dm-grid tr.dm-ro td { color: var(--md-on-surface-variant); }
.dm-scroll-x { overflow-x: auto; }

.dm-livebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 14px; border-radius: 6px; background: var(--md-secondary-container); }
.dm-gauges { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 6px; }
.dm-gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 6px; background: var(--md-surface); font-size: 13px; color: var(--md-on-surface-variant); }
.dm-gauge svg { width: 100%; max-width: 150px; }
.dm-gauge circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.dm-gauge-bg { stroke: var(--md-outline-variant); }
.dm-gauge-val { stroke: var(--md-primary); transition: stroke-dasharray .45s linear; }
.dm-gauge text { text-anchor: middle; fill: var(--md-on-surface); }
.dm-gauge-n { font-size: 17px; font-weight: 700; }
.dm-gauge-u { font-size: 9px; fill: var(--md-on-surface-variant) !important; }

.dm-jobs { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 12px; align-items: start; }
.dm-jobs-side { display: flex; flex-direction: column; gap: 12px; }
.dm-chat { width: 100%; flex-wrap: nowrap; }
.dm-chat input { flex: 1; min-width: 0; }

/* ── Status bar ─────────────────────────────────────────────────────── */
.dm-status { flex: none; display: flex; align-items: center; gap: 22px; padding: 5px 16px; font-size: 12.5px; background: var(--md-surface-container-low); border-top: 1px solid var(--md-outline-variant); white-space: nowrap; overflow: hidden; }
.dm-status-mod { color: var(--md-warning); }
.dm-noscript { padding: 24px; text-align: center; }

/* ── Dialog ─────────────────────────────────────────────────────────── */
.dm-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .6); }
.dm-modal-box { width: 100%; max-width: 460px; padding: 22px; display: flex; flex-direction: column; gap: 12px; background: var(--md-surface-container-high); border: 1px solid var(--md-outline-variant); border-radius: var(--md-r-sm); }
.dm-modal-box h2 { font-size: 19px; font-weight: 600; }
.dm-modal-box p { color: var(--md-on-surface-variant); }

.dm-body :focus-visible { outline: 2px solid var(--md-link); outline-offset: 1px; }

/* ── Narrower screens ───────────────────────────────────────────────── */
@media (max-width: 1180px) {
    .dm-params { grid-template-columns: 220px minmax(0, 1fr) 290px; }
    .dm-head-tag { display: none; }
    .dm-vf { width: 170px; }
}
@media (max-width: 900px) {
    .dm-body { height: auto; min-height: 100vh; overflow: auto; }
    .dm-strip { flex-wrap: wrap; gap: 6px 12px; }
    .dm-strip-text { order: 3; flex-basis: 100%; font-size: 13px; }
    .dm-strip-link { margin-left: auto; }
    .dm-main { flex-direction: column; }
    .dm-rail { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--md-outline-variant); }
    .dm-rail hr, .dm-rail-foot { display: none; }
    .dm-nav { width: auto; }
    .dm-vehicle { flex-wrap: wrap; }
    .dm-vf { width: calc(50% - 7px); }
    .dm-vf-file, .dm-sopsbox { display: none; }
    .dm-home-grid, .dm-stats, .dm-tiles, .dm-tiles-3, .dm-jobs { grid-template-columns: 1fr; }
    .dm-gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dm-page { padding: 14px 12px; overflow: visible; }
    .dm-xml { max-height: 70vh; }
    .dm-params { display: flex; flex-direction: column; padding: 10px; }
    .dm-groups .dm-panel-h, .dm-tree { display: none; }
    .dm-tree-select { display: block; width: 100%; padding: 9px 10px; background: var(--md-surface-container); color: var(--md-on-surface); border: 0; }
    .dm-list { min-height: 60vh; }
    .dm-table-wrap { max-height: 62vh; }
    .dm-toolbar { flex-wrap: wrap; }
    .dm-details { display: none; position: fixed; inset: auto 0 0 0; z-index: 40; max-height: 78vh; border-radius: 12px 12px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .5); }
    .dm-details.is-open { display: flex; }
    .dm-details-close { display: block; }
    .dm-status span:nth-child(n+4) { display: none; }
    .dm-brand-sub { display: none; }
}
