:root {
    color-scheme: dark;
    --sov-bg: #12141a;
    --sov-panel: #1a1f2b;
    --sov-border: #2d3548;
    --sov-text: #e8edf7;
    --sov-muted: #9aa6bd;
    --sov-accent: #6ea8ff;
    --sov-danger: #ff6b6b;
    --sov-success: #5bd38d;
    --sov-system: #243047;
    --sov-system-selected: #35518a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--sov-bg);
    color: var(--sov-text);
    font-family: Inter, Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

.sov-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.sov-top-bar {
    position: relative;
    z-index: 900;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: color-mix(in srgb, var(--sov-panel) 92%, #000 8%);
    border-bottom: 1px solid var(--sov-border);
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
}

.sov-top-bar-brand {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.sov-top-bar-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.sov-top-bar-map {
    margin: 0;
    color: var(--sov-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sov-top-bar-meta {
    flex: 1;
    min-width: 0;
    color: var(--sov-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sov-map-versions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem 0.5rem;
    grid-column: 2;
    justify-self: center;
}

.sov-map-versions[hidden] {
    display: none;
}

.sov-map-versions-label {
    color: var(--sov-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.sov-map-version-select {
    appearance: none;
    -webkit-appearance: none;
    min-width: 8.5rem;
    max-width: 12rem;
    min-height: 1.85rem;
    padding: 0.3rem 1.75rem 0.3rem 0.55rem;
    border: 1px solid rgba(45, 53, 72, 0.7);
    border-radius: 8px;
    background-color: rgba(15, 19, 27, 0.72);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%239aa6bd' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 14px 14px;
    color: var(--sov-text);
    color-scheme: dark;
    cursor: pointer;
    backdrop-filter: blur(6px);
    font-size: 0.78rem;
}

.sov-map-version-select:focus {
    outline: none;
    border-color: var(--sov-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--sov-accent) 30%, transparent);
}

.sov-map-version-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.85rem;
    min-height: 1.85rem;
    padding: 0.2rem;
    background: rgba(15, 19, 27, 0.72);
    color: var(--sov-text);
    border: 1px solid rgba(45, 53, 72, 0.65);
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(6px);
}

.sov-map-version-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.sov-map-version-button:hover {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
}

.sov-map-version-button--danger:hover {
    border-color: var(--sov-danger);
    color: #fca5a5;
}

.sov-save-version-dialog {
    width: min(460px, 100%);
    padding: 1.25rem 1.5rem 1.35rem;
    background: var(--sov-panel);
    border: 1px solid var(--sov-border);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.sov-save-version-dialog-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
}

.sov-save-version-dialog-header p {
    margin: 0 0 1rem;
    color: var(--sov-muted);
    font-size: 0.9rem;
}

.sov-save-version-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.sov-top-bar-actions {
    display: flex;
    flex-shrink: 0;
    gap: 0.5rem;
}

.sov-top-bar-button {
    padding: 0.5rem 0.85rem;
    background: #0f131b;
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.sov-top-bar-button:hover {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
}

.sov-top-bar-button--primary {
    background: color-mix(in srgb, var(--sov-accent) 18%, #0f131b);
    border-color: color-mix(in srgb, var(--sov-accent) 45%, var(--sov-border));
}

.sov-top-bar-button--primary:hover {
    background: color-mix(in srgb, var(--sov-accent) 28%, #0f131b);
    color: var(--sov-text);
}

.sov-top-bar-button--danger:hover {
    border-color: var(--sov-danger);
    color: #fca5a5;
}

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

.sov-map-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: var(--sov-bg);
}

.sov-map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 0.55rem 0.75rem 0.85rem;
    background: linear-gradient(
        180deg,
        rgba(18, 20, 26, 0.92) 0%,
        rgba(18, 20, 26, 0.55) 70%,
        rgba(18, 20, 26, 0) 100%
    );
    pointer-events: none;
}

.sov-map-overlay > * {
    pointer-events: auto;
}

.sov-map-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0;
    border: 0;
}

.sov-sovereignty-legend-panel {
    grid-column: 1;
    justify-self: start;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.sov-sovereignty-legend-panel:empty {
    display: none;
}

.sov-map-zoom-controls {
    display: flex;
    flex-shrink: 0;
    grid-column: 3;
    justify-self: end;
    gap: 0.35rem;
    padding: 0.2rem;
    background: rgba(15, 19, 27, 0.72);
    border: 1px solid rgba(45, 53, 72, 0.65);
    border-radius: 10px;
    backdrop-filter: blur(8px);
}

.sov-map-control {
    min-width: 2rem;
    padding: 0.3rem 0.6rem;
    background: transparent;
    color: var(--sov-text);
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
}

.sov-map-control:hover {
    background: rgba(110, 168, 255, 0.12);
    border-color: rgba(110, 168, 255, 0.35);
}

.sov-new-map-dialog {
    width: min(520px, 100%);
    padding: 1.25rem 1.5rem 1.35rem;
    background: var(--sov-panel);
    border: 1px solid var(--sov-border);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.sov-new-map-dialog-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
}

.sov-new-map-dialog-header p {
    margin: 0 0 1rem;
    color: var(--sov-muted);
    font-size: 0.9rem;
}

.sov-new-map-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.sov-new-map-region-fields,
.sov-new-map-fields {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.sov-field input[type='text'],
.sov-field input[type='search'] {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--sov-border);
    border-radius: 8px;
    background: var(--sov-panel);
    color: var(--sov-text);
    color-scheme: dark;
}

.sov-field input[type='text']:focus,
.sov-field input[type='search']:focus {
    outline: none;
    border-color: var(--sov-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--sov-accent) 30%, transparent);
}

.sov-new-map-region-picker {
    gap: 0.55rem;
}

.sov-region-search-wrap {
    position: relative;
}

.sov-region-search-results {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 5;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    max-height: 14rem;
    overflow: auto;
    background: #0f131b;
    border: 1px solid var(--sov-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.sov-region-search-results[hidden] {
    display: none;
}

.sov-region-search-result {
    display: block;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--sov-text);
    text-align: left;
    cursor: pointer;
}

.sov-region-search-result:hover,
.sov-region-search-result--active {
    background: rgba(110, 168, 255, 0.14);
    color: var(--sov-accent);
}

.sov-region-search-empty {
    padding: 0.55rem 0.65rem;
    color: var(--sov-muted);
    font-size: 0.85rem;
}

.sov-new-map-region-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 2rem;
}

.sov-new-map-region-empty {
    margin: 0;
    color: var(--sov-muted);
    font-size: 0.85rem;
}

.sov-new-map-region-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.35rem 0.25rem 0.55rem;
    background: #0f131b;
    border: 1px solid var(--sov-border);
    border-radius: 999px;
    font-size: 0.82rem;
}

.sov-new-map-region-chip-label {
    color: var(--sov-text);
}

.sov-new-map-region-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--sov-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.sov-new-map-region-chip-remove:hover {
    background: rgba(255, 107, 107, 0.15);
    color: #fca5a5;
}

.sov-region-outline {
    fill: none;
    stroke: var(--sov-region-color, #5a6f8f);
    stroke-width: 1;
    stroke-dasharray: 6 14;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    opacity: 0.35;
    pointer-events: none;
}

.sov-region-panel-label {
    fill: var(--sov-region-color, #b8c9e6);
    font-size: 120px;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
    paint-order: stroke fill;
    stroke: #0b0f17;
    stroke-width: 18px;
    stroke-linejoin: round;
}

.sov-map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 2rem;
    color: var(--sov-muted);
    font-size: 0.95rem;
    text-align: center;
    pointer-events: none;
}

.sov-map-empty[hidden] {
    display: none;
}

.sov-header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
}

.sov-subtitle {
    margin: 0;
    color: var(--sov-muted);
}

.sov-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.5rem 0;
}

.sov-toolbar-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    margin-left: auto;
}

.sov-toolbar-actions {
    display: flex;
    gap: 0.5rem;
}

.sov-toolbar-button {
    padding: 0.55rem 0.9rem;
    background: #0f131b;
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.sov-toolbar-button:hover {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
}

.sov-toolbar-button--danger:hover {
    border-color: var(--sov-danger);
    color: #fca5a5;
}

.sov-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 280px;
    font-size: 0.85rem;
}

.sov-field label {
    color: var(--sov-muted);
}

.sov-field select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.65rem 2.25rem 0.65rem 0.75rem;
    border: 1px solid var(--sov-border);
    border-radius: 8px;
    background-color: var(--sov-panel);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%239aa6bd' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px 14px;
    color: var(--sov-text);
    color-scheme: dark;
    cursor: pointer;
}

.sov-field select:focus {
    outline: none;
    border-color: var(--sov-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--sov-accent) 30%, transparent);
}

.sov-field select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sov-toolbar-stats {
    color: var(--sov-muted);
    font-size: 0.9rem;
}

.sov-layout {
    display: block;
}

.sov-sovereignty-legend {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sov-sovereignty-legend-heading {
    color: var(--sov-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sov-sovereignty-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
}

.sov-sovereignty-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.45rem;
    border: 1px solid rgba(45, 53, 72, 0.7);
    border-radius: 999px;
    background: rgba(15, 19, 27, 0.72);
    backdrop-filter: blur(6px);
    font-size: 0.75rem;
}

.sov-sovereignty-legend-icon {
    border-radius: 3px;
    display: block;
}

.sov-sovereignty-legend-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    border: 2px solid transparent;
    display: inline-block;
}

.sov-sovereignty-legend-label {
    color: var(--sov-text);
    font-weight: 600;
}

.sov-sovereignty-legend-count {
    color: var(--sov-muted);
    font-size: 0.7rem;
}

.sov-system-sovereignty-icon {
    pointer-events: none;
}

.sov-system-sovereignty-badge {
    pointer-events: all;
    cursor: default;
}

.sov-map-viewport {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    outline: none;
    cursor: grab;
}

.sov-map-viewport:focus-visible {
    box-shadow: inset 0 0 0 2px var(--sov-accent);
}

.sov-map-viewport--dragging {
    cursor: grabbing;
}

.sov-map {
    display: block;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top, #1d2433 0%, #12141a 70%);
    user-select: none;
}

.sov-jumps line {
    stroke: #4f5d78;
    stroke-width: 2;
}

.sov-jumps line.sov-jump-cross-region {
    stroke: #d4a72c;
    stroke-width: 2;
    stroke-dasharray: 12 10;
    stroke-linecap: round;
    opacity: 0.7;
}

.sov-workforce-flow-indicators {
    pointer-events: none;
}

.sov-workforce-flow-arrow-shaft {
    stroke: #fbbf24;
    opacity: 0.95;
}

.sov-workforce-flow-arrow-head {
    fill: #fbbf24;
    opacity: 0.95;
}

.sov-system {
    pointer-events: bounding-box;
}

.sov-system--npc {
    pointer-events: none;
}

.sov-system--npc .sov-system-sovereignty-badge {
    pointer-events: all;
}

.sov-system-npc-backdrop {
    fill: #161b26;
}

.sov-system > rect:not(.sov-system-hit),
.sov-system > path,
.sov-system > text,
.sov-system > line {
    pointer-events: none;
}

.sov-system-workforce-flow {
    pointer-events: none;
}

.sov-system-hit {
    cursor: pointer;
    pointer-events: all;
}

.sov-system--selected .sov-system-hit {
    filter: drop-shadow(0 0 6px rgba(110, 168, 255, 0.8));
}

.sov-system--over-budget .sov-system-hit {
    stroke: var(--sov-danger);
}

.sov-system-resource {
    pointer-events: none;
}

.sov-system-upgrade-slot {
    pointer-events: none;
}

.sov-system-upgrade-slot--interactive {
    pointer-events: all;
}

.sov-system-upgrade-slot-hit {
    cursor: pointer;
}

.sov-system-upgrade-slot--interactive:hover rect:first-child {
    stroke: var(--sov-accent);
    stroke-width: 1;
}

.sov-dialog-section h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.sov-placeholder,
.sov-system-meta {
    color: var(--sov-muted);
}

.sov-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(8, 10, 14, 0.72);
    backdrop-filter: blur(4px);
}

.sov-dialog-backdrop[hidden] {
    display: none;
}

body.sov-dialog-open {
    overflow: hidden;
}

.sov-prompt-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(8, 10, 14, 0.8);
    backdrop-filter: blur(4px);
}

.sov-prompt-backdrop[hidden] {
    display: none;
}

.sov-prompt {
    width: min(420px, 100%);
    padding: 1.35rem 1.5rem 1.25rem;
    background: var(--sov-panel);
    border: 1px solid var(--sov-border);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.sov-prompt--warning {
    border-color: rgba(240, 179, 92, 0.45);
}

.sov-prompt:not(.sov-prompt--warning) .sov-prompt-icon {
    display: none;
}

.sov-prompt:not(.sov-prompt--warning) .sov-prompt-title {
    margin-top: 0;
}

.sov-prompt-icon {
    font-size: 1.75rem;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.sov-prompt-title {
    margin: 0 0 0.65rem;
    font-size: 1.1rem;
}

.sov-prompt-message {
    margin: 0 0 1.25rem;
    color: var(--sov-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-line;
}

.sov-prompt-actions {
    display: flex;
    justify-content: center;
    gap: 0.65rem;
}

.sov-prompt-button {
    min-width: 7rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--sov-border);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.sov-prompt-button--secondary {
    background: #0f131b;
    color: var(--sov-text);
}

.sov-prompt-button--secondary:hover {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
}

.sov-prompt-button--primary {
    background: var(--sov-accent);
    border-color: var(--sov-accent);
    color: #0f131b;
}

.sov-prompt-button--primary:hover {
    filter: brightness(1.08);
}

.sov-prompt--warning .sov-prompt-button--primary {
    background: #d97706;
    border-color: #d97706;
    color: #fff8eb;
}

.sov-dialog {
    width: min(960px, 100%);
    height: min(88vh, 900px);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--sov-panel);
    border: 1px solid var(--sov-border);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.sov-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--sov-border);
}

.sov-dialog-header-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

.sov-dialog-header-workforce {
    flex: 0 1 auto;
    min-width: 0;
}

.sov-workforce-control {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.35rem 0.65rem;
    background: #0f131b;
    border: 1px solid var(--sov-border);
    border-radius: 10px;
    min-width: 0;
}

.sov-workforce-control--has-error {
    border-color: rgba(239, 68, 68, 0.55);
}

.sov-workforce-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.sov-workforce-heading {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--sov-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sov-workforce-mode-group {
    display: flex;
    flex-shrink: 0;
    gap: 0.25rem;
}

.sov-workforce-mode {
    padding: 0.2rem 0.5rem;
    background: transparent;
    color: var(--sov-muted);
    border: 1px solid var(--sov-border);
    border-radius: 999px;
    font-size: 0.72rem;
    line-height: 1.2;
    cursor: pointer;
}

.sov-workforce-mode:hover {
    color: var(--sov-text);
    border-color: var(--sov-accent);
}

.sov-workforce-mode--active {
    color: var(--sov-text);
    border-color: var(--sov-accent);
    background: rgba(110, 168, 255, 0.15);
}

.sov-workforce-field {
    display: grid;
    gap: 0.35rem;
}

.sov-workforce-field-label {
    font-size: 0.72rem;
    color: var(--sov-muted);
}

.sov-workforce-field select,
.sov-workforce-field input[type='number'] {
    width: 100%;
    min-height: 2rem;
    padding: 0.35rem 0.6rem;
    background: var(--sov-panel);
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 8px;
}

.sov-workforce-export-inline {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1 1 auto;
    min-width: 0;
}

.sov-workforce-export-inline select,
.sov-workforce-export-inline input[type='number'] {
    min-height: 1.65rem;
    padding: 0.2rem 0.45rem;
    background: var(--sov-panel);
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 6px;
    font-size: 0.72rem;
}

.sov-workforce-export-inline select {
    flex: 1 1 8rem;
    min-width: 0;
    max-width: 11rem;
}

.sov-workforce-export-inline input[type='number'] {
    width: 4.25rem;
    flex: 0 0 auto;
}

.sov-workforce-incoming {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.72rem;
    color: var(--sov-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sov-workforce-field-hint {
    flex-shrink: 0;
    font-size: 0.68rem;
    color: var(--sov-muted);
    white-space: nowrap;
}

.sov-workforce-error {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.25;
    color: var(--sov-danger);
    white-space: nowrap;
}

.sov-workforce-control .sov-workforce-error {
    padding: 0 0.1rem;
}

.sov-dialog-heading {
    flex-shrink: 0;
    min-width: 0;
}

.sov-dialog-heading h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.2;
}

.sov-dialog-heading .sov-system-meta {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
}

.sov-dialog-close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: #0f131b;
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 8px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.sov-dialog-close:hover {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
}

.sov-dialog-body {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sov-dialog-section {
    padding: 1.25rem 1.5rem;
    min-height: 0;
    overflow: auto;
}

.sov-dialog-section--upgrades {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--sov-border);
    background: rgba(15, 19, 27, 0.35);
    overflow: hidden;
}

.sov-dialog-section--upgrades h3 {
    margin-top: 0;
    flex-shrink: 0;
}

.sov-dialog-budget {
    flex-shrink: 0;
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--sov-border);
}

.sov-dialog-fuel {
    flex-shrink: 0;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-top: 1px solid var(--sov-border);
    border-bottom: 1px solid var(--sov-border);
}

.sov-dialog-fuel .sov-fuel-consumption {
    margin-bottom: 0;
}

.sov-upgrade-filters,
.sov-upgrade-search {
    flex-shrink: 0;
}

.sov-budget {
    margin-bottom: 0;
}

.sov-budget-heading {
    margin: 0 0 0.65rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sov-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sov-budget-rows {
    display: grid;
    gap: 0.85rem;
}

.sov-budget-row {
    display: grid;
    gap: 0.3rem;
}

.sov-budget-details {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.sov-budget-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sov-text);
}

.sov-budget-meta {
    font-size: 0.75rem;
    color: var(--sov-muted);
    font-variant-numeric: tabular-nums;
    min-width: 0;
}

.sov-budget-remaining-wrap {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sov-budget-remaining {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.sov-budget-delta {
    text-align: right;
    font-size: 0.75rem;
    font-weight: 600;
    color: #f0b35c;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sov-budget-row--preview .sov-budget-remaining {
    color: var(--sov-accent);
}

.sov-budget-row--over .sov-budget-remaining {
    color: var(--sov-danger);
}

.sov-budget-row--preview.sov-budget-row--over .sov-budget-remaining {
    color: var(--sov-danger);
}

.sov-dialog-subsection {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--sov-border);
}

.sov-fuel-consumption {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0;
}

.sov-fuel-heading {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sov-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sov-fuel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.sov-fuel-values {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-height: 1.25rem;
}

.sov-fuel-figures {
    font-variant-numeric: tabular-nums;
}

.sov-fuel-delta {
    min-width: 2.5rem;
    text-align: right;
    font-size: 0.8rem;
    color: #f0b35c;
    font-variant-numeric: tabular-nums;
}

.sov-fuel-row--preview .sov-fuel-figures {
    color: var(--sov-accent);
}

.sov-budget-bar {
    position: relative;
    height: 8px;
    background: #0f131b;
    border-radius: 999px;
    overflow: hidden;
}

.sov-budget-fill,
.sov-budget-fill-preview {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 999px;
    transition: width 0.15s ease, left 0.15s ease;
}

.sov-budget-row--segmented .sov-budget-fill {
    border-radius: 999px 0 0 999px;
}

.sov-budget-row--segmented .sov-budget-fill-preview {
    border-radius: 0 999px 999px 0;
}

.sov-budget-row--segmented .sov-budget-fill-preview--solo {
    border-radius: 999px;
}

.sov-budget-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sov-accent), #8ec5ff);
    transition: width 0.15s ease;
    z-index: 1;
}

.sov-budget-fill-preview {
    background: linear-gradient(90deg, #d97706, #fbbf24);
    z-index: 2;
}

.sov-budget-row--over .sov-budget-fill-preview {
    background: linear-gradient(90deg, #dc2626, #ff9b9b);
}

.sov-budget-row--over .sov-budget-fill {
    background: linear-gradient(90deg, var(--sov-danger), #ff9b9b);
}

.sov-budget-row--preview.sov-budget-row--over .sov-budget-fill {
    background: linear-gradient(90deg, var(--sov-accent), #8ec5ff);
}

.sov-budget-row--preview.sov-budget-row--over .sov-budget-fill-preview {
    background: linear-gradient(90deg, #d97706, #fbbf24);
}

.sov-installed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.sov-system-upgrade-icon {
    pointer-events: none;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
}

.sov-installed-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0.65rem;
    background: #0f131b;
    border-radius: 8px;
    font-size: 0.9rem;
}

.sov-installed-upgrade-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: #1a2030;
}

.sov-installed-upgrade-name {
    flex: 1;
    min-width: 0;
}

.sov-installed-list button,
.sov-upgrade-button {
    background: #0f131b;
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 8px;
    cursor: pointer;
}

.sov-installed-list button {
    padding: 0.25rem 0.5rem;
}

.sov-installed-remove:hover {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
}

.sov-installed-remove--preview {
    border-color: var(--sov-accent);
    color: var(--sov-accent);
    box-shadow: 0 0 0 1px var(--sov-accent);
}

.sov-anomaly-preview h3 {
    margin-top: 0;
}

.sov-anomaly-preview-body {
    display: grid;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    background: #0f131b;
    border: 1px solid var(--sov-border);
    border-radius: 6px;
}

.sov-anomaly-placeholder {
    margin: 0;
    font-size: 0.8rem;
    color: #6f8f6f;
}

.sov-anomaly-group {
    display: grid;
    gap: 0.3rem;
}

.sov-anomaly-group-heading {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 600;
    color: #5f6f78;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sov-anomaly-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.15rem;
}

.sov-anomaly-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 0.45rem 0.65rem;
    min-height: 22px;
    font-size: 0.9rem;
    line-height: 1.25;
    color: #8fd98f;
}

.sov-anomaly-item--with-count {
    grid-template-columns: 18px minmax(0, 1fr) 2.25rem;
}

.sov-anomaly-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sov-anomaly-count {
    justify-self: end;
    font-variant-numeric: tabular-nums;
    color: #7bc97b;
    text-align: right;
}

.sov-anomaly-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: #8fd98f;
    object-fit: contain;
}

.sov-anomaly-icon--type {
    border-radius: 2px;
}

.sov-upgrade-list {
    display: grid;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    margin-top: 0.75rem;
    align-content: start;
    grid-auto-rows: max-content;
}

.sov-upgrade-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.sov-upgrade-filter {
    padding: 0.35rem 0.65rem;
    background: #0f131b;
    color: var(--sov-muted);
    border: 1px solid var(--sov-border);
    border-radius: 999px;
    font-size: 0.78rem;
    cursor: pointer;
}

.sov-upgrade-filter:hover {
    color: var(--sov-text);
    border-color: var(--sov-accent);
}

.sov-upgrade-filter--active {
    color: var(--sov-text);
    border-color: var(--sov-accent);
    background: rgba(110, 168, 255, 0.15);
}

.sov-upgrade-search input {
    width: 100%;
    padding: 0.55rem 0.65rem;
    background: #0f131b;
    color: var(--sov-text);
    border: 1px solid var(--sov-border);
    border-radius: 8px;
}

.sov-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sov-upgrade-button {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    text-align: left;
    padding: 0.65rem 0.75rem;
}

.sov-upgrade-button-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: #1a2030;
}

.sov-upgrade-button-content {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.sov-upgrade-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sov-upgrade-button--installed:not(:disabled) {
    border-color: #3d6f45;
}

.sov-upgrade-button--preview {
    border-color: var(--sov-accent);
    box-shadow: 0 0 0 1px var(--sov-accent);
}

.sov-upgrade-button--blocked {
    opacity: 0.65;
    cursor: not-allowed;
}

.sov-upgrade-button[aria-disabled='true'] {
    cursor: not-allowed;
}

.sov-system-upgrade-slot--preview .sov-system-upgrade-icon {
    pointer-events: none;
}

.sov-upgrade-status {
    color: #f0b35c;
    font-size: 0.75rem;
}

.sov-upgrade-name {
    font-weight: 600;
}

.sov-upgrade-cost {
    color: var(--sov-muted);
    font-size: 0.8rem;
}

@media (max-width: 800px) {
    .sov-dialog-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .sov-dialog-header-end {
        order: 2;
        flex-basis: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .sov-workforce-row {
        flex-wrap: wrap;
    }

    .sov-workforce-control .sov-workforce-error {
        white-space: normal;
    }

    .sov-dialog-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(0, 1.2fr);
    }

    .sov-dialog-section--upgrades {
        border-left: 0;
        border-top: 1px solid var(--sov-border);
    }
}
