﻿:root {
    color-scheme: light dark;
    --border: #ccc;
    --ok-bg: #e6f4ea;
    --ok-border: #34a853;
    --warn-bg: #fdecea;
    --warn-border: #d93025;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    line-height: 1.4;
}

h1 {
    font-size: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    margin: 2rem 0 1rem;
}

.page-header h1 {
    margin: 0;
}

.icon-button {
    background: none;
    border: none;
    padding: 0.25rem;
    line-height: 0;
    color: inherit;
    cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
    color: #1a73e8;
}

.flyout {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    min-width: 320px;
    max-width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: Canvas;
    color: CanvasText;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flyout:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.flyout-title {
    margin: 0;
    font-size: 1.1rem;
}

.flyout label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    gap: 0.25rem;
}

.flyout input[type="text"],
.flyout textarea {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
}

.flyout-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

#edit-cancel {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: none;
    color: inherit;
    cursor: pointer;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.scenario-option {
    display: block;
    margin: 0.4rem 0;
}

.inputs-section {
    margin-bottom: 1rem;
}

.inputs-section > summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
}

.field-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    gap: 0.25rem;
    align-items: flex-start;
}

.field-grid input {
    box-sizing: border-box;
}

.field-grid label.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.subgroup-row {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}

.subgroup-row fieldset.subgroup {
    flex: 1 1 220px;
}

.field-grid fieldset.subgroup {
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field-grid fieldset.subgroup legend {
    font-size: 0.85rem;
    padding: 0 0.25rem;
}

.total-line {
    font-size: 0.85rem;
    font-weight: 600;
    color: #888;
    margin: 0;
}

.subgroup-hint {
    font-size: 0.8rem;
    color: #888;
    margin: 0;
}

input[type="number"] {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

button[type="submit"] {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    background: #1a73e8;
    color: white;
    cursor: pointer;
}

button[type="submit"]:hover {
    background: #1558b0;
}

#results {
    margin-top: 2rem;
}

.summary-box {
    border: 1px solid var(--border);
    border-left-width: 6px;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #1f2937;
    color: #f3f4f6;
}

.summary-box.ok {
    border-left-color: var(--ok-border);
}

.summary-box.warn {
    border-left-color: var(--warn-border);
}

.summary-box p {
    margin: 0.3rem 0;
}

.run-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.run-table th,
.run-table td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.run-table th {
    background: rgba(0, 0, 0, 0.05);
}

.breakdown-list {
    margin: 0;
    padding-left: 1.1rem;
    list-style: disc;
}

.run-toggle {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: #1a73e8;
    cursor: pointer;
    text-decoration: underline;
}

.run-toggle:hover {
    color: #1558b0;
}

.run-detail-row td {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.03);
}

.run-detail-row .run-table {
    margin-bottom: 0;
}

.failure {
    color: var(--warn-border);
}

.success {
    color: #888;
}

details {
    margin-top: 1rem;
}

details pre {
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.04);
    padding: 1rem;
    border-radius: 6px;
    max-height: 500px;
    overflow-y: auto;
}

.error-box {
    border: 1px solid var(--warn-border);
    background: var(--warn-bg);
    /* Explicit text colour: the background is light in both themes, so inheriting
       the page colour leaves this unreadable under a dark colour-scheme. */
    color: #7f1d1d;
    border-radius: 6px;
    padding: 1rem;
}

.loading {
    font-style: italic;
    color: #888;
}

.flyout {
    max-width: 420px;
}

#edit-result:not(:empty) {
    margin-top: 0.25rem;
}

#edit-result .summary-box {
    margin-bottom: 0.5rem;
}

.agent-trace {
    margin-top: 0;
    font-size: 0.85rem;
}

.agent-trace summary {
    cursor: pointer;
    color: #1a73e8;
}

.agent-trace p {
    margin: 0.4rem 0;
    overflow-wrap: anywhere;
}

.agent-note {
    color: #888;
    font-style: italic;
}

.flyout-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.flyout-close {
    background: none;
    border: none;
    padding: 0 0.25rem;
    font-size: 1.4rem;
    line-height: 1;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
}

.flyout-close:hover,
.flyout-close:focus-visible {
    opacity: 1;
    color: #1a73e8;
}

.hamburger-toggle {
    margin-left: auto;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 10;
    min-width: 160px;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: Canvas;
    color: CanvasText;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dropdown-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 4px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.dropdown-menu button:hover,
.dropdown-menu button:focus-visible {
    background: rgba(26, 115, 232, 0.1);
    color: #1a73e8;
}

.flyout-right {
    left: auto;
    right: 0;
}

.observe-section {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.observe-section h2 {
    margin-top: 0;
}

.placeholder-text {
    color: #888;
    font-style: italic;
}

/* Optimal page link in the main menu - styled like the menu's buttons */
.dropdown-menu a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus-visible {
    background: rgba(26, 115, 232, 0.1);
    color: #1a73e8;
}

/* Optimal page */
.page-intro {
    margin: 0 0 1rem;
    color: #555;
}

.recommended-row td {
    font-weight: 600;
}

/* Superscript footnote with a hover/focus/tap tooltip (main page year tables) */
.footnote {
    position: relative;
    margin-left: 0.15em;
}

.footnote-ref {
    color: #1a73e8;
    text-decoration: none;
    font-weight: 600;
}

.footnote-tip {
    display: none;
    position: absolute;
    left: 0;
    top: 1.4em;
    z-index: 10;
    width: 20rem;
    max-width: 70vw;
    padding: 0.5rem 0.65rem;
    border: 1px solid #c9d7ef;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: #333;
    font-size: 0.8rem;
    font-weight: normal;
    line-height: 1.35;
    white-space: normal;
}

.footnote:hover .footnote-tip,
.footnote:focus-within .footnote-tip,
.footnote.open .footnote-tip {
    display: block;
}

/* Model Info page */
.info-section {
    margin: 2rem 0;
}

.info-section h2 {
    font-size: 1.25rem;
    margin: 0 0 0.6rem;
}

.info-section h3 {
    font-size: 1rem;
    margin: 1.2rem 0 0.4rem;
}

.info-section p {
    margin: 0 0 0.7rem;
}

.info-lede {
    font-size: 1.05rem;
}

.info-meta {
    color: #666;
    font-size: 0.85rem;
}

.info-notes {
    margin: 0 0 0.8rem;
    padding-left: 1.2rem;
}

.info-notes li {
    margin-bottom: 0.35rem;
}

.info-callout {
    border-left: 4px solid #1a73e8;
    padding-left: 0.8rem;
}

.info-code {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    overflow-x: auto;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.8rem;
}

.stat-tile {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.8rem;
    display: grid;
    gap: 0.3rem;
    align-content: start;
}

.stat-tile b {
    font-size: 1.4rem;
    font-variant-numeric: tabular-nums;
}

.stat-tile span {
    color: #666;
    font-size: 0.85rem;
}

.stat-tile.key {
    border-color: var(--ok-border);
    background: var(--ok-bg);
    color: #1e1e1e;
}

.stat-tile.key span {
    color: #333;
}

.table-scroll {
    overflow-x: auto;
    margin-bottom: 0.8rem;
}

.table-scroll .run-table {
    margin-bottom: 0;
}

.run-table td.num,
.run-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.strategy-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
}

.gain {
    color: #188038;
}

.loss {
    color: #c5221f;
}

.strategy-grid td.grid-cell {
    min-width: 8.5rem;
}

.grid-main {
    display: block;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.grid-sub {
    display: block;
    color: #666;
    font-size: 0.75rem;
}

.strategy-grid td.grid-cell.gain {
    background: rgba(52, 168, 83, 0.12);
}

.strategy-grid td.grid-cell.loss {
    background: rgba(217, 48, 37, 0.1);
}

.strategy-grid td.grid-cell.baseline {
    background: rgba(26, 115, 232, 0.1);
}

.run-table tr.slice-group th {
    background: rgba(0, 0, 0, 0.08);
}

.run-table td.household {
    min-width: 22rem;
}

.case-study tr.year-first td {
    border-top-width: 2px;
}

.summary-link {
    color: inherit;
    text-decoration: underline;
}

/* Optimal page: "Run in Simulator" on each scenario's result, and the note it leaves on the main page */
.simulator-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.run-in-simulator {
    padding: 0.45rem 1rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 4px;
    background: #1a73e8;
    color: white;
    cursor: pointer;
}

.run-in-simulator:hover {
    background: #1558b0;
}

.run-in-simulator:focus-visible {
    outline: 2px solid #8ab4f8;
    outline-offset: 2px;
}

.simulator-message {
    color: #f28b82;
    font-size: 0.9rem;
}

.handoff-note {
    margin-top: 2rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-left: 4px solid #1a73e8;
    border-radius: 6px;
    font-size: 0.92rem;
}

.handoff-note + #results {
    margin-top: 1rem;
}
