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

body {
    display: flex;
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #e0e0e0;
    background: #1a1a2e;
}

/* Sidebar (left) */
#sidebar {
    width: 320px;
    min-width: 320px;
    background: #16213e;
    padding: 16px;
    overflow-y: auto;
    border-right: 2px solid #0f3460;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#sidebar h2 {
    color: #e94560;
    margin-bottom: 8px;
    font-size: 18px;
}

#sidebar h3,
#right-panel h3 {
    color: #94a3b8;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Right panel (modifiers) */
#right-panel {
    width: 280px;
    min-width: 280px;
    background: #16213e;
    padding: 16px;
    overflow-y: auto;
    border-left: 2px solid #0f3460;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#right-panel h2 {
    color: #e94560;
    margin-bottom: 8px;
    font-size: 18px;
}

.section {
    background: #1a1a2e;
    border-radius: 6px;
    padding: 12px;
}

/* Inputs */
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #16213e;
    color: #e0e0e0;
    font-size: 13px;
    margin-bottom: 6px;
}

input[type="number"] {
    width: 60px;
}

/* Buttons */
button {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}

#btn-load-save,
#btn-calc-control,
#btn-optimize {
    background: #e94560;
    color: white;
}

#btn-load-save:hover,
#btn-calc-control:hover,
#btn-optimize:hover {
    background: #c73e54;
}

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

.btn-danger {
    background: #6b2130;
    color: #f87171;
    font-size: 11px;
    padding: 4px 10px;
    margin-top: 6px;
}

.btn-danger:hover {
    background: #832638;
}

/* Mode buttons */
.btn-group {
    display: flex;
    gap: 2px;
}

.mode-btn {
    flex: 1;
    background: #0f3460;
    color: #94a3b8;
    font-size: 12px;
    padding: 5px 8px;
}

.mode-btn.active {
    background: #e94560;
    color: white;
}

/* Placement toggle buttons */
.placement-toggles {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.toggle-btn {
    flex: 1;
    background: #0f3460;
    color: #94a3b8;
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid transparent;
}

.toggle-btn.active {
    background: #1e3a5f;
    color: #60a5fa;
    border-color: #60a5fa;
}

/* Unified slider styles */
.slider-wrap {
    padding: 0 2px;
}

.slider-wrap input[type="range"] {
    width: 100%;
    margin: 4px 0 2px;
    accent-color: #e94560;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #94a3b8;
    padding: 0 2px;
}

.slider-labels.tri {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #94a3b8;
    padding: 0 2px;
}

/* Status messages */
.status {
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
    min-height: 16px;
}

.status.error {
    color: #e94560;
}

.status.success {
    color: #4ade80;
}

/* Province info */
#province-info {
    font-size: 13px;
    line-height: 1.5;
    color: #94a3b8;
}

#province-info .name {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 15px;
}

#province-info .tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
}

.tag.owned { background: #365314; color: #a3e635; }
.tag.not-owned { background: #44403c; color: #a8a29e; }
.tag.capital { background: #854d0e; color: #fbbf24; }
.tag.governor { background: #1e3a5f; color: #60a5fa; }

/* Empire info */
#empire-info {
    font-size: 13px;
    line-height: 1.6;
}

/* Governor list */
#governor-list {
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.gov-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    background: #16213e;
    border-radius: 3px;
    margin-bottom: 2px;
    font-size: 12px;
}

.gov-item .remove-btn {
    background: none;
    border: none;
    color: #e94560;
    cursor: pointer;
    padding: 0 4px;
    font-size: 14px;
}

/* Inline layout */
.inline {
    display: flex;
    gap: 6px;
    align-items: center;
}

.spacer {
    height: 8px;
}

/* Stats panel */
#stats-panel {
    font-size: 13px;
    line-height: 1.6;
}

#stats-panel .stat-value {
    font-weight: 600;
    color: #e0e0e0;
}

/* Map */
#map {
    flex: 1;
    background: #1e1e2e;
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    background: #16213e;
    color: #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
    background: #16213e;
}

.leaflet-popup-content {
    margin: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

/* Custom markers */
.capital-marker {
    font-size: 22px;
    color: #fbbf24;
    text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.5);
}

.governor-marker {
    font-size: 18px;
    color: #60a5fa;
    text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.5);
}

/* Control value labels */
.control-label {
    background: none !important;
    border: none !important;
}

.control-label span {
    display: block;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 3px rgba(0,0,0,1), 0 0 6px rgba(0,0,0,0.8),
                 1px 1px 1px rgba(0,0,0,0.9);
    line-height: 16px;
    pointer-events: none;
}

/* Checkbox toggle label */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #e0e0e0;
}

.toggle-label input[type="checkbox"] {
    accent-color: #e94560;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #94a3b8;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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