/* ============================================
   ITMS Admin Dashboard Styles
   Matching React Native App Theme
   ============================================ */

:root {
    /* Light Theme Colors (matching app) */
    --bg-primary: #F0F4F8;
    --bg-card: #FFFFFF;
    --text-primary: #102A43;
    --text-secondary: #486581;
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --accent: #3B82F6;
    --border: #D9E2EC;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --shadow: rgba(0, 0, 0, 0.08);
    
    /* Fonts (matching app) */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
}

/* Prevent scrolling on dashboard screen */
#dashboardScreen {
    overflow: hidden;
    height: 100vh;
}

/* Allow scrolling on login screen */
#loginScreen {
    overflow: auto;
}

/* Touch-friendly scrolling */
* {
    -webkit-overflow-scrolling: touch;
}

/* Better touch targets */
button,
a,
input,
select,
.mode-card,
.junction-card,
.tab-btn {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
    touch-action: manipulation;
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-container {
    min-height: 100vh;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.logo-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 12px var(--shadow);
    overflow: hidden;
}

.logo-circle img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--text-primary);
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.subtitle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.subtitle-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

.welcome-text {
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}

.input-group {
    margin-bottom: 1rem;
}

.input-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    margin-left: 0.25rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #F9FAFB;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.625rem 0.875rem;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.icon-box {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.input-wrapper:focus-within .icon-box {
    background: var(--primary);
    color: white;
}

.input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
    margin-left: 0.75rem;
}

.input-wrapper input::placeholder {
    color: #adb5bd;
}

.eye-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.footer {
    margin-top: 1.25rem;
    text-align: center;
}

.version-text {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 73px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-small {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-small img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.navbar-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-logout {
    background: var(--error);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.dashboard-container {
    display: flex;
    height: 100vh;
    padding-top: 73px;
    overflow: hidden;
    position: relative;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    height: calc(100vh - 73px);
    position: fixed;
    left: 0;
    top: 73px;
    z-index: 50;
}

.tab-btn {
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.tab-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.tab-btn svg {
    flex-shrink: 0;
}

/* ============================================
   CONTENT AREA
   ============================================ */

.content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - 73px);
    background: var(--bg-primary);
    width: calc(100% - 280px);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.content-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.content-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   TABLE STYLES
   ============================================ */

.table-container {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table thead {
    background: var(--bg-primary);
}

.data-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.data-table td {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--bg-primary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.inactive {
    background: rgba(107, 114, 128, 0.1);
    color: #6B7280;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon.delete:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.loading-cell {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-secondary);
}

.loading-cell .spinner {
    margin: 0 auto 1rem;
}

/* ============================================
   FORM STYLES
   ============================================ */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.form-section {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.data-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9375rem;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ============================================
   JUNCTIONS LIST
   ============================================ */

.junctions-list-section {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.junctions-grid {
    display: grid;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

.junction-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.3s ease;
}

.junction-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--shadow);
}

.junction-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.junction-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.junction-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
}

.junction-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.junction-detail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.junction-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ============================================
   MODE CONTROL
   ============================================ */

.control-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.junction-selector-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.selector-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.junction-select {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.3s ease;
}

.junction-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 1.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mode-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow);
}

.mode-card.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(59, 130, 246, 0.05));
}

.mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.mode-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.mode-card.active .mode-icon {
    background: var(--primary);
    color: white;
}

.mode-status {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.mode-card.active .mode-status {
    color: var(--success);
}

.mode-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.mode-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: var(--bg-card);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-form {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn-secondary {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--border);
}

.modal-actions .btn-primary {
    flex: 1;
    width: auto;
}

/* Lane Selector Grid */
.lane-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.lane-checkbox {
    cursor: pointer;
}

.lane-checkbox input[type="checkbox"] {
    display: none;
}

.lane-checkbox-card {
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
}

.lane-checkbox:hover .lane-checkbox-card {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.lane-checkbox input[type="checkbox"]:checked + .lane-checkbox-card {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(59, 130, 246, 0.1));
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.lane-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.lane-checkbox input[type="checkbox"]:checked + .lane-checkbox-card .lane-icon {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.lane-checkbox-card span {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Confirmation Modal */
.confirm-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.confirm-icon svg {
    color: var(--primary);
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 320px;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 2000;
    border-left: 4px solid var(--primary);
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.info {
    border-left-color: var(--primary);
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.toast.error .toast-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.toast.warning .toast-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.toast.info .toast-icon {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.toast-icon::before {
    content: '✓';
    font-weight: bold;
}

.toast.error .toast-icon::before {
    content: '✕';
}

.toast.warning .toast-icon::before {
    content: '!';
}

.toast.info .toast-icon::before {
    content: 'ℹ';
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    gap: 1rem;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet and below */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .modes-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    
    .navbar {
        padding: 1rem 1.5rem;
    }
}

/* Mobile landscape and below */
@media (max-width: 768px) {
    /* Allow body scrolling on mobile */
    body {
        overflow: auto;
        height: auto;
    }
    
    #dashboardScreen {
        overflow: auto;
        height: auto;
    }
    
    /* Dashboard Layout */
    .dashboard-container {
        flex-direction: column;
        padding-top: 73px;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    
    /* Sidebar becomes horizontal */
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
        gap: 0.5rem;
        -webkit-overflow-scrolling: touch;
        position: relative;
        top: 0;
        left: 0;
        z-index: 40;
    }
    
    .tab-btn {
        white-space: nowrap;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
        min-width: fit-content;
    }
    
    .tab-btn span {
        display: inline;
    }
    
    /* Content Area */
    .content {
        padding: 1.5rem 1rem;
        margin-left: 0;
        height: auto;
        min-height: calc(100vh - 73px - 60px);
        overflow-y: visible;
        width: 100%;
    }
    
    /* Navbar */
    .navbar {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
    }
    
    .navbar-left {
        gap: 0.75rem;
    }
    
    .navbar-title {
        font-size: 1rem;
    }
    
    .navbar-right {
        gap: 0.75rem;
    }
    
    .user-details {
        display: none;
    }
    
    .btn-logout {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .btn-logout span {
        display: none;
    }
    
    /* Content Header */
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .content-title {
        font-size: 1.5rem;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-section {
        padding: 1.5rem;
    }
    
    /* Table */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Mode Cards */
    .modes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .mode-card {
        padding: 1.5rem;
    }
    
    /* Junction Cards */
    .junction-card {
        padding: 1rem;
    }
    
    /* Modal */
    .modal-container {
        width: 92%;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 1.25rem 1.5rem;
    }
    
    .modal-form {
        padding: 1.5rem;
    }
    
    .modal-title {
        font-size: 1.125rem;
    }
    
    .lane-selector-grid {
        grid-template-columns: 1fr;
    }
    
    /* Toast */
    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        min-width: auto;
        padding: 0.875rem 1.25rem;
    }
    
    .toast-content {
        font-size: 0.875rem;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    /* Login Screen */
    .login-container {
        padding: 1rem;
    }
    
    .login-card {
        padding: 2rem 1.25rem;
    }
    
    .title {
        font-size: 1.875rem;
    }
    
    .subtitle-text {
        font-size: 0.875rem;
    }
    
    .logo-circle {
        width: 80px;
        height: 80px;
    }
    
    .logo-circle img {
        width: 50px;
        height: 50px;
    }
    
    .form-card {
        padding: 1.25rem;
    }
    
    .welcome-text {
        font-size: 1.125rem;
    }
    
    .input-wrapper {
        padding: 0.625rem 0.875rem;
    }
    
    .input-wrapper input {
        font-size: 0.9375rem;
    }
    
    .btn-primary {
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
    }
    
    /* Dashboard */
    .navbar {
        padding: 0.75rem 0.875rem;
    }
    
    .logo-small {
        width: 32px;
        height: 32px;
    }
    
    .logo-small img {
        width: 28px;
        height: 28px;
    }
    
    .navbar-title {
        font-size: 0.9375rem;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    .btn-logout {
        padding: 0.5rem;
        border-radius: 8px;
    }
    
    /* Sidebar */
    .sidebar {
        padding: 0.75rem;
        gap: 0.375rem;
    }
    
    .tab-btn {
        padding: 0.75rem 0.875rem;
        font-size: 0.8125rem;
        gap: 0.625rem;
    }
    
    .tab-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Content */
    .content {
        padding: 1rem 0.875rem;
    }
    
    .content-title {
        font-size: 1.375rem;
    }
    
    .content-subtitle {
        font-size: 0.8125rem;
    }
    
    /* Forms */
    .form-section {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .section-title {
        font-size: 1.125rem;
        margin-bottom: 1.25rem;
    }
    
    .data-form {
        gap: 1rem;
    }
    
    .form-group label {
        font-size: 0.8125rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Table */
    .data-table {
        min-width: 550px;
    }
    
    .data-table th {
        padding: 0.75rem 0.875rem;
        font-size: 0.6875rem;
    }
    
    .data-table td {
        padding: 1rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
    }
    
    .btn-icon svg {
        width: 16px;
        height: 16px;
    }
    
    /* Mode Cards */
    .mode-card {
        padding: 1.25rem;
        border-radius: 16px;
    }
    
    .mode-icon {
        width: 42px;
        height: 42px;
    }
    
    .mode-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .mode-title {
        font-size: 1.125rem;
    }
    
    .mode-description {
        font-size: 0.8125rem;
    }
    
    .mode-status {
        font-size: 0.6875rem;
    }
    
    /* Junction Cards */
    .junction-card {
        padding: 0.875rem;
    }
    
    .junction-name {
        font-size: 0.9375rem;
    }
    
    .junction-code {
        font-size: 0.6875rem;
        padding: 0.1875rem 0.5rem;
    }
    
    .junction-details {
        font-size: 0.8125rem;
    }
    
    /* Junction Selector */
    .junction-selector-card {
        padding: 1.25rem;
    }
    
    .junction-select {
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
    }
    
    /* Modal */
    .modal-container {
        width: 95%;
        max-height: 90vh;
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 1rem 1.25rem;
    }
    
    .modal-title {
        font-size: 1rem;
    }
    
    .modal-form {
        padding: 1.25rem;
        gap: 1rem;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn-secondary,
    .modal-actions .btn-primary {
        width: 100%;
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }
    
    /* Lane Selector */
    .lane-selector-grid {
        gap: 0.75rem;
    }
    
    .lane-checkbox-card {
        padding: 1.25rem;
    }
    
    .lane-icon {
        width: 42px;
        height: 42px;
        font-size: 1.125rem;
    }
    
    .lane-checkbox-card span {
        font-size: 0.8125rem;
    }
    
    /* Toast */
    .toast {
        min-width: auto;
        padding: 0.75rem 1rem;
        border-radius: 10px;
    }
    
    .toast-icon {
        width: 20px;
        height: 20px;
        font-size: 0.75rem;
    }
    
    .toast-title {
        font-size: 0.875rem;
    }
    
    .toast-message {
        font-size: 0.8125rem;
    }
    
    /* Spinner */
    .spinner {
        width: 32px;
        height: 32px;
        border-width: 2px;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .login-card {
        padding: 1.5rem 1rem;
    }
    
    .title {
        font-size: 1.625rem;
    }
    
    .navbar-title {
        font-size: 0.875rem;
    }
    
    .content {
        padding: 0.875rem 0.75rem;
    }
    
    .form-section {
        padding: 1rem;
    }
    
    .mode-card {
        padding: 1rem;
    }
    
    .modal-form {
        padding: 1rem;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
    display: none !important;
}
