/* Shared styles for the calculator pages (diagnostic, RECIST 1.1, PERCIST,
   adrenal washout, decay, E-value). Matches the original calculator look;
   page-specific rules stay in each page's own <style> block. Dark-theme
   values for these tokens live in site.css. */

:root {
    --primary-color: #2d3748;
    --secondary-color: #4a5568;
    --accent-color: #4299e1;
    --background-color: #f7fafc;
    --muted: #718096;
    --grid: #e2e8f0;
    --crit: #d03b3b;
    --good: #0ca30c;
    --info-bg: #ebf8ff;
    --info-border: #bee3f8;
    --info-ink: #2c5282;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --warn-bg: #fffaf0;
    --warn-border: #fbd38d;
    --warn-ink: #9c4221;
    --err-bg: #fff5f5;
    --err-border: #feb2b2;
    --err-ink: #9b2c2c;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    background-color: var(--background-color);
    color: var(--primary-color);
}

main { max-width: 1200px; margin: 3rem auto 4rem; padding: 0 2rem; }

/* Page heading */
.page-head { margin-bottom: 2rem; }
.page-head h1 { font-size: 2.25rem; line-height: 1.2; letter-spacing: -.02em; margin-bottom: .75rem; }
.page-head .lede { font-size: 1.1rem; color: var(--secondary-color); max-width: 70ch; }
.page-head .secnote { color: var(--secondary-color); font-size: .95rem; max-width: 78ch; margin-top: .75rem; }

/* Layout */
.content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.span-all { grid-column: 1 / -1; }

/* Cards */
.card, .input-section, .results-section, .contingency-table, .formula-section {
    background: var(--surface, white); padding: 2rem; border-radius: 8px; box-shadow: var(--card-shadow, 0 2px 4px rgba(0, 0, 0, 0.1));
}
.contingency-table, .formula-section { grid-column: 1 / -1; }
.card h2, .input-section h2, .results-section h2 { font-size: 1.35rem; letter-spacing: -.01em; margin-bottom: 1.25rem; }
.card h3, .contingency-table h3, .formula-section h3 { font-size: 1.15rem; margin-bottom: 1rem; }
.card-note { font-size: .9rem; color: var(--secondary-color); margin: -.75rem 0 1.25rem; max-width: 78ch; }

/* Form controls */
label { display: block; font-weight: 600; margin-bottom: .4rem; }
input[type=number], input[type=text], select {
    width: 100%; font: inherit; padding: .6rem .8rem; border-radius: 8px;
    border: 1px solid var(--grid); background: var(--surface, white); color: var(--primary-color);
    transition: border-color .2s ease, box-shadow .2s ease;
}
input[type=number]:focus, input[type=text]:focus, select:focus {
    outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(66, 153, 225, .25);
}
input:disabled, select:disabled { background: var(--background-color); color: var(--muted); }
.input-group, .form-group { margin-bottom: 1.5rem; }
.input-group:last-child, .form-group:last-child { margin-bottom: 0; }
.input-help, .help-text { font-size: .85rem; color: var(--muted); margin-top: .35rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.fieldset-title {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
    font-weight: 600; margin: 0 0 .75rem;
}
.fieldset + .fieldset { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--grid); }
.error { border-color: var(--crit) !important; box-shadow: 0 0 0 3px rgba(208, 59, 59, .15) !important; }
.error-message { color: var(--crit); font-size: .85rem; margin-top: .35rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .9rem;
    padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--grid); background: var(--surface, white);
    color: var(--secondary-color); cursor: pointer; transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent-color); color: var(--accent-color); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(66, 153, 225, .35); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Segmented control (mode / scale switches) */
.segmented { display: inline-flex; border: 1px solid var(--grid); border-radius: 8px; overflow: hidden; background: var(--surface, white); }
.segmented button {
    font: inherit; font-size: .88rem; padding: .45rem .9rem; border: 0; background: transparent;
    color: var(--secondary-color); cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--grid); }
.segmented button[aria-pressed="true"] { background: var(--info-bg); color: var(--info-ink); font-weight: 600; }
.segmented button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-color); }

/* Results */
.result-item {
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    padding: .7rem .75rem; border-bottom: 1px solid var(--grid);
}
.result-item:last-of-type { border-bottom: none; }
.result-item:hover { background: var(--background-color); }
.result-label { color: var(--secondary-color); }
.result-value {
    font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums;
    color: var(--primary-color); white-space: nowrap; text-align: right;
}
.result-value .ci { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); }
.result-item.headline .result-value { font-size: 1.5rem; }
.results-note { font-size: .85rem; color: var(--muted); margin-top: 1rem; }

.formula {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem;
    color: var(--secondary-color); background: var(--background-color); border-left: 3px solid var(--accent-color);
    border-radius: 0 6px 6px 0; padding: .7rem 1rem; overflow-x: auto;
}
.formula + .formula { margin-top: .6rem; }

/* Interpretation and warning boxes */
.interpretation {
    background: var(--info-bg); border: 1px solid var(--info-border); border-radius: 8px;
    padding: 1rem 1.25rem; color: var(--secondary-color); margin-top: 1.25rem;
}
.interpretation h3 { font-size: 1rem; color: var(--info-ink); margin-bottom: .5rem; }
.interpretation p + p, .interpretation p + ul, .interpretation ul + p { margin-top: .5rem; }
.interpretation ul { padding-left: 1.1rem; }
.interpretation strong { color: var(--primary-color); }
.warning {
    background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-ink); border-radius: 8px;
    padding: .75rem 1rem; margin-top: 1rem; font-size: .9rem;
}
.warning ul { padding-left: 1.1rem; }
.warning li + li { margin-top: .25rem; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .75rem 1rem; text-align: center; border: 1px solid var(--grid); }
th { background: var(--background-color); font-weight: 600; }
thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td { font-size: 1.05rem; }

/* Rule lists and references */
.rules { padding-left: 1.1rem; color: var(--secondary-color); font-size: .95rem; }
.rules li + li { margin-top: .5rem; }
.rules strong { color: var(--primary-color); }
.refs { padding-left: 1.1rem; color: var(--secondary-color); font-size: .88rem; }
.refs li + li { margin-top: .4rem; }
.refs a { color: var(--accent-color); }
.disclaimer { font-size: .85rem; color: var(--muted); margin-top: 1.25rem; max-width: 78ch; }

/* Charts */
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem 1rem; margin-bottom: .75rem; }
.chart-head h3 { margin-bottom: 0; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: .85rem; color: var(--secondary-color); margin-bottom: .5rem; }
.legend .key { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend .key.dashed { border-top-style: dashed; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 4px; border-radius: 4px; }
.chart .tick { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .axis-title { font-size: 12px; fill: var(--secondary-color); }
.chart .mark-label {
    font-size: 12px; fill: var(--secondary-color); font-weight: 600;
    paint-order: stroke; stroke: var(--surface, white); stroke-width: 4px; stroke-linejoin: round;
}
.chart-tip {
    position: absolute; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .1s;
    background: var(--surface, white); color: var(--primary-color); border: 1px solid var(--grid); border-radius: 8px;
    padding: .5rem .65rem; font-size: .8rem; line-height: 1.45; box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
    min-width: 150px; white-space: nowrap;
}
.chart-tip .tip-title { color: var(--muted); font-size: .75rem; margin-bottom: .2rem; }
.chart-tip .tip-row { display: flex; align-items: center; gap: .45rem; }
.chart-tip .tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip .tip-key { width: 12px; height: 0; border-top: 2px solid; flex: none; }
.chart-tip .tip-muted { color: var(--secondary-color); }

/* Report summary and export card */
.export-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem 1rem; margin-bottom: .5rem; }
.export-head h2 { margin-bottom: 0; }
.export-note { font-size: .9rem; color: var(--secondary-color); margin: 0 0 1rem; max-width: 78ch; }
.summary-text {
    white-space: pre-wrap; font: inherit; font-size: .93rem; line-height: 1.6; color: var(--primary-color);
    background: var(--background-color); border: 1px solid var(--grid); border-radius: 8px;
    padding: 1rem 1.15rem; margin: 0; max-height: 360px; overflow: auto;
}
.summary-text.empty { color: var(--muted); }
.summary-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 1.25rem 0 .5rem; }

details.table-view { margin-top: 1rem; }
details.table-view summary { cursor: pointer; color: var(--accent-color); font-size: .9rem; }
details.table-view table { margin-top: .75rem; }
details.table-view td, details.table-view th { padding: .45rem .75rem; font-size: .9rem; }

@media (max-width: 768px) {
    main { padding: 0 1rem; }
    .page-head h1 { font-size: 1.6rem; }
    .content { grid-template-columns: minmax(0, 1fr); }
    .card, .input-section, .results-section, .contingency-table, .formula-section { padding: 1.25rem; }
    th, td { padding: .6rem .6rem; }
    .result-value { font-size: 1.1rem; }
}
