:root {
    color-scheme: light;
    --bg: #f4f6f7;
    --panel: #ffffff;
    --text: #1d252c;
    --muted: #63717c;
    --line: #d9e0e5;
    --accent: #176f6b;
    --accent-dark: #10534f;
    --danger: #aa2e25;
    --ok: #1d7f43;
    --code: #111820;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

.shell {
    width: min(1800px, calc(100% - 20px));
    margin: 10px auto;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.signed-in-user {
    color: var(--muted);
    font-size: 14px;
}

.logout-form {
    margin: 0;
}

.logout-button {
    min-height: 28px;
    color: var(--accent-dark);
}

.login-page {
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 28px;
    background: var(--panel);
    box-shadow: 0 16px 48px rgba(29, 37, 44, 0.12);
}

.login-intro {
    margin: 12px 0 22px;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-form label {
    margin: 0;
}

.login-form button {
    min-height: 42px;
}

.login-error {
    border: 1px solid #efc4c0;
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--danger);
    background: #fbecea;
}

h1,
h2 {
    margin: 0;
    line-height: 1.1;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
}

.workspace {
    display: grid;
    grid-template-columns:
        minmax(260px, 0.78fr)
        minmax(260px, 0.78fr)
        minmax(520px, 1.55fr)
        minmax(320px, 0.9fr);
    gap: 10px;
    align-items: start;
}

.generator-column,
.parser-column,
.map-column,
.debug-column {
    display: grid;
    gap: 10px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
    margin-bottom: 10px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--code);
    background: #fbfcfd;
    line-height: 1.45;
}

input,
select {
    min-height: 42px;
    margin-top: 7px;
}

textarea {
    min-height: 132px;
    resize: vertical;
}

#last-generated {
    min-height: 76px;
}

.generator-log-label {
    margin-top: 16px;
}

.listen-controls {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.listen-status {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(23, 111, 107, 0.18);
    border-color: var(--accent);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

button {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    cursor: pointer;
    color: var(--text);
    background: #fff;
}

button[type="submit"] {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
}

button[type="submit"]:hover {
    background: var(--accent-dark);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    background: #eef2f4;
    color: var(--muted);
}

.status-ok {
    color: var(--ok);
    background: #e8f5ee;
}

.status-error {
    color: var(--danger);
    background: #fbecea;
}

.summary {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 9px 12px;
    margin: 0 0 16px;
}

.summary dt,
.map-readout dt {
    color: var(--muted);
    font-weight: 700;
}

.summary dd,
.map-readout dd {
    margin: 0;
    overflow-wrap: anywhere;
}

pre {
    min-height: 650px;
    max-height: 82vh;
    margin: 0;
    overflow: auto;
    border-radius: 8px;
    padding: 16px;
    color: #f1f5f8;
    background: var(--code);
    line-height: 1.5;
}

.map-panel {
    padding-bottom: 12px;
}

.map-tools {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.route-status {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-weight: 700;
}

.route-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.route-actions button {
    min-height: 34px;
    padding: 0 12px;
}

.map-shell {
    position: relative;
    min-height: 300px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

#map {
    min-height: 520px;
    height: 70vh;
    max-height: 820px;
    background: #e8eef0;
}

.map-readout {
    position: absolute;
    left: 14px;
    bottom: 14px;
    display: grid;
    grid-template-columns: 84px 1fr;
    gap: 6px 10px;
    min-width: 230px;
    margin: 0;
    border: 1px solid rgba(217, 224, 229, 0.9);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.9);
    z-index: 500;
    pointer-events: none;
}

.route-table-wrap {
    margin-top: 10px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.route-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 14px;
}

.route-table th,
.route-table td {
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}

.route-table th {
    color: var(--muted);
    background: #f8fafb;
    font-weight: 700;
}

.route-table tr:last-child td {
    border-bottom: 0;
}

.route-table tr.is-selected td {
    background: #fbecea;
}

.route-table input {
    min-height: 34px;
    margin-top: 0;
    padding: 7px 8px;
}

.route-table button {
    min-height: 32px;
    padding: 0 10px;
}

.route-point-label {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
    font-size: 12px;
    font-weight: 700;
}

.route-point-label.is-selected {
    background: var(--danger);
}

@media (max-width: 1450px) {
    .workspace {
        grid-template-columns: minmax(280px, 0.85fr) minmax(520px, 1.15fr);
    }

    .parser-column,
    .debug-column {
        grid-column: auto;
    }
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .debug-column {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .shell {
        width: min(100% - 12px, 1800px);
        margin: 8px auto;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .panel {
        padding: 16px;
    }

    h1 {
        font-size: 25px;
    }

    .actions,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .map-readout {
        right: 12px;
        min-width: 0;
    }

    .route-actions {
        flex-direction: column;
    }
}

/* Modular workspace shell */

.eyebrow {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.module-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px;
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 5px 20px rgba(17, 24, 32, 0.06);
}

.module-nav-button {
    flex: 0 0 auto;
    border-color: transparent;
    color: var(--muted);
    background: transparent;
    font-weight: 700;
}

.module-nav-button:hover {
    color: var(--accent-dark);
    background: #eef7f6;
}

.module-nav-button.is-active {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
}

.module-view[hidden] {
    display: none !important;
}

.overview-hero {
    margin-bottom: 14px;
    border-radius: 12px;
    padding: clamp(24px, 4vw, 54px);
    color: #fff;
    background:
        linear-gradient(120deg, rgba(10, 65, 74, 0.96), rgba(23, 111, 107, 0.82)),
        #10534f;
}

.overview-hero .eyebrow {
    color: #9de4df;
}

.overview-hero h2 {
    max-width: 700px;
    font-size: clamp(28px, 4vw, 48px);
}

.overview-hero p:last-child {
    max-width: 720px;
    margin: 14px 0 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 17px;
    line-height: 1.6;
}

.module-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.module-card {
    display: grid;
    align-content: start;
    gap: 10px;
    min-height: 180px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    text-align: left;
    background: var(--panel);
}

button.module-card {
    height: auto;
}

button.module-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(16, 83, 79, 0.1);
    transform: translateY(-1px);
}

.module-card strong {
    font-size: 20px;
}

.module-card > span:last-child {
    color: var(--muted);
    line-height: 1.5;
}

.module-card-index {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.module-card-static {
    background: #edf4f4;
}

.view-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin: 8px 0 14px;
}

.view-heading > p {
    max-width: 600px;
    margin: 0;
    color: var(--muted);
    text-align: right;
}

.focused-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 12px;
}

.generator-workspace {
    display: grid;
    grid-template-columns: minmax(280px, 0.55fr) minmax(560px, 1.45fr);
    gap: 12px;
    align-items: start;
}

.generator-panel {
    position: sticky;
    top: 68px;
}

.live-panel {
    max-width: 900px;
}

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

.muted-copy {
    color: var(--muted);
    line-height: 1.55;
}

.console-panel pre {
    min-height: 420px;
    max-height: calc(100vh - 220px);
}

@media (max-width: 1100px) {
    .module-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .generator-workspace {
        grid-template-columns: 1fr;
    }

    .generator-panel {
        position: static;
    }
}

@media (max-width: 760px) {
    .module-cards,
    .focused-grid,
    .live-form-grid {
        grid-template-columns: 1fr;
    }

    .view-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .view-heading > p {
        text-align: left;
    }
}

@media (max-width: 560px) {
    .module-nav {
        margin-right: -6px;
        margin-left: -6px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .module-card {
        min-height: 150px;
    }
}

.vdm-controls {
    margin-bottom: 12px;
}

.vdm-control-grid {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(195px, 0.8fr) minmax(195px, 0.8fr) auto auto;
    gap: 12px;
    align-items: end;
}

.vdm-control-grid button {
    min-height: 42px;
    margin-bottom: 8px;
}

.vdm-controls .muted-copy {
    margin: 4px 0 0;
}

.vdm-availability {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    margin: 6px 0 14px;
}

.vdm-availability div {
    display: flex;
    gap: 8px;
}

.vdm-availability dt {
    color: var(--muted);
    font-weight: 700;
}

.vdm-availability dd {
    margin: 0;
    font-family: Consolas, monospace;
}

.vdm-progress {
    margin: 8px 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #f7f9fa;
}

.vdm-progress-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
}

.vdm-progress progress {
    display: block;
    width: 100%;
    height: 12px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    accent-color: var(--accent);
}

.vdm-progress progress::-webkit-progress-bar {
    background: #dfe7e9;
}

.vdm-progress progress::-webkit-progress-value {
    background: var(--accent);
}

.vdm-summary-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.65fr) minmax(520px, 1.35fr);
    gap: 12px;
    margin-bottom: 12px;
    align-items: stretch;
}

.vdm-summary {
    grid-template-columns: 125px minmax(0, 1fr);
}

.vdm-types h3 {
    margin: 18px 0 10px;
    font-size: 14px;
}

.vdm-type-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.vdm-type-list span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 8px;
    color: var(--muted);
    background: #f7f9fa;
    font-family: Consolas, monospace;
    font-size: 12px;
}

.vdm-map-panel {
    min-height: 480px;
}

#vdm-map {
    width: 100%;
    min-height: 430px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e8edef;
}

.vdm-viewer-header {
    gap: 16px;
}

.vdm-viewer-header h2 {
    margin-bottom: 4px;
}

.vdm-pagination {
    display: flex;
    gap: 8px;
}

.vdm-table-wrap {
    max-height: 640px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.vdm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.vdm-table th,
.vdm-table td {
    border-bottom: 1px solid var(--line);
    padding: 7px 9px;
    text-align: left;
    vertical-align: top;
}

.vdm-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #edf3f4;
}

.vdm-table th:first-child,
.vdm-table td:first-child {
    width: 74px;
    color: var(--muted);
    text-align: right;
}

.vdm-sentence {
    min-width: 620px;
    overflow-wrap: anywhere;
    font-family: Consolas, "Courier New", monospace;
    color: var(--code);
}

.vdm-state {
    white-space: nowrap;
    font-weight: 700;
}

.vdm-state-valid {
    color: var(--ok);
}

.vdm-state-checksum_mismatch,
.vdm-state-invalid {
    color: var(--danger);
}

.vdm-state-no_checksum {
    color: #956300;
}

@media (max-width: 900px) {
    .vdm-control-grid,
    .vdm-summary-grid {
        grid-template-columns: 1fr;
    }

    .vdm-control-grid button {
        margin-bottom: 0;
    }

    .vdm-map-panel,
    #vdm-map {
        min-height: 360px;
    }
}
