:root {
    color-scheme: dark;
    --bg-primary: #000000;
    --bg-surface: #000a0d;
    --bg-elevated: #001114;
    --fg-primary: #b8fbff;
    --fg-dim: #2a5a60;
    --accent: #00e5ff;
    --accent-bright: #7dffff;
    --highlight: #39ff88;
    --highlight-dim: #1a5c38;
    --alert: #ff4444;
    --line: rgba(0, 229, 255, 0.35);
    --line-highlight: rgba(57, 255, 136, 0.35);
    --glow-sm: 0 0 4px rgba(0, 229, 255, 0.6);
    --glow-lg: 0 0 20px rgba(0, 229, 255, 0.4);
    --glow-highlight: 0 0 8px rgba(57, 255, 136, 0.6);
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg-primary);
    color: var(--fg-primary);
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
    line-height: 1.6;
    scroll-behavior: smooth;
    font-variant-numeric: tabular-nums;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
svg {
    max-width: 100%;
}

a,
.btn-link {
    color: var(--accent);
}

a:hover,
.btn-link:hover {
    color: var(--accent-bright);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    color: var(--fg-primary);
    font-weight: 500;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1 {
    font-size: 48px;
}

h2 {
    font-size: 32px;
}

h3 {
    font-size: 20px;
}

p,
ul,
ol,
dl {
    margin: 0;
}

code {
    color: var(--highlight);
}

.terminal-window,
.terminal-panel,
.terminal-card,
.control-panel,
.live-panel,
.results-panel,
.order-panel,
.follow-up-panel,
.empty-state,
.metric-card,
.vendor-order,
.project-card,
.vendor-toggle,
.live-vendor,
.live-feed-row,
.vendor-order dl div,
.tag-list span,
.status-chip,
.order-summary span,
.status-strip,
.terminal-output {
    border: 1px solid var(--line);
    background: var(--bg-surface);
    border-radius: 1px;
}

.terminal-window {
    overflow: hidden;
}

.terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 40px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elevated);
}

.terminal-dots {
    display: flex;
    gap: 0.4rem;
}

.dot {
    width: 8px;
    height: 8px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    box-shadow: var(--glow-sm);
}

.dot-green {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.terminal-title,
.prompt-line,
.card-label,
.field-label,
.panel-label,
.section-heading > strong,
.metric-card span,
.live-vendor span,
.live-vendor small,
.live-feed-card small,
.card-cell small,
.price-stack small,
.vendor-price-cell small,
.order-card small,
.vendor-toggle small,
.vendor-order dt,
.nav-status-copy {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 400;
}

.panel-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--accent);
}

.panel-label > span:first-child {
    color: var(--accent);
}

.status-tag {
    color: var(--fg-dim);
}

.status-tag.is-live {
    color: var(--highlight);
}

.prompt-line::before {
    content: "$ ";
    color: var(--accent);
}

.terminal-output {
    display: grid;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--fg-primary);
}

.button,
.section-link,
.text-action,
.icon-button,
.expand-order-button,
.optimization-tab,
.rz-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--accent);
    border-radius: 1px;
    background: transparent;
    color: var(--accent);
    font: inherit;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.button:hover,
.section-link:hover,
.text-action:hover,
.icon-button:hover,
.expand-order-button:hover,
.optimization-tab:hover,
.rz-button:hover {
    color: var(--accent-bright);
    border-color: var(--accent-bright);
    box-shadow: var(--glow-lg);
}

.button.button-primary,
.run-button,
.button.is-primary {
    border-color: var(--highlight);
    color: var(--highlight);
}

.button.button-primary:hover,
.run-button:hover,
.button.is-primary:hover {
    color: var(--highlight);
    border-color: var(--highlight);
    box-shadow: var(--glow-highlight);
}

.terminal-link::before {
    content: "> ";
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.button:focus-visible,
.section-link:focus-visible,
.text-action:focus-visible,
.icon-button:focus-visible,
.expand-order-button:focus-visible,
.optimization-tab:focus-visible,
.nav-link:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
    box-shadow: var(--glow-sm);
}

.home-page,
.projects-page,
.mtg-page,
.single-panel-page {
    display: grid;
    gap: 0.5rem;
}

.terminal-panel,
.single-panel-page {
    display: grid;
    gap: 1rem;
}

.terminal-panel {
    padding: 1.25rem;
}

.terminal-card,
.project-card {
    display: grid;
    gap: 0.75rem;
    padding: 0.85rem;
}

.hero-panel {
    min-height: 320px;
    align-content: start;
}

.home-screen {
    height: calc(100vh - 0.7rem);
}

.mtg-page {
    min-height: calc(100vh - 0.7rem);
}

.console-window {
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.console-titlebar {
    min-height: 38px;
    padding: 0.55rem 0.85rem;
}

.mtg-shell {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem;
    align-content: start;
}

.mtg-hero-panel {
    position: relative;
    gap: 1rem;
    padding-top: 2.5rem;
    padding-bottom: 2rem;
}

.mtg-readouts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-board-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: minmax(10rem, 1.1fr) minmax(7rem, 0.85fr) minmax(10rem, 1fr);
    gap: 0.75rem;
    padding: 0.75rem;
    min-height: 0;
    height: 100%;
}

.board-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.board-layer-grid {
    opacity: 0.08;
    background-image:
        linear-gradient(to right, var(--accent) 1px, transparent 1px),
        linear-gradient(to bottom, var(--accent) 1px, transparent 1px);
    background-size: calc((100% - 3.85rem) / 12) 100%, 100% 4.5rem;
    animation: grid-drift 16s linear infinite;
}

.board-panel {
    position: relative;
    z-index: 1;
    min-width: 0;
    display: grid;
    align-content: start;
    padding: 0.75rem;
    overflow: hidden;
    animation: panel-boot 700ms ease both;
    transition:
        border-color 180ms ease,
        box-shadow 180ms ease,
        transform 180ms ease;
}

.board-panel::before {
    content: "";
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: 0.75rem;
    height: 1px;
    background: var(--line);
    transform: scaleX(0);
    transform-origin: left;
    opacity: 0.8;
    animation: panel-trace 900ms ease-out 180ms both;
}

.board-panel-active {
    z-index: 2;
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
    animation:
        panel-boot 700ms ease both,
        live-pulse 4.2s ease-in-out 1.2s infinite;
}

.board-panel-node {
    grid-column: 1 / span 5;
    grid-row: 1;
    min-height: 0;
}

.board-panel-world {
    grid-column: 6 / span 7;
    grid-row: 1/3;
    min-height: 0;
}

.board-panel-contact {
    grid-column: 10 / span 3;
    grid-row: 1 / span 2;
}

.board-panel-ops {
    grid-column: 1 / span 5;
    grid-row: 2;
    min-height: 0;
}

.board-panel-nav {
    grid-column: 8 / span 5;
    grid-row: 3;
}

.board-panel-vis {
    grid-column: 1 / span 7;
    grid-row: 3;
}

.board-panel-overlay {
    z-index: 3;
    align-self: end;
    justify-self: stretch;
    margin: 0 1rem 1rem 0;
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
    background: var(--bg-elevated);
}

.panel-corner {
    position: absolute;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.panel-corner-top {
    top: 0.75rem;
    right: 0.75rem;
}

.panel-corner-bottom {
    right: 0.75rem;
    bottom: 0.75rem;
}

.hero-system-line {
    display: inline-flex;
    align-items: baseline;
    max-width: calc(100% - 1.5rem);
    color: var(--accent);
}

.contact-links,
.project-nav-box {
    animation: content-rise 720ms ease both;
}

.type-line {
    min-height: 1em;
    visibility: hidden;
}

.type-line.is-ready {
    visibility: visible;
}

.panel-copy,
.placeholder-copy {
    color: var(--fg-dim);
}

.hero-lede {
    max-width: 44rem;
    font-size: 18px;
    color: var(--fg-primary);
}

.hero-summary,
.contact-panel p,
.projects-page p,
.project-card p,
.featured-project p,
.terminal-card p,
.page-header p,
.section-heading p,
.empty-state p,
.muted {
    color: var(--fg-dim);
}

.hero-actions,
.tag-list,
.order-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.terminal-cursor {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--accent);
    animation: blink 1s step-end infinite;
}

.focus-items,
.process-grid,
.project-grid,
.metric-grid,
.follow-up-panel,
.contact-links {
    display: grid;
    gap: 1rem;
}

.focus-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.process-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.journal-feed {
    display: grid;
    gap: 0.35rem;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
    visibility: hidden;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--line-highlight) transparent;
}

.journal-feed.is-ready {
    visibility: visible;
}

.journal-line {
    position: relative;
    display: grid;
    gap: 0.35rem;
    align-items: start;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(0, 229, 255, 0.12);
    color: var(--fg-primary);
    transition:
        opacity 150ms linear,
        clip-path 180ms linear,
        filter 180ms linear;
    clip-path: inset(0 0 0 0);
    filter: brightness(1);
}

.journal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    min-width: 0;
}

.journal-line::before {
    content: "";
    position: absolute;
    top: -0.1rem;
    bottom: -0.1rem;
    left: 0;
    width: 1.25rem;
    background: rgba(0, 229, 255, 0.18);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
    opacity: 0;
    transform: translateX(-140%);
    pointer-events: none;
}

.journal-line--incoming {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    filter: brightness(1.8);
}

.journal-line--incoming::before {
    opacity: 1;
    transform: translateX(0);
    transition:
        transform 180ms linear,
        opacity 180ms linear;
}

.journal-time,
.journal-source {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.journal-message {
    min-width: 0;
    line-height: 1.5;
    padding-left: 0.9rem;
    color: var(--fg-primary);
}

.journal-source,
.journal-message {
    overflow-wrap: anywhere;
}

.project-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.project-nav-box {
    display: grid;
    gap: 0.5rem;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--line);
    background: var(--bg-surface);
    color: var(--accent);
    text-decoration: none;
    align-content: end;
    transition:
        border-color 180ms ease,
        box-shadow 180ms ease,
        color 180ms ease,
        transform 180ms ease;
}

.project-nav-box:nth-child(1) {
    animation-delay: 0.14s;
}

.project-nav-box:nth-child(2) {
    animation-delay: 0.22s;
}

.project-nav-box:nth-child(3) {
    animation-delay: 0.3s;
}

.project-nav-box:nth-child(4) {
    animation-delay: 0.38s;
}

.project-nav-box strong,
.project-nav-box small,
.project-nav-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.project-nav-box strong {
    color: var(--fg-primary);
    font-weight: 500;
}

.project-nav-box small,
.project-nav-label {
    color: var(--fg-dim);
}

.project-nav-box:hover {
    border-color: var(--accent-bright);
    color: var(--accent-bright);
    box-shadow: var(--glow-lg);
    transform: translateY(-2px);
}

.project-nav-box.is-live {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
    animation:
        content-rise 720ms ease both,
        live-pulse 4.8s ease-in-out 1.4s infinite;
}

.project-nav-box.is-live strong {
    color: var(--highlight);
}

.project-nav-box.is-empty {
    color: var(--fg-dim);
}

.board-panel-node {
    animation-delay: 0.05s;
}

.board-panel-world {
    animation-delay: 0.12s;
}

.board-panel-contact {
    animation-delay: 0.22s;
}

.board-panel-ops {
    animation-delay: 0.18s;
}

.board-panel-vis {
    animation-delay: 0.26s;
}

.board-panel-nav {
    animation-delay: 0.3s;
}

.board-panel-contact .contact-links {
    animation-delay: 0.3s;
}

.wireframe-placeholder {
    position: relative;
    min-height: 100%;
    height: 100%;
    border: 1px solid var(--line);
    overflow: hidden;
}

.wireframe-placeholder-small {
    min-height: 180px;
}

.wireframe-placeholder-world {
    min-height: 100%;
}

.wireframe-ring,
.wireframe-axis {
    position: absolute;
    border: 1px solid var(--line);
    box-shadow: var(--glow-sm);
}

.wireframe-ring {
    border-radius: 50%;
}

.wireframe-ring-a {
    inset: 12% 18%;
}

.wireframe-ring-b {
    inset: 24% 30%;
}

.wireframe-axis-h {
    left: 8%;
    right: 8%;
    top: 50%;
}

.wireframe-axis-v {
    top: 8%;
    bottom: 8%;
    left: 50%;
}

.wireframe-node {
    position: absolute;
    width: 8px;
    height: 8px;
    border: 1px solid var(--line-highlight);
    background: var(--bg-primary);
    box-shadow: var(--glow-highlight);
}

.wireframe-node-a {
    top: 22%;
    left: 26%;
}

.wireframe-node-b {
    top: 58%;
    right: 24%;
}

.wireframe-node-c {
    bottom: 18%;
    left: 48%;
}

.hud-readouts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    margin-top: auto;
}

.hud-readout {
    display: grid;
    gap: 0.35rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    background: var(--bg-surface);
}

.hud-readout.is-anchored {
    align-self: end;
}

.hud-readout-label {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hud-readout strong {
    color: var(--fg-primary);
    font-weight: 500;
    letter-spacing: 0.08em;
}

.hud-readout strong.is-live {
    color: var(--highlight);
}

.featured-project {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.project-preview .terminal-output {
    border: 0;
    padding-top: 0;
}

.featured-project-copy,
.project-card {
    display: grid;
    gap: 1rem;
}

.project-card-placeholder {
    align-content: start;
}

.section-header,
.page-header,
.section-heading,
.project-card-footer,
.vendor-order-header,
.vendor-order li,
.follow-up-panel li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.page-header {
    flex-wrap: wrap;
}

.status-strip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border: 1px solid var(--line-highlight);
    border-radius: 50%;
    background: transparent;
    box-shadow: var(--glow-highlight);
}

.status-strip.is-running {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.control-panel {
    position: relative;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(280px, 420px);
    gap: 1rem;
    padding: 1.25rem;
    padding-top: 2.6rem;
    align-items: start;
}

.search-panel {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.control-panel > .panel-label {
    grid-column: 1 / -1;
}

.decklist-panel {
    display: grid;
    gap: 0.65rem;
}

.vendor-grid,
.filter-grid,
.live-vendor-grid,
.vendor-order-grid {
    display: grid;
    gap: 0.75rem;
}

.vendor-grid,
.filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.live-vendor-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.vendor-order-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.vendor-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    cursor: pointer;
}

.vendor-toggle.is-selected,
.vendor-price-cell.is-cheapest,
.optimization-tab.is-active,
.nav-status,
.vendor-order.is-active {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.vendor-toggle strong,
.vendor-toggle small {
    display: block;
}

.message {
    padding: 0.875rem;
    border-radius: 1px;
}

.message-error,
.vendor-access-alert,
.text-danger,
.validation-message,
.invalid,
.blazor-error-boundary {
    border: 1px solid var(--alert);
    color: var(--alert);
}

.vendor-access-alert,
.message-error {
    background: var(--bg-elevated);
}

.empty-state,
.live-panel,
.results-panel,
.order-panel,
.follow-up-panel,
.metric-card {
    padding: 1.25rem;
}

.metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card strong,
.section-heading > strong,
.live-vendor strong,
.live-feed-price,
.vendor-order-header span,
.vendor-order li > strong,
.follow-up-panel li strong,
.price-link,
.order-card-link {
    color: var(--highlight);
}

.live-feed-list {
    display: grid;
    gap: 0.75rem;
    max-height: 360px;
    overflow: auto;
}

.results-grid {
    overflow-x: auto;
}

.live-feed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem;
}

.live-feed-row.is-warning {
    border-color: var(--alert);
}

.live-vendor.has-warning {
    border-color: var(--alert);
    box-shadow: none;
}

.live-feed-row.is-missing,
.vendor-price-cell.is-missing {
    border-color: var(--line);
    box-shadow: none;
}

.card-cell,
.price-stack,
.vendor-price-cell,
.order-card,
.live-feed-card,
.live-vendor {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.vendor-price-cell {
    justify-items: end;
}

.optimization-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.optimization-tab {
    align-items: flex-start;
    flex-direction: column;
}

.vendor-order {
    padding: 1rem;
}

.vendor-order dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
}

.vendor-order dt,
.vendor-order dd {
    margin: 0;
}

.vendor-order dd {
    color: var(--fg-primary);
}

.vendor-order ul,
.follow-up-panel ul {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.follow-up-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rz-textarea,
.rz-inputtext,
.rz-spinner,
.rz-numeric,
.rz-dropdown,
.rz-dropdown-label,
.rz-dropdown-trigger,
.rz-numeric input {
    width: 100%;
    border-color: var(--line) !important;
    background: var(--bg-elevated) !important;
    color: var(--fg-primary) !important;
    font-family: "JetBrains Mono", monospace !important;
    border-radius: 1px !important;
}

.rz-textarea::placeholder,
.rz-inputtext::placeholder {
    color: var(--fg-dim) !important;
}

.rz-state-disabled,
.rz-state-disabled .rz-inputtext,
.rz-state-disabled .rz-textarea {
    opacity: 0.65;
}

.rz-button.rz-primary,
.rz-button.rz-primary.rz-state-hover,
.rz-button.rz-primary:hover {
    border: 1px solid var(--highlight) !important;
    background: transparent !important;
    color: var(--highlight) !important;
    box-shadow: none !important;
}

.rz-button.rz-primary:hover {
    box-shadow: var(--glow-highlight) !important;
}

.rz-chkbox-box {
    border-color: var(--line) !important;
    background: var(--bg-primary) !important;
    border-radius: 1px !important;
}

.rz-chkbox-box.rz-state-active,
.rz-chkbox-box.rz-state-active:hover {
    border-color: var(--line-highlight) !important;
    box-shadow: var(--glow-highlight) !important;
}

.rz-icon-check {
    color: var(--highlight) !important;
}

.rz-datatable,
.rz-data-grid,
.rz-grid-table,
.rz-paginator {
    background: transparent !important;
    color: var(--fg-primary) !important;
}

.rz-data-grid {
    overflow-x: auto;
}

.rz-grid-table {
    min-width: 720px;
}

.rz-grid-table thead th,
.rz-datatable-thead th {
    border-color: var(--line) !important;
    background: var(--bg-elevated) !important;
    color: var(--accent) !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 400;
}

.rz-grid-table td,
.rz-datatable-data td {
    border-color: var(--line) !important;
    background: var(--bg-surface) !important;
    color: var(--fg-primary) !important;
}

.rz-grid-table tr:hover td {
    border-color: var(--line-highlight) !important;
    box-shadow: inset 0 0 0 1px rgba(57, 255, 136, 0.15);
}

.rz-paginator,
.rz-paginator-element,
.rz-page-numbers .rz-paginator-element,
.rz-paginator .rz-dropdown,
.rz-paginator .rz-dropdown-trigger,
.rz-paginator .rz-inputtext,
.rz-paginator .rz-numeric {
    border-color: var(--line) !important;
    background: var(--bg-elevated) !important;
    color: var(--fg-primary) !important;
}

.rz-paginator-element.rz-state-active,
.rz-paginator .rz-paginator-page.rz-state-active,
.rz-paginator .rz-state-active {
    border-color: var(--line-highlight) !important;
    color: var(--highlight) !important;
    box-shadow: var(--glow-highlight) !important;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--highlight);
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

@keyframes blink-soft {
    50% {
        opacity: 0.35;
    }
}

@keyframes panel-boot {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes content-rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes panel-trace {
    from {
        transform: scaleX(0);
        opacity: 0.2;
    }

    to {
        transform: scaleX(1);
        opacity: 0.8;
    }
}

@keyframes live-pulse {
    0%,
    100% {
        box-shadow: var(--glow-highlight);
    }

    50% {
        box-shadow: 0 0 12px rgba(57, 255, 136, 0.45);
    }
}

@keyframes grid-drift {
    0%,
    100% {
        opacity: 0.08;
        background-position: 0 0, 0 0;
    }

    50% {
        opacity: 0.12;
        background-position: 8px 0, 0 10px;
    }
}

@media (max-width: 1100px) {
    .featured-project,
    .control-panel,
    .focus-items,
    .process-grid,
    .project-grid {
        grid-template-columns: 1fr;
    }

    .home-board-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        grid-template-rows: auto;
        min-height: 0;
    }

    .board-panel-node {
        grid-column: 1 / span 3;
        grid-row: auto;
    }

    .board-panel-world {
        grid-column: 4 / span 3;
        grid-row: auto;
    }

    .board-panel-contact {
        grid-column: 4 / span 3;
        grid-row: auto;
        margin: 0;
    }

    .board-panel-ops,
    .board-panel-vis,
    .board-panel-nav,
    .board-panel-contact {
        grid-column: span 3;
        grid-row: auto;
    }

    .board-panel-vis {
        min-height: 20rem;
    }

    .project-nav-grid,
    .hud-readouts {
        grid-template-columns: 1fr;
    }

    .mtg-readouts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    body {
        font-size: 13px;
    }

    h1 {
        font-size: 32px;
    }

    h2 {
        font-size: 24px;
    }

    .hero-lede {
        font-size: 16px;
    }

    .home-board-grid {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .home-screen,
    .mtg-page {
        height: auto;
        min-height: 0;
    }

    .console-window {
        height: auto;
    }

    .console-titlebar,
    .terminal-titlebar {
        padding: 0.5rem 0.65rem;
    }

    .terminal-title {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .terminal-panel,
    .terminal-card,
    .control-panel,
    .live-panel,
    .results-panel,
    .order-panel,
    .follow-up-panel,
    .empty-state,
    .metric-card {
        padding: 0.9rem;
    }

    .mtg-shell {
        gap: 0.35rem;
        padding: 0.35rem;
    }

    .mtg-hero-panel,
    .control-panel {
        padding-top: 2.35rem;
    }

    .board-panel-node,
    .board-panel-world,
    .board-panel-ops,
    .board-panel-vis,
    .board-panel-nav,
    .board-panel-contact {
        grid-column: 1;
        grid-row: auto;
    }

    .board-panel-overlay {
        margin: 0;
    }

    .vendor-grid,
    .filter-grid,
    .metric-grid,
    .mtg-readouts,
    .follow-up-panel,
    .contact-links,
    .project-nav-grid {
        grid-template-columns: 1fr;
    }

    .journal-line {
        gap: 0.3rem;
    }

    .live-feed-row,
    .vendor-order li {
        gap: 0.5rem;
    }

    .live-feed-row {
        align-items: flex-start;
    }

    .status-strip {
        width: 100%;
        justify-content: flex-start;
    }

    .section-header,
    .page-header,
    .section-heading,
    .project-card-footer,
    .vendor-order-header,
    .vendor-order li,
    .follow-up-panel li,
    .panel-label {
        flex-direction: column;
    }

    .panel-corner {
        position: static;
        font-size: 11px;
    }

    .page-header,
    .section-heading,
    .vendor-order-header {
        gap: 0.5rem;
    }

    .vendor-order dl {
        grid-template-columns: 1fr;
    }

    .live-feed-list {
        max-height: none;
    }

    .results-grid .rz-data-grid,
    .results-grid .rz-grid-table {
        min-width: 720px;
    }
}

@media (max-width: 560px) {
    h1 {
        font-size: 26px;
    }

    h2 {
        font-size: 20px;
    }

    .nav-brand-name {
        font-size: 18px;
    }

    .nav-window-body {
        gap: 0.65rem;
        padding: 0.65rem;
    }

    .nav-list {
        display: grid;
        grid-template-columns: 1fr;
    }

    .nav-item ::deep .nav-link,
    .nav-item .nav-link {
        padding: 0.65rem 0.75rem;
    }

    .terminal-card,
    .control-panel,
    .live-panel,
    .results-panel,
    .order-panel,
    .follow-up-panel,
    .empty-state,
    .metric-card {
        padding: 0.8rem;
    }

    .mtg-hero-panel,
    .control-panel {
        padding-top: 2.15rem;
    }

    .wireframe-placeholder-small {
        min-height: 140px;
    }

    .project-nav-box {
        min-height: 86px;
    }
}

/* MTG search workspace: compact input rail with a results pane revealed on demand. */
.mtg-page {
    min-height: calc(100vh - 0.7rem);
}

.mtg-workspace {
    display: grid;
    grid-template-columns: minmax(0, 540px);
    justify-content: center;
    align-items: start;
    gap: 0;
    min-width: 0;
    min-height: calc(100vh - 0.7rem);
    padding: 0.75rem;
    overflow: hidden;
}

.mtg-workspace.has-results {
    grid-template-columns: minmax(320px, 0.34fr) minmax(0, 1fr);
    justify-content: stretch;
    gap: 0.75rem;
}

.mtg-workspace .control-panel {
    position: sticky;
    top: 0.75rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
    padding: 1rem;
    align-items: start;
    background: var(--bg-surface);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.mtg-workspace .control-panel:focus-within {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.mtg-control-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--line);
}

.mtg-control-header h1 {
    margin-top: 0.45rem;
    font-size: clamp(1.5rem, 2.2vw, 2.15rem);
}

.control-count {
    flex: none;
    padding-top: 0.15rem;
    color: var(--fg-dim);
    font-size: 11px;
    letter-spacing: 0.08em;
}

.mtg-workspace .vendor-grid {
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.mtg-workspace .vendor-toggle {
    padding: 0.6rem 0.7rem;
}

.mtg-workspace .vendor-toggle small {
    color: var(--fg-dim);
}

.mtg-workspace .filter-grid {
    gap: 0.55rem;
}

.mtg-workspace .run-button {
    width: 100%;
    min-height: 2.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.mtg-results-pane {
    display: grid;
    align-content: start;
    gap: 0.75rem;
    min-width: 0;
    transform-origin: left center;
    animation: mtg-results-reveal 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.results-status-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.6rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line-highlight);
    background: var(--bg-surface);
    box-shadow: var(--glow-highlight);
    color: var(--highlight);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.results-status-bar .results-vendor-count {
    margin-left: auto;
    color: var(--fg-dim);
    font-size: 11px;
}

.mtg-results-pane .live-panel,
.mtg-results-pane .results-panel,
.mtg-results-pane .order-panel,
.mtg-results-pane .follow-up-panel,
.mtg-results-pane .metric-card {
    padding: 0.9rem;
}

.mtg-results-pane h2 {
    font-size: clamp(1.2rem, 2vw, 1.65rem);
}

.mtg-results-pane .metric-grid {
    gap: 0.75rem;
}

.mtg-results-pane .metric-card {
    display: grid;
    gap: 0.25rem;
    text-align: center;
}

.mtg-results-pane .metric-card span {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
}

.mtg-results-pane .metric-card strong {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

@keyframes mtg-results-reveal {
    from {
        opacity: 0;
        transform: translateX(-2rem);
        clip-path: inset(0 100% 0 0);
    }

    to {
        opacity: 1;
        transform: translateX(0);
        clip-path: inset(0 0 0 0);
    }
}

@media (max-width: 980px) {
    .mtg-workspace.has-results {
        grid-template-columns: minmax(270px, 0.42fr) minmax(0, 1fr);
    }

    .mtg-control-header {
        display: grid;
    }
}

@media (max-width: 760px) {
    .mtg-workspace,
    .mtg-workspace.has-results {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.5rem;
        padding: 0.35rem;
        overflow: visible;
    }

    .mtg-workspace .control-panel {
        position: static;
        top: auto;
        padding: 0.8rem;
    }

    .mtg-control-header {
        display: flex;
    }

    .mtg-results-pane {
        animation-name: mtg-results-reveal-mobile;
    }
}

@keyframes mtg-results-reveal-mobile {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mtg-results-pane {
        animation: none;
    }
}

@media (max-width: 760px) {
    .mtg-page {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-console-window,
    .mtg-page .console-window {
        display: block;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-console-window > .console-titlebar {
        display: flex;
        width: 100%;
        min-width: 0;
    }

    .mtg-console-window .terminal-title {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 11px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .mtg-board {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-board .mtg-workspace,
    .mtg-board .mtg-workspace.has-results {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0.35rem;
        overflow: visible;
    }

    .mtg-board .control-panel,
    .mtg-board .mtg-workspace:not(.has-results) .control-panel {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        height: auto;
        min-height: 0;
        padding: 0.8rem;
        overflow: visible;
    }

    .mtg-board .mtg-workspace.has-results .control-panel {
        display: none;
    }

    .mtg-board .decklist-panel .rz-textarea {
        height: 13rem;
        min-height: 13rem;
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid,
    .mtg-board .mtg-workspace.has-results .vendor-grid,
    .mtg-board .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mtg-results-pane {
        grid-template-rows: auto auto auto;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .results-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .results-tab:nth-child(3) {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
        border-right: 0;
    }

    .mtg-results-pane > .order-panel,
    .mtg-results-pane > .results-panel,
    .mtg-results-pane > .follow-up-panel,
    .mtg-results-pane > .live-panel,
    .mtg-results-pane .vendor-order-grid,
    .mtg-results-pane .vendor-order {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-results-pane .vendor-order-grid,
    .mtg-results-pane .follow-up-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .mtg-results-pane .results-grid {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow-x: auto;
        overflow-y: visible;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--line-highlight) transparent;
    }
}

@media (max-width: 480px) {
    .mtg-console-window .terminal-dots {
        display: none;
    }

    .mtg-control-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid,
    .mtg-board .mtg-workspace.has-results .vendor-grid,
    .mtg-board .filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Finance analyser workspace: CSV import and cashflow inspection console. */
.finance-page {
    height: calc(100vh - 0.7rem);
    min-height: 0;
    overflow: hidden;
}

.finance-console-window {
    height: 100%;
    min-height: 0;
    animation: mtg-console-boot 520ms ease-out both;
}

.finance-console-window > .console-titlebar {
    animation: mtg-titlebar-boot 620ms ease-out 80ms both;
}

.finance-console-window .terminal-dots,
.finance-console-window .terminal-title,
.finance-console-window .terminal-home-link {
    animation: content-rise 520ms ease-out 220ms both;
}

.finance-board {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.finance-board > .board-layer-grid {
    background-size: 5rem 100%, 100% 4.5rem;
}

.finance-workspace {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.75rem;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    padding: 0.75rem;
    overflow: hidden;
}

.finance-workspace.has-results {
    justify-content: stretch;
}

.finance-workspace.show-inputs-tab {
    grid-template-rows: auto minmax(0, 1fr);
}

.finance-workspace:not(.show-inputs-tab) .finance-control-panel {
    display: none;
}

.finance-control-panel {
    position: relative;
    grid-row: 2;
    display: grid;
    gap: 1rem;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    padding: 1rem;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 1px;
    background: var(--bg-surface);
    animation: panel-boot 620ms ease-out 140ms both;
    scrollbar-width: thin;
    scrollbar-color: var(--line-highlight) transparent;
}

.finance-control-panel::before {
    content: "";
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: 1px;
    background: var(--accent);
    box-shadow: var(--glow-sm);
    transform-origin: left;
    animation: panel-trace 900ms ease-out 340ms both;
    pointer-events: none;
}

.finance-control-panel:focus-within {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.finance-inputs-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
}

.finance-inputs-view .finance-control-header,
.finance-inputs-view .finance-exclusion-panel {
    grid-column: 1 / -1;
}

.finance-control-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--line);
    animation: content-rise 520ms ease-out 260ms both;
}

.finance-control-header > div,
.section-heading > div {
    min-width: 0;
}

.finance-control-header h1 {
    margin-top: 0.45rem;
    font-size: clamp(1.5rem, 2.2vw, 2.15rem);
    overflow-wrap: anywhere;
}

.finance-input-panel,
.finance-overview-panel,
.finance-subpanel,
.category-card,
.projection-card,
.cashflow-month,
.top-merchant-row,
.recurring-row,
.recurring-detail-row,
.import-file-row,
.excluded-transaction-row,
.import-warning-panel {
    border: 1px solid var(--line);
    border-radius: 1px;
    background: var(--bg-surface);
}

.finance-input-panel {
    display: grid;
    gap: 0.85rem;
    min-width: 0;
    max-width: 100%;
    padding: 0.9rem;
    animation: content-rise 520ms ease-out both;
}

.finance-input-panel:nth-of-type(2) {
    animation-delay: 360ms;
}

.finance-input-panel:nth-of-type(3) {
    animation-delay: 440ms;
}

.income-source-list,
.bank-account-list,
.import-file-list,
.top-merchant-list,
.income-normalised-list,
.account-normalised-list,
.recurring-list,
.recurring-detail-list {
    display: grid;
    gap: 0.55rem;
}

.income-source-row,
.bank-account-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(110px, 0.55fr) minmax(120px, 0.55fr) auto;
    gap: 0.55rem;
    align-items: end;
    min-width: 0;
    max-width: 100%;
}

.income-source-row label,
.bank-account-row label,
.transaction-filter-bar label {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.income-source-row > *,
.bank-account-row > *,
.finance-button-row > *,
.transaction-filter-bar > * {
    min-width: 0;
}

.finance-input,
.finance-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 40px;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 1px;
    background: var(--bg-elevated);
    color: var(--fg-primary);
    font: inherit;
    letter-spacing: 0;
}

.finance-input::placeholder {
    color: var(--fg-dim);
}

.finance-select {
    appearance: auto;
}

.finance-button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    min-width: 0;
}

.finance-button-row .button,
.finance-button-row .run-button {
    width: 100%;
}

.finance-remove-button {
    width: 40px;
    min-width: 40px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.finance-remove-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.file-drop-zone {
    display: grid;
    gap: 0.45rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    background: var(--bg-elevated);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.file-drop-zone input[type="file"] {
    width: 100%;
    color: var(--fg-primary);
    font: inherit;
    text-transform: none;
    letter-spacing: 0;
}

.file-drop-zone input[type="file"]::file-selector-button {
    min-height: 32px;
    margin-right: 0.75rem;
    border: 1px solid var(--accent);
    border-radius: 1px;
    background: transparent;
    color: var(--accent);
    font: inherit;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.file-drop-zone:hover,
.file-drop-zone:focus-within {
    border-color: var(--accent-bright);
    color: var(--accent-bright);
    box-shadow: var(--glow-lg);
}

.file-drop-zone small,
.import-file-row small,
.recurring-row small,
.recurring-detail-row small,
.projection-card small,
.cashflow-month small,
.account-normalised-list small,
.top-merchant-row small,
.category-card dt {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.import-file-row,
.top-merchant-row,
.recurring-row,
.excluded-transaction-row,
.income-normalised-list div,
.account-normalised-list div {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.65rem;
}

.import-file-row span,
.top-merchant-row span,
.recurring-row span,
.recurring-detail-row > span,
.recurring-detail-stats,
.excluded-transaction-row span,
.account-normalised-list span {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.import-file-row strong,
.top-merchant-row strong,
.recurring-row strong,
.recurring-detail-row strong,
.excluded-transaction-row strong,
.income-normalised-list strong,
.account-normalised-list strong {
    overflow-wrap: anywhere;
}

.finance-toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.7rem;
    border: 1px solid var(--line);
    background: var(--bg-elevated);
}

.finance-toggle-row input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 0.2rem;
    accent-color: var(--highlight);
}

.finance-toggle-row span {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.finance-toggle-row small,
.excluded-transaction-row small,
.exclusion-summary small {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.exclusion-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    min-width: 0;
}

.exclusion-summary span {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.6rem;
    border: 1px solid var(--line);
    background: var(--bg-elevated);
}

.exclusion-summary strong {
    color: var(--highlight);
    font-size: 1.15rem;
}

.excluded-transaction-list {
    display: grid;
    gap: 0.55rem;
    min-width: 0;
}

.excluded-transaction-row {
    border-color: var(--alert);
}

.transaction-exclude-button,
.transaction-include-button {
    min-height: 32px;
    padding: 0.35rem 0.55rem;
    font-size: 12px;
    white-space: nowrap;
}

.transaction-include-button {
    flex: 0 0 auto;
}

.account-normalised-list div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
}

.account-normalised-list div > small {
    grid-column: 1 / -1;
    justify-self: end;
}

.import-warning-panel {
    display: grid;
    gap: 0.45rem;
    padding: 0.7rem;
    border-color: var(--alert);
    color: var(--alert);
    background: var(--bg-elevated);
}

.import-warning-panel ul {
    display: grid;
    gap: 0.3rem;
    margin: 0;
    padding-left: 1rem;
}

.finance-results-pane {
    position: relative;
    grid-row: 1;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: start;
    gap: 0.75rem;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    transform-origin: left center;
    animation: mtg-results-reveal 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.finance-results-pane .results-status-bar {
    animation: mtg-status-lock 540ms ease-out 160ms both;
}

.finance-results-pane .results-status-bar.is-running .status-dot {
    animation: live-pulse 2.4s ease-in-out infinite;
}

.finance-results-pane .results-tabs {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.finance-workspace.show-inputs-tab .finance-results-pane {
    grid-template-rows: auto auto;
    height: auto;
    overflow: visible;
}

.finance-overview-panel {
    display: grid;
    align-content: start;
    gap: 1rem;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    padding: 0.9rem;
    overflow: auto;
    animation: mtg-content-scan 360ms ease-out both;
    scrollbar-width: thin;
    scrollbar-color: var(--line-highlight) transparent;
}

.finance-metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.75rem;
}

.finance-metric-grid .metric-card {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.8rem;
    text-align: center;
}

.finance-metric-grid .metric-card strong {
    font-size: clamp(1rem, 1.35vw, 1.35rem);
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.finance-data-readout-list {
    display: grid;
    gap: 0.55rem;
    min-width: 0;
}

.finance-data-readout-list div {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: baseline;
    min-width: 0;
    padding: 0.6rem;
    border: 1px solid var(--line);
    background: var(--bg-elevated);
}

.finance-data-readout-list span {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
}

.finance-data-readout-list strong {
    justify-self: end;
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.finance-split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    min-height: 0;
}

.finance-subpanel {
    display: grid;
    align-content: start;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.85rem;
}

.cashflow-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.55rem;
}

.cashflow-month,
.projection-card {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.65rem;
}

.cashflow-month {
    width: 100%;
    color: var(--fg-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.cashflow-month:hover,
.cashflow-month:focus-visible {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.cashflow-month span,
.projection-card span {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.finance-timeline-panel {
    gap: 0.85rem;
}

.finance-chart-controls {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(150px, 220px);
    gap: 0.75rem;
    align-items: end;
    min-width: 0;
}

.finance-chart-controls label {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.finance-segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    border: 1px solid var(--line);
    background: var(--bg-surface);
}

.finance-chart-toggle {
    min-height: 40px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--accent);
    font: inherit;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.finance-chart-toggle:last-child {
    border-right: 0;
}

.finance-chart-toggle:hover,
.finance-chart-toggle:focus-visible {
    color: var(--accent-bright);
    box-shadow: inset 0 -1px 0 var(--accent);
}

.finance-chart-toggle.is-active {
    color: var(--highlight);
    box-shadow: inset 0 -1px 0 var(--highlight), var(--glow-highlight);
}

.finance-period-metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.finance-chart-panel {
    display: grid;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.85rem;
    border: 1px solid var(--line);
    background: var(--bg-surface);
}

.finance-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
}

.finance-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 8px;
    border: 1px solid var(--accent);
}

.legend-swatch.is-income {
    background: rgba(0, 229, 255, 0.16);
}

.legend-swatch.is-outgoing {
    background: rgba(0, 229, 255, 0.32);
}

.legend-swatch.is-net {
    border-color: var(--highlight);
    background: rgba(57, 255, 136, 0.18);
}

.finance-chart {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(46px, 1fr);
    gap: 0.35rem;
    min-width: 0;
    min-height: 260px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 0.35rem;
    scrollbar-width: thin;
    scrollbar-color: var(--line-highlight) transparent;
}

.finance-chart-point {
    display: grid;
    grid-template-rows: minmax(180px, 1fr) auto auto;
    gap: 0.3rem;
    min-width: 0;
    color: var(--fg-primary);
    text-align: center;
}

.finance-chart-bars {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 0.18rem;
    min-width: 0;
    min-height: 180px;
    padding: 0.25rem;
    border-bottom: 1px solid var(--line);
}

.finance-chart-bar {
    display: block;
    min-height: 0;
    border: 1px solid var(--line);
    background: rgba(0, 229, 255, 0.16);
    box-shadow: var(--glow-sm);
}

.finance-chart-bar.is-outgoing {
    background: rgba(0, 229, 255, 0.32);
}

.finance-chart-bar.is-net {
    border-color: var(--line-highlight);
    background: rgba(57, 255, 136, 0.16);
    box-shadow: var(--glow-highlight);
}

.finance-chart-bar.is-net.is-negative {
    border-color: rgba(255, 68, 68, 0.45);
    background: rgba(255, 68, 68, 0.12);
    box-shadow: none;
}

.finance-chart-point > span,
.finance-chart-point small {
    min-width: 0;
    overflow-wrap: anywhere;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.finance-chart-point > span {
    color: var(--fg-dim);
    font-size: 11px;
}

.finance-chart-point small {
    color: var(--fg-primary);
    font-size: 10px;
}

.top-merchant-row > strong,
.recurring-row > strong {
    flex: none;
    color: var(--highlight);
    text-align: right;
}

.recurring-detail-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
    gap: 0.75rem;
    min-width: 0;
    padding: 0.65rem;
}

.recurring-detail-stats {
    justify-items: end;
    text-align: right;
}

.recurring-detail-stats > strong {
    color: var(--highlight);
    font-variant-numeric: tabular-nums;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
    min-height: 0;
}

.category-card {
    display: grid;
    gap: 0.65rem;
    min-width: 0;
    padding: 0.8rem;
}

.category-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--highlight);
}

.category-meter {
    height: 6px;
    border: 1px solid var(--line);
    background: var(--bg-primary);
}

.category-meter span {
    display: block;
    height: 100%;
    max-width: 100%;
    background: var(--highlight);
    box-shadow: var(--glow-highlight);
}

.category-card dl {
    display: grid;
    gap: 0.45rem;
    margin: 0;
}

.category-card dl div {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.category-card dt,
.category-card dd {
    margin: 0;
}

.category-card dd {
    color: var(--fg-primary);
    text-align: right;
    overflow-wrap: anywhere;
}

.transaction-filter-bar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(110px, 0.28fr) minmax(120px, 0.32fr) minmax(160px, 0.45fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.clear-filter-button {
    min-height: 40px;
    white-space: nowrap;
}

.transaction-insight-grid {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 0.55rem;
}

.transaction-insight-grid .metric-card {
    min-height: 76px;
    padding: 0.65rem;
}

.transaction-insight-grid .metric-card strong {
    font-size: 1rem;
}

.finance-grid {
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.finance-transaction-panel {
    grid-template-rows: auto auto auto minmax(0, 1fr);
    overflow: hidden;
}

.transaction-table-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--line);
    background: var(--bg-surface);
    scrollbar-width: thin;
    scrollbar-color: var(--line-highlight) transparent;
}

.transaction-table-header,
.transaction-table-row {
    display: grid;
    grid-template-columns: minmax(98px, 0.55fr) minmax(260px, 1.55fr) minmax(150px, 0.75fr) minmax(130px, 0.65fr) minmax(340px, 1.8fr) minmax(110px, 0.5fr);
    min-width: 1120px;
}

.transaction-table-header {
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elevated);
}

.transaction-table-header > *,
.transaction-table-row > * {
    min-width: 0;
    padding: 0.55rem 0.65rem;
    border-right: 1px solid var(--line);
}

.transaction-table-header > :last-child,
.transaction-table-row > :last-child {
    border-right: 0;
}

.transaction-table-header > span,
.transaction-sort-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    min-height: 42px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--accent);
    font: inherit;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.transaction-table-header > span {
    cursor: default;
}

.transaction-sort-button:hover,
.transaction-sort-button:focus-visible {
    color: var(--accent-bright);
    box-shadow: inset 0 -1px 0 var(--accent);
}

.transaction-sort-button.is-active {
    color: var(--highlight);
    box-shadow: inset 0 -1px 0 var(--highlight), var(--glow-highlight);
}

.transaction-sort-button small {
    color: inherit;
    font-size: 10px;
}

.transaction-table-body {
    min-width: 1120px;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line-highlight) transparent;
}

.transaction-table-row {
    height: 64px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-surface);
    color: var(--fg-primary);
}

.transaction-table-row:hover {
    box-shadow: inset 0 0 0 1px rgba(57, 255, 136, 0.15);
}

.transaction-table-row time,
.transaction-table-row > span,
.transaction-table-row > strong {
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-table-row .card-cell strong,
.transaction-table-row .card-cell small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transaction-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.transaction-empty-row {
    min-width: 1120px;
    padding: 1rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.finance-control-panel .rz-spinner,
.finance-control-panel .rz-numeric,
.finance-control-panel .rz-numeric input,
.finance-control-panel .rz-inputtext {
    min-width: 0 !important;
    max-width: 100% !important;
}

.projection-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.projection-card {
    border-color: var(--line-highlight);
    box-shadow: var(--glow-highlight);
}

.projection-card strong,
.cashflow-month strong,
.income-normalised-list strong,
.account-normalised-list strong {
    font-variant-numeric: tabular-nums;
}

.is-positive {
    color: var(--highlight) !important;
}

.is-negative {
    color: var(--alert) !important;
}

@media (max-width: 1180px) {
    .finance-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .finance-period-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .income-source-row,
    .bank-account-row {
        grid-template-columns: minmax(0, 1fr) minmax(105px, 0.55fr);
    }

    .income-source-row label:nth-child(3),
    .bank-account-row label:nth-child(3) {
        grid-column: 1 / span 1;
    }
}

@media (max-width: 900px) {
    .finance-split-grid,
    .projection-grid,
    .finance-period-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-chart-controls {
        grid-template-columns: minmax(0, 1fr);
    }

    .transaction-filter-bar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .finance-page,
    .finance-console-window,
    .finance-page .console-window,
    .finance-board {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .finance-console-window > .console-titlebar {
        display: flex;
        width: 100%;
        min-width: 0;
    }

    .finance-console-window .terminal-title {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 11px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .finance-workspace,
    .finance-workspace.has-results {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0.35rem;
        overflow: visible;
    }

    .finance-control-panel,
    .finance-workspace:not(.has-results) .finance-control-panel {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        height: auto;
        min-height: 0;
        padding: 0.8rem;
        overflow: visible;
    }

    .finance-workspace.show-inputs-tab .finance-control-panel {
        display: grid;
        animation: mtg-mobile-pane-from-left 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .finance-workspace:not(.show-inputs-tab) .finance-control-panel {
        display: none;
    }

    .finance-workspace:not(.show-inputs-tab) .finance-results-pane {
        animation: mtg-mobile-pane-from-right 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .finance-results-pane,
    .finance-overview-panel,
    .finance-grid {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .finance-transaction-panel,
    .transaction-table-shell {
        overflow: hidden;
    }

    .transaction-table-body {
        max-height: 70vh;
    }

    .finance-results-pane {
        grid-template-rows: auto auto auto;
    }

    .finance-results-pane .results-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-results-pane .results-tab {
        border-right: 1px solid var(--line);
    }

    .finance-results-pane .results-tab:nth-child(2n) {
        border-right: 0;
    }

    .finance-results-pane .results-tab:nth-child(n+3) {
        border-top: 1px solid var(--line);
    }

    .finance-results-pane .results-tab:nth-child(5) {
        grid-column: auto;
        border-right: 1px solid var(--line);
    }

    .finance-metric-grid,
    .finance-split-grid,
    .projection-grid,
    .finance-period-metric-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .finance-grid {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--line-highlight) transparent;
    }

    .finance-grid .rz-data-grid,
    .finance-grid .rz-grid-table {
        min-width: 820px;
    }

    .results-status-bar .results-vendor-count {
        display: none;
    }
}

@media (max-width: 560px) {
    .income-source-row,
    .bank-account-row,
    .finance-button-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .income-source-row label:nth-child(3),
    .bank-account-row label:nth-child(3) {
        grid-column: auto;
    }

    .finance-remove-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .finance-console-window .terminal-dots {
        display: none;
    }

    .finance-control-header,
    .category-card-header,
    .category-card dl div,
    .finance-data-readout-list div,
    .import-file-row,
    .top-merchant-row,
    .recurring-row,
    .recurring-detail-row,
    .excluded-transaction-row,
    .income-normalised-list div,
    .account-normalised-list div {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .top-merchant-row > strong,
    .recurring-row > strong,
    .recurring-detail-stats,
    .finance-data-readout-list strong,
    .category-card dd {
        text-align: left;
        justify-self: start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .finance-console-window,
    .finance-console-window > .console-titlebar,
    .finance-console-window .terminal-dots,
    .finance-console-window .terminal-title,
    .finance-console-window .terminal-home-link,
    .finance-control-panel,
    .finance-control-panel::before,
    .finance-control-header,
    .finance-input-panel,
    .finance-results-pane,
    .finance-results-pane .results-status-bar,
    .finance-results-pane .results-status-bar.is-running .status-dot,
    .finance-overview-panel {
        animation: none;
        transition: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mtg-board .mtg-workspace.has-results.show-mobile-controls .control-panel,
    .mtg-board .mtg-workspace.has-results:not(.show-mobile-controls) .mtg-results-pane {
        animation: none;
    }
}

/* Mobile layout repairs. Desktop composition remains unchanged above 760px. */
@media (max-width: 760px) {
    html,
    body {
        width: 100%;
        overflow-x: hidden;
    }

    .home-page,
    .home-screen {
        width: 100%;
        height: auto;
        min-height: 0;
    }

    .home-page .console-window {
        display: block;
        height: auto;
        overflow: visible;
    }

    .home-board-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0.35rem;
        overflow: visible;
    }

    .home-board-grid .board-panel {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
        min-width: 0;
        margin: 0;
        overflow: hidden;
    }

    .home-board-grid .board-panel-node {
        order: 1;
        min-height: 17rem;
    }

    .home-board-grid .board-panel-world {
        order: 2;
        min-height: 21rem;
    }

    .home-board-grid .board-panel-ops {
        order: 4;
        min-height: 13rem;
    }

    .home-board-grid .board-panel-vis {
        order: 5;
        min-height: 21rem;
    }

    .home-board-grid .board-panel-nav {
        order: 3;
        min-height: 0;
    }

    .home-board-grid .board-panel-contact {
        order: 6;
    }

    .home-board-grid .board-panel-overlay {
        position: relative;
        inset: auto;
        justify-self: stretch;
    }

    .home-board-grid .journal-feed {
        max-height: none;
        overflow: visible;
    }

    .home-board-grid .hero-lede,
    .home-board-grid .hero-summary,
    .home-board-grid .journal-message,
    .home-board-grid .project-nav-box,
    .home-board-grid .contact-links a {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .mtg-page {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-console-window,
    .mtg-page .console-window {
        display: block;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-console-window > .console-titlebar {
        display: flex;
        width: 100%;
        min-width: 0;
    }

    .mtg-console-window .terminal-title {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 11px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .terminal-home-link {
        flex: none;
    }

    .mtg-board {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-board .mtg-workspace,
    .mtg-board .mtg-workspace.has-results {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0.35rem;
        overflow: visible;
    }

    .mtg-board .control-panel,
    .mtg-board .mtg-workspace:not(.has-results) .control-panel {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        height: auto;
        min-height: 0;
        padding: 0.8rem;
        overflow: visible;
    }

    .mtg-board .decklist-panel .rz-textarea {
        height: 13rem;
        min-height: 13rem;
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid,
    .mtg-board .mtg-workspace.has-results .vendor-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mtg-board .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mtg-results-pane {
        display: grid;
        grid-template-rows: auto auto auto;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .results-status-bar {
        min-width: 0;
    }

    .results-status-bar strong {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .results-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .results-tab:nth-child(3) {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
        border-right: 0;
    }

    .mtg-results-pane > .order-panel,
    .mtg-results-pane > .results-panel,
    .mtg-results-pane > .follow-up-panel,
    .mtg-results-pane > .live-panel,
    .mtg-results-pane .vendor-order-grid,
    .mtg-results-pane .vendor-order,
    .mtg-results-pane .results-grid {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-results-pane .vendor-order-grid,
    .mtg-results-pane .follow-up-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .mtg-results-pane .results-grid {
        width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--line-highlight) transparent;
    }

    .mtg-results-pane .results-grid .rz-data-grid,
    .mtg-results-pane .results-grid .rz-grid-table {
        min-width: 720px;
    }

    .mtg-results-pane .section-heading,
    .mtg-results-pane .vendor-order-header,
    .mtg-results-pane .vendor-order li,
    .mtg-results-pane .follow-up-panel li {
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .console-titlebar,
    .terminal-titlebar {
        gap: 0.45rem;
        padding: 0.45rem 0.5rem;
    }

    .mtg-console-window .terminal-dots {
        display: none;
    }

    .mtg-control-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .control-count {
        padding-top: 0;
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid,
    .mtg-board .mtg-workspace.has-results .vendor-grid,
    .mtg-board .filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .results-tab {
        min-height: 2.5rem;
        padding-inline: 0.35rem;
        font-size: 11px;
    }

    .live-feed-row,
    .vendor-order li {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
    }

    .live-feed-price,
    .vendor-order li > strong {
        overflow-wrap: anywhere;
        text-align: right;
    }
}

/* Full-viewport MTG control console. These rules intentionally mirror Home's shell. */
.mtg-page {
    height: calc(100vh - 0.7rem);
    min-height: 0;
    overflow: hidden;
}

.mtg-console-window {
    height: 100%;
    min-height: 0;
    animation: mtg-console-boot 520ms ease-out both;
}

.mtg-console-window > .console-titlebar {
    animation: mtg-titlebar-boot 620ms ease-out 80ms both;
}

.mtg-console-window .terminal-dots,
.mtg-console-window .terminal-title,
.mtg-console-window .terminal-home-link {
    animation: content-rise 520ms ease-out 220ms both;
}

.terminal-home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    margin-left: auto;
    padding: 0.15rem 0.65rem;
    border: 1px solid var(--line);
    color: var(--accent);
    font-size: 11px;
    line-height: 1;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.terminal-home-link:hover,
.terminal-home-link:focus-visible {
    border-color: var(--accent-bright);
    color: var(--accent-bright);
    box-shadow: var(--glow-sm);
}

.mobile-pane-toggle {
    display: none;
}

.mtg-board {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.mtg-board > .board-layer-grid {
    background-size: 5rem 100%, 100% 4.5rem;
}

.mtg-board .mtg-workspace {
    position: relative;
    z-index: 1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);
    justify-content: stretch;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0.75rem;
    transition: grid-template-columns 420ms cubic-bezier(0.22, 1, 0.36, 1), gap 420ms ease;
}

.mtg-board .mtg-workspace.has-results {
    grid-template-columns: minmax(300px, 0.34fr) minmax(0, 1fr);
}

.mtg-board .control-panel {
    position: relative;
    top: auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
    animation: panel-boot 620ms ease-out 140ms both;
}

.mtg-board .control-panel::before {
    content: "";
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: 1px;
    background: var(--accent);
    box-shadow: var(--glow-sm);
    transform-origin: left;
    animation: panel-trace 900ms ease-out 340ms both;
    pointer-events: none;
}

.mtg-control-header {
    animation: content-rise 520ms ease-out 260ms both;
}

.mtg-board .decklist-panel {
    animation: content-rise 560ms ease-out 340ms both;
}

.mtg-board .search-panel > * {
    animation: content-rise 520ms ease-out both;
}

.mtg-board .search-panel > :nth-child(1) {
    animation-delay: 420ms;
}

.mtg-board .search-panel > :nth-child(2) {
    animation-delay: 500ms;
}

.mtg-board .search-panel > :nth-child(3) {
    animation-delay: 580ms;
}

.mtg-board .vendor-toggle {
    animation: mtg-control-register 420ms ease-out both;
}

.mtg-board .vendor-toggle:nth-child(1) {
    animation-delay: 500ms;
}

.mtg-board .vendor-toggle:nth-child(2) {
    animation-delay: 550ms;
}

.mtg-board .vendor-toggle:nth-child(3) {
    animation-delay: 600ms;
}

.mtg-board .vendor-toggle:nth-child(4) {
    animation-delay: 650ms;
}

.mtg-board .mtg-workspace:not(.has-results) .control-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.mtg-board .mtg-workspace:not(.has-results) .decklist-panel,
.mtg-board .mtg-workspace:not(.has-results) .search-panel {
    min-height: 0;
}

.mtg-board .mtg-workspace:not(.has-results) .vendor-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mtg-board .mtg-workspace:not(.has-results) .search-panel {
    grid-template-columns: minmax(0, 1fr);
}

.mtg-board .decklist-panel {
    grid-template-rows: auto minmax(0, 1fr);
}

.mtg-board .decklist-panel .rz-textarea {
    height: 100%;
    min-height: 8rem;
    resize: none;
}

.mtg-board .mtg-workspace.has-results .control-panel {
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.mtg-board .mtg-workspace.has-results .search-panel {
    gap: 0.65rem;
}

.mtg-board .mtg-workspace.has-results .vendor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mtg-board .mtg-workspace.has-results .vendor-toggle {
    min-width: 0;
}

.mtg-board .mtg-workspace.has-results .vendor-toggle small {
    display: none;
}

.mtg-results-pane {
    position: relative;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.mtg-results-pane .results-status-bar {
    animation: mtg-status-lock 540ms ease-out 160ms both;
}

.mtg-results-pane .results-status-bar.is-running .status-dot {
    animation: live-pulse 2.4s ease-in-out infinite;
}

.results-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: 1px solid var(--line);
    background: var(--bg-surface);
    animation: content-rise 460ms ease-out 180ms both;
}

.results-tab {
    min-height: 2.7rem;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--accent);
    font: inherit;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.results-tab:last-child {
    border-right: 0;
}

.results-tab:hover,
.results-tab:focus-visible {
    color: var(--accent-bright);
    box-shadow: inset 0 -1px 0 var(--accent);
}

.results-tab.is-active {
    color: var(--highlight);
    box-shadow: inset 0 -1px 0 var(--highlight), var(--glow-highlight);
}

.results-tab:disabled {
    color: var(--fg-dim);
    cursor: not-allowed;
    opacity: 0.55;
}

.results-tab:disabled:hover,
.results-tab:disabled:focus-visible {
    box-shadow: none;
}

.mtg-results-pane > .order-panel,
.mtg-results-pane > .results-panel,
.mtg-results-pane > .follow-up-panel,
.mtg-results-pane > .live-panel {
    min-height: 0;
    overflow: hidden;
}

.mtg-results-pane > .order-panel,
.mtg-results-pane > .results-panel,
.mtg-results-pane > .follow-up-panel,
.mtg-results-pane > .live-panel {
    animation: mtg-content-scan 360ms ease-out both;
}

.mtg-results-pane .live-vendor,
.mtg-results-pane .live-feed-row {
    animation: content-rise 360ms ease-out both;
}

.mtg-results-pane .live-vendor:nth-child(2n),
.mtg-results-pane .live-feed-row:nth-child(2n) {
    animation-delay: 45ms;
}

.mtg-results-pane .live-vendor:nth-child(3n),
.mtg-results-pane .live-feed-row:nth-child(3n) {
    animation-delay: 90ms;
}

.mtg-results-pane .order-panel {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    align-content: start;
}

.mtg-results-pane .vendor-order-grid {
    min-height: 0;
    overflow: hidden;
}

.mtg-results-pane .vendor-order {
    min-height: 0;
    overflow: hidden;
    padding: 0.7rem;
}

.mtg-results-pane .vendor-order ul {
    gap: 0.35rem;
}

.mtg-results-pane .vendor-order li {
    gap: 0.4rem;
}

.mtg-results-pane .results-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.mtg-results-pane .results-grid {
    min-height: 0;
    overflow: hidden;
}

.mtg-results-pane .follow-up-panel {
    align-content: start;
}

.issues-clear {
    grid-column: 1 / -1;
}

@keyframes mtg-console-boot {
    from {
        opacity: 0;
        clip-path: inset(0 50% 0 50%);
    }

    to {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

@keyframes mtg-titlebar-boot {
    from {
        opacity: 0;
        transform: scaleX(0.7);
    }

    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes mtg-control-register {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes mtg-status-lock {
    from {
        opacity: 0;
        transform: scaleX(0.82);
        transform-origin: left;
    }

    to {
        opacity: 1;
        transform: scaleX(1);
        transform-origin: left;
    }
}

@keyframes mtg-content-scan {
    from {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        clip-path: inset(0 0 0 0);
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .mtg-board .mtg-workspace.has-results {
        grid-template-columns: minmax(260px, 0.4fr) minmax(0, 1fr);
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .mtg-page {
        height: calc(100dvh - 0.4rem);
    }

    .mtg-board .mtg-workspace,
    .mtg-board .mtg-workspace.has-results {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
    }

    .mtg-board .mtg-workspace.has-results .control-panel {
        display: none;
    }

    .mtg-board .mtg-workspace.has-results.show-mobile-controls .control-panel {
        display: grid;
        animation: mtg-mobile-pane-from-left 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .mtg-board .mtg-workspace.has-results.show-mobile-controls .mtg-results-pane {
        display: none;
    }

    .mtg-board .mtg-workspace.has-results:not(.show-mobile-controls) .mtg-results-pane {
        animation: mtg-mobile-pane-from-right 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .mobile-pane-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 30px;
        padding: 0.3rem 0.65rem;
        border: 1px solid var(--accent);
        background: transparent;
        color: var(--accent);
        font: inherit;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        cursor: pointer;
    }

    .mobile-pane-toggle:hover,
    .mobile-pane-toggle:focus-visible {
        border-color: var(--accent-bright);
        color: var(--accent-bright);
        box-shadow: var(--glow-sm);
    }

    .results-status-bar .mobile-pane-toggle {
        flex: none;
        margin-left: auto;
    }

    .mtg-control-header h1 {
        font-size: 1.35rem;
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .results-status-bar .results-vendor-count {
        display: none;
    }
}

@keyframes mtg-mobile-pane-from-left {
    from {
        opacity: 0;
        transform: translateX(-1.5rem);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes mtg-mobile-pane-from-right {
    from {
        opacity: 0;
        transform: translateX(1.5rem);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mtg-console-window,
    .mtg-console-window > .console-titlebar,
    .mtg-console-window .terminal-dots,
    .mtg-console-window .terminal-title,
    .mtg-console-window .terminal-home-link,
    .mtg-board .control-panel,
    .mtg-board .control-panel::before,
    .mtg-control-header,
    .mtg-board .decklist-panel,
    .mtg-board .search-panel > *,
    .mtg-board .vendor-toggle,
    .mtg-results-pane,
    .mtg-results-pane .results-status-bar,
    .mtg-results-pane .results-status-bar.is-running .status-dot,
    .results-tabs,
    .mtg-results-pane > .order-panel,
    .mtg-results-pane > .results-panel,
    .mtg-results-pane > .follow-up-panel,
    .mtg-results-pane > .live-panel,
    .mtg-results-pane .live-vendor,
    .mtg-results-pane .live-feed-row {
        animation: none;
        transition: none;
    }
}

/* Final narrow-screen overrides must follow the desktop MTG console declarations. */
@media (max-width: 760px) {
    .mtg-page,
    .mtg-console-window,
    .mtg-page .console-window,
    .mtg-board {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-board .mtg-workspace,
    .mtg-board .mtg-workspace.has-results {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0.35rem;
        overflow: visible;
    }

    .mtg-board .control-panel,
    .mtg-board .mtg-workspace:not(.has-results) .control-panel {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-board .mtg-workspace.has-results .control-panel {
        display: none;
    }

    .mtg-results-pane,
    .mtg-results-pane > .order-panel,
    .mtg-results-pane > .results-panel,
    .mtg-results-pane > .follow-up-panel,
    .mtg-results-pane > .live-panel,
    .mtg-results-pane .vendor-order-grid,
    .mtg-results-pane .vendor-order {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .mtg-results-pane {
        grid-template-rows: auto auto auto;
    }

    .mtg-results-pane .results-grid {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow-x: auto;
        overflow-y: visible;
        overscroll-behavior-x: contain;
    }

    .results-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .results-tab:nth-child(3) {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
        border-right: 0;
    }

    .mtg-board .decklist-panel .rz-textarea {
        height: 13rem;
        min-height: 13rem;
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid,
    .mtg-board .mtg-workspace.has-results .vendor-grid,
    .mtg-board .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .mtg-console-window .terminal-dots {
        display: none;
    }

    .mtg-control-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .mtg-board .mtg-workspace:not(.has-results) .vendor-grid,
    .mtg-board .mtg-workspace.has-results .vendor-grid,
    .mtg-board .filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
