/* Calibration — standard curve fitting & inverse workbench.
   Visual language mirrors WBBubblechart (frosted rail, quiet white cards, warm accent).
   The whole shell is rendered at 110% with body zoom + compensated width/height. */

:root {
    color-scheme: light;
    --ink: #1c1c1e;
    --ink-soft: #48484e;
    --muted: #73737a;
    --muted-2: #8e8e93;
    --muted-3: #a6a6ae;
    --line: #e5e5ea;
    --line-soft: #f0f0f4;
    --gray: #f2f2f7;
    --well: #f6f6f9;
    --surface: #fff;
    --accent: #ff9500;
    --accent-deep: #d67d00;
    --accent-soft: #fff7eb;
    --accent-soft-2: #ffefd7;
    --accent-ink: #805218;
    --fit: #c4603e;
    --fit-soft: #f7e8df;
    --blue: #007aff;
    --blue-soft: #eaf3ff;
    --green: #34c759;
    --green-ink: #248a3d;
    --green-soft: #eef9f0;
    --red: #c0584b;
    --red-soft: #fff0ee;
    --radius: 20px;
    --shadow: 0 4px 24px #1c1c1e06, 0 1px 3px #1c1c1e03;
    --shadow-lift: 0 10px 32px #1c1c1e10;
    --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
    --ease: cubic-bezier(.25, .46, .45, .94);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--gray); }
body {
    margin: 0;
    min-width: 320px;
    width: 100%;
    height: 100dvh;
    background: var(--gray);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    zoom: 1.1; /* requested 110% presentation */
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 650; line-height: 1.35; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .4; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #8bc2ff; outline-offset: 2px; }
::selection { color: #004a9c; background: #dcecff; }
small { font-size: 10px; }
code, .q-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- shell */
.app-shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(220px, .88fr) minmax(0, 3.3fr) minmax(248px, 1.02fr);
    gap: 14px;
    width: 100%;
    height: 100%;
    padding: 12px;
    margin: 0 auto;
    max-width: none;
}
.q-rail {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #ffffffbf;
    border: 1px solid #ffffffb3;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.q-main {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 3px;
    scrollbar-width: thin;
    scrollbar-color: #d5d5dc transparent;
    scroll-behavior: smooth;
}
.q-context {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 3px;
    scrollbar-width: thin;
    scrollbar-color: #d5d5dc transparent;
}
.q-skip { position: fixed; top: -60px; left: 16px; z-index: 15000; padding: 9px 16px; border-radius: 10px; background: var(--ink); color: #fff; }
.q-skip:focus { top: 12px; }

/* ------------------------------------------------------------- brand & steps */
.q-brand-block { flex: none; display: flex; flex-direction: column; gap: 12px; padding: 20px 16px 14px; }
.q-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.q-brand-mark { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; color: #fff; border: 1px solid #ffffff66; background: linear-gradient(145deg, #ffb341, #f28d00); box-shadow: 0 4px 12px #f29b1924, inset 0 1px #ffffff70; }
.q-brand-mark svg { width: 24px; height: 24px; }
.q-brand-copy { display: grid; gap: 1px; min-width: 0; line-height: 1.35; }
.q-brand-copy strong { font-size: 16px; letter-spacing: -.5px; font-weight: 650; }
.q-brand-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--muted-2); }
.q-status { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 9px; border: 1px solid #d9efdd; border-radius: 999px; color: var(--green-ink); background: #effaf1; font-size: 10px; white-space: nowrap; overflow: hidden; }
.q-status > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.q-status-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #34c75912; }
.q-status.is-saving { color: #ad6a10; background: #fff7e8; border-color: #f3dfbc; }
.q-status.is-saving .q-status-dot { background: var(--accent); box-shadow: 0 0 0 3px #ff950014; }
.q-status.is-local { color: var(--muted-2); background: #f4f4f8; border-color: #e9e9ef; }
.q-status.is-local .q-status-dot { background: #b8b8be; box-shadow: none; }

.q-steps { flex: none; display: grid; gap: 5px; margin: 0 12px; padding: 0 0 15px; border-bottom: 1px solid #e8e8ee; }
.q-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; gap: 0 10px; min-width: 0; min-height: 47px; padding: 6px 9px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--ink); text-align: left; transition: background .18s, box-shadow .18s; }
.q-step:hover:not(.is-active) { background: #f0f0f5; }
.q-step-no { grid-row: 1 / 3; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #f0f0f5; color: var(--muted-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.q-step-no .bi { font-size: 14px; }
.q-step-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-step-state { font-size: 9.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-step.is-active { background: var(--ink); box-shadow: 0 4px 12px #1c1c1e12; }
.q-step.is-active .q-step-name { color: #fff; }
.q-step.is-active .q-step-state { color: #bcbcc2; }
.q-step.is-active .q-step-no { background: #ffffff1a; color: #fff; }
.q-step.is-complete:not(.is-active) .q-step-no { background: var(--green-soft); color: var(--green-ink); font-size: 0; }
.q-step.is-complete:not(.is-active) .q-step-no::before { content: '✓'; font-size: 14px; }
.q-guide-btn { background: var(--accent-soft); }
.q-guide-btn:hover { background: var(--accent-soft-2); }
.q-guide-btn .q-step-name { color: var(--accent-ink); }
.q-guide-btn .q-step-state { color: #a9782c; }
.q-guide-btn .q-step-no { background: #ffe7c2; color: var(--accent-ink); }

/* ------------------------------------------------------------- sidebar model & points */
.q-side-model { flex: none; display: flex; flex-direction: column; gap: 3px; margin: 12px 12px 0; padding: 11px 12px; border: 1px solid #f1e2cc; border-radius: 14px; background: linear-gradient(135deg, #fffaf2, #fffdf9); cursor: pointer; transition: box-shadow .18s, border-color .18s; }
.q-side-model:hover { border-color: #e7cda7; box-shadow: 0 5px 16px #1c1c1e08; }
.q-side-model-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted-2); font-size: 9px; }
.q-side-model strong { display: flex; align-items: baseline; gap: 7px; font-size: 15px; letter-spacing: -.4px; }
.q-side-model strong small { color: var(--muted-2); font-size: 9px; font-weight: 400; letter-spacing: 0; }
.q-side-model > span { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }
.q-points-panel { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 0 12px; }
.q-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 3px 8px; }
.q-panel-title { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink-soft); font-size: 11px; font-weight: 600; }
.q-panel-title .bi { color: var(--muted-2); font-size: 12px; }
.q-count { display: inline-grid; place-items: center; min-width: 18px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--gray); color: var(--muted); font-size: 9px; font-weight: 500; }
.q-add-mini { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 11px; }
.q-add-mini:hover { background: var(--gray); color: var(--ink); }
.q-point-list { flex: 1 1 auto; min-height: 70px; overflow-y: auto; overflow-x: hidden; padding: 1px 1px 6px; scrollbar-width: thin; scrollbar-color: #dedee5 transparent; }
.q-point-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 35px; margin: 1px 0; padding: 5px 7px; border: 0; border-radius: 9px; background: transparent; text-align: left; color: var(--ink); min-width: 0; }
.q-point-row:hover { background: var(--gray); }
.q-point-row.is-active { background: var(--accent-soft); box-shadow: inset 2px 0 var(--accent); }
.q-point-index { flex: 0 0 20px; color: var(--muted-3); font-family: var(--mono); font-size: 8.5px; font-variant-numeric: tabular-nums; }
.q-point-copy { display: flex; flex: 1; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.q-point-copy b { color: var(--ink-soft); font-size: 10.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.q-point-copy small { color: var(--muted-3); font-size: 9px; font-variant-numeric: tabular-nums; }
.q-point-dot { width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: #d7d7de; }
.q-point-dot.is-warn { background: var(--red); box-shadow: 0 0 0 3px #c0584b14; }
.q-point-dot.is-good { background: #a7c7b2; }
.q-point-row.is-active .q-point-copy b { color: #7a4d0d; }
.q-side-batch { flex: none; display: flex; align-items: center; gap: 8px; margin: 0 12px 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: #ffffffa6; cursor: pointer; transition: background .18s, border-color .18s; }
.q-side-batch:hover { background: #fff; border-color: #dcdce4; }
.q-side-batch-icon { display: grid; place-items: center; width: 27px; height: 27px; flex: 0 0 27px; border-radius: 9px; background: var(--blue-soft); color: #2d72b8; font-size: 12px; }
.q-side-batch-copy { display: grid; gap: 1px; min-width: 0; flex: 1; }
.q-side-batch-copy strong { font-size: 10px; font-weight: 600; }
.q-side-batch-copy small { color: var(--muted-3); font-size: 8.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-side-batch > .bi { color: var(--muted-3); font-size: 10px; }
.q-list-hint { flex: none; margin: 0 2px 9px; color: var(--muted-3); font-size: 8.5px; line-height: 1.55; }
.q-rail-footer { flex: none; margin-top: auto; position: relative; z-index: 30; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 9px 12px 10px; border-top: 1px solid #e8e8ee; }
.q-rail-footer > .q-btn { flex: 1; }
.q-utility { flex: 1; position: relative; }
.q-utility > summary { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 10px; background: #ffffff80; color: var(--muted); font-size: 11px; list-style: none; }
.q-utility > summary::-webkit-details-marker { display: none; }
.q-utility[open] > summary { background: var(--gray); }
.q-utility-pop { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 500; display: grid; gap: 2px; width: 214px; padding: 6px; border: 1px solid #fff; border-radius: 14px; background: #ffffffed; box-shadow: 0 12px 40px #1c1c1e20; backdrop-filter: blur(20px); }
.q-utility-pop button { min-height: 33px; padding: 7px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); text-align: left; font-size: 11px; }
.q-utility-pop button:hover { background: var(--gray); }
.q-utility-pop button.danger { color: var(--red); background: var(--red-soft); }
.q-storage-note { flex: 0 0 100%; display: flex; align-items: center; gap: 6px; padding: 6px 3px 0; color: var(--muted-3); font-size: 8.5px; }
.q-storage-note .bi { font-size: 10px; }

/* ------------------------------------------------------------- shared controls */
.q-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 6px 11px; border: 1px solid transparent; border-radius: 10px; background: var(--gray); color: var(--ink-soft); font-size: 11px; font-weight: 500; white-space: nowrap; transition: background .18s, box-shadow .18s, transform .18s; }
.q-btn:hover:not(:disabled) { background: #e9e9ef; transform: translateY(-1px); box-shadow: 0 3px 8px #1c1c1e08; }
.q-btn:active:not(:disabled) { transform: scale(.98); }
.q-btn .bi { font-size: 12px; }
.q-btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: 0 3px 8px #1c1c1e0d; }
.q-btn.primary:hover:not(:disabled) { background: #343436; }
.q-btn.quiet { background: #fff; border-color: var(--line); color: var(--muted); }
.q-btn.quiet:hover:not(:disabled) { background: var(--well); }
.q-btn.compact { min-height: 27px; padding: 4px 8px; border-radius: 8px; font-size: 10px; }
.q-btn.accent { background: var(--accent-soft); border-color: #f2ddbd; color: var(--accent-ink); }
.q-btn.accent:hover:not(:disabled) { background: var(--accent-soft-2); }
.q-btn.danger { background: var(--red-soft); color: var(--red); }
.q-segmented { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: var(--gray); }
.q-segmented button { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 4px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 500; }
.q-segmented button .bi { font-size: 10px; }
.q-segmented button:hover { color: var(--ink); }
.q-segmented button.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px #1c1c1e12; }
.q-pill, .q-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: var(--well); color: var(--muted); font-size: 9px; white-space: nowrap; }
.q-pill .bi { font-size: 10px; }
.q-pill.warm { color: var(--accent-ink); background: var(--accent-soft); }
.q-pill.green { color: var(--green-ink); background: var(--green-soft); }
.q-chip { padding: 2px 7px; font-size: 8.5px; }
.q-chip.hit { color: #a4372f; background: #fff0ed; }
.q-chip.calm { color: #4c7b5d; background: var(--green-soft); }
.q-chip.warn { color: #9a6a22; background: var(--accent-soft); }
.q-chip.bad { color: #a4372f; background: var(--red-soft); }
.q-chip.blue { color: #1b62b3; background: var(--blue-soft); }
.q-switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9.5px; white-space: nowrap; cursor: pointer; }
.q-switch input { appearance: none; -webkit-appearance: none; position: relative; flex: 0 0 auto; width: 28px; height: 16px; margin: 0; border: 0; border-radius: 999px; background: #dedee5; cursor: pointer; transition: background .18s; }
.q-switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0002; transition: transform .18s; }
.q-switch input:checked { background: var(--green); }
.q-switch input:checked::after { transform: translateX(12px); }
.q-check { display: flex; align-items: flex-start; gap: 7px; margin: 7px 0; color: var(--ink-soft); font-size: 10px; line-height: 1.5; cursor: pointer; }
.q-check input { flex: 0 0 auto; width: 13px; height: 13px; margin: 1px 0 0; accent-color: var(--ink); }
.q-check small { color: var(--muted-3); }
.q-eyebrow { display: block; color: var(--muted-3); font-size: 8px; font-weight: 600; letter-spacing: 1.4px; }
.q-muted { color: var(--muted-2); font-size: 9px; }

/* ------------------------------------------------------------- cards & stage */
.q-card, .q-stage { min-width: 0; background: var(--surface); border: 1px solid #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.q-stage { display: flex; flex-direction: column; flex: none; overflow: hidden; }
.q-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.q-stage-title { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.q-stage-title h1 { font-size: 13.5px; font-weight: 650; letter-spacing: -.2px; white-space: nowrap; }
.q-stage-sub { color: var(--muted-2); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-stage-badges { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.q-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 8px 14px; border-bottom: 1px solid var(--line-soft); }
.q-toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
.q-toolbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.q-chart-wrap { position: relative; flex: 1 1 auto; height: 452px; min-height: 340px; padding: 4px 8px 0; background: #fff; }
#main-chart { display: block; width: 100%; height: 100%; overflow: visible; }
.q-chart-tip { position: absolute; z-index: 40; min-width: 150px; max-width: 240px; padding: 9px 10px; border: 1px solid #ffffff1a; border-radius: 11px; background: #1c1c1ef2; color: #fff; box-shadow: 0 10px 28px #1c1c1e33; font-size: 10px; line-height: 1.55; pointer-events: none; backdrop-filter: blur(8px); }
.q-chart-tip strong { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 600; }
.q-tip-row { display: flex; justify-content: space-between; gap: 14px; color: #d8d8dd; }
.q-tip-row b { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.q-tip-note { margin-top: 4px; color: #a9a9b0; font-size: 9px; }
.q-stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; padding: 7px 14px; border-top: 1px solid var(--line-soft); color: var(--muted-2); font-size: 9.5px; }
.q-stage-foot > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-stage-foot .bi { color: var(--accent); font-size: 11px; }
.q-stage-foot #stage-footnote { flex: 0 0 auto; color: var(--muted-3); }
.q-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.q-card-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.q-card-title .bi { color: var(--muted-2); font-size: 13px; }
.q-card-title h2 { font-size: 12.5px; font-weight: 650; letter-spacing: -.15px; white-space: nowrap; }
.q-card-title .q-muted { font-size: 9px; }
.q-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.q-card-body { padding: 14px; }
.q-table-wrap { width: 100%; overflow: auto; scrollbar-width: thin; scrollbar-color: #d9d9e0 transparent; }
.q-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 10.5px; white-space: nowrap; }
.q-table th { position: sticky; top: 0; z-index: 3; padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); background: #fafafc; color: var(--muted-2); font-size: 9px; font-weight: 500; letter-spacing: .01em; }
.q-table th:first-child, .q-table td:first-child { text-align: left; }
.q-table th:first-child { z-index: 4; }
.q-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid #f3f3f6; color: #3e3e44; font-variant-numeric: tabular-nums; }
.q-table tbody tr:last-child td { border-bottom: 0; }
.q-table tbody tr:hover td { background: #fcfcfe; }
.q-table tbody tr.is-active td { background: #fffaf3; }
.q-table tbody tr.is-warn td { background: #fff8f6; }
.q-table .q-left { text-align: left; }
.q-table .q-center { text-align: center; }
.q-empty { padding: 38px 20px; text-align: center; color: var(--muted-2); font-size: 11px; }
.q-small { font-size: 9px; color: var(--muted-3); }

/* ------------------------------------------------------------- point input table */
.q-point-table-wrap { max-height: 360px; overflow: auto; }
.q-point-table th { padding: 8px 10px; }
.q-point-table td { padding: 4px 8px; }
.q-point-table .q-idx { width: 40px; color: var(--muted-3); font-family: var(--mono); font-size: 9px; text-align: center; }
.q-num-input { width: 94px; height: 29px; padding: 4px 7px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--ink); font-size: 10.5px; font-variant-numeric: tabular-nums; text-align: right; outline: 0; transition: background .15s, border-color .15s; }
.q-num-input:hover { background: var(--well); }
.q-num-input:focus { background: #fff; border-color: #a8ccff; box-shadow: 0 0 0 3px #007aff0a; }
.q-note-input { width: 100%; min-width: 110px; height: 29px; padding: 4px 7px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--ink-soft); font-size: 10px; outline: 0; }
.q-note-input:hover { background: var(--well); }
.q-note-input:focus { background: #fff; border: 1px solid #a8ccff; }
.q-point-table .q-dot { display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%; background: #d7d7de; vertical-align: 1px; }
.q-point-table .q-dot.ok { background: #a7c7b2; }
.q-point-table .q-dot.warn { background: var(--red); }
.q-del { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-3); font-size: 10px; }
.q-del:hover { color: var(--red); background: var(--red-soft); }
.q-table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--line-soft); background: #fcfcfe; color: var(--muted-2); font-size: 9px; }
.q-table-foot .bi { font-size: 10px; color: var(--muted-3); }
.q-inputs-note { display: flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------- verdict / model table */
.q-verdict { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 14px; padding: 16px 18px; border: 1px solid #f0d8b5; border-radius: 16px; background: linear-gradient(135deg, #fffaf1, #fffdf9); }
.q-verdict.is-bad { border-color: #f0d1cd; background: linear-gradient(135deg, #fff7f5, #fffdfc); }
.q-verdict-main { min-width: 0; flex: 1 1 240px; }
.q-verdict-main .q-eyebrow { color: #b08a54; }
.q-verdict-main strong { display: block; margin-top: 3px; color: #6d4813; font-size: 19px; letter-spacing: -.6px; }
.q-verdict-main p { margin-top: 2px; color: #94744b; font-size: 9.5px; }
.q-verdict-eq { flex: 0 1 auto; max-width: 100%; padding: 8px 11px; border-radius: 10px; background: #ffffffb5; color: #5e4a30; font-family: var(--mono); font-size: 10px; overflow-wrap: anywhere; }
.q-verdict-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.q-verdict .q-chip { background: #ffffffb5; }
.q-model-note { display: flex; align-items: flex-start; gap: 7px; margin: 0 14px 12px; padding: 8px 10px; border-radius: 10px; background: var(--well); color: var(--muted); font-size: 9px; line-height: 1.6; }
.q-model-note .bi { flex: 0 0 auto; margin-top: 1px; color: var(--muted-2); font-size: 10px; }
.q-evidence { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 14px 14px; }
.q-model-table td { white-space: normal; }
.q-model-table .q-model-name { font-weight: 600; color: var(--ink-soft); }
.q-model-table tr.is-selected td { background: #fffaf3; }
.q-model-table tr.is-selected td:first-child { box-shadow: inset 2px 0 var(--accent); }
.q-model-table tr.is-unavailable td { color: var(--muted-3); }
.q-model-table .q-form { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.q-model-table .q-reason { display: block; margin-top: 2px; color: var(--muted-3); font-size: 8.5px; max-width: 180px; white-space: normal; }
.q-use-model { min-height: 23px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); font-size: 8.5px; }
.q-use-model:hover { color: var(--ink); background: var(--well); }
.q-use-model.is-current { border-color: #f0d8b5; background: var(--accent-soft); color: var(--accent-ink); }

/* ------------------------------------------------------------- fit stats */
.q-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 14px; }
.q-kpi { padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--well); min-width: 0; }
.q-kpi > span { display: block; color: var(--muted-2); font-size: 8.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-kpi > strong { display: block; margin-top: 3px; color: var(--ink); font-size: 19px; font-weight: 600; letter-spacing: -.6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-kpi > strong small { margin-left: 2px; color: var(--muted-3); font-size: 8.5px; font-weight: 500; letter-spacing: 0; }
.q-kpi .q-chip { margin-top: 4px; }
.q-equation { display: flex; align-items: center; gap: 10px; margin: 0 14px 12px; padding: 13px 14px; border: 1px solid #f0e1cf; border-radius: 13px; background: #fffdf9; }
.q-equation-code { flex: 1; min-width: 0; color: #5f4021; font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.q-equation-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.q-warn-list { display: grid; gap: 6px; padding: 0 14px 14px; }
.q-warn { display: flex; align-items: flex-start; gap: 7px; padding: 8px 10px; border-radius: 9px; background: #fff8ec; color: #8a6424; font-size: 9.5px; line-height: 1.6; }
.q-warn.is-info { background: #f7f9fb; color: #64798b; }
.q-warn.is-good { background: var(--green-soft); color: #477e57; }
.q-warn .bi { flex: 0 0 auto; margin-top: 1px; font-size: 10px; }
.q-resid-line { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.q-engine { margin: 0 14px 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: #fcfcfe; overflow: hidden; }
.q-engine > summary { display: flex; align-items: center; gap: 7px; padding: 10px 12px; color: var(--ink-soft); font-size: 10px; font-weight: 500; list-style: none; cursor: pointer; }
.q-engine > summary::-webkit-details-marker { display: none; }
.q-engine > summary .bi { color: var(--muted-3); font-size: 10px; transition: transform .18s; }
.q-engine[open] > summary .bi { transform: rotate(90deg); }
.q-engine-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0 10px 12px; }
.q-engine-group { min-width: 0; padding: 9px 10px; border: 1px solid #f0f0f4; border-radius: 9px; background: #fff; }
.q-engine-group h4 { margin: 0 0 5px; color: var(--muted-2); font-size: 8.5px; font-weight: 600; letter-spacing: .02em; }
.q-engine-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 2.5px 0; border-bottom: 1px dashed #f3f3f6; font-size: 8.5px; }
.q-engine-row:last-child { border-bottom: 0; }
.q-engine-row span { color: var(--muted); overflow-wrap: anywhere; }
.q-engine-row b { flex: 0 0 auto; color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.q-engine-row b.is-bad { color: var(--red); }
.q-engine-row b.is-good { color: var(--green-ink); }

/* ------------------------------------------------------------- inverse */
.q-inverse-body { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 12px; padding: 14px; }
.q-single { display: flex; flex-direction: column; gap: 9px; padding: 13px 14px; border: 1px solid #f0e1cf; border-radius: 15px; background: linear-gradient(140deg, #fffaf2, #fffdf9); min-width: 0; }
.q-single-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.q-single-label > span { color: var(--accent-ink); font-size: 9px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.q-single-input { display: flex; align-items: center; gap: 8px; }
.q-single-input label { color: var(--muted); font-size: 9.5px; white-space: nowrap; }
.q-single-input input { flex: 1; min-width: 0; height: 38px; padding: 6px 10px; border: 1px solid #ead6b9; border-radius: 10px; background: #fff; color: var(--ink); font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; outline: 0; }
.q-single-input input:focus { border-color: #d9b37c; box-shadow: 0 0 0 3px #ff950014; }
.q-single-result { display: flex; align-items: baseline; gap: 7px; min-height: 42px; }
.q-single-result strong { color: var(--ink); font-size: 32px; font-weight: 600; letter-spacing: -1.5px; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.q-single-result > span { color: var(--muted-2); font-size: 10px; }
.q-single-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.q-single-sub { color: var(--muted); font-size: 9px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.q-single-sub b { color: var(--ink-soft); font-weight: 500; }
.q-single-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.q-single.is-bad { background: #fff8f6; border-color: #f0d1cd; }
.q-single.is-bad .q-single-result strong { color: var(--red); }
.q-batch { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line-soft); border-radius: 15px; background: #fff; overflow: hidden; }
.q-batch-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); background: #fcfcfe; }
.q-batch-head strong { font-size: 10px; font-weight: 600; }
.q-batch-head .q-card-actions { margin-left: auto; }
.q-batch-wrap { max-height: 275px; overflow: auto; }
.q-batch-table th { padding: 7px 8px; }
.q-batch-table td { padding: 4px 8px; }
.q-batch-table .q-num-input { width: 78px; }
.q-batch-table .q-note-input { min-width: 84px; }
.q-batch-x { color: var(--ink); font-weight: 500; }
.q-batch-x.is-out { color: var(--red); }
.q-batch-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line-soft); background: #fcfcfe; color: var(--muted-3); font-size: 8.5px; }
.q-batch-empty { padding: 26px 16px; text-align: center; color: var(--muted-2); font-size: 10px; line-height: 1.8; }
.q-inverse-note { padding: 0 14px 14px; color: var(--muted-3); font-size: 9px; line-height: 1.6; }

/* ------------------------------------------------------------- context */
.q-context-section { display: flex; flex-direction: column; gap: 12px; }
.q-context-card { padding: 14px; background: #fff; border: 1px solid #fff; border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.q-context-card h3 { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; letter-spacing: -.1px; }
.q-context-card h3 > .bi { color: var(--muted-2); font-size: 13px; font-weight: 400; }
.q-context-card .q-head-right { margin-left: auto; color: var(--muted-3); font-size: 8.5px; font-weight: 400; }
.q-context-card > p { margin-top: 7px; color: var(--muted); font-size: 9.5px; line-height: 1.65; }
.q-field { display: block; margin-top: 10px; color: var(--muted); font-size: 9.5px; }
.q-field > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.q-field > span b { color: var(--ink-soft); font-size: 9.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.q-field select, .q-field input[type="number"], .q-field input[type="text"] { width: 100%; height: 32px; margin-top: 5px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--well); color: var(--ink); font-size: 10.5px; outline: 0; }
.q-field select:focus, .q-field input:focus { background: #fff; border-color: #a8ccff; box-shadow: 0 0 0 3px #007aff0a; }
.q-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 9px; }
.q-inline .q-field { margin-top: 0; }
.q-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #f0f0f4; font-size: 10px; }
.q-kv:last-child { border-bottom: 0; }
.q-kv > span { color: var(--muted); }
.q-kv > strong { color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.q-kv > strong.is-good { color: var(--green-ink); }
.q-kv > strong.is-warn { color: var(--accent-deep); }
.q-kv > strong.is-bad { color: var(--red); }
.q-kv .q-kv-sub { display: block; margin-top: 1px; color: var(--muted-3); font-size: 8px; font-weight: 400; }
.q-note-warm { display: flex; align-items: flex-start; gap: 7px; margin-top: 9px; padding: 8px 9px; border-radius: 10px; background: var(--accent-soft); color: #87662f; font-size: 9px; line-height: 1.6; }
.q-note-warm .bi { flex: 0 0 auto; margin-top: 1px; color: var(--accent-deep); font-size: 10px; }
.q-context-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.q-context-actions .q-btn { flex: 1 1 auto; }
.q-condition { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #f0f0f4; font-size: 9.5px; color: var(--muted); }
.q-condition:last-child { border-bottom: 0; }
.q-condition b { color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums; }
.q-ok { color: var(--green-ink); }
.q-no { color: var(--red); }
.q-model-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.q-model-chips button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); font-size: 8.5px; }
.q-model-chips button:hover { background: var(--well); color: var(--ink); }
.q-model-chips button.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.q-context-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.q-context-list button { padding: 3px 6px; border: 0; border-radius: 6px; background: var(--gray); color: var(--muted); font-size: 8.5px; }
.q-context-list button:hover { background: #e9e9ef; color: var(--ink); }
.q-statusline { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted-2); font-size: 9px; }
.q-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--green); }
.q-dot.warn { background: var(--accent); }
.q-dot.bad { background: var(--red); }
.q-dot.idle { background: #c7c7cf; }
.q-storage-card { padding: 11px 13px; background: #fbfbfd; border: 1px solid var(--line-soft); border-radius: 14px; color: var(--muted-3); font-size: 8.5px; line-height: 1.6; }
.q-storage-card strong { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9.5px; font-weight: 600; margin-bottom: 3px; }
.q-storage-card .bi { color: var(--green); font-size: 10px; }

/* ------------------------------------------------------------- modal / toast */
.q-toast { position: absolute; left: 50%; bottom: 22px; z-index: 2000; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; max-width: 80%; padding: 9px 14px; border: 1px solid #ffffff1a; border-radius: 12px; background: #1c1c1ef2; color: #fff; box-shadow: 0 12px 36px #1c1c1e2e; font-size: 11px; animation: q-toast-in .2s var(--ease); }
.q-toast .bi { font-size: 12px; }
.q-toast.is-warm { background: #8a5a12f2; }
.q-toast.is-bad { background: #b63831f2; }
@keyframes q-toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.q-modal { position: absolute; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 24px; background: #1c1c1e33; backdrop-filter: blur(4px); }
.q-modal-panel { width: min(780px, 100%); max-height: 92%; overflow: auto; border: 1px solid #fff; border-radius: 22px; background: #fff; box-shadow: 0 24px 80px #1c1c1e33; }
.q-modal-panel.is-narrow { width: min(480px, 100%); }
.q-modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); background: #fffffff2; backdrop-filter: blur(14px); }
.q-modal-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-deep); font-size: 15px; }
.q-modal-head h2 { font-size: 15px; letter-spacing: -.3px; }
.q-modal-head p { margin-top: 1px; color: var(--muted-2); font-size: 9.5px; }
.q-modal-close { margin-left: auto; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 9px; background: var(--gray); color: var(--muted); }
.q-modal-close:hover { background: #e9e9ef; color: var(--ink); }
.q-help-body { display: grid; gap: 12px; padding: 18px 20px 22px; }
.q-help-block { padding: 13px 14px; border: 1px solid #f0f0f4; border-radius: 14px; background: var(--well); }
.q-help-block h3 { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-size: 11px; font-weight: 600; }
.q-help-block h3 .bi { color: var(--accent-deep); font-size: 11px; }
.q-help-block p, .q-help-block li { color: var(--muted); font-size: 9.5px; line-height: 1.75; }
.q-help-block ul { margin: 3px 0 0 15px; padding: 0; }
.q-help-block code { padding: 1px 4px; border-radius: 4px; background: #fff; font-size: 8.5px; }
.q-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.q-help-note { display: flex; gap: 7px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: 9px; line-height: 1.65; }
.q-help-note .bi { flex: 0 0 auto; margin-top: 1px; }
.q-shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 16px; margin-top: 4px; }
.q-shortcuts div { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9.5px; }
kbd { display: inline-block; min-width: 18px; padding: 1px 5px; border: 1px solid #dcdce3; border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--ink-soft); font-family: var(--mono); font-size: 8.5px; text-align: center; }
.q-paste-body { display: grid; gap: 10px; padding: 16px 20px 20px; }
.q-paste-body textarea { width: 100%; min-height: 160px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--well); color: var(--ink-soft); font-family: var(--mono); font-size: 10px; line-height: 1.7; resize: vertical; outline: 0; }
.q-paste-body textarea:focus { background: #fff; border-color: #a8ccff; box-shadow: 0 0 0 3px #007aff0a; }
.q-paste-hint { color: var(--muted-3); font-size: 9px; line-height: 1.65; }
.q-paste-actions { display: flex; justify-content: flex-end; gap: 6px; }
.q-loading { position: absolute; inset: 0; z-index: 1800; display: grid; place-items: center; background: #f2f2f7cc; backdrop-filter: blur(3px); }
.q-loading-card { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-radius: 14px; background: #fff; box-shadow: var(--shadow-lift); color: var(--ink-soft); font-size: 11px; }
.q-spinner { width: 15px; height: 15px; border: 2px solid #eeeef3; border-top-color: var(--accent); border-radius: 50%; animation: q-spin .8s linear infinite; }
@keyframes q-spin { to { transform: rotate(360deg); } }

/* scrollbars */
.q-main::-webkit-scrollbar, .q-context::-webkit-scrollbar, .q-point-list::-webkit-scrollbar, .q-table-wrap::-webkit-scrollbar, .q-point-table-wrap::-webkit-scrollbar, .q-batch-wrap::-webkit-scrollbar, .q-modal-panel::-webkit-scrollbar { width: 8px; height: 8px; }
.q-main::-webkit-scrollbar-thumb, .q-context::-webkit-scrollbar-thumb, .q-point-list::-webkit-scrollbar-thumb, .q-table-wrap::-webkit-scrollbar-thumb, .q-point-table-wrap::-webkit-scrollbar-thumb, .q-batch-wrap::-webkit-scrollbar-thumb, .q-modal-panel::-webkit-scrollbar-thumb { background: #d9d9e0; border: 2px solid transparent; border-radius: 8px; background-clip: content-box; }
.q-main::-webkit-scrollbar-thumb:hover, .q-context::-webkit-scrollbar-thumb:hover { background: #c1c1ca; background-clip: content-box; }

/* responsive */
@media (max-width: 1420px) {
    .app-shell { grid-template-columns: minmax(210px, .9fr) minmax(0, 3.2fr) minmax(226px, 1fr); gap: 12px; }
    .q-chart-wrap { height: 430px; }
    .q-kpi > strong { font-size: 17px; }
}
@media (max-width: 1200px) {
    body { height: auto; min-height: 100dvh; }
    .app-shell { grid-template-columns: 218px minmax(0, 1fr); grid-template-rows: auto auto auto; height: auto; }
    .q-rail { position: sticky; top: 12px; height: calc(100dvh - 24px); }
    .q-main { overflow: visible; height: auto; }
    .q-context { grid-column: 1 / -1; overflow: visible; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .q-context-section { display: contents; }
    .q-context > .q-context-section > .q-context-card { height: 100%; }
    .q-context > .q-context-section > .q-context-card:first-child { grid-column: 1 / -1; }
    .q-inverse-body { grid-template-columns: 1fr; }
    .q-engine-grid { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
    .app-shell { display: flex; flex-direction: column; height: auto; padding: 10px; }
    .q-rail { position: static; height: auto; }
    .q-steps { grid-template-columns: 1fr 1fr; }
    .q-samples-panel { max-height: 280px; }
    .q-main { overflow: visible; }
    .q-context { display: flex; overflow: visible; }
    .q-context > .q-context-section { display: flex; }
    .q-chart-wrap { height: 360px; min-height: 320px; }
    .q-kpis { grid-template-columns: 1fr 1fr; }
    .q-card-actions { width: 100%; margin-left: 0; }
    .q-help-grid { grid-template-columns: 1fr; }
    .q-toolbar-actions { margin-left: 0; }
}
@media (max-width: 640px) {
    .q-stage-title { flex-direction: column; align-items: flex-start; gap: 2px; }
    .q-segmented button .bi { display: none; }
    .q-kpis { grid-template-columns: 1fr 1fr; }
    .q-single-result strong { font-size: 26px; }
    .q-shortcuts { grid-template-columns: 1fr; }
    .q-inverse-body { padding: 10px; }
    .q-modal { padding: 10px; }
}

/* print */
@media print {
    html, body { background: #fff !important; }
    body { zoom: 1 !important; width: 100% !important; height: auto !important; }
    .app-shell { display: block; height: auto; padding: 0; }
    .q-rail, .q-context, .q-card-actions, .q-toolbar, .q-stage-foot, .q-engine,
    .q-table-foot, .q-toast, .q-modal, .q-skip, .q-single-actions, .q-batch-head .q-card-actions { display: none !important; }
    .q-main { display: block; overflow: visible; height: auto; padding: 0; }
    .q-stage, .q-card { break-inside: avoid; border: 1px solid #ddd; box-shadow: none; margin-bottom: 12px; }
    .q-chart-wrap { height: 380px; }
    .q-table-wrap, .q-point-table-wrap, .q-batch-wrap { max-height: none; overflow: visible; }
    .q-table th { position: static; }
    .q-table td, .q-table th { white-space: normal; }
    .q-inverse-body { grid-template-columns: 1fr 1fr; }
}

/* ================================================================ simplified views
   Three focused pages: 标曲数据 → 浓度反算 → 拟合详情. The process data lives
   only on the third page; the first screen is always the input table. */
.q-view { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.q-view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 4px 2px 2px; }
.q-view-head-copy { min-width: 0; }
.q-view-eyebrow { display: block; color: var(--muted-3); font-size: 7.5px; font-weight: 600; letter-spacing: 1.5px; }
.q-view-head h1 { margin-top: 4px; color: var(--ink); font-size: 20px; font-weight: 650; letter-spacing: -.7px; }
.q-view-head p { margin-top: 4px; max-width: 620px; color: var(--muted); font-size: 9.5px; line-height: 1.65; }
.q-view-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px; flex: 0 0 auto; }
.q-view-actions .q-pill { background: #fff; border: 1px solid var(--line-soft); }
.q-view-actions .q-pill.warm { border-color: #f2ddbd; background: var(--accent-soft); }
.q-view-links { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 0 2px 8px; }

/* unit selection */
.q-unit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); background: #fbfbfd; }
.q-unit-label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.q-unit-label .bi { color: var(--muted-3); font-size: 10px; }
.q-unit-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.q-unit-chip { min-height: 24px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: 8.5px; white-space: nowrap; }
.q-unit-chip:hover { border-color: #d6d6df; color: var(--ink); }
.q-unit-chip.is-active { border-color: #f0d3a7; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.q-unit-custom { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 8.5px; }
.q-unit-custom input { width: 106px; height: 26px; padding: 3px 7px; border: 1px solid #f0d3a7; border-radius: 7px; background: #fff; color: var(--accent-ink); font-size: 9px; outline: 0; }
.q-unit-custom input:focus { border-color: #d9b37c; box-shadow: 0 0 0 3px #ff950010; }

/* data summary */
.q-data-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; padding: 14px 16px; }
.q-summary-main { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; flex: 1 1 380px; }
.q-summary-main > strong { font-size: 16px; letter-spacing: -.4px; white-space: nowrap; }
.q-summary-eq { min-width: 0; padding: 4px 8px; border-radius: 7px; background: var(--well); color: #5d4a33; font-family: var(--mono); font-size: 9.5px; overflow-wrap: anywhere; }
.q-summary-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--muted); font-size: 8.5px; font-variant-numeric: tabular-nums; }
.q-summary-stats b { color: var(--ink-soft); font-weight: 600; }
.q-summary-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-left: auto; }
.q-summary-warn { flex: 0 0 100%; display: flex; align-items: center; gap: 6px; padding-top: 2px; color: var(--accent-deep); font-size: 8.5px; }
.q-summary-warn .bi { font-size: 10px; }
.q-summary-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 4px 0; color: var(--muted); font-size: 10px; }

/* chart heights for the three focused pages */
.q-chart-wrap { height: 330px; min-height: 280px; }
.q-chart-wrap--preview { height: 310px; }
.q-chart-wrap--inverse { height: 330px; }
.q-chart-wrap--process { height: 360px; }
.q-chart-wrap .q-chart-tip { position: absolute; }
.q-chart-wrap .q-note { font-family: inherit; }

/* inverse page */
.q-inverse-layout { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); gap: 12px; align-items: stretch; }
.q-inverse-layout > .q-card { min-width: 0; overflow: hidden; }
.q-inverse-layout #single-box { min-width: 0; }
.q-inverse-layout .q-single { height: 100%; min-height: 100%; box-shadow: var(--shadow); border-color: #f0e1cf; }
.q-inverse-layout .q-chart-wrap { height: 300px; }
.q-batch { box-shadow: var(--shadow); border: 1px solid #fff; border-radius: var(--radius); }
.q-batch-head { padding: 12px 14px; }
.q-batch-wrap { max-height: 330px; }
.q-side-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; padding-top: 6px; border-top: 1px dashed #f0e1cf; color: var(--muted-3); font-size: 8px; }
.q-side-meta:empty { display: none; }
.q-side-meta span:last-child { color: var(--green-ink); }
.q-side-quick { flex: none; display: flex; gap: 6px; margin: 8px 12px 0; }
.q-side-quick .q-btn { flex: 1; }

/* process page */
.q-verdict { margin: 0; box-shadow: var(--shadow); }
.q-view .q-verdict { margin: 0; }
.q-view .q-verdict + .q-card { margin-top: 0; }
#verdict:empty { display: none; }
.q-next-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding: 9px 10px; border-radius: 10px; background: var(--well); font-size: 9.5px; }
.q-next-summary strong { font-size: 11.5px; }
.q-next-summary .q-mono { color: var(--muted); font-size: 8.5px; }
.q-context-actions .q-btn .bi { font-size: 10px; }
.q-view-links .q-btn { background: #ffffffb8; border-color: var(--line); color: var(--muted); }

/* mobile: put the input table first; hide the persistent rail extras */
@media (max-width: 920px) {
    .app-shell { padding: 8px; gap: 8px; }
    .q-rail { border-radius: 18px; }
    .q-brand-block { padding: 12px 14px 8px; gap: 8px; }
    .q-brand-mark { flex-basis: 32px; width: 32px; height: 32px; }
    .q-brand-mark svg { width: 20px; height: 20px; }
    .q-brand-copy strong { font-size: 15px; }
    .q-brand-copy span { display: none; }
    .q-status { padding: 4px 8px; font-size: 9px; }
    .q-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 0 10px; padding: 0 0 10px; }
    .q-step { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px; padding: 5px 4px; border-radius: 11px; }
    .q-step-no { width: 21px; height: 21px; font-size: 9px; flex: 0 0 21px; }
    .q-step-name { font-size: 10px; white-space: nowrap; }
    .q-step-state { display: none; }
    .q-step.is-active { background: var(--ink); }
    .q-guide-btn, .q-side-model, .q-side-quick, .q-rail-footer { display: none !important; }
    .q-main { gap: 10px; padding-right: 0; }
    .q-view { gap: 10px; }
    .q-view-head { align-items: flex-start; flex-direction: column; gap: 6px; padding: 2px 2px 0; }
    .q-view-head h1 { font-size: 19px; }
    .q-view-head p { font-size: 9px; }
    .q-view-actions { justify-content: flex-start; }
    .q-unit-row { padding: 9px 11px; gap: 6px; }
    .q-unit-chip { font-size: 8px; padding: 3px 7px; }
    .q-unit-custom input { width: 96px; }
    .q-data-summary { padding: 12px; }
    .q-summary-main { flex-basis: 100%; }
    .q-summary-actions { margin-left: 0; width: 100%; }
    .q-summary-actions .q-btn { flex: 1; }
    .q-inverse-layout { grid-template-columns: 1fr; }
    .q-inverse-layout .q-single { min-height: 0; }
    .q-chart-wrap, .q-chart-wrap--preview, .q-chart-wrap--inverse { height: 300px; min-height: 260px; }
    .q-chart-wrap--process { height: 320px; }
    .q-point-table-wrap { max-height: 430px; }
    .q-context { padding-right: 0; }
    .q-view-links { padding-bottom: 4px; }
    .q-view-links .q-btn { flex: 1; }
}
@media (max-width: 640px) {
    .q-view-head-actions .q-btn { min-height: 28px; }
    .q-card-head { padding: 10px 11px; }
    .q-card-title h2 { font-size: 12px; }
    .q-card-actions .q-btn { padding-inline: 7px; }
    .q-point-table th, .q-point-table td { padding-left: 5px; padding-right: 5px; }
    .q-num-input { width: 80px; padding-inline: 5px; }
    .q-note-input { min-width: 74px; }
    .q-point-table .q-idx { width: 28px; }
    .q-batch-table .q-num-input { width: 68px; }
    .q-batch-table .q-note-input { min-width: 66px; }
    .q-kpis { grid-template-columns: 1fr 1fr; padding: 11px; }
    .q-kpi > strong { font-size: 17px; }
    .q-equation { margin-inline: 11px; padding: 11px; }
    .q-warn-list { padding-inline: 11px; }
    .q-resid-line { padding-inline: 11px; }
    .q-engine { margin-inline: 11px; }
    .q-engine-grid { grid-template-columns: 1fr; }
    .q-single { padding: 12px; }
    .q-single-result strong { font-size: 28px; }
    .q-single-input input { height: 36px; font-size: 14px; }
    .q-verdict { padding: 14px; gap: 10px; }
    .q-verdict-main strong { font-size: 17px; }
    .q-verdict-eq { flex-basis: 100%; }
    .q-view-actions .q-pill { font-size: 8px; }
    .q-unit-label { font-size: 8.5px; }
    .q-side-summary, .q-side-quick { display: none !important; }
}
@media print {
    .q-view-actions, .q-view-links, .q-side-model, .q-side-quick { display: none !important; }
    .q-view:not([hidden]) { display: block; }
    .q-view > * { margin-bottom: 10px; }
    .q-chart-wrap, .q-chart-wrap--preview, .q-chart-wrap--inverse, .q-chart-wrap--process { height: 340px; }
    .q-inverse-layout { grid-template-columns: 1fr 1fr; }
}

/* chart SVG hosts: the draw function fills these elements */
#data-chart, #inverse-chart, #process-chart { display: block; width: 100%; height: 100%; overflow: visible; touch-action: manipulation; }

/* readability tweaks for the focused pages */
.q-point-table-wrap { max-height: 424px; }
@media (max-width: 640px) {
    .q-model-table th:nth-child(2), .q-model-table td:nth-child(2),
    .q-model-table th:nth-child(3), .q-model-table td:nth-child(3),
    .q-model-table th:nth-child(6), .q-model-table td:nth-child(6),
    .q-model-table th:nth-child(7), .q-model-table td:nth-child(7) { display: none; }
    .q-model-table th:first-child, .q-model-table td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; }
    .q-model-table th:first-child { background: #fafafc; }
    .q-model-table tr.is-selected td:first-child { background: #fffaf3; }
    .q-model-table .q-reason { max-width: 84px; }
    .q-model-table th, .q-model-table td { padding-inline: 7px; }
    .q-model-table .q-model-name { font-size: 10px; }
}

/* ------------------------------------------------------------------ right rail
   Give the context column its own frosted surface (so the unused height reads as
   a deliberate rail, not a blank page area) and make context cards stretch on
   narrow screens. The 920px rule intentionally comes after the earlier
   align-items:start grid rule. */
.q-context {
    padding: 12px;
    background: #f8f8fbcc;
    border: 1px solid #ffffffcc;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.q-context > .q-context-section { width: 100%; min-width: 0; }
.q-context-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding: 10px 4px 2px;
    color: var(--muted-3);
    font-size: 8.5px;
    line-height: 1.5;
}
.q-context-foot .q-dot { width: 5px; height: 5px; flex: 0 0 5px; background: var(--green); }
@media (max-width: 1200px) {
    .q-context { align-items: stretch; }
    .q-context-foot { grid-column: 1 / -1; margin-top: 0; }
}
@media (max-width: 920px) {
    .q-context { display: flex; flex-direction: column; align-items: stretch; padding: 10px; }
    .q-context > .q-context-section { display: flex; flex-direction: column; gap: 12px; width: 100%; }
    .q-context > .q-context-section > .q-context-card { width: 100%; height: auto; }
}

/* The data-entry page does not need a settings rail: let the table, summary and
   preview use the full width. The rail returns for back-calculation / fit details. */
.app-shell.is-data-view { grid-template-columns: minmax(226px, .88fr) minmax(0, 4.3fr); }
.app-shell.is-data-view .q-context { display: none !important; }
@media (max-width: 1200px) {
    .app-shell.is-data-view { grid-template-columns: 218px minmax(0, 1fr); }
}
