@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --bg-top: #f6f5ef;
    --bg-bottom: #ece9df;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-solid: #ffffff;
    --surface-hover: #f8f7f1;
    --border: rgba(222, 222, 203, 0.92);
    --border-strong: rgba(193, 193, 192, 0.96);
    --text-primary: #222222;
    --text-secondary: #5b5b5b;
    --text-tertiary: #909090;
    --accent: #5d8cd7;
    --accent-hover: #4c7cca;
    --accent-soft: rgba(129, 173, 236, 0.18);
    --success: #007a55;
    --destructive: #c70036;
    --radius-sm: 2px;
    --radius-md: 3px;
    --radius-lg: 4px;
    --outline-soft: 1px solid var(--border);
    --outline-strong: 1px solid var(--border-strong);
    --font-ui: "Montserrat", "Segoe UI", sans-serif;
    --font-mono: "SF Mono", "Cascadia Code", "Menlo", "Consolas", monospace;
}

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

html,
body {
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at top left, rgba(164, 198, 247, 0.22), transparent 28%),
        radial-gradient(circle at top right, rgba(129, 173, 236, 0.14), transparent 26%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    color: var(--text-primary);
    font-family: var(--font-ui);
    height: 100vh;
    padding: 14px;
    overflow: hidden;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
}

.app-grid {
    display: grid;
    grid-template-columns: 326px minmax(0, 1fr);
    gap: 14px;
    height: 100%;
}

.left-column,
.right-column {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.permanent-panel,
.feature-panel-host,
.ribbon-panel,
.chart-area,
.feature-placeholder-card,
.loading-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.permanent-panel,
.feature-panel-host,
.ribbon-panel,
.chart-area,
.feature-placeholder-card {
    background: var(--surface);
    border: var(--outline-soft);
}

.permanent-panel {
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 308px;
}

.panel-brand {
    padding: 24px 19px 19px;
    border-bottom: var(--outline-soft);
}

.panel-brand h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.panel-brand p {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-tertiary);
}

.feature-panel-host {
    border-radius: var(--radius-lg);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}

.feature-panel-host::-webkit-scrollbar {
    width: 6px;
}

.feature-panel-host::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
}

.ribbon-panel {
    border-radius: var(--radius-lg);
    padding: 0 19px;
    display: flex;
    align-items: end;
    min-height: 86px;
    background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.74));
}

.ribbon-tabs {
    width: 100%;
    display: flex;
    align-items: end;
    gap: 6px;
    border-bottom: var(--outline-soft);
    padding-top: 14px;
}

.ribbon-tab {
    border: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    padding: 14px 18px;
    font: inherit;
    font-size: 22px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.ribbon-tab:hover {
    color: var(--text-primary);
    background: rgba(34, 34, 34, 0.04);
    border-bottom-color: rgba(34, 34, 34, 0.18);
}

.ribbon-tab.active {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.56);
    border-bottom-color: var(--accent);
}

.workspace-main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex: 1;
}

.workspace-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.workspace-panel[hidden] {
    display: none;
}

.feature-sidebar.hidden,
.drop-zone.hidden,
.hidden {
    display: none;
}

.panel-section {
    padding: 14px 18px;
    border-bottom: var(--outline-soft);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section-log {
    margin-top: auto;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.feature-heading {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feature-title {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.feature-description {
    font-size: 16px;
    color: var(--text-tertiary);
    line-height: 1.55;
}

.drop-zone {
    border: var(--outline-soft);
    border-radius: var(--radius-md);
    padding: 12px 11px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.74);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
    margin: 0 18px 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.drop-zone:last-child {
    margin-bottom: 18px;
}

.drop-zone:hover,
.drop-zone.dragover {
    transform: translateY(-1px);
    border-color: var(--accent);
    background: var(--surface-hover);
}

.drop-zone-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(180deg, #ffffff, #f3f8ff);
    border: var(--outline-soft);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.drop-zone-icon svg {
    width: 14px;
    height: 14px;
}

.drop-zone-content {
    flex: 1;
    min-width: 0;
}

.drop-zone-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drop-zone-subtitle {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.file-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
    display: none;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.control-group {
    margin-bottom: 10px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

select,
input[type="text"],
input[type="number"],
input[type="time"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border: var(--outline-soft);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="time"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
    background: #ffffff;
}

select:disabled {
    color: #94a3b8;
    cursor: not-allowed;
    background: #f8fafc;
}

input[type="color"] {
    width: 42px;
    height: 30px;
    border: var(--outline-soft);
    border-radius: var(--radius-sm);
    padding: 3px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

.color-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.color-control .control-label {
    margin-bottom: 0;
}

.row-inputs,
.button-row {
    display: flex;
    gap: 6px;
}

.row-inputs > .control-group,
.button-row > * {
    flex: 1;
}

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    padding: 5px 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 18px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    inset: 0;
    background-color: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider::before {
    transform: translateX(12px);
}

.btn {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 9px 11px;
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: -0.01em;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(180deg, #81adec, var(--accent));
    color: #ffffff;
    box-shadow: inset 0 1px rgba(255,255,255,0.22), inset 0 -1px rgba(0,0,0,0.14);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #9abcf0, var(--accent-hover));
}

.btn-primary:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(34, 34, 34, 0.08);
    color: var(--text-primary);
    border-color: transparent;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(34, 34, 34, 0.12);
}

.btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.search-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.search-row input {
    flex: 1;
}

.search-row .btn {
    width: auto;
    flex-shrink: 0;
    padding-inline: 13px;
}

.status-console {
    background: rgba(252, 252, 249, 0.96);
    border: var(--outline-soft);
    border-radius: var(--radius-md);
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
    height: 86px;
    overflow-y: auto;
    line-height: 1.55;
}

.status-console .error-msg {
    color: var(--destructive);
}

.status-console .info-msg {
    color: var(--text-tertiary);
}

.chart-area {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.chart-area::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(252, 252, 249, 0.88)),
        radial-gradient(circle at top right, rgba(129, 173, 236, 0.08), transparent 22%);
    pointer-events: none;
}

#tsd-plot,
.empty-state {
    position: relative;
    z-index: 1;
}

#tsd-plot {
    width: 100%;
    height: 100%;
}

#occupancy-plot {
    width: 100%;
    height: 100%;
}

#speed-profile-plot {
    position: relative;
    width: 100%;
    height: 100%;
}

.speed-profile-chart-area {
    align-items: flex-start;
    justify-content: flex-start;
    overflow: auto;
}

.speed-profile-chart-area .empty-state {
    z-index: 2;
}

.speed-profile-chart-frame {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 100%;
    height: 100%;
    min-width: 480px;
    min-height: 360px;
    resize: both;
    overflow: hidden;
    background: #ffffff;
}

.plot-size-inputs {
    align-items: center;
}

.plot-size-inputs span {
    flex: 0 0 auto;
    color: var(--text-tertiary);
    font-size: 13px;
}

.plot-size-inputs input {
    min-width: 0;
}

.tsd-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 188px minmax(0, 1fr);
}

.tsd-station-pane {
    position: relative;
    border-right: var(--outline-soft);
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(250,250,246,0.88));
    overflow: hidden;
}

#tsd-station-labels {
    position: relative;
    width: 100%;
    height: 100%;
}

.tsd-station-label {
    position: absolute;
    left: 16px;
    right: 16px;
    transform: translateY(-50%);
    font-size: 17px;
    font-weight: 600;
    color: #425466;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tsd-plot-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
}

.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(180deg, #ffffff, #f3f8ff);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    box-shadow: var(--shadow-sm);
}

.empty-state-icon svg {
    width: 24px;
    height: 24px;
}

.empty-state h2,
.feature-placeholder-card h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-secondary);
}

.empty-state p,
.feature-placeholder-card p {
    font-size: 20px;
    color: var(--text-tertiary);
    max-width: 320px;
    line-height: 1.6;
}

.feature-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-placeholder-card {
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(241, 245, 249, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-card {
    min-width: 220px;
    background: rgba(255, 255, 255, 0.96);
    border: var(--outline-soft);
    border-radius: var(--radius-lg);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.14);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(10, 132, 255, 0.18);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

.loading-message {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1180px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .app-grid {
        grid-template-columns: 1fr;
    }

    .left-column,
    .right-column {
        gap: 18px;
    }
}
