/* ============================================================================
   Driver RT Dashboard - Main Styles
   ============================================================================ */

:root {
    /* Colors */
    --primary: #e94560;
    --primary-dark: #d63850;
    --primary-light: #ff6b85;
    --secondary: #0f3460;
    --secondary-dark: #0a2545;
    --secondary-light: #16213e;

    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --info: #3b82f6;

    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --bg-light: #f3f4f6;
    --bg-white: #ffffff;

    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;

    --border-color: #e5e7eb;
    --border-dark: #374151;

    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 70px;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

/* ============================================================================
   Animations
   ============================================================================ */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   Reset & Base Styles
   ============================================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-light);
    overflow-x: hidden;
}

/* ============================================================================
   Login Screen
   ============================================================================ */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--secondary) 50%, var(--secondary-dark) 100%);
    padding: var(--spacing-lg);
}

.login-container {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    padding: var(--spacing-xl);
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-header .logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-lg);
    box-shadow: 0 10px 40px rgba(233, 69, 96, 0.3);
}

.login-header .logo svg {
    width: 45px;
    height: 45px;
    fill: var(--text-white);
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.login-header .tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-form {
    margin-top: var(--spacing-xl);
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: var(--transition-fast);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    margin-right: var(--spacing-sm);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.error-message {
    background: #fee2e2;
    color: var(--danger);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    font-size: 0.9rem;
    border: 1px solid #fecaca;
}

.login-footer {
    margin-top: var(--spacing-lg);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-footer code {
    background: var(--bg-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
}

/* ============================================================================
   Dashboard App Layout
   ============================================================================ */

.dashboard-app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--secondary);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-small svg {
    width: 24px;
    height: 24px;
    fill: var(--text-white);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-md) 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0.75rem var(--spacing-lg);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition-fast);
    position: relative;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-white);
}

.nav-item.active {
    background: rgba(233, 69, 96, 0.15);
    color: var(--primary-light);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.nav-separator {
    height: 1px;
    background: var(--border-dark);
    margin: var(--spacing-md) var(--spacing-lg);
}

.nav-section-title {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
}

.badge {
    background: var(--primary);
    color: var(--text-white);
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    margin-left: auto;
}

.sidebar-brand {
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-brand svg {
    flex-shrink: 0;
}

.sidebar-sync {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--spacing-md) var(--spacing-lg);
    background: rgba(0, 0, 0, 0.15);
}

.sync-status-loading {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.sync-status-content {
    font-size: 0.85rem;
}

.sync-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.sync-status-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
}

.sync-status-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.sync-status-time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.sync-now-btn {
    background: transparent;
    border: none;
    padding: 0.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.6);
}

.sync-now-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.sync-now-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sync-now-btn svg {
    width: 16px;
    height: 16px;
}

.sync-now-btn.syncing svg {
    animation: spin 1s linear infinite;
}

.sync-now-btn.sync-success {
    color: #4ade80;
}

.sync-now-btn.sync-error {
    color: #ef4444;
}

.sync-status-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: rgba(255, 255, 255, 0.8);
}

.sync-status-info svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sync-status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sync-status-badge.success {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.sync-status-badge.error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.sync-status-badge.running {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.sync-stats {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.sync-stat {
    display: flex;
    flex-direction: column;
}

.sync-stat-value {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
}

.sync-stat-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: auto;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid var(--border-dark);
    padding: var(--spacing-lg);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    width: 100%;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.user-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.btn-logout {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-logout svg {
    width: 18px;
    height: 18px;
    fill: var(--text-white);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-logout-full {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    transition: var(--transition-fast);
    color: var(--text-white);
    text-decoration: none;
    font-size: 0.85rem;
}

.btn-logout-full svg {
    width: 18px;
    height: 18px;
    fill: var(--text-white);
}

.btn-logout-full:hover {
    background: rgba(255, 255, 255, 0.15);
}

.user-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-user-action {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    color: var(--text-white);
    text-decoration: none;
}

.btn-user-action svg {
    fill: var(--text-white);
}

.btn-user-action:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-lg) var(--spacing-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.page-actions {
    display: flex;
    gap: var(--spacing-md);
}

.page-content {
    flex: 1;
    padding: var(--spacing-xl);
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-white);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.3);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

.btn-danger {
    background: var(--danger);
    color: var(--text-white);
}

.btn-success {
    background: var(--success);
    color: var(--text-white);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--text-white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   Loading State
   ============================================================================ */

.loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

/* ============================================================================
   Dashboard Components
   ============================================================================ */

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

/* 5-column grid for trip statuses */
.stats-grid-5 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* 2-column grid for secondary stats */
.stats-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    gap: var(--spacing-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

.stat-content {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--spacing-lg);
}

.card-body.no-padding {
    padding: 0;
}

/* Clickable stat cards */
.stat-card-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.stat-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card-highlight {
    border: 2px solid #f59e0b;
}

.stat-desc {
    font-size: 0.8rem;
    margin-top: 4px;
    color: var(--text-secondary);
}

/* Secondary stat cards */
.stat-card-secondary {
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-card-alert {
    border-left: 3px solid #ef4444;
}

.stat-icon-sm {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-sm svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.stat-change {
    font-size: 0.85rem;
    margin-top: 4px;
    color: var(--text-secondary);
}

.stat-updating {
    animation: pulse 0.3s ease;
}

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

/* Quick Actions Card */
.quick-actions-card {
    grid-column: 1 / -1;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.quick-action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quick-action-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.quick-action-text {
    flex: 1;
}

.quick-action-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.quick-action-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}

.activity-item:hover {
    background: var(--bg-light);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.activity-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Trips List */
.trips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trip-item {
    display: block;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.trip-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateX(2px);
}

.trip-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.trip-number {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.badge-sm {
    font-size: 0.75rem;
    padding: 3px 8px;
}

.trip-route {
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.trip-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.trip-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.trip-meta-item svg {
    fill: currentColor;
    opacity: 0.6;
}

.trip-driver,
.trip-carrier {
    display: inline-block;
}

.trip-status {
    flex-shrink: 0;
    margin-left: 12px;
}

/* Health Grid */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.health-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.health-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.health-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-indicator.health-ok {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.health-indicator.health-warning {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.health-indicator.health-error {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.health-text {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.loading-sm {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================================
   Tables
   ============================================================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background: rgba(233, 69, 96, 0.02);
}

/* Trip row with missed stops - light red background */
.data-table tbody tr.has-missed-stops {
    background: rgba(254, 226, 226, 0.3);
}

.data-table tbody tr.has-missed-stops:hover {
    background: rgba(254, 226, 226, 0.5);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================================
   Forms & Inputs
   ============================================================================ */

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.toolbar-filters {
    display: flex;
    gap: var(--spacing-md);
    flex: 1;
    flex-wrap: wrap;
}

.toolbar-actions {
    display: flex;
    gap: var(--spacing-md);
}

.search-input,
.filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    transition: var(--transition-fast);
    font-family: inherit;
}

.search-input {
    min-width: 250px;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

.filter-select {
    min-width: 150px;
    cursor: pointer;
}

/* ============================================================================
   Badges & Status
   ============================================================================ */

.status-planned {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.status-scheduled {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.status-in-transit {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.status-completed {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-cancelled {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ============================================================================
   Lists
   ============================================================================ */

.trips-list,
.activity-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.trip-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    background: var(--bg-light);
    transition: var(--transition-fast);
}

.trip-item:hover {
    background: #e5e7eb;
}

.trip-info {
    flex: 1;
}

.trip-number {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.trip-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.trip-badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
}

.activity-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.activity-update {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.activity-create {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.activity-checkin {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.activity-content {
    flex: 1;
}

.activity-text {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.activity-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============================================================================
   Empty States
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.error-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--danger);
}

.loading-sm {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition-normal);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-filters,
    .toolbar-actions {
        width: 100%;
    }

    .search-input,
    .filter-select {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   TRIP MODAL STYLES
   ======================================== */

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

/* Modal content container */
.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.trip-modal-content {
    max-width: 1400px;
}

/* Modal header */
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    gap: 15px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2937;
    flex: 1;
    min-width: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

/* Modal body */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Trip info section */
.trip-info-section {
    margin-bottom: 24px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.trip-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
}

.info-item div {
    font-size: 0.95rem;
    color: #1f2937;
}

/* Stops section */
.stops-section {
    margin-top: 24px;
}

.stops-section h3 {
    font-size: 1.25rem;
    margin: 0 0 16px 0;
    color: #1f2937;
}

.stops-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Stop card */
.stop-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.stop-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stop-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    cursor: pointer;
    user-select: none;
    background: #f9fafb;
    transition: background 0.2s;
}

.stop-header:hover {
    background: #f3f4f6;
}

.stop-sequence {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stop-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.stop-type-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stop-type-pickup {
    background: #dbeafe;
    color: #1e40af;
}

.stop-type-delivery {
    background: #dcfce7;
    color: #166534;
}

.stop-type-layover {
    background: #fef3c7;
    color: #92400e;
}

.stop-type-default {
    background: #f3f4f6;
    color: #4b5563;
}

.stop-status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stop-completed {
    background: #d1fae5;
    color: #065f46;
}

.stop-pending {
    background: #fef3c7;
    color: #92400e;
}

.stop-missed {
    background: #fee2e2;
    color: #991b1b;
}

/* Missed reason note */
.stop-missed-reason {
    font-size: 0.75rem;
    color: #991b1b;
    background: #fee2e2;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 8px;
    font-weight: 500;
}

.stop-at-stop {
    background: #dbeafe;
    color: #1e40af;
}

.stop-info {
    flex: 1;
    min-width: 0;
}

.stop-location {
    font-weight: 600;
    font-size: 1rem;
    color: #1f2937;
    margin-bottom: 4px;
}

.stop-details {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #6b7280;
}

.stop-address-inline {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.4;
}

.stop-times {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
}

.stop-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pro-count {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
}

.stop-totals {
    font-size: 0.85rem;
    color: #6b7280;
    margin-right: 12px;
}

.toggle-icon {
    transition: transform 0.2s;
}

.stop-header:hover .toggle-icon {
    color: #3b82f6;
}

/* Stop body (collapsed by default) */
.stop-body {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.stop-address {
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #4b5563;
    margin-bottom: 16px;
    line-height: 1.6;
}

/* Stop Update Button */
.stop-update-btn {
    padding: 4px 12px !important;
    font-size: 0.75rem !important;
    margin-right: 8px;
    white-space: nowrap;
}

/* Stop Update Modal */
.stop-update-modal-content {
    max-width: 420px;
    width: 90%;
}

.stop-update-info {
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.stop-update-info .stop-type-badge {
    margin-left: 8px;
    vertical-align: middle;
}

.stop-update-form .form-group {
    margin-bottom: 16px;
}

.stop-update-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stop-update-form input[type="datetime-local"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #1e293b;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stop-update-form input[type="datetime-local"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Primary action button area */
.stop-update-primary-action {
    margin-top: 24px;
}

.stop-update-primary-action .btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
}

/* Modal footer - Missed on left, Cancel on right */
.stop-update-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 0 0;
    border-top: 1px solid #e2e8f0;
    margin-top: 20px;
    gap: 12px;
}

.stop-update-footer .btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
}

/* Outline danger button style */
.btn-outline-danger {
    background: transparent;
    color: #dc2626;
    border: 1px solid #dc2626;
    transition: all 0.2s;
}

.btn-outline-danger:hover {
    background: #dc2626;
    color: white;
}

/* Outline secondary button style (for Edit button) */
.btn-outline-secondary {
    background: transparent;
    color: #64748b;
    border: 1px solid #94a3b8;
    transition: all 0.2s;
}

.btn-outline-secondary:hover {
    background: #64748b;
    color: white;
}

/* Outline success button style (for Reopen) */
.btn-outline-success {
    background: transparent;
    color: #16a34a;
    border: 1px solid #16a34a;
    transition: all 0.2s;
}

.btn-outline-success:hover {
    background: #16a34a;
    color: white;
}

/* Stop Edit Button */
.stop-edit-btn {
    padding: 4px 12px !important;
    font-size: 0.75rem !important;
    margin-right: 8px;
    white-space: nowrap;
}

/* Missed badge in modal */
.badge-missed {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* Missed info in edit modal */
.stop-missed-info {
    padding: 8px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #991b1b;
}

.stop-missed-info label {
    font-weight: 600;
    margin-right: 4px;
}

.btn-block {
    width: 100%;
}

/* PROs container */
.pros-container {
    margin-top: 16px;
}

.pros-container h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 12px 0;
}

.pros-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* PRO item - OLD STYLE (kept for backwards compatibility) */
.pro-item {
    padding: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: background 0.2s;
}

.pro-item:hover {
    background: #f3f4f6;
}

.pro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.pro-number {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.pro-details {
    font-size: 0.85rem;
    color: #6b7280;
}

/* PRO item - COMPACT SINGLE-LINE STYLE */
.pro-item-compact {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.15s;
    font-size: 0.9rem;
}

.pro-item-compact:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.pro-item-compact:last-child {
    border-bottom: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.pro-item-compact:hover {
    background: #f3f4f6;
}

.pro-number-compact {
    font-weight: 600;
    color: #1f2937;
    min-width: 100px;
    flex-shrink: 0;
}

.pro-terminals {
    font-size: 0.7rem;
    font-weight: 500;
    color: #6b7280;
    letter-spacing: 0.5px;
    margin-left: auto;
    flex-shrink: 0;
}

.pro-type-indicator {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.pro-type-dl {
    background: #dbeafe;
    color: #1e40af;
}

.pro-type-pu {
    background: #fef3c7;
    color: #92400e;
}

.pro-type-lh {
    background: #f3e8ff;
    color: #6b21a8;
}

.pro-type-default {
    background: #f3f4f6;
    color: #6b7280;
}

/* PRO status badges */
.pro-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.pro-status-delivered {
    background: #d1fae5;
    color: #065f46;
}

.pro-status-pending {
    background: #fef3c7;
    color: #92400e;
}

.pro-status-missed {
    background: #fee2e2;
    color: #991b1b;
}

.pro-status-picked_up {
    background: #dbeafe;
    color: #1e40af;
}

.pro-stats-compact {
    color: #6b7280;
    font-size: 0.85rem;
    min-width: 180px;
    flex-shrink: 0;
}

.pro-parties-compact {
    color: #4b5563;
    font-size: 0.85rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.party-label {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.pro-body {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.85rem;
    color: #4b5563;
}

.pro-body div {
    margin-bottom: 4px;
}

.pro-body strong {
    color: #1f2937;
    font-weight: 600;
}

/* Stop progress indicator */
.stop-progress {
    display: inline-block;
    padding: 4px 10px;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 32px;
    color: #9ca3af;
    font-size: 0.95rem;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .trip-info-grid {
        grid-template-columns: 1fr;
    }

    .stop-header {
        flex-wrap: wrap;
    }

    .stop-info {
        flex-basis: 100%;
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.toast-icon {
    font-size: 20px;
    font-weight: bold;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #1f2937;
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #374151;
}

.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info {
    border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-fade-out {
    animation: slideOut 0.3s ease-in;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    font-size: 13px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label input[type="checkbox"] {
    margin: 0;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="tel"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="date"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[readonly] {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

.form-group small {
    font-size: 11px;
    color: #6b7280;
    margin-top: -2px;
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

/* Responsive Forms */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .toast {
        left: 20px;
        right: 20px;
        min-width: auto;
    }
}

/* Carrier Modal Specific Styles */
.carrier-modal {
    max-width: 550px;
}

.carrier-form-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-section {
    background: #f9fafb;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    padding: 4px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.checkbox-label span {
    user-select: none;
}

.checkbox-label:hover {
    color: #1f2937;
}

/* Driver Modal Specific Styles */
.driver-modal {
    max-width: 650px;
}

.driver-form-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.driver-form-layout .form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

.section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .carrier-modal {
        max-width: 100%;
    }

    .driver-modal,
    .user-modal {
        max-width: 100%;
    }
}

/* User Modal */
.user-modal {
    max-width: 550px;
}

.user-form-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-form-layout .form-group {
    margin-bottom: 0;
}

.modal-footer-left {
    display: flex;
    gap: 8px;
    margin-right: auto;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #b91c1c;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 13px;
    color: #374151;
}

.user-info-section {
    background: #f9fafb;
    border-radius: 8px;
    padding: 14px;
}

.table-summary {
    padding: 8px 16px;
    font-size: 13px;
    color: #6b7280;
    border-bottom: 1px solid var(--border-color);
}

.form-notice {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
}

.btn-success {
    background: #16a34a;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #15803d;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px solid #f3f4f6;
}

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

.activity-action {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.activity-detail {
    color: #6b7280;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-time {
    color: #9ca3af;
    font-size: 12px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .modal-footer-left {
        flex-wrap: wrap;
    }
}

/* ============================================================================
   Dashboard Compact Layout
   ============================================================================ */

/* Stats Overview - Horizontal Bar */
.stats-overview {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    overflow-x: auto;
}

.stat-compact {
    flex: 1;
    min-width: 140px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.stat-compact:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-compact-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: var(--spacing-sm);
}

.stat-compact-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Status-specific colors */
.stat-compact.stat-planned .stat-compact-value {
    color: #6b7280;
}

.stat-compact.stat-scheduled .stat-compact-value {
    color: #3b82f6;
}

.stat-compact.stat-in-transit .stat-compact-value {
    color: #f59e0b;
}

.stat-compact.stat-completed .stat-compact-value {
    color: #10b981;
}

.stat-compact.stat-cancelled .stat-compact-value {
    color: #ef4444;
}

/* Dashboard Main Grid */
.dashboard-main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

/* Compact card body */
.card-body-compact {
    padding: 0;
}

/* Compact Trip Item */
.trip-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.trip-compact:last-child {
    border-bottom: none;
}

.trip-compact:hover {
    background: var(--bg-light);
}

.trip-compact-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
    min-width: 0;
}

.trip-compact-number {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.trip-compact-route {
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Compact Activity Item */
.activity-compact {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.activity-compact:last-child {
    border-bottom: none;
}

.activity-compact:hover {
    background: var(--bg-light);
}

.activity-compact-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.activity-compact-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Alert Card */
.card-alert {
    grid-column: span 1;
}

.alert-list {
    display: flex;
    flex-direction: column;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
    text-decoration: none;
    color: inherit;
}

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

.alert-item:hover {
    background: var(--bg-light);
}

.alert-item.alert-warning {
    background: rgba(251, 191, 36, 0.05);
}

.alert-item.alert-info {
    background: rgba(59, 130, 246, 0.05);
}

.alert-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-item.alert-warning svg {
    fill: #f59e0b;
}

.alert-item.alert-info svg {
    fill: #3b82f6;
}

.alert-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.alert-title {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

.alert-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* System Status Grid */
.system-status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.status-item:has(.status-indicator) {
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-sm);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.status-ok {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.status-indicator.status-warning {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.status-indicator.status-error {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.status-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Quick Actions Bar */
.quick-actions-bar {
    display: flex;
    gap: var(--spacing-md);
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    min-width: 100px;
    text-align: center;
}

.quick-action:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.quick-action svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.quick-action span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Badge Info */
.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* Responsive Compact Layout */
@media (max-width: 1200px) {
    .dashboard-main-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .stats-overview {
        flex-wrap: wrap;
    }

    .stat-compact {
        min-width: calc(50% - var(--spacing-sm));
    }

    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions-bar {
        justify-content: space-between;
    }

    .quick-action {
        min-width: auto;
        flex: 1;
    }
}

@media (max-width: 480px) {
    .stat-compact {
        min-width: 100%;
    }
}

/* ============================================================================
   Terminal / Sync Log Modal Styles
   ============================================================================ */

.terminal-output {
    height: 100%;
    background: #1a1a1a;
    color: #00ff00;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.terminal-header {
    background: #2a2a2a;
    padding: 8px 16px;
    border-bottom: 1px solid #3a3a3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.terminal-title {
    color: #888;
    font-size: 12px;
    font-weight: 600;
}

.terminal-time {
    color: #666;
    font-size: 11px;
}

.terminal-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.log-line {
    padding: 2px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    color: #00ff00;
}

.log-line.log-error {
    color: #ff5555;
    font-weight: 500;
}

.log-line.log-warning {
    color: #ffaa00;
}

.log-line.log-success {
    color: #50fa7b;
    font-weight: 500;
}

.log-line.log-separator {
    color: #555;
    margin: 8px 0;
}

.log-line.log-empty {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 40px 0;
}

/* Terminal scrollbar */
.terminal-content::-webkit-scrollbar {
    width: 8px;
}

.terminal-content::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.terminal-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.terminal-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==========================================================================
   TRIP MODAL TABS & CHANGE HISTORY
   ========================================================================== */

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.modal-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
}

.modal-tab:hover {
    color: #2196F3;
    background: #f5f5f5;
}

.modal-tab.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
}

/* Tab Content */
.tab-content {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Changes Timeline */
.changes-timeline {
    padding: 10px 0;
}

.change-date-group {
    margin-bottom: 30px;
}

.change-date-header {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.change-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.change-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: #fff;
    border-left: 4px solid #2196F3;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.change-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: translateX(2px);
}

.change-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.change-content {
    flex: 1;
}

.change-time {
    font-size: 12px;
    color: #999;
    margin-bottom: 5px;
}

.change-description {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    margin-bottom: 5px;
}

.change-description strong {
    color: #2196F3;
    font-weight: 600;
}

.old-value {
    display: inline-block;
    padding: 2px 6px;
    background: #ffebee;
    color: #c62828;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}

.new-value {
    display: inline-block;
    padding: 2px 6px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
}

.change-source {
    font-size: 11px;
    color: #999;
    font-style: italic;
}

/* Single-line change item */
.change-item-single-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    margin-bottom: 2px;
    background: #fff;
    border-left: 4px solid #2196F3;
    font-size: 13px;
    line-height: 1.5;
}

.change-icon-inline {
    font-size: 16px;
    flex-shrink: 0;
}

.change-time-inline {
    color: #666;
    font-size: 12px;
    flex-shrink: 0;
    min-width: 150px;
}

.change-description-inline {
    flex: 1;
    color: #333;
}

.change-description-inline strong {
    color: #2196F3;
    font-weight: 600;
}

.change-source-inline {
    font-size: 11px;
    color: #999;
    font-style: italic;
    flex-shrink: 0;
}


/* ========================================
   Settings Page
   ======================================== */

.settings-grid {
    display: grid;
    gap: 20px;
}

/* Bot Control Sections */
.bot-control-section {
    padding: 20px 0;
}

.bot-control-section:first-child {
    padding-top: 0;
}

.bot-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.bot-header h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #1a1a2e;
}

.bot-header .text-muted {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.bot-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-idle {
    background: #e5e7eb;
    color: #374151;
}

.status-running {
    background: #dcfce7;
    color: #166534;
    animation: pulse-running 2s infinite;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

@keyframes pulse-running {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.bot-info {
    margin-bottom: 15px;
}

.bot-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    font-size: 13px;
    color: #374151;
}

.bot-info-grid strong {
    color: #1a1a2e;
    font-weight: 600;
}

.bot-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #10b981;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

input:disabled + .slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.divider {
    height: 1px;
    background: #e5e7eb;
    margin: 20px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .bot-header {
        flex-direction: column;
        gap: 10px;
    }

    .bot-info-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   Trip Map Modal Styles
   ============================================================================ */

.map-modal {
    z-index: 15000 !important; /* Higher than other modals to ensure visibility when stacked */
}

.map-modal .modal-content {
    width: 95vw;
    max-width: 1400px;
    height: 85vh;
    max-height: 900px;
}

.map-modal-body {
    display: flex;
    gap: 0;
    height: calc(85vh - 60px);
    overflow: hidden;
}

.trip-map {
    flex: 1;
    height: 100% !important;
    min-height: 600px !important;
    background: #e5e7eb;
    position: relative;
}

/* Ensure Leaflet container fills the space */
.trip-map .leaflet-container {
    height: 100% !important;
    min-height: 600px !important;
}

.map-stops-list {
    width: 300px;
    background: white;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 15px;
}

.map-stops-list h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.map-stop-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: #f9fafb;
    border-radius: var(--radius-md);
    border-left: 3px solid #2196F3;
    transition: var(--transition-fast);
    cursor: pointer;
}

.map-stop-item:hover {
    background: #f3f4f6;
    transform: translateX(2px);
}

.map-stop-item.stop-completed {
    border-left-color: #4caf50;
}

.map-stop-item.stop-pending {
    border-left-color: #9e9e9e;
}

.map-stop-item.stop-at-stop {
    border-left-color: #ff9800;
}

.map-stop-item.stop-missed {
    border-left-color: #f44336;
}

.map-stop-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #2196F3;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.map-stop-details {
    flex: 1;
}

.map-stop-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.map-stop-type {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 3px;
}

.map-stop-address {
    font-size: 12px;
    color: var(--text-light);
}

.map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 16px;
}

/* Leaflet custom styles */
.leaflet-container {
    font-family: inherit;
}

.custom-marker {
    background: transparent;
    border: none;
}

.distance-label {
    background: transparent;
    border: none;
}

/* Responsive map modal */
@media (max-width: 768px) {
    .map-modal .modal-content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .map-modal-body {
        flex-direction: column;
        height: calc(100vh - 60px);
    }

    .trip-map {
        height: 60%;
    }

    .map-stops-list {
        width: 100%;
        height: 40%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}
