#dashboardRoot,
#consoleRoot {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#consoleRoot {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.console-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.75rem;
}

.dashboard-grid {
    flex: 1;
    display: grid;
    gap: 1rem;
    padding: 1rem;
    overflow-y: auto;
    grid-template-columns: repeat(1, minmax(0, 1fr));
}
body.theme-dark {
    background-color: #0b1120;
    color: #e2e8f0;
}

body.theme-light {
    background-color: #f9fafb;
    color: #1f2937;
}

body.theme-light .map-container {
    background-color: #e5e7eb;
}

body.theme-light .activity-footer {
    background-color: #f3f4f6;
    border-top: 1px solid #d1d5db;
    color: #1f2937;
}

body.theme-light .console-list li {
    color: #1f2937;
}

body.theme-light .activity-actions .btn-outline-light {
    color: #1f2937;
    border-color: #1f2937;
}

body.theme-light .activity-actions .btn-outline-light:hover,
body.theme-light .activity-actions .btn-outline-light:focus {
    background-color: #1f2937;
    color: #ffffff;
}

body.theme-light .sensor-overview-card {
    border-color: #d1d5db;
    background-color: #ffffff;
}

body.theme-light .gauge-meter-value {
    color: #1f2937;
}

body.theme-light .dashboard-tile {
    background-color: #ffffff;
    border-color: #d1d5db;
    color: #1f2937;
}

body.theme-light .console-view {
    background-color: #ffffff;
    color: #1f2937;
}

body.theme-light .modal-content {
    background-color: #ffffff;
    color: #1f2937;
}

body.theme-dark .modal-content {
    background-color: #0f172a;
    color: #e2e8f0;
    border: 1px solid #1e293b;
}

body.theme-dark .modal-header,
body.theme-dark .modal-footer {
    border-color: #1f2937;
}

body.theme-dark .nav-tabs .nav-link {
    background-color: #0f172a;
    border-color: #1e293b;
    color: #94a3b8;
}

body.theme-dark .nav-tabs .nav-link.active {
    background-color: #1f2937;
    color: #f8fafc;
    border-color: #2563eb #2563eb #1f2937;
}

body.theme-dark .nav-tabs .nav-link:not(.active):hover {
    color: #f8fafc;
}

body.theme-dark .tab-content {
    background-color: #0f172a;
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus {
    background-color: #111827;
    border-color: #1f2937;
    color: #e2e8f0;
}

body.theme-dark .form-control::placeholder {
    color: #94a3b8;
}

body.theme-dark .accordion-item {
    background-color: #0f172a;
    border-color: #1f2937;
}

body.theme-dark .accordion-button {
    background-color: #111827;
    color: #e2e8f0;
}

body.theme-dark .accordion-button::after {
    filter: invert(1);
}

body.theme-dark .accordion-button:not(.collapsed) {
    color: #f8fafc;
    background-color: #1f2937;
    box-shadow: none;
}

body.theme-dark .accordion-body {
    background-color: #0f172a;
    color: #e2e8f0;
}

body.theme-dark .sensor-overview-card {
    border-color: #1f2937;
    background-color: #0f172a;
}

body.theme-dark .dashboard-tile {
    background-color: #0f172a;
    border-color: #1f2937;
    color: #e2e8f0;
}

body.theme-dark .console-view {
    background-color: #0f172a;
    color: #e2e8f0;
}

body.theme-dark .list-group-item {
    background-color: #111827;
    border-color: #1f2937;
    color: #e2e8f0;
}

body.theme-dark .list-group-item .text-muted {
    color: #cbd5f5 !important;
}

body.theme-dark .btn-close {
    filter: invert(1);
}

body.theme-dark .add-logger-panel .card {
    background-color: #0f172a;
    color: #e2e8f0;
    border: 1px solid #1f2937;
}

body.theme-dark .add-logger-panel .card-header,
body.theme-dark .add-logger-panel .card-footer {
    border-color: #1f2937;
}

body.theme-dark .add-logger-panel .alert {
    background-color: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
    border-color: rgba(59, 130, 246, 0.3);
}

body.theme-dark .leaflet-control {
    background-color: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid #1f2937;
}

body.theme-dark .leaflet-control a {
    color: #60a5fa;
}

body.theme-light .leaflet-control {
    background-color: rgba(255, 255, 255, 0.9);
    color: #1f2937;
}
html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.app-main {
    width: 100%;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.app-main {
    width: 100%;
    padding: 0;
}

#appRoot {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.map-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background-color: #0f172a;
    margin: 0;
}

.leaflet-container {
    font: inherit;
}

.logger-popup {
    min-width: 220px;
}

.dashboard-alert {
    width: 100%;
    padding: 0 1rem;
    color: #fff;
    margin: 0;
    transition: background-color 0.2s ease;
    font-family: "Courier New", Courier, "Lucida Console", monospace;
}

.status-spinner {
    margin-right: 0.5rem;
}

.dashboard-alert.status-green {
    background-color: #198754;
}

.dashboard-alert.status-yellow {
    background-color: #ffc107;
    color: #111827;
}

.dashboard-alert.status-red {
    background-color: #dc3545;
}

.dashboard-alert.flash {
    animation: alert-flash 0.5s ease-in-out 1;
}

.add-logger-panel {
    position: absolute;
    top: 100px;
    right: 20px;
    width: 320px;
    z-index: 1000;
}

.add-logger-panel select {
    width: 100%;
}

.add-logger-panel .card-body {
    max-height: 260px;
    overflow-y: auto;
}

.status-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    background-color: #6c757d;
}

.status-indicator.status-green {
    background-color: #198754;
}

.status-indicator.status-yellow {
    background-color: #ffc107;
}

.status-indicator.status-red {
    background-color: #dc3545;
}

.sensor-overview-card {
    border: 1px solid #e9ecef;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #ffffff;
}

.sensor-overview-card .sensor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.sensor-overview-card .sensor-title {
    font-weight: 600;
    margin-bottom: 0;
}

.sensor-overview-card .last-reading-meta {
    font-size: 0.75rem;
    color: #6c757d;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gauge-number {
    font-size: 2rem;
    font-weight: 600;
}

.gauge-progress .progress {
    height: 10px;
    background-color: #f1f3f5;
}

.gauge-progress .progress-threshold {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0.9;
}

.gauge-progress {
    position: relative;
}

.gauge-gradient {
    position: relative;
    width: 100%;
    height: 82px;
}

.gauge-gradient .meter-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, #198754 0%, #ffc107 50%, #dc3545 100%);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.gauge-gradient .threshold-marker {
    position: absolute;
    top: -10px;
    width: 0;
    height: 32px;
    border-left: 3px solid;
    transform: translateX(-50%);
    pointer-events: none;
}

.gauge-gradient .threshold-marker .label {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    padding: 0.1rem 0.25rem;
    border-radius: 0.25rem;
    background: rgba(17, 24, 39, 0.9);
    color: #fff;
    white-space: nowrap;
}

.gauge-gradient .meter-indicator {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    height: 82px;
    width: 2px;
    background-color: #343a40;
}

.gauge-meter {
    position: relative;
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
}

.gauge-meter svg {
    width: 100%;
    height: auto;
}

.gauge-meter .threshold-label {
    font-size: 0.65rem;
    text-anchor: middle;
    dominant-baseline: middle;
    fill: currentColor;
}

.gauge-meter .threshold-tick {
    stroke-width: 3;
}

.threshold-color-green {
    color: #198754;
    fill: #198754;
}

.threshold-color-yellow {
    color: #ffc107;
    fill: #ffc107;
}

.threshold-color-red {
    color: #dc3545;
    fill: #dc3545;
}

.gauge-meter .minmax-label {
    font-size: 0.7rem;
    fill: #6c757d;
}

.gauge-meter-value {
    margin-top: 0.4rem;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

.sensor-settings-card {
    border-radius: 0;
}

.sensor-settings-card .mode-select {
    width: 100%;
}

.sensor-settings-card .accordion-button {
    font-weight: 600;
}

.dashboard-tile {
    border: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    aspect-ratio: 1 / 1;
    transition: transform 0.2s ease;
}

.dashboard-tile:hover {
    transform: translateY(-2px);
}

.dashboard-tile-title {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dashboard-tile-gauge {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.dashboard-tile-gauge > * {
    width: 100%;
    max-width: 260px;
}

.dashboard-tile-meta {
    font-size: 0.75rem;
    opacity: 0.8;
    text-align: center;
}

.dashboard-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    color: rgba(148, 163, 184, 0.9);
    font-size: 0.9rem;
    padding: 2rem;
    aspect-ratio: 1 / 1;
}

.dashboard-tile.status-green {
    box-shadow: inset 0 0 0 2px rgba(25, 135, 84, 0.35);
}

.dashboard-tile.status-yellow {
    box-shadow: inset 0 0 0 2px rgba(255, 193, 7, 0.5);
}

.dashboard-tile.status-red {
    box-shadow: inset 0 0 0 2px rgba(220, 53, 69, 0.55);
}

.console-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.console-full {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.75rem;
}

.console-full-entry {
    display: grid;
    grid-template-columns: 80px 1fr;
    grid-template-rows: auto auto;
    column-gap: 1rem;
    row-gap: 0.3rem;
    font-size: 0.85rem;
}

.console-full-time {
    font-weight: 600;
    color: #22d3ee;
}

.console-full-body {
    font-weight: 600;
}

.console-full-meta {
    grid-column: 1 / span 2;
    font-size: 0.75rem;
    opacity: 0.7;
}

.console-empty {
    opacity: 0.6;
    font-size: 0.85rem;
}

.console-list.console-full {
    padding: 0;
    max-height: none;
    overflow-y: auto;
}

.map-label {
    background: rgba(15, 23, 42, 0.88);
    color: #f8fafc;
    padding: 0.35rem 0.55rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.35);
    font-size: 0.75rem;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -115%);
}

.theme-light .map-label {
    background: rgba(255, 255, 255, 0.92);
    color: #1f2937;
    border-color: rgba(148, 163, 184, 0.55);
    box-shadow: 0 6px 18px rgba(148, 163, 184, 0.25);
}

.map-label strong {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.78rem;
}

.map-label .map-label-reading {
    display: block;
}

.map-label .map-label-reading .label-name {
    font-weight: 600;
    margin-right: 0.25rem;
}

@media (max-width: 768px) {
    .console-full-entry {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        row-gap: 0.2rem;
    }

    .console-full-time,
    .console-full-body,
    .console-full-meta {
        grid-column: 1;
    }
}

.activity-footer {
    width: 100%;
    background-color: #0b1120;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    max-height: 180px;
    overflow: hidden;
    margin: 0;
    flex-shrink: 0;
}

.activity-columns {
    display: flex;
    gap: 0;
    padding: 0.5rem 0;
    align-items: stretch;
    height: 100%;
}

.activity-feed {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding-right: 0.5rem;
}

.activity-actions {
    flex: 0 0 120px;
    width: 120px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.25rem;
}

.activity-actions .btn {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 90px;
    height: 20px;
    font-size: 0.65rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.activity-actions .btn + .btn {
    margin-top: 0.25rem;
}

.map-label-toggle {
    color: #e2e8f0;
    font-size: 0.75rem;
}

.theme-light .map-label-toggle {
    color: #1f2937;
}

.map-label-toggle .form-check-input,
.map-label-toggle .form-check-label {
    cursor: pointer;
}

.activity-subactions {
    width: 90px;
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
}

.activity-mini-btn {
    width: 45px;
    height: 20px;
    font-size: 0.6rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.activity-mini-btn + .activity-mini-btn {
    margin-top: 0;
}

.activity-actions .btn:disabled,
.activity-mini-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.activity-footer .console-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    max-height: 140px;
    overflow-y: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.75rem;
}

.activity-footer .console-list li {
    padding: 0.2rem 0;
    color: #e2e8f0;
}

.activity-footer .console-list .reading-value {
    font-weight: 600;
}

@media (max-width: 768px) {
    .activity-columns {
        flex-direction: column;
    }

    .activity-actions {
        flex-direction: row;
        width: 100%;
        flex: none;
        align-items: center;
        gap: 0.5rem;
    }

    .activity-actions .btn + .btn {
        margin-top: 0;
    }

    .activity-actions .btn {
        flex: none;
    }

    .map-label-toggle {
        width: 100%;
    }

    .activity-subactions {
        width: auto;
        gap: 0.5rem;
    }

    .activity-mini-btn {
        width: 70px;
        height: 28px;
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

.sensor-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.sensor-status-pill.status-green {
    background-color: rgba(25, 135, 84, 0.15);
    color: #198754;
}

.sensor-status-pill.status-yellow {
    background-color: rgba(255, 193, 7, 0.15);
    color: #856404;
}

.sensor-status-pill.status-red {
    background-color: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.logger-modal .modal-dialog {
    max-width: 860px;
    max-height: 80vh;
}

.logger-modal .modal-content {
    max-height: 80vh;
    overflow: hidden;
}

.logger-modal .modal-body {
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

#historyTab {
    max-height: calc(60vh - 120px);
    overflow-y: auto;
}

.sensor-condition .min-input,
.sensor-condition .max-input {
    transition: opacity 0.15s ease;
}

.simulate-result {
    color: #6c757d;
}
.simulate-result.status-green {
    color: #198754;
    font-weight: 600;
}
.simulate-result.status-yellow {
    color: #856404;
    font-weight: 600;
}
.simulate-result.status-red {
    color: #dc3545;
    font-weight: 600;
}

.dashboard-alert.flash {
    animation: alert-flash 0.5s ease-in-out 1;
}

@keyframes alert-flash {
    0%, 100% {
        filter: none;
    }
    50% {
        filter: brightness(2.5);
    }
}

.alert-border-flash {
    animation: border-flash 1s linear infinite alternate;
}

@keyframes border-flash {
    from {
        box-shadow: 0 0 0 5px rgba(220, 20, 60, 0.9);
    }
    to {
        box-shadow: 0 0 0 5px rgba(220, 20, 60, 0.2);
    }
}


