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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

header {
    background: #16213e;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.25rem;
    color: #e94560;
    font-weight: 600;
}

#main-layout {
    display: flex;
    height: calc(100vh - 52px);
}

#sidebar {
    width: 340px;
    min-width: 340px;
    background: #16213e;
    border-right: 1px solid #0f3460;
    overflow-y: auto;
    padding: 1rem;
}

#sidebar section {
    margin-bottom: 1.5rem;
}

#sidebar h2 {
    font-size: 1rem;
    color: #e94560;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #0f3460;
}

#map {
    flex: 1;
}

/* Forms */
label {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    color: #a0a0b0;
}

.field-hint {
    display: block;
    font-size: 0.7rem;
    color: #6a6a7a;
    margin-bottom: 0.4rem;
    padding-left: 0.2rem;
    min-height: 0.85rem;
}

input[type="text"],
input[type="number"],
select {
    display: block;
    width: 100%;
    padding: 0.4rem 0.6rem;
    margin-top: 0.2rem;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.85rem;
}

input[type="color"] {
    display: block;
    width: 100%;
    height: 32px;
    margin-top: 0.2rem;
    padding: 2px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    cursor: pointer;
}

input:focus,
select:focus {
    outline: none;
    border-color: #e94560;
}

/* Buttons */
button {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

button:not(.secondary):not(.danger) {
    background: #e94560;
    color: #fff;
}

button:not(.secondary):not(.danger):hover {
    background: #c73650;
}

button.secondary {
    background: #0f3460;
    color: #e0e0e0;
}

button.secondary:hover {
    background: #1a4a80;
}

button.danger {
    background: #8b0000;
    color: #fff;
}

button.danger:hover {
    background: #a00000;
}

.form-row {
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #a0a0b0;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
    accent-color: #e94560;
}
.operational-toggle {
    margin: 0.4rem 0;
    padding: 0.35rem 0.5rem;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
}
.operational-status {
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: auto;
}
.operational-status.offline {
    color: #ff1744;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Lists */
ul {
    list-style: none;
    margin-top: 0.5rem;
}

ul li {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: #1a1a2e;
    border-radius: 4px;
    border: 1px solid #0f3460;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: border-color 0.2s;
}

ul li:hover {
    border-color: #e94560;
}

ul li .color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

ul li .node-type-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #0f3460;
    color: #a0a0b0;
    margin-left: auto;
    flex-shrink: 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: #16213e;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #0f3460;
    width: 360px;
    max-width: 90%;
}

.modal-content h2 {
    color: #e94560;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* Node hint */
#node-hint {
    font-size: 0.8rem;
    color: #707080;
    font-style: italic;
    margin-bottom: 0.5rem;
}

/* Node editor */
#node-editor hr {
    border: none;
    border-top: 1px solid #0f3460;
    margin: 0.75rem 0;
}

#node-stats-content {
    font-size: 0.8rem;
    color: #a0a0b0;
}

#node-stats-content span {
    display: inline-block;
    margin-right: 1rem;
    margin-bottom: 0.25rem;
}

#save-indicator {
    font-size: 0.75rem;
    color: #4caf50;
    margin-top: 0.5rem;
    transition: opacity 0.3s;
}

#save-indicator.fade {
    opacity: 0;
}

/* Map click mode indicator */
body.placing-node #map {
    cursor: crosshair;
}

/* Simulation panel */
.sim-selector-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.sim-selector-row select {
    flex: 1;
    min-width: 0;
}

.sim-selector-row button {
    white-space: nowrap;
    flex-shrink: 0;
}

#sim-status {
    margin-top: 0.6rem;
}

.sim-info-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.sim-status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-running  { background: #1a4a1a; color: #4caf50; border: 1px solid #4caf50; }
.status-paused   { background: #4a3a00; color: #ffc107; border: 1px solid #ffc107; }
.status-stopped  { background: #4a1010; color: #ef5350; border: 1px solid #ef5350; }

.sim-time {
    font-size: 0.8rem;
    color: #a0a0b0;
}

.sim-speed-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: #a0a0b0;
}

.sim-speed-label {
    margin-right: 0.15rem;
}

.icon-btn {
    padding: 0.2rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    min-width: 1.6rem;
}

#sim-speed {
    min-width: 2.5rem;
    text-align: center;
    color: #e0e0e0;
    font-weight: 600;
}

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

.header-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
}

.header-btn.active {
    background: #e94560;
    color: #fff;
}

/* Stats panel */
#stats-panel {
    width: 320px;
    min-width: 320px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stats-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #0f3460;
}

.stats-header h2 {
    font-size: 1rem;
    color: #e94560;
    margin: 0;
}

.stats-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    margin-left: auto;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

.stats-section {
    margin-bottom: 1rem;
}

.stats-section h3 {
    font-size: 0.8rem;
    color: #a0a0b0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.stats-empty {
    font-size: 0.8rem;
    color: #505060;
    font-style: italic;
}

/* Community stats 3-column grid (label / total / last tick) */
.comm-stats-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.15rem 0.5rem;
    align-items: baseline;
    font-size: 0.78rem;
    margin-top: 0.3rem;
}
.comm-hdr {
    font-size: 0.7rem;
    color: #808090;
    text-transform: uppercase;
}
.comm-label {
    color: #a0a0b0;
    white-space: nowrap;
}

/* Stat grids */
.stat-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.stat-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.3rem;
}

.stat-item {
    background: #1a1a2e;
    border-radius: 4px;
    padding: 0.3rem 0.4rem;
    border: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stat-item-full {
    grid-column: 1 / -1;
}

.stat-label {
    font-size: 0.65rem;
    color: #606070;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e0e0e0;
}

.stat-value.produced  { color: #4caf50; }
.stat-value.consumed  { color: #ef5350; }
.stat-value.earned    { color: #4caf50; }
.stat-value.spent     { color: #ef5350; }
.stat-value.good      { color: #4caf50; }
.stat-value.warn      { color: #ffc107; }
.stat-value.bad       { color: #ef5350; }

/* Community stat card */
.stat-card {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.stat-card-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}
.comm-nodes-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
    color: #888;
    padding-top: 0.4rem;
    margin-top: 0.3rem;
    border-top: 1px solid #0f3460;
}
.comm-nodes-toggle:hover {
    color: #c0c0d0;
}
.fold-arrow {
    font-size: 0.55rem;
    color: inherit;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.fold-arrow.expanded {
    transform: rotate(90deg);
}
.comm-nodes {
    padding-top: 0.35rem;
}
.comm-nodes .node-stat-row {
    border-color: transparent;
    background: #12122a;
    margin-bottom: 0.25rem;
    padding: 0.35rem 0.4rem;
}
.comm-nodes .node-stat-row:last-child {
    margin-bottom: 0;
}
.ungrouped-heading {
    font-size: 0.8rem;
    color: #888;
    margin: 0.8rem 0 0.4rem;
    font-weight: 500;
}

.stat-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e0e0e0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background: #0f3460;
    color: #a0a0b0;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-solar      { background: #2a2a00; color: #ffc107; }
.badge-wind       { background: #002a2a; color: #26c6da; }
.badge-industrial { background: #2a1a00; color: #ff7043; }
.badge-battery    { background: #1a2a00; color: #66bb6a; }
.badge-household  { background: #0f3460; color: #a0a0b0; }

/* Node stat rows */
.node-stat-row {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 0.45rem 0.5rem;
    margin-bottom: 0.4rem;
}

.node-stat-row.clickable {
    cursor: pointer;
    transition: background 0.15s;
}
.node-stat-row.clickable:hover {
    background: #0f3460;
}
.node-stat-row.selected {
    background: #0f3460;
    border-color: #00e5ff;
}

.node-stat-row.offline {
    opacity: 0.55;
    border-color: #3a1010;
}

.node-stat-summary {
    font-size: 0.75rem;
    color: #a0a0b0;
    padding-left: 1.2rem;
}
.node-stat-summary .produced { color: #66bb6a; }
.node-stat-summary .consumed { color: #ef5350; }

.node-stat-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.node-stat-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: #e0e0e0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background: #4a1010;
    color: #ef5350;
    flex-shrink: 0;
}

.node-stat-total {
    font-size: 0.7rem;
    color: #606070;
    margin-top: 0.25rem;
}

.node-stat-total span {
    font-weight: 600;
}

/* Battery bar */
.batt-bar {
    width: 100%;
    height: 5px;
    background: #0f3460;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.batt-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Node hover tooltip on map */
.node-stats-tooltip {
    background: #16213e !important;
    border: 1px solid #0f3460 !important;
    border-radius: 8px !important;
    color: #e0e0e0 !important;
    padding: 0.8rem 1rem !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 0.88rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
    white-space: normal !important;
    max-width: 520px !important;
}

.node-stats-tooltip::before {
    border-right-color: #0f3460 !important;
    border-top-color: transparent !important;
}
.node-stats-tooltip.leaflet-tooltip-left::before {
    border-right-color: transparent !important;
    border-left-color: #0f3460 !important;
}

.tt-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #e94560;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.tt-grid {
    display: grid;
    grid-template-columns: auto auto auto;
    gap: 0.2rem 0.8rem;
    align-items: baseline;
}

.tt-label {
    font-size: 0.78rem;
    color: #707080;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tt-hdr {
    font-size: 0.72rem;
    color: #505068;
    text-align: right;
    font-weight: 600;
    text-transform: uppercase;
}

.tt-val {
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.tt-green { color: #4caf50; }
.tt-red   { color: #ef5350; }
.tt-solar { color: #ffc107; }
.tt-wind  { color: #26c6da; }
.tt-override { font-style: italic; text-decoration: underline dotted; }
.tt-section-hdr {
    grid-column: 1 / -1;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-top: 0.3rem;
}

.tt-chart {
    margin-top: 0.6rem;
    min-height: 0;
}

.tt-chart-svg {
    width: 100%;
    height: 140px;
    display: block;
}

.tt-chart-label {
    fill: #707080;
    font-size: 9px;
    font-family: inherit;
}

.tt-chart-legend {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    font-size: 0.75rem;
    margin-top: 0.2rem;
    color: #707080;
}

.tt-chart-leg-solar::before {
    content: '';
    display: inline-block;
    width: 10px; height: 10px;
    background: #ffc107;
    border-radius: 2px;
    margin-right: 3px;
    vertical-align: middle;
    opacity: 0.7;
}

.tt-chart-leg-wind::before {
    content: '';
    display: inline-block;
    width: 10px; height: 10px;
    background: #26c6da;
    border-radius: 2px;
    margin-right: 3px;
    vertical-align: middle;
    opacity: 0.7;
}

.tt-chart-leg-cons::before {
    content: '';
    display: inline-block;
    width: 10px; height: 10px;
    background: #ef5350;
    border-radius: 2px;
    margin-right: 3px;
    vertical-align: middle;
    opacity: 0.7;
}

/* Node highlight ring (pulsing) */
.node-highlight-ring {
    animation: highlight-pulse 1.5s ease-in-out infinite;
}
@keyframes highlight-pulse {
    0%, 100% { stroke-opacity: 0.9; fill-opacity: 0.15; }
    50%      { stroke-opacity: 0.4; fill-opacity: 0.05; }
}

/* Placeholder marker for planned nodes */
.node-placeholder {
    background: none !important;
    border: none !important;
}
.node-placeholder-icon {
    width: 32px;
    height: 32px;
    border: 2.5px dashed #00e5ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #00e5ff;
    opacity: 0.7;
    animation: placeholder-pulse 2s ease-in-out infinite;
}
@keyframes placeholder-pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(1.1); }
}

/* Energy labels on map nodes */
.energy-label {
    background: none !important;
    border: none !important;
}

.energy-label-inner {
    display: flex;
    gap: 4px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1.00rem;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 0 3px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.7);
    justify-content: center;
}

.el-prod {
    color: #4caf50;
}

.el-cons {
    color: #ef5350;
}

/* Solar/wind stat colors */
.stat-value.solar { color: #ffc107; }
.stat-value.wind  { color: #26c6da; }

/* Heatmap toggle buttons */
.heatmap-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 4px;
}

.heatmap-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #16213eee;
    color: #a0a0b0;
    cursor: pointer;
    transition: all 0.2s;
}

.heatmap-btn:hover {
    border-color: #e94560;
    color: #e0e0e0;
}

.heatmap-btn.active-solar {
    background: rgba(255, 193, 7, 0.25);
    border-color: #ffc107;
    color: #ffc107;
}

.heatmap-btn.active-wind {
    background: rgba(38, 198, 218, 0.25);
    border-color: #26c6da;
    color: #26c6da;
}

/* Heatmap legend */
.heatmap-legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    z-index: 1000;
    background: #16213eee;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.7rem;
    color: #a0a0b0;
}

.heatmap-legend-title {
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 4px;
}

.heatmap-legend-bar {
    width: 140px;
    height: 12px;
    border-radius: 2px;
    margin-bottom: 2px;
}

.heatmap-legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
}

.heatmap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 200;
}

/* Heatmap month slider */
.heatmap-slider-row {
    position: absolute;
    top: 44px;
    right: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 30, 50, 0.9);
    border-radius: 6px;
    padding: 4px 10px;
    border: 1px solid #444;
}

.heatmap-slider-row input[type="range"] {
    width: 130px;
    accent-color: #e94560;
    cursor: pointer;
}

.heatmap-slider-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #e0e0e0;
    min-width: 70px;
    text-align: center;
}

/* Weather value markers on map */
.weather-value-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.wv-inner {
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 1px 2px rgba(0,0,0,0.7);
    text-align: center;
    white-space: nowrap;
}

.wv-unit {
    font-weight: 400;
    font-size: 0.5rem;
    opacity: 0.8;
    margin-left: 1px;
}

.wv-station .wv-inner {
    color: #000;
    text-shadow: 0 0 3px rgba(255,255,255,0.8), 0 1px 2px rgba(255,255,255,0.5);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Weather override section in node editor */
.override-heading {
    color: #e0e0e0;
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.override-row {
    display: flex;
    gap: 8px;
    margin-bottom: 0.4rem;
}

.override-row label {
    flex: 1;
    font-size: 0.8rem;
}

.override-row input {
    width: 100%;
}

.tt-offline {
    margin-top: 0.3rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #ef5350;
    background: #4a1010;
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

/* --- Failure overlay on map markers --- */

.node-failure-overlay {
    background: none !important;
    border: none !important;
}
.node-failure-icon {
    font-size: 1.1rem;
    color: #ff1744;
    text-shadow: 0 0 6px rgba(255, 23, 68, 0.8);
    text-align: center;
    animation: failure-blink 1.2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes failure-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* --- Help modal --- */

.help-modal-content {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    display: flex;
    width: 720px;
    max-width: 92vw;
    height: 520px;
    max-height: 85vh;
    overflow: hidden;
}

.help-sidebar {
    width: 190px;
    min-width: 190px;
    background: #0f1a30;
    border-right: 1px solid #0f3460;
    padding: 1rem 0;
    overflow-y: auto;
}
.help-sidebar h3 {
    font-size: 0.85rem;
    color: #e94560;
    padding: 0 0.8rem 0.6rem;
}
.help-sidebar ul {
    list-style: none;
}
.help-topic-item {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
    color: #a0a0b0;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.help-topic-item:hover {
    background: #16213e;
    color: #e0e0e0;
}
.help-topic-item.active {
    background: #16213e;
    color: #fff;
    border-left-color: #e94560;
}

.help-body {
    flex: 1;
    padding: 1.2rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.help-body #help-article {
    flex: 1;
    overflow-y: auto;
    padding-right: 15px;
}

.help-body h2 {
    font-size: 1.05rem;
    color: #e94560;
    margin-bottom: 0.8rem;
}
.help-body h3 {
    font-size: 0.9rem;
    color: #00e5ff;
    margin: 1rem 0 0.4rem;
}
.help-body h4 {
    font-size: 0.82rem;
    color: #c0c0d0;
    margin: 0.7rem 0 0.3rem;
}
.help-body p {
    font-size: 0.8rem;
    color: #c0c0d0;
    line-height: 1.55;
    margin-bottom: 0.6rem;
}
.help-body ul, .help-body ol {
    font-size: 0.8rem;
    color: #c0c0d0;
    line-height: 1.55;
    padding-left: 1.3rem;
    margin-bottom: 0.6rem;
}
.help-body li {
    margin-bottom: 0.25rem;
}
.help-body strong {
    color: #e0e0e0;
}
.help-body em {
    color: #ffc107;
    font-style: normal;
}
.help-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin-bottom: 0.8rem;
}
.help-body th {
    text-align: left;
    color: #00e5ff;
    border-bottom: 1px solid #0f3460;
    padding: 0.3rem 0.5rem;
    font-weight: 600;
}
.help-body td {
    color: #c0c0d0;
    border-bottom: 1px solid #0a0f20;
    padding: 0.3rem 0.5rem;
}
.help-loading {
    color: #666;
    font-style: italic;
}
.help-close-btn {
    margin-top: 0.8rem;
    align-self: flex-end;
    flex-shrink: 0;
}

/* --- Toast notifications --- */

#toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: #e0e0e0;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    word-wrap: break-word;
}
.toast-visible {
    opacity: 1;
    transform: translateX(0);
}
.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}

.toast-error {
    background: #3a1020;
    border-left: 3px solid #ef5350;
}
.toast-warning {
    background: #3a2a10;
    border-left: 3px solid #ffa726;
}
.toast-info {
    background: #102a3a;
    border-left: 3px solid #42a5f5;
}
.toast-success {
    background: #103a1a;
    border-left: 3px solid #66bb6a;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}
.toast-error .toast-icon { color: #ef5350; }
.toast-warning .toast-icon { color: #ffa726; }
.toast-info .toast-icon { color: #42a5f5; }
.toast-success .toast-icon { color: #66bb6a; }

.toast-msg {
    flex: 1;
    min-width: 0;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.toast-close:hover {
    color: #e0e0e0;
}

/* Login overlay */
#login-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
}

#login-overlay.hidden {
    display: none;
}

.login-box {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 2rem 2.5rem;
    text-align: center;
    min-width: 320px;
}

.login-box h2 {
    margin-bottom: 0.5rem;
    color: #e0e0e0;
}

.login-box p {
    color: #888;
    margin-bottom: 1.2rem;
    font-size: 0.9rem;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#login-password {
    padding: 0.6rem 0.8rem;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 1rem;
    outline: none;
}

#login-password:focus {
    border-color: #e94560;
}

#login-form button {
    padding: 0.6rem;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

#login-form button:hover {
    background: #c73e54;
}

.login-error {
    color: #ef5350;
    margin-top: 0.75rem;
    font-size: 0.85rem;
}
