/**
 * The City Service – Cab Service Management System
 * Corporate ERP Design System & Responsive Stylesheet
 * Developer: PDP Infotech Solutions
 */

:root {
    --tcs-primary: #0f172a;
    --tcs-primary-dark: #020617;
    --tcs-sidebar-bg: #1e293b;
    --tcs-sidebar-hover: #334155;
    --tcs-sidebar-active: #2563eb;
    --tcs-accent: #d97706;
    --tcs-accent-hover: #b45309;
    --tcs-info: #0284c7;
    --tcs-success: #16a34a;
    --tcs-warning: #d97706;
    --tcs-danger: #dc2626;
    --tcs-bg-body: #f8fafc;
    --tcs-card-bg: #ffffff;
    --tcs-text-main: #0f172a;
    --tcs-text-muted: #64748b;
    --tcs-border: #e2e8f0;
    --tcs-sidebar-width: 250px;
    --tcs-header-height: 60px;
    --tcs-radius: 8px;
    --tcs-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
    --tcs-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

/* Global Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tcs-bg-body);
    color: var(--tcs-text-main);
    font-size: 14.5px;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Headings */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--tcs-primary);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Layout Framework */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar Architecture */
.app-sidebar {
    width: var(--tcs-sidebar-width);
    background-color: var(--tcs-sidebar-bg);
    color: #f1f5f9;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    height: var(--tcs-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background-color: var(--tcs-primary-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand-badge {
    background-color: var(--tcs-accent);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem;
}

.nav-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 0.75rem 0.75rem 0.25rem;
    font-weight: 700;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.75rem;
    color: #cbd5e1;
    border-radius: var(--tcs-radius);
    font-size: 0.88rem;
    margin-bottom: 0.15rem;
    transition: all 0.15s ease-in-out;
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
    color: #94a3b8;
}

.sidebar-nav .nav-link:hover {
    color: #ffffff;
    background-color: var(--tcs-sidebar-hover);
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background-color: var(--tcs-sidebar-active);
    font-weight: 600;
}

.sidebar-nav .nav-link.active i {
    color: #ffffff;
}

.sidebar-nav .nav-link.disabled-planned {
    opacity: 0.55;
    cursor: not-allowed;
}

.sidebar-nav .nav-link.disabled-planned:hover {
    background-color: transparent;
    color: #cbd5e1;
}

.sidebar-user {
    padding: 0.85rem 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Main Content Area */
.app-main {
    flex-grow: 1;
    margin-left: var(--tcs-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Navbar */
.app-navbar {
    height: var(--tcs-header-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--tcs-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.navbar-toggle-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--tcs-border);
    border-radius: var(--tcs-radius);
    padding: 0.35rem 0.6rem;
    color: var(--tcs-primary);
    cursor: pointer;
}

.navbar-toggle-btn:hover {
    background-color: #f1f5f9;
}

.app-page-content {
    flex-grow: 1;
    padding: 1.5rem;
}

.app-footer {
    padding: 1rem 1.5rem;
    background-color: #1e293b;
    border-top: 1px solid #334155;
    font-size: 0.82rem;
    color: #94a3b8;
}

.app-footer strong {
    color: #f1f5f9;
}

.app-footer a {
    color: #38bdf8;
    text-decoration: none;
}

.app-footer a:hover {
    color: #7dd3fc;
    text-decoration: underline;
}

.app-footer a:focus-visible {
    outline: 2px solid #38bdf8 !important;
    outline-offset: 2px;
}

.app-footer .footer-brand {
    color: #cbd5e1;
}

.app-footer .footer-dev {
    color: #94a3b8;
}

/* Sidebar Backdrop for Mobile/Tablet */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1030;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* Professional Cards */
.card-erp {
    background-color: var(--tcs-card-bg);
    border: 1px solid var(--tcs-border);
    border-radius: var(--tcs-radius);
    box-shadow: var(--tcs-shadow);
    margin-bottom: 1.25rem;
}

.card-erp-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--tcs-border);
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.card-erp-body {
    padding: 1.25rem;
}

/* Role Badges & Status Contrast System */
.badge-role {
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-role-super_admin { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-role-admin { background-color: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }
.badge-role-accounts { background-color: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-role-operations { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-role-driver { background-color: #f1f5f9; color: #1e293b; border: 1px solid #cbd5e1; }

/* Global High-Contrast Subtle Badges */
.badge.bg-primary-subtle { background-color: #dbeafe !important; color: #1e40af !important; border: 1px solid #bfdbfe; }
.badge.bg-secondary-subtle { background-color: #f1f5f9 !important; color: #334155 !important; border: 1px solid #e2e8f0; }
.badge.bg-success-subtle { background-color: #dcfce7 !important; color: #166534 !important; border: 1px solid #bbf7d0; }
.badge.bg-info-subtle { background-color: #e0f2fe !important; color: #0369a1 !important; border: 1px solid #bae6fd; }
.badge.bg-warning-subtle { background-color: #fef3c7 !important; color: #92400e !important; border: 1px solid #fde68a; }
.badge.bg-danger-subtle { background-color: #fee2e2 !important; color: #991b1b !important; border: 1px solid #fecaca; }

/* Global Accessible Text Contrast */
.text-secondary { color: #475569 !important; }
.text-muted { color: #64748b !important; }

/* Buttons */
.btn-tcs-primary {
    background-color: var(--tcs-primary);
    color: #ffffff;
    border: 1px solid var(--tcs-primary);
    border-radius: var(--tcs-radius);
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.btn-tcs-primary:hover {
    background-color: var(--tcs-primary-dark);
    border-color: var(--tcs-primary-dark);
    color: #ffffff;
}

/* Login Screen Framework */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0f172a;
    padding: 1rem;
}

.login-card {
    background: #ffffff;
    border: 1px solid #334155;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background-color: #ffffff;
    padding: 2rem 1.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--tcs-border);
}

.login-brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background-color: #0f172a;
    color: #d97706;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--tcs-primary);
    margin: 0;
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--tcs-text-muted);
    margin-top: 0.25rem;
}

.login-body {
    padding: 1.75rem;
}

.login-footer {
    padding: 0.85rem 1.75rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--tcs-border);
    font-size: 0.78rem;
    color: var(--tcs-text-muted);
    text-align: center;
}

/* Form Controls & Password Toggle */
.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-radius: var(--tcs-radius);
    border: 1px solid var(--tcs-border);
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    color: var(--tcs-text-main);
}

.form-control:focus, .form-select:focus {
    border-color: var(--tcs-sidebar-active);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.password-toggle-btn {
    background: transparent;
    border: 1px solid var(--tcs-border);
    border-left: none;
    color: var(--tcs-text-muted);
    cursor: pointer;
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    border-top-right-radius: var(--tcs-radius) !important;
    border-bottom-right-radius: var(--tcs-radius) !important;
}

.password-toggle-btn:hover {
    color: var(--tcs-primary);
    background-color: #f1f5f9;
}

/* Responsive Table Wrappers */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Professional Corporate Admin Dashboard Styles
   ========================================================================== */

/* Dashboard Header & Banner */
.dashboard-welcome-banner {
    background: #ffffff;
    border: 1px solid var(--tcs-border);
    border-radius: var(--tcs-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--tcs-shadow);
}

.dashboard-date-badge {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: var(--tcs-radius);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Dashboard Section Titles */
.dashboard-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tcs-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dashboard-section-subtitle {
    font-size: 0.82rem;
    color: var(--tcs-text-muted);
    margin-bottom: 1rem;
}

/* Professional KPI Cards */
.kpi-card {
    background: #ffffff;
    border: 1px solid var(--tcs-border);
    border-radius: var(--tcs-radius);
    padding: 1.15rem 1.25rem;
    height: 100%;
    box-shadow: var(--tcs-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tcs-shadow-md);
    border-color: #cbd5e1;
}

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

.kpi-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--tcs-primary);
    margin-bottom: 0.35rem;
}

.kpi-subtext {
    font-size: 0.78rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Specific KPI Icon Variants */
.kpi-icon-primary { background: #eff6ff; color: #2563eb; }
.kpi-icon-success { background: #f0fdf4; color: #16a34a; }
.kpi-icon-warning { background: #fefce8; color: #ca8a04; }
.kpi-icon-info { background: #f0f9ff; color: #0284c7; }
.kpi-icon-danger { background: #fef2f2; color: #dc2626; }
.kpi-icon-dark { background: #f8fafc; color: #0f172a; }
.kpi-icon-purple { background: #faf5ff; color: #9333ea; }

/* Operational Status Grid & Badges */
.status-pill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
}

.status-pill-card {
    background: #ffffff;
    border: 1px solid var(--tcs-border);
    border-radius: var(--tcs-radius);
    padding: 0.85rem 1rem;
    text-align: center;
    transition: all 0.15s ease;
    text-decoration: none;
    display: block;
    color: inherit;
}

.status-pill-card:hover {
    border-color: var(--tcs-sidebar-active);
    box-shadow: var(--tcs-shadow);
    color: inherit;
}

.status-pill-count {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--tcs-primary);
    line-height: 1.1;
}

.status-pill-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    margin-top: 0.25rem;
}

/* Quick Action Buttons */
.quick-action-item {
    background: #ffffff;
    border: 1px solid var(--tcs-border);
    border-radius: var(--tcs-radius);
    padding: 0.75rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--tcs-primary);
    transition: all 0.15s ease;
}

.quick-action-item:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: var(--tcs-sidebar-active);
    transform: translateX(2px);
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Attention / Alert Items */
.attention-item {
    padding: 0.75rem 1rem;
    border-radius: var(--tcs-radius);
    border: 1px solid var(--tcs-border);
    margin-bottom: 0.5rem;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.attention-item.alert-warning-soft {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.attention-item.alert-danger-soft {
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

.attention-item.alert-info-soft {
    border-left: 4px solid #0284c7;
    background: #f0f9ff;
}

/* Media Queries & Responsive Breakpoints */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0 !important;
    }

    .navbar-toggle-btn {
        display: inline-flex;
    }

    .app-navbar {
        padding: 0 1rem;
    }

    .app-page-content {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.45rem;
    }
}

@media (max-width: 575.98px) {
    .login-card {
        border-radius: 8px;
    }

    .login-body {
        padding: 1.25rem;
    }

    .login-header {
        padding: 1.5rem 1.25rem 0.85rem;
    }

    .app-navbar {
        padding: 0 0.75rem;
    }

    .app-page-content {
        padding: 0.75rem;
    }

    .status-pill-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.35rem;
    }
}

/* ==========================================================================
   WhatsApp Communication & Dispatch Buttons
   ========================================================================== */
.btn-whatsapp-solid {
    background-color: #25d366;
    border-color: #25d366;
    color: #ffffff !important;
    font-weight: 500;
}

.btn-whatsapp-solid:hover,
.btn-whatsapp-solid:focus {
    background-color: #128c7e;
    border-color: #128c7e;
    color: #ffffff !important;
}

.btn-outline-whatsapp {
    color: #128c7e;
    border-color: #25d366;
    background-color: rgba(37, 211, 102, 0.06);
}

.btn-outline-whatsapp:hover,
.btn-outline-whatsapp:focus {
    color: #ffffff;
    background-color: #128c7e;
    border-color: #128c7e;
}

.btn-whatsapp-guest {
    color: #0f766e;
    border-color: #14b8a6;
    background-color: rgba(20, 184, 166, 0.08);
}

.btn-whatsapp-guest:hover,
.btn-whatsapp-guest:focus {
    color: #ffffff;
    background-color: #0f766e;
    border-color: #0f766e;
}

.btn-whatsapp-driver {
    color: #15803d;
    border-color: #22c55e;
    background-color: rgba(34, 197, 94, 0.08);
}

.btn-whatsapp-driver:hover,
.btn-whatsapp-driver:focus {
    color: #ffffff;
    background-color: #15803d;
    border-color: #15803d;
}

.whatsapp-preview-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #25d366;
    border-radius: 6px;
    padding: 0.85rem;
    font-family: var(--font-family-monospace, monospace);
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: #1e293b;
}

/* Duty detail page: compact summary, legible cards, and touch-friendly actions. */
.duty-detail-page {
    --duty-border: #e2e8f0;
    --duty-ink: #172033;
    color: var(--duty-ink);
}

.duty-header-card {
    border-left: 4px solid #2563eb !important;
}

.duty-header-layout {
    min-width: 0;
}

.duty-header-identity {
    min-width: 0;
}

.duty-number {
    max-width: 100%;
    font-size: clamp(1rem, 1.5vw, 1.35rem);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.duty-header-schedule {
    flex-wrap: wrap;
}

.duty-header-meta-item {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.25;
}

.duty-header-meta-label {
    color: #64748b;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.duty-header-meta-item strong {
    color: #172033;
    font-size: 0.85rem;
    font-weight: 600;
}

.duty-action-toolbar {
    min-width: 0;
}

.duty-action-toolbar .btn {
    min-height: 2.15rem;
    white-space: normal;
}

.duty-info-card {
    border: 1px solid var(--duty-border) !important;
    border-radius: 0.65rem;
}

.duty-info-card .card-header {
    min-height: 2.65rem;
}

.duty-info-card .card-body {
    padding: 0.85rem !important;
}

.duty-info-card .text-truncate {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
}

.duty-dispatch-card {
    border-color: #d8e2ee !important;
    border-left-width: 4px !important;
}

.duty-dispatch-card-guest {
    border-left-color: #16a34a !important;
}

.duty-dispatch-card-driver {
    border-left-color: #0f766e !important;
}

.duty-dispatch-card summary {
    cursor: pointer;
    font-weight: 600;
}

.duty-dispatch-card .btn {
    min-height: 2.35rem;
}

@media (min-width: 1200px) {
    .duty-action-toolbar {
        width: auto !important;
        max-width: 58rem;
        justify-content: flex-end;
    }
}

@media (max-width: 1199.98px) {
    .duty-action-toolbar {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
        width: 100%;
    }

    .duty-action-toolbar .btn {
        justify-content: center;
    }
}

@media (max-width: 575.98px) {
    .duty-header-body {
        padding: 0.8rem !important;
    }

    .duty-header-identity {
        width: 100%;
    }

    .duty-header-schedule {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 0.5rem !important;
    }

    .duty-action-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem !important;
    }

    .duty-action-toolbar .btn {
        min-width: 0;
        padding: 0.4rem 0.45rem;
        font-size: 0.78rem;
        line-height: 1.2;
    }

    .duty-info-card .card-header {
        padding: 0.55rem 0.7rem !important;
    }

    .duty-info-card .card-body {
        padding: 0.7rem !important;
    }

    .duty-dispatch-card {
        padding: 0.75rem !important;
    }
}

@media (min-width: 576px) {
    .border-start-sm {
        border-left: 1px solid #e2e8f0;
    }
}

/* ==========================================================================
   Global Responsive Safeguards & Form Controls
   ========================================================================== */
input, select, textarea, button {
    max-width: 100%;
}

canvas {
    max-width: 100% !important;
    height: auto !important;
}

.btn-toolbar, .btn-group, .d-flex.gap-2, .d-flex.gap-3 {
    flex-wrap: wrap;
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .table-responsive {
        margin-bottom: 0.5rem;
    }
}

/* ==========================================================================
   Section 4: Itemized Billable Line Items – Responsive Table & Mobile Cards
   ========================================================================== */
.invoice-items-table-wrapper {
    width: 100%;
    background-color: #ffffff;
}

.invoice-items-table {
    width: 100%;
    table-layout: fixed;
    margin-bottom: 0;
    border-collapse: collapse;
}

.invoice-items-table th {
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    font-weight: 700;
    padding: 0.6rem 0.45rem;
    background-color: #f8fafc;
    border-bottom: 2px solid var(--tcs-border);
    white-space: nowrap;
}

.invoice-items-table td {
    vertical-align: middle;
    padding: 0.45rem 0.35rem;
    border-color: var(--tcs-border);
}

.invoice-items-table td.cell-item-type { width: 18%; }
.invoice-items-table td.cell-desc { width: 24%; }
.invoice-items-table td.cell-qty { width: 8%; }
.invoice-items-table td.cell-rate { width: 13%; }
.invoice-items-table td.cell-taxable { width: 10%; }
.invoice-items-table td.cell-amount { width: 18%; }
.invoice-items-table td.cell-action { width: 9%; }

.invoice-items-table .form-select-sm,
.invoice-items-table .form-control-sm {
    font-size: 0.84rem;
    padding: 0.35rem 0.45rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 4px;
}

.invoice-items-table .item-desc {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Change 3: Night Charges Row Distinct Styling (Subtle pale amber with accessible contrast) */
.night-charges-row {
    background-color: #fefce8 !important;
    border-left: 3px solid #f59e0b !important;
}

.night-charges-row td {
    background-color: #fefce8 !important;
}

.night-charges-row .item-amount {
    color: #92400e !important;
    font-weight: 700;
}

.night-badge-container .badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Mobile Responsive Transformation: Cards (< 768px) */
@media (max-width: 767.98px) {
    .invoice-items-table-wrapper {
        border: none !important;
        padding: 0.5rem !important;
        background: transparent;
    }

    .invoice-items-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    .invoice-items-table thead {
        display: none !important;
    }

    .invoice-items-table tbody {
        display: block !important;
        width: 100% !important;
    }

    .invoice-items-table tr.item-row {
        display: block !important;
        width: 100% !important;
        background: #ffffff;
        border: 1px solid var(--tcs-border) !important;
        border-radius: 8px;
        padding: 0.85rem;
        margin-bottom: 0.85rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        box-sizing: border-box;
    }

    .invoice-items-table tr.item-row.night-charges-row {
        background-color: #fefce8 !important;
        border: 1px solid #fde68a !important;
        border-left: 4px solid #f59e0b !important;
    }

    .invoice-items-table tr.item-row:last-child {
        margin-bottom: 0;
    }

    .invoice-items-table td {
        display: block !important;
        width: 100% !important;
        padding: 0.35rem 0 !important;
        border: none !important;
        text-align: left !important;
        box-sizing: border-box;
    }

    .invoice-items-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        color: #64748b;
        margin-bottom: 0.25rem;
        letter-spacing: 0.04em;
    }

    .invoice-items-table td.cell-taxable {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 0 !important;
        border-top: 1px dashed #e2e8f0 !important;
        border-bottom: 1px dashed #e2e8f0 !important;
        margin: 0.5rem 0;
    }

    .invoice-items-table td.cell-taxable::before {
        margin-bottom: 0;
    }

    .invoice-items-table td.cell-taxable .d-flex {
        margin: 0 !important;
    }

    .invoice-items-table td.cell-amount {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 0 !important;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--tcs-primary);
        border-bottom: 1px solid #f1f5f9 !important;
        margin-bottom: 0.5rem;
    }

    .invoice-items-table td.cell-amount::before {
        margin-bottom: 0;
        font-size: 0.75rem;
        color: #64748b;
    }

    .invoice-items-table td.cell-action {
        padding-top: 0.4rem !important;
    }

    .invoice-items-table td.cell-action::before {
        display: none;
    }

    .invoice-items-table td.cell-action .btn-remove-row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
        padding: 0.45rem;
        font-size: 0.85rem;
    }

    .invoice-items-table td.cell-action .btn-remove-row::after {
        content: " Remove Line Item";
        font-weight: 500;
    }
}

/* Print Specific Preservation */
@media print {
    .invoice-items-table {
        display: table !important;
        table-layout: fixed !important;
        width: 100% !important;
    }
    .invoice-items-table thead {
        display: table-header-group !important;
    }
    .invoice-items-table tbody {
        display: table-row-group !important;
    }
    .invoice-items-table tr {
        display: table-row !important;
    }
    .invoice-items-table td {
        display: table-cell !important;
        border: 1px solid #000000 !important;
    }
    .invoice-items-table td::before {
        display: none !important;
    }
    .invoice-items-table td.cell-action,
    .invoice-items-table th:last-child {
        display: none !important;
    }
}

/* ==========================================================================
   CHANGE 2: Responsive Web App & Mobile Usability Enhancements
   ========================================================================== */

/* Accessibility: Visible Focus Indicators */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--tcs-sidebar-active) !important;
    outline-offset: 2px;
}

/* Accessibility: Respect Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Touch Friendly Interactive Targets (~44px minimum) */
.navbar-toggle-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

#sidebarClose {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.sidebar-nav .nav-link {
    min-height: 42px;
    display: flex;
    align-items: center;
}

.password-toggle-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* PWA Installation Affordance Button */
.btn-pwa-install {
    background-color: var(--tcs-sidebar-active);
    color: #ffffff;
    border: none;
    border-radius: var(--tcs-radius);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    min-height: 40px;
    transition: background-color 0.15s ease;
}

.btn-pwa-install:hover {
    background-color: #1d4ed8;
    color: #ffffff;
}

/* Fluid Mobile Adaptation for 320px - 480px Viewports */
@media (max-width: 480px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .app-container, .app-main {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .card-erp, .card {
        max-width: 100%;
        border-radius: 8px;
    }

    .card-erp-body, .card-body {
        padding: 0.85rem;
    }

    .login-card {
        width: 100%;
        max-width: 100%;
        margin: 0.5rem;
        border-radius: 8px;
    }

    /* Prevent horizontal page blowouts from wide tables while keeping data accessible */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border-radius: var(--tcs-radius);
    }

    /* Font size 16px on mobile form controls prevents iOS auto-zoom */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    select.form-select,
    textarea.form-control {
        font-size: 16px !important;
    }

    /* Action buttons in tables: touch accessible sizing */
    .table .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .table .btn-sm {
        min-height: 38px;
        min-width: 38px;
        padding: 0.35rem 0.6rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Modal containment on small screens */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
}

/* Responsive Table Pinning & Scroll Indicator */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}



