body {
    background-color: #f4f6f9;
}

.card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    border: none;
}

.card-header {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ── Navbar tab pills ──────────────────────────────────────────── */

/* Prevent any container from overflowing viewport */
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

.nav-pills-navbar .nav-link {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    border-radius: 4px;
}

.nav-pills-navbar .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.nav-pills-navbar .nav-link:hover:not(.active) {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

/* ── Tab content — DRM fills viewport ──────────────────────────── */

#tab-drm {
    background: #1a1d21;
    min-height: calc(100vh - 42px);
}

/* Camera grid — 2 rows of 10 + depth camera to the right */
.cam-grid-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cam-rows {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cam-row {
    display: flex;
    gap: 2px;
}

.cam-dot {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background-color: #6c757d;
}

.cam-dot.active {
    background-color: #0d6efd;
}

.cam-dot:not(.depth):hover {
    opacity: 0.75;
    transform: scale(1.1);
    transition: all 0.15s;
}

.cam-dot.depth {
    width: 42px;
    height: 58px;
    font-size: 0.6rem;
    background-color: #6c757d;
    border: 2px solid #0d6efd;
}

.cam-dot.depth.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* All ON / All OFF buttons inside camera grid */
.cam-bulk-btns {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    margin-left: 12px;
}

.cam-bulk-btn {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 4px 8px;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    background: #fff;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
}

.cam-bulk-btn:hover {
    background: #e9ecef;
}

.cam-bulk-btn.on {
    background: #198754;
    border-color: #198754;
    color: #fff;
}

.cam-bulk-btn.off {
    background: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

/* Health indicators */
.health-item {
    font-size: 0.82rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f8f9fa;
}

.health-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    background-color: #6c757d;
}

.health-dot.ok       { background-color: #198754; }
.health-dot.warning  { background-color: #ffc107; }
.health-dot.critical { background-color: #dc3545; }

/* Map */
#map {
    border-bottom: 1px solid #dee2e6;
}

/* Export form — wrap on narrow screens */
.card-body .row.g-3 {
    flex-wrap: wrap !important;
}

/* Export files list */
.export-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
    min-width: 0;
}

.export-file-item > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    margin-right: 8px;
}

.export-file-item:last-child {
    border-bottom: none;
}

/* ═══════════════════════════════════════════════════════════════════
   DRM Monitor styles — scoped to .drm-wrapper
   ═══════════════════════════════════════════════════════════════════ */

.drm-wrapper {
    background: #1a1d21;
    color: #e0e0e0;
}

.drm-wrapper .card {
    background: #22262a;
    border: 1px solid #333;
}

.drm-wrapper .card-header {
    border-bottom: 1px solid #333;
}

.drm-wrapper .text-muted {
    color: #8a9199 !important;
}

.drm-card {
    border-radius: 6px;
}

/* Main content fills viewport */
.drm-main {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 42px);
    overflow: hidden;
}

.drm-main-row {
    flex: 1;
    min-height: 0;
    flex-wrap: nowrap !important;
}

.drm-main-row > div {
    min-height: 0;
    max-height: 100%;
}

.drm-main-row .drm-card {
    min-height: 0;
    overflow: hidden;
}

/* Context labels */
.drm-label {
    font-size: 0.8rem;
    color: #8a9199;
    min-width: 60px;
}

/* ── CPU stacked bar ────────────────────────────────────────────── */

.cpu-stacked-bar {
    display: flex;
    height: 22px;
    border-radius: 4px;
    overflow: hidden;
    background: #3a3f44;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.cpu-segment {
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.cpu-free {
    background: #3a3f44;
}

/* CPU legend */
.cpu-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    white-space: nowrap;
    color: #adb5bd;
}

.cpu-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

/* ── Process table ──────────────────────────────────────────────── */

.drm-proc-table {
    font-size: 0.82rem;
    margin: 0;
    color: #e0e0e0;
}

.drm-proc-table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8a9199;
    border-bottom: 1px solid #333;
    padding: 4px 8px;
    background: #22262a;
    overflow: hidden;
    white-space: nowrap;
}

.drm-proc-table tbody tr {
    transition: background 0.2s;
}

.drm-proc-table tbody tr:hover {
    background: #2a2f34 !important;
}

.drm-proc-table td {
    padding: 5px 8px;
    vertical-align: middle;
    border-bottom: 1px solid #2a2f34;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Process row — colored left border */
.proc-row {
    border-left: 4px solid #555;
    transition: opacity 0.5s ease, border-left-color 0.3s ease, background 0.5s ease;
}

.proc-row-frozen {
    opacity: 0.45;
}

/* Process color dot */
.proc-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}

.proc-dot-active {
    animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 3px currentColor; }
    50%      { opacity: 0.5; box-shadow: 0 0 6px currentColor; }
}

/* ── Process table divider ─────────────────────────────────────── */

.proc-divider td {
    padding: 2px 8px !important;
    border-bottom: none !important;
}

.proc-divider-line {
    border-top: 1px solid #495057;
    position: relative;
    margin: 2px 0;
}

.proc-divider-label {
    position: absolute;
    top: -8px;
    right: 12px;
    background: #22262a;
    padding: 0 8px;
    font-size: 0.65rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Dynamic CPU/RAM bars ──────────────────────────────────────── */

.proc-bar-wrap {
    position: relative;
    height: 24px;
    min-width: 78px;
    border-radius: 3px;
    overflow: hidden;
}

.proc-bar-bg {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    background: #2a2f34;
    border-radius: 3px;
}

.proc-bar-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.85;
}

.proc-bar-mem {
    opacity: 0.75;
}

.proc-bar-text {
    position: absolute;
    right: 6px;
    top: 0;
    line-height: 24px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #e0e0e0;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ── Priority badges ────────────────────────────────────────────── */

.prio-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.prio-frozen {
    background: #495057;
    color: #adb5bd;
    text-decoration: line-through;
}

.prio-idle {
    background: #495057;
    color: #adb5bd;
}

.prio-bg {
    background: #1a4a5c;
    color: #5bc0de;
}

.prio-low {
    background: #1a4a5c;
    color: #5bc0de;
}

.prio-medium {
    background: #1a3a6e;
    color: #6ea8fe;
}

.prio-high {
    background: #664d03;
    color: #ffda6a;
}

.prio-critical {
    background: #58151c;
    color: #ea868f;
    animation: prio-pulse 1.5s ease-in-out infinite;
}

.prio-always-on {
    background: #0a3069;
    color: #6ea8fe;
    border: 1px solid #6ea8fe40;
}

.prio-system {
    background: #495057;
    color: #dee2e6;
}

@keyframes prio-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; background: #7c1d24; }
}

/* ── Scenario buttons ───────────────────────────────────────────── */

.drm-wrapper .scenario-btn {
    text-align: left;
    padding: 4px 12px;
    border-width: 2px;
}

.drm-wrapper .scenario-btn.active {
    font-weight: bold;
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.4);
}

.drm-scenario-active {
    color: #6ea8fe;
    font-weight: 700;
}

/* ── Event log ──────────────────────────────────────────────────── */

.drm-log-container {
    overflow-y: auto;
    min-height: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
}

.drm-log-entry {
    padding: 2px 10px;
    border-bottom: 1px solid #2a2f34;
    border-left: 3px solid transparent;
}

.drm-log-entry:nth-child(odd) {
    background: #252a2e;
}

.drm-log-time {
    color: #6c757d;
    margin-right: 6px;
}

.drm-log-entry.log-incident {
    border-left-color: #dc3545;
    color: #ea868f;
}

.drm-log-entry.log-resolve {
    border-left-color: #198754;
    color: #75b798;
}

.drm-log-entry.log-stop {
    border-left-color: #fd7e14;
}

.drm-log-entry.log-move {
    border-left-color: #0d6efd;
}

.drm-log-entry.log-brake {
    border-left-color: #ffc107;
    color: #ffda6a;
}

.drm-log-entry.log-priority {
    border-left-color: #6f42c1;
    color: #a98eda;
}

/* ── Animations ─────────────────────────────────────────────────── */

.drm-pulse {
    animation: drm-pulse-anim 1s ease-in-out infinite;
}

@keyframes drm-pulse-anim {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 8px 2px rgba(220, 53, 69, 0.6); }
}

.drm-log-new {
    animation: log-slide-in 0.3s ease-out;
}

@keyframes log-slide-in {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.proc-row-flash {
    animation: proc-flash 0.8s ease-out;
}

@keyframes proc-flash {
    0%   { background: rgba(13, 110, 253, 0.35) !important; }
    100% { background: transparent !important; }
}
