:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --card-bg: #1e293b;
    --bg-control: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --accent-color: #38bdf8;
    --accent: #38bdf8;
    --input-bg: #0f1629;
    
    /* Light Colors */
    --light-red: #ef4444;
    --light-yellow: #f59e0b;
    --light-green: #10b981;
    --light-off: #27272a;
    
    /* Glow Effects */
    --glow-red: 0 0 15px #ef4444, 0 0 5px #ef4444;
    --glow-yellow: 0 0 15px #f59e0b, 0 0 5px #f59e0b;
    --glow-green: 0 0 15px #10b981, 0 0 5px #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Dashboard Header */
header {
    background-color: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-status {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.status-badge {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: var(--accent-color);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Dashboard Grid */
.dashboard-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    flex: 1;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 1400px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }
}

/* Left side: Map and Controls */
.main-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Junction Map Styling */
.junction-wrapper {
    position: relative;
    width: 600px;
    height: 600px;
    background-color: #0f172a;
    border-radius: 0.75rem;
    overflow: hidden;
    margin: 0 auto;
    border: 2px solid #334155;
}

.junction-map {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Roads layout */
.road-horizontal, .road-vertical {
    background-color: #1e293b;
    position: absolute;
}

.road-horizontal {
    width: 100%;
    height: 140px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 3px dashed #475569;
    border-bottom: 3px dashed #475569;
}

.road-vertical {
    height: 100%;
    width: 140px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 3px dashed #475569;
    border-right: 3px dashed #475569;
}

.intersection-center {
    position: absolute;
    width: 140px;
    height: 140px;
    background-color: #1e293b;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

/* Lane Markings */
.lane-line {
    position: absolute;
    background-color: #ff9f1c; /* Orange center lines */
}

.road-horizontal .lane-line {
    width: 100%;
    height: 3px;
    top: 50%;
    transform: translateY(-50%);
}

.road-vertical .lane-line {
    height: 100%;
    width: 3px;
    left: 50%;
    transform: translateX(-50%);
}

/* Stop lines */
.stop-line {
    position: absolute;
    background-color: #ffffff;
    z-index: 5;
}

.stop-line.lane-1 {
    width: 70px;
    height: 4px;
    left: calc(50% - 70px);
    top: calc(50% + 70px); /* Enters from bottom, stops before intersection */
}
.stop-line.lane-2 {
    width: 4px;
    height: 70px;
    left: calc(50% + 70px);
    top: 50%;
    transform: translateY(-100%);
}
.stop-line.lane-3 {
    width: 70px;
    height: 4px;
    left: 50%;
    top: calc(50% - 70px); /* Enters from top, stops before intersection */
}
.stop-line.lane-4 {
    width: 4px;
    height: 70px;
    left: calc(50% - 70px - 4px);
    top: 50%;
}

/* Pole points on map */
.map-pole {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: #ec4899; /* Pink pole indicator */
    border-radius: 50%;
    border: 2px solid white;
    z-index: 10;
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.6);
}

.map-pole.pole-1 { left: calc(50% - 7px); top: calc(50% - 90px); }
.map-pole.pole-2 { left: calc(50% + 90px); top: calc(50% - 7px); }
.map-pole.pole-3 { left: calc(50% - 7px); top: calc(50% + 90px); }
.map-pole.pole-4 { left: calc(50% - 90px); top: calc(50% - 7px); }

/* Control panel styles */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn {
    background-color: var(--accent-color);
    color: #0f172a;
    border: none;
    padding: 0.75rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-control);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--light-red);
    color: white;
}

.btn-wifi {
    background: linear-gradient(135deg, #6c63ff, #3b82f6);
    color: white;
    font-weight: 700;
}
.btn-wifi:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 9999px;
    background: var(--bg-control);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Pole Detail Inspector Side Panel - Cross Layout */
.pole-inspector {
    display: grid;
    grid-template-columns: 1.2fr 1.3fr 1.2fr;
    grid-template-rows: auto auto auto;
    gap: 0.75rem;
    align-items: center;
}

.pos-top {
    grid-column: 2;
    grid-row: 1;
}

.pos-left {
    grid-column: 1;
    grid-row: 2;
}

.pos-center {
    grid-column: 2;
    grid-row: 2;
    background-color: rgba(30, 41, 59, 0.9);
    border: 2px solid var(--accent-color);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.pos-right {
    grid-column: 3;
    grid-row: 2;
}

.pos-bottom {
    grid-column: 2;
    grid-row: 3;
}

.rot-180 .pole-layout-container {
    transform: rotate(180deg);
}

.rot-90 .pole-layout-container {
    transform: rotate(90deg);
    /* Prevent overflow when rectangular element rotates */
    margin: 1.5rem 0; 
}

.rot-anti-90 .pole-layout-container {
    transform: rotate(-90deg);
    /* Prevent overflow when rectangular element rotates */
    margin: 1.5rem 0; 
}

.pole-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pole-card-title {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
    text-align: center;
    position: relative;
    z-index: 10;
    background-color: var(--bg-card);
}

.pole-layout-container {
    background: #111827;
    border-radius: 0.5rem;
    padding: 0.75rem 0.5rem;
    position: relative;
    border: 1px solid #374151;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Road Representation in Detail Panel */
.pole-detail-centerline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #ff9f1c; /* Orange center line */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.pole-detail-physical-pole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background-color: #ec4899; /* Pink physical pole */
    border-radius: 50%;
    border: 2px solid white;
    z-index: 5;
    box-shadow: 0 0 6px rgba(236, 72, 153, 0.8);
}

/* Layout Grid for the Pole Board */
.pole-lights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1rem;
    row-gap: 0.5rem;
    width: 100%;
    position: relative;
    z-index: 2;
}

.assembly-side {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 230px;
}

.assembly-side.left {
    align-items: flex-end;
    padding-right: 0.1rem;
}

.assembly-side.right {
    align-items: flex-start;
    padding-left: 0.1rem;
}

/* Vertical and horizontal groups */
.vertical-signals-wrapper {
    display: flex;
    gap: 0.4rem;
}

.left .vertical-signals-wrapper {
    flex-direction: row;
}

.right .vertical-signals-wrapper {
    flex-direction: row-reverse;
}

.vertical-column {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.25rem;
    border-radius: 0.25rem;
    border: 1px solid #334155;
    align-items: center;
}

.horizontal-row {
    display: flex;
    gap: 0.15rem;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.25rem;
    border-radius: 0.25rem;
    border: 1px solid #334155;
    align-items: center;
    margin-top: 0.5rem;
    width: fit-content;
}

/* Light Indicators styles - Compact Size */
.light-unit {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--light-off);
    border: 1.5px solid #52525b;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.15);
    font-size: 0.65rem;
    font-weight: 700;
    transition: all 0.15s ease-in-out;
}

/* Shapes & Directions */
.light-unit.diamond {
    border-radius: 2px;
    transform: rotate(45deg);
}

.light-unit.diamond span {
    transform: rotate(-45deg);
    font-size: 0.45rem;
    font-weight: 900;
}

.light-unit.arrow-box {
    border-radius: 3px;
    background-color: rgba(39, 39, 42, 0.5);
    font-size: 0.55rem;
}


/* Light Active states */
.light-unit.red.active {
    background-color: var(--light-red);
    border-color: #f87171;
    color: white;
    box-shadow: var(--glow-red);
}

.light-unit.yellow.active {
    background-color: var(--light-yellow);
    border-color: #fbbf24;
    color: white;
    box-shadow: var(--glow-yellow);
}

.light-unit.green.active {
    background-color: var(--light-green);
    border-color: #34d399;
    color: white;
    box-shadow: var(--glow-green);
}

/* Cars and Animations */
.car {
    position: absolute;
    width: 14px;
    height: 24px;
    border-radius: 3px;
    background-color: var(--accent-color);
    z-index: 8;
    transition: transform 0.1s linear;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Pedestrian icons on map */
.pedestrian-node {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e2e8f0;
    z-index: 7;
}

/* Lane Labels */
.lane-label {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
    z-index: 1;
}

.lane-label.l1 { top: 25%; left: 42%; }
.lane-label.l2 { top: 40%; left: 75%; }
.lane-label.l3 { top: 70%; left: 55%; }
.lane-label.l4 { top: 55%; left: 20%; }

/* Admin Tab Navigation & Layout Styles */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 0.25rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--accent-color);
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tab-content {
    display: none;
    flex: 1;
}

.tab-content.active {
    display: block;
}

/* Designer Main Container Grid */
.designer-container {
    display: grid;
    grid-template-columns: 320px 380px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    height: calc(100vh - 75px);
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 1200px) {
    .designer-container {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }
}

.designer-panel {
    display: flex;
    height: 100%;
    min-height: 400px;
}

.flex-col {
    flex-direction: column;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.scrollable-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 0.25rem;
}

/* Custom Scrollbar */
.scrollable-list::-webkit-scrollbar {
    width: 6px;
}
.scrollable-list::-webkit-scrollbar-track {
    background: transparent;
}
.scrollable-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.scrollable-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Mode Item Cards */
.mode-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.mode-item:hover {
    border-color: var(--accent-color);
    background: rgba(15, 23, 42, 0.7);
}

.mode-item.active {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.08);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.1);
}

.mode-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    overflow: hidden;
}

.mode-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.mode-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.mode-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.mode-item:hover .mode-actions, .mode-item.active .mode-actions {
    opacity: 1;
}

/* Selection list/dropdown styles */
.select-input {
    background-color: var(--bg-control);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.select-input:focus {
    border-color: var(--accent-color);
}

/* Badge tags */
.badge {
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid rgba(236, 72, 153, 0.3);
    color: #f472b6;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Sizing Modifiers for Buttons */
.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 0.375rem;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 0.25rem;
}

.btn-icon {
    padding: 0.3rem;
    border-radius: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon.delete:hover {
    color: var(--light-red);
    background: rgba(239, 68, 68, 0.1);
}

/* Phase Items */
.phase-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.phase-item:hover {
    border-color: var(--accent-color);
}

.phase-item.active {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.08);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.1);
}

.phase-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.phase-index {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.15);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phase-name-input {
    background: transparent;
    border: none;
    border-bottom: 1px dashed transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.1rem 0;
    flex: 1;
    outline: none;
}

.phase-name-input:focus {
    border-bottom-color: var(--accent-color);
}

.phase-details-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.phase-duration-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.phase-duration-input {
    background: var(--bg-control);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.25rem;
    padding: 0.15rem 0.35rem;
    width: 45px;
    font-size: 0.8rem;
    text-align: center;
    outline: none;
}

.phase-duration-input:focus {
    border-color: var(--accent-color);
}

.phase-order-actions {
    display: flex;
    gap: 0.15rem;
    margin-left: auto;
}

/* Light Configurator Elements */
.pole-selector-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.pole-selector-bar .btn.active {
    background: #ec4899;
    color: white;
    border-color: #f472b6;
}

.preset-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.interactive-designer-view {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111827;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.light-unit.interactive {
    cursor: pointer;
}

.light-unit.interactive:hover {
    transform: scale(1.15);
    border-color: white;
    box-shadow: 0 0 5px rgba(255,255,255,0.4);
}

.light-unit.arrow-unit {
  border-radius: 3px;
  font-size: .65rem;
}
.asm-label {
  font-size: .5rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: .1rem;
}

/* ── Tab: designer active ────────────────────────────────────── */
#tab-designer { flex-direction: column; }
#tab-designer.active {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.designer-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 75px);
  overflow: hidden;
  background-color: #0b1329;
  width: 100%;
}

/* Toolbar */
.designer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #131f3b;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 10;
  flex-shrink: 0;
}

/* Timeline Editor Scrollable Grid */
.tl-editor {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Ruler */
.tl-ruler-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  position: sticky;
  top: 0;
  background: #0b1329;
  z-index: 5;
  padding: 0.25rem 0;
  border-bottom: 2px solid #1e293b;
}

.tl-label-col {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-right: 1rem;
  gap: 0.5rem;
}

.tl-ruler {
  flex: 1;
  height: 25px;
  position: relative;
  border-left: 1px solid #475569;
  border-right: 1px solid #475569;
}

.tl-tick {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  border-left: 1px solid #334155;
  height: 8px;
  padding-top: 10px;
  line-height: 1;
}

/* Lanes List */
.tl-lanes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.tl-lane {
  display: flex;
  align-items: center;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 0;
  transition: all 0.2s ease;
  cursor: grab;
}

.tl-lane:active {
  cursor: grabbing;
}

.tl-lane:hover {
  background: rgba(30, 41, 59, 0.65);
  border-color: var(--accent-color);
}

.tl-lane.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent-color);
  background: rgba(56, 189, 248, 0.08);
}

.tl-lane.drag-over {
  border-top: 2px solid var(--accent-color);
  box-shadow: 0 -4px 10px rgba(56, 189, 248, 0.15);
}

.tl-lane-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tl-lane-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-lane-del {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}

.tl-lane-del:hover {
  color: var(--light-red);
}

.tl-bars-col {
  flex: 1;
  padding-right: 1rem;
}

.tl-bars-wrap {
  display: flex;
  align-items: center;
  position: relative;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid #334155;
  border-radius: 0.375rem;
  height: 50px;
  padding: 3px;
  gap: 2px;
}

.tl-bar {
  height: 100%;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 0.5rem;
  transition: transform 0.1s, box-shadow 0.15s;
  overflow: hidden;
  user-select: none;
}

.tl-bar:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

.tl-bar.active {
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tl-bar.blank {
  background: rgba(51, 65, 85, 0.2);
  border: 1px dashed #475569;
}

.tl-bar.filler {
  background: repeating-linear-gradient(
    45deg,
    rgba(71, 85, 105, 0.15),
    rgba(71, 85, 105, 0.15) 10px,
    rgba(71, 85, 105, 0.05) 10px,
    rgba(71, 85, 105, 0.05) 20px
  );
  border: 1px dashed rgba(71, 85, 105, 0.3);
  cursor: default;
}
.tl-bar.filler:hover {
  transform: none;
  box-shadow: none;
}

.tl-bar-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.tl-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.tl-bar-dur {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.75;
}

.tl-add-seg-btn {
  background: var(--bg-control);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: auto;
}

.tl-add-seg-btn:hover {
  background: var(--accent-color);
  color: #0f172a;
  border-color: var(--accent-color);
  transform: scale(1.1);
}

.tl-add-track-row {
  margin-top: 1rem;
}

/* Popovers & Modal Modifiers */
.tl-popover {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  width: 320px;
  max-width: 90vw;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  z-index: 1005;
  color: var(--text-primary);
}

.pop-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 1020;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  outline: none;
  pointer-events: all;
}
.pop-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.pop-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  padding-right: 1.5rem;
}

.pop-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.pop-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.pop-field label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.pop-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pop-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 2px;
  gap: 2px;
  margin-bottom: 0.75rem;
}

.pop-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s;
}

.pop-tab.active {
  background: var(--bg-control);
  color: var(--text-primary);
}

.pop-seg-preview {
  padding: 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tl-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1004;
  cursor: default;
}

/* Misc overrides */
#tab-simulation.active { display: block; }
#tab-simulation .dashboard-container { max-height: calc(100vh - 80px); overflow-y: auto; }
#light-config-area::-webkit-scrollbar { width: 5px; }
#light-config-area::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.tl-lane-name-input {
  cursor: text;
}
.tl-bars-wrap, .tl-bar, .tl-lane-btn, .tl-lane-del {
  cursor: pointer;
}
.tl-lane-name-input:hover {
  border-bottom-color: var(--text-secondary) !important;
}
.tl-lane-name-input:focus {
  border-bottom-color: var(--accent-color) !important;
  background: rgba(15, 23, 42, 0.4);
}

.light-unit { cursor: pointer; transition: transform 0.1s ease; }

.light-unit:hover { transform: scale(1.1); }

/* ── Intersection Visualizer CSS ────────────────────────────── */
.intersection-view {
    position: relative;
    background-color: #0f172a !important; /* Dark asphalt */
    border: 2px dashed #334155 !important;
    overflow: hidden;
    display: block !important;
}
.lane-divider-v {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed #f59e0b;
    opacity: 0.6;
}
.lane-divider-h {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px dashed #f59e0b;
    opacity: 0.6;
}
.crosswalk {
    position: absolute;
    background: repeating-linear-gradient(
        90deg,
        #e2e8f0,
        #e2e8f0 4px,
        transparent 4px,
        transparent 8px
    );
    opacity: 0.8;
}
.crosswalk-top {
    top: 4px;
    left: 15%;
    right: 15%;
    height: 8px;
}
.crosswalk-bottom {
    bottom: 4px;
    left: 15%;
    right: 15%;
    height: 8px;
}
.crosswalk-left {
    left: 4px;
    top: 15%;
    bottom: 15%;
    width: 8px;
    background: repeating-linear-gradient(
        0deg,
        #e2e8f0,
        #e2e8f0 4px,
        transparent 4px,
        transparent 8px
    );
}
.crosswalk-right {
    right: 4px;
    top: 15%;
    bottom: 15%;
    width: 8px;
    background: repeating-linear-gradient(
        0deg,
        #e2e8f0,
        #e2e8f0 4px,
        transparent 4px,
        transparent 8px
    );
}
.intersection-box {
    position: absolute;
    left: 28%;
    top: 28%;
    width: 44%;
    height: 44%;
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 50%;
}

/* ── Plus-Shaped Road Intersection System ────────────────────── */
.pole-inspector {
    display: grid !important;
    grid-template-columns: 1.2fr 1.3fr 1.2fr !important;
    grid-template-rows: 1fr 1fr 1fr !important;
    gap: 0 !important; /* Eliminate gaps so roads touch */
    align-items: stretch !important;
    background-color: #020617 !important; /* Outside background */
    padding: 2rem !important;
    border-radius: 1.5rem !important;
    border: 1px solid #1e293b !important;
}

.pole-card {
    background-color: #0f172a !important; /* Asphalt road */
    border: none !important;
    border-left: 3px solid #475569 !important;  /* Road shoulder left */
    border-right: 3px solid #475569 !important; /* Road shoulder right */
    border-radius: 0 !important; /* straight road edges */
    padding: 1rem 0.5rem !important;
    margin: 0 !important;
    box-shadow: none !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

.pole-card-title {
    position: absolute !important;
    top: 6px !important;
    left: 8px !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    color: #475569 !important;
    z-index: 5 !important;
    border: none !important;
    padding: 0 !important;
}

.pole-detail-centerline {
    background-color: transparent !important;
    border-left: 2px dashed #f59e0b !important; /* Dashed yellow divider */
    width: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    opacity: 0.7 !important;
}

.intersection-view {
    background-color: #0f172a !important; /* Asphalt road center */
    border: none !important;
    border-radius: 0 !important;
    height: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
}

/* Ensure the layout container fits the full road width */
.pole-layout-container {
    background: transparent !important;
    border: none !important;
    padding: 0.5rem 0 !important;
    border-radius: 0 !important;
}

/* ════════════════════════════════════════════════════════
   6. MULTIUSER & MULTI-INTERSECTION ADDITIONS
   ════════════════════════════════════════════════════════ */

/* Login Container */
#login-container {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-main);
    z-index: 9999;
}

body.app-mode #login-container {
    display: none !important;
}

body.login-mode #app-container {
    display: none !important;
}

.login-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    width: 420px;
    max-width: 90%;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 3.5rem;
    display: inline-block;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.3));
}

.login-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.login-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.login-form .input-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.login-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-form input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

#login-submit {
    width: 100%;
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.85rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: all 0.2s;
}

#login-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.3);
}

.error-msg {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    padding: 0.65rem;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}

/* App Container Layout */
#app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar Navigation */
aside.sidebar {
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(15px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 1.5rem 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-bottom: 2rem;
}

.brand-icon {
    font-size: 1.8rem;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-color);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem;
}

.user-icon {
    font-size: 1.5rem;
}

.username-display {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.btn-logout {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Main Content Panel */
.main-content {
    padding: 2rem;
    overflow-y: auto;
    height: 100vh;
}

/* Tab Switching Views */
.tab-view {
    display: none;
}

.tab-view.active {
    display: block;
}

/* Mobile Header & Bottom Nav (Hidden on Desktop) */
.mobile-header, .mobile-nav {
    display: none;
}

/* Searchable Dropdown Styles */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.searchable-dropdown input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.searchable-dropdown input:focus {
    border-color: var(--accent);
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 0.4rem;
    max-height: 220px;
    overflow-y: auto;
    z-index: 101;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.dropdown-item {
    padding: 0.7rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-color);
}

.dropdown-item.selected {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-color);
    font-weight: 600;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Layout helpers */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.view-header {
    margin-bottom: 2rem;
}

.view-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
}

.view-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Modern Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    z-index: 999;
}

.modal-card {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.25rem 2rem;
    width: 440px;
    max-width: 92vw;
    z-index: 1000;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body .input-group {
    margin-bottom: 1.25rem;
}

.modal-body label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.modal-body input, .modal-body select {
    width: 100%;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* Inspector list simulation states */
.pole-states-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.pole-state-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.pole-state-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.pole-state-lights {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.dashboard-header-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.intersection-selector-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 280px;
}

.intersection-selector-section label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-summary {
    display: flex;
    gap: 0.75rem;
}

/* Mode assignment tags for cards */
.tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.tag-auto {
    background: rgba(16, 185, 129, 0.15);
    color: var(--light-green);
}

.tag-manual {
    background: rgba(245, 158, 11, 0.15);
    color: var(--light-yellow);
}

.tag-em {
    background: rgba(239, 68, 68, 0.15);
    color: var(--light-red);
}

/* User management roles */
.tag-role {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tag-role-admin {
    background: rgba(129, 140, 248, 0.15);
    color: #818cf8;
}

/* Action button badges */
.action-btn-group {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.action-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.action-btn.action-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Responsive Viewports */
@media (max-width: 1024px) {
    #app-container {
        grid-template-columns: 1fr;
        overflow-x: hidden;
    }
    aside.sidebar {
        display: none !important;
    }
    /* ── Mobile Header ─── */
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: rgba(15, 23, 42, 0.97);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border-color);
        padding: 0.6rem 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
        min-height: 54px;
    }
    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }
    .mobile-brand h2 {
        font-size: 1rem;
        font-weight: 800;
        background: linear-gradient(to right, #38bdf8, #818cf8);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    /* Language toggle — smaller on mobile */
    .mobile-lang-btn {
        padding: 0.3rem 0.55rem !important;
        font-size: 0.72rem !important;
        border-radius: 6px !important;
    }
    .mobile-logout {
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 1.2rem;
        cursor: pointer;
    }
    /* ── Main content — clear bottom nav ── */
    .main-content {
        padding: 0.75rem 0.75rem 5.5rem 0.75rem;
        height: auto;
        overflow-x: hidden;
    }
    /* ── Bottom nav ── */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 62px;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border-color);
        z-index: 999;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .mob-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0.3rem 0.15rem;
        flex: 1;
        text-decoration: none;
        min-width: 0;
        transition: color 0.15s;
    }
    .mob-icon {
        font-size: 1.2rem;
        margin-bottom: 0.12rem;
    }
    .mob-label {
        font-size: 0.58rem;
        font-weight: 600;
        white-space: nowrap;
    }
    .mob-nav-item.active {
        color: var(--accent-color);
    }
    /* ── Dashboard header panel ── */
    .dashboard-header-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        margin-bottom: 1rem;
    }
    .intersection-selector-section {
        min-width: 0;
        width: 100%;
    }
    .status-summary {
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .status-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
    }
    /* ── Cards ── */
    .card {
        padding: 0.9rem 0.85rem;
        border-radius: 0.75rem;
    }
    .card-title {
        font-size: 0.95rem;
        flex-wrap: wrap;
        gap: 0.4rem;
        row-gap: 0.4rem;
        margin-bottom: 0.6rem;
    }
    /* Card title inner button group — wrap on narrow screens */
    .card-title > div {
        flex-wrap: wrap;
        gap: 0.4rem !important;
    }
    /* ── Quick Controls: keep buttons on screen ── */
    .quick-controls-grid {
        gap: 0.5rem !important;
    }
    /* R1-R4 shift buttons: equal width, wrap if needed */
    .road-shift-btn {
        min-width: 0 !important;
        flex: 1 1 0 !important;
        padding: 0.65rem 0 !important;
        font-size: 0.95rem !important;
    }
    /* ── Controls grid ── */
    .controls-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    /* ── Modifier card ── */
    .modifier-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .modifier-input-group {
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    /* ── Pole states grid ── */
    .pole-states-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }
    /* ── Main panel spacing ── */
    .main-panel {
        gap: 0.85rem;
    }
    .dashboard-container {
        padding: 0;
        gap: 0.85rem;
    }
    /* ── Combinations list ── */
    #combinations-list-container {
        max-height: 220px !important;
    }
}

/* ── Extra small phones (≤ 480px) ── */
@media (max-width: 480px) {
    .mobile-brand h2 {
        font-size: 0.9rem;
    }
    .status-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.5rem;
    }
    .card {
        padding: 0.75rem 0.7rem;
        border-radius: 0.6rem;
    }
    .card-title {
        font-size: 0.88rem;
    }
    /* Pause + AllRed buttons — smaller on tiny phones */
    #btnQuickPause, #btnQuickAllRed {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.72rem !important;
    }
    .road-shift-btn {
        font-size: 0.88rem !important;
        padding: 0.55rem 0 !important;
    }
    .btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.88rem;
    }
    .mob-label {
        font-size: 0.55rem;
    }
    .mob-icon {
        font-size: 1.1rem;
    }
    .modifier-roads-row {
        gap: 0.75rem;
    }
    .road-btn {
        width: 38px;
        height: 38px;
        font-size: 0.88rem;
    }
    .searchable-dropdown input {
        font-size: 0.85rem;
        padding: 0.6rem 0.85rem;
    }
    .main-content {
        padding: 0.6rem 0.6rem 5.5rem 0.6rem;
    }
    .dashboard-header-panel {
        margin-bottom: 0.75rem;
    }
}

/* ── Mobile: Phase combination items ── */
@media (max-width: 1024px) {
    /* shift cycle label — truncate gracefully */
    [data-i18n="shift_cycle_label"] {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.78rem !important;
    }
    /* Combination items — full width on mobile */
    .comb-item {
        flex-direction: row;
        align-items: center;
        padding: 0.55rem 0.7rem !important;
    }
    /* Bottom nav active indicator pill */
    .mob-nav-item.active .mob-icon {
        position: relative;
    }
    .mob-nav-item.active::before {
        content: '';
        display: block;
        width: 24px;
        height: 3px;
        background: var(--accent-color);
        border-radius: 9999px;
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }
    .mob-nav-item {
        position: relative;
    }
    /* View-header in admin pages */
    .view-header h2 {
        font-size: 1.2rem;
    }
    .view-header p {
        font-size: 0.8rem;
    }
    /* Tables — allow horizontal scroll */
    .data-table th,
    .data-table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.8rem;
    }
    /* Pole inspector grid on small screens */
    .pole-inspector {
        gap: 0.4rem;
    }
    /* Speed slider label */
    #sim-elapsed {
        font-size: 1rem !important;
    }
}
/* Language Toggle Button styling */

.lang-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    outline: none;
}
.lang-toggle-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.login-lang-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
}

/* Sidebar toggle controls */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 2rem;
}

.sidebar-close-trigger {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    outline: none;
}

.sidebar-close-trigger:hover {
    color: var(--accent-color);
}

.sidebar-toggle-btn {
    display: none;
}

#app-container.sidebar-collapsed .sidebar-toggle-btn {
    display: flex;
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 100;
}

#app-container.sidebar-collapsed .sidebar-toggle-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Sidebar transition updates — Desktop only */
@media (min-width: 1025px) {
    #app-container {
        display: grid;
        grid-template-columns: 260px 1fr;
        min-height: 100vh;
        transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    aside.sidebar {
        background-color: rgba(15, 23, 42, 0.85);
        backdrop-filter: blur(15px);
        border-right: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        height: 100vh;
        position: sticky;
        top: 0;
        padding: 1.5rem 1rem;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #app-container.sidebar-collapsed {
        grid-template-columns: 0px 1fr;
    }

    #app-container.sidebar-collapsed aside.sidebar {
        transform: translateX(-260px);
        width: 0;
        padding: 1.5rem 0;
        border-right: none;
        overflow: hidden;
    }

    #app-container.sidebar-collapsed .main-content {
        padding-left: 5rem; /* Make room for floating toggle button */
    }
}

@media (max-width: 1024px) {
    .desktop-only-toggle {
        display: none !important;
    }
}

/* Cycle Timing Modifier Card Styles */
.modifier-card {
    border: 1.5px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    background-color: var(--card-bg);
}

.modifier-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.modifier-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
}

.modifier-cycle-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}

.modifier-cycle-input {
    width: 60px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color);
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
}
.modifier-cycle-input::-webkit-outer-spin-button,
.modifier-cycle-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.modifier-sec-suffix {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 0.15rem;
}

.modifier-roads-row {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 0.75rem 0 1.25rem;
}

.road-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
}

.road-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.road-btn.active {
    background-color: #fef1b8;
    color: #333333;
    border-color: #fdd835;
    box-shadow: 0 0 8px rgba(253, 216, 53, 0.4);
}

.modifier-settings-panel {
    background-color: #fef1b8;
    border-radius: 6px;
    padding: 1.25rem;
    position: relative;
    border: 1px solid #fdd835;
}

.modifier-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modifier-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #333333;
    width: 70px;
}

.modifier-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modifier-value-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.modifier-time-input {
    width: 45px;
    background: transparent;
    border: none;
    outline: none;
    color: #333333;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
}
.modifier-time-input::-webkit-outer-spin-button,
.modifier-time-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.modifier-step-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #b8a666;
    background: #fdf2c2;
    color: #333333;
    font-size: 1.25rem;
    line-height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    outline: none;
    padding: 0;
}

.modifier-step-btn:hover {
    background: #f9e294;
}

.modifier-step-input {
    width: 38px;
    border: 1px solid #b8a666;
    background: #ffffff;
    color: #333333;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    border-radius: 4px;
    padding: 0.2rem 0;
    outline: none;
}

.modifier-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* Quick Controls Styling */
.btn-pending-shift {
    background-color: var(--accent-color) !important;
    color: #0f172a !important;
    animation: pulse-highlight 1.5s infinite;
    border: 1px solid var(--accent-color) !important;
}

@keyframes pulse-highlight {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(56, 189, 248, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}

.road-shift-btn {
    flex: 1;
    padding: 0.75rem;
    font-weight: bold;
    font-size: 1.1rem;
    border-radius: 8px;
}

/* Phase Combinations Overrides */
.comb-item:hover {
    border-color: var(--accent-color) !important;
    background: rgba(15, 23, 42, 0.5) !important;
}

.active-comb {
    border-color: var(--light-green) !important;
    background: rgba(16, 185, 129, 0.08) !important;
}

.pending-comb {
    border-color: var(--light-yellow) !important;
    background: rgba(245, 158, 11, 0.08) !important;
}

.comb-select-btn:hover {
    background-color: var(--accent-color) !important;
    color: #0f172a !important;
    border-color: var(--accent-color) !important;
}

.active-btn {
    background-color: var(--light-green) !important;
    color: white !important;
    border-color: var(--light-green) !important;
}

.pending-btn {
    background-color: var(--light-yellow) !important;
    color: #0f172a !important;
    border-color: var(--light-yellow) !important;
}\n