:root {
    --navy-950: #071429;
    --navy-900: #0b1f3a;
    --navy-800: #123861;
    --navy-700: #15507d;
    --teal-500: #16b6a9;
    --cyan-400: #46c7ee;
    --amber-400: #f5b84b;
    --rose-500: #e4586c;
    --violet-500: #7a68e8;
    --surface: #f4f8fc;
    --card: #ffffff;
    --ink: #172033;
    --muted: #66758a;
    --line: #d9e4ef;
    --bs-body-font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

body {
    font-family: var(--bs-body-font-family);
}

body.integra-shell {
    background:
        radial-gradient(circle at 20% 0%, rgba(70, 199, 238, .16), transparent 24rem),
        linear-gradient(180deg, #edf5fb 0%, var(--surface) 32%, #f8fbfe 100%);
    background-attachment: fixed;
    color: var(--ink);
}

.app-main, .app-content { background: transparent; }

/* ---------- Top bar ---------- */
.integra-topbar {
    background: linear-gradient(90deg, var(--navy-950), var(--navy-800)) !important;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.integra-topbar .nav-link { color: rgba(255, 255, 255, .86); }
.topbar-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; }
.topbar-link { border-radius: 8px; }
.topbar-icon:hover, .topbar-link:hover { color: #fff !important; background: rgba(255, 255, 255, .1); }
.user-chip {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .4rem .75rem; border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 999px; background: rgba(255, 255, 255, .08); color: #fff;
}
.user-chip:hover { color: #fff; background: rgba(255, 255, 255, .16); }

/* ---------- Sidebar ---------- */
.integra-sidebar { background: linear-gradient(180deg, var(--navy-950), #0c2442 58%, #092039) !important; }
.sidebar-brand { height: 57px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
/* The menu scrolls on its own when it is taller than the screen (layout-fixed keeps the sidebar at screen height). */
.layout-fixed .app-sidebar { display: flex; flex-direction: column; max-height: 100vh; }
.layout-fixed .app-sidebar .sidebar-wrapper { flex: 1 1 auto; min-height: 0; overflow-y: auto !important; overflow-x: hidden; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent; }
.layout-fixed .app-sidebar .sidebar-wrapper::-webkit-scrollbar { width: 6px; }
.layout-fixed .app-sidebar .sidebar-wrapper::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .25); border-radius: 3px; }
.layout-fixed .app-sidebar .sidebar-wrapper .sidebar-menu { padding-bottom: 1.5rem; }
.brand-link { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: #fff; }
.brand-text { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.brand-badge {
    width: 38px; height: 38px; flex: 0 0 38px; display: inline-grid; place-items: center;
    border-radius: 8px; background: linear-gradient(135deg, var(--cyan-400), var(--teal-500));
    color: var(--navy-950); font-weight: 800; font-size: .75rem;
}
.brand-badge-lg { width: 64px; height: 64px; font-size: 1.1rem; }
.sidebar-menu .nav-link { border-radius: 8px; margin: .08rem .65rem; color: rgba(255, 255, 255, .78); }
.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link.active { background: rgba(70, 199, 238, .14) !important; color: #fff !important; }
.sidebar-menu .nav-link.active { box-shadow: inset 3px 0 0 var(--cyan-400); }
.sidebar-menu .nav-treeview .nav-link { font-size: .92rem; }

/* ---------- Page hero ---------- */
.screen-hero {
    position: relative; overflow: hidden; min-height: 132px;
    padding: 1.45rem 1.7rem; border-radius: 8px; margin-bottom: 1.25rem;
    background: linear-gradient(135deg, rgba(7, 20, 41, .96), rgba(18, 56, 97, .94) 58%, rgba(22, 182, 169, .86));
    color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    box-shadow: 0 18px 40px rgba(7, 20, 41, .18);
}
.screen-hero::after {
    content: ""; position: absolute; inset: auto -4rem -7rem auto;
    width: 20rem; height: 20rem; border: 42px solid rgba(255, 255, 255, .08); border-radius: 50%;
}
.screen-hero > * { position: relative; z-index: 1; }
.hero-kicker { display: block; color: #aeeaf5; text-transform: uppercase; font-size: .75rem; font-weight: 700; letter-spacing: .08rem; }
.screen-hero h1 { margin: .25rem 0 0; font-size: 1.85rem; font-weight: 760; }
.screen-hero p { margin: .35rem 0 0; color: rgba(255, 255, 255, .78); }
.hero-orbit {
    width: 76px; height: 76px; flex: 0 0 76px; border-radius: 8px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); font-size: 2.2rem;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.hero-actions .btn-light { color: var(--navy-900); font-weight: 700; }

/* ---------- Loader ---------- */
.hero-loader {
    position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
    transition: opacity .28s ease, visibility .28s ease;
}
.hero-loader.is-hidden { opacity: 0; visibility: hidden; }
.hero-loader-card {
    width: min(360px, calc(100vw - 2rem)); padding: 1.5rem; border-radius: 8px;
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); color: #fff; text-align: center;
}
.hero-loader-mark {
    width: 72px; height: 72px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 8px;
    background: linear-gradient(135deg, var(--cyan-400), var(--teal-500)); color: var(--navy-950); font-weight: 900;
}
.hero-loader-bar { height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .16); }
.hero-loader-bar span { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--amber-400); animation: loader-slide 1s ease-in-out infinite; }
.hero-loader-text { margin-top: .8rem; color: #cfe9f6; font-size: .9rem; }
@keyframes loader-slide { 0% { transform: translateX(-105%); } 100% { transform: translateX(250%); } }

/* ---------- Cards, buttons, forms ---------- */
.card { border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(9, 32, 57, .08); }
.card-header { background: linear-gradient(180deg, #fff, #f7fbff); border-bottom-color: var(--line); font-weight: 700; }
.card-header .badge { font-weight: 600; }
.btn { border-radius: 7px; }
.btn-primary { background: linear-gradient(135deg, var(--navy-800), var(--navy-700)); border-color: var(--navy-700); }
.btn-primary:hover, .btn-primary:focus { background: var(--navy-900); border-color: var(--navy-900); }
.btn-teal { background: var(--teal-500); border-color: var(--teal-500); color: #fff; }
.btn-teal:hover { background: #119c91; color: #fff; }
.form-label { font-weight: 600; color: var(--ink); font-size: .9rem; }
.form-label .req { color: var(--rose-500); }
.form-control, .form-select { border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--cyan-400); box-shadow: 0 0 0 .2rem rgba(70, 199, 238, .2); }
.form-control[readonly] { background: #f3f7fb; }
.field-validation-error { display: block; margin-top: .25rem; font-size: .82rem; font-weight: 700; }
.section-title { font-size: .78rem; font-weight: 800; letter-spacing: .08rem; text-transform: uppercase; color: var(--muted); margin: 1.6rem 0 .8rem; }

/* ---------- Dashboard stats ---------- */
.hero-stat {
    border: 0; border-radius: 8px; padding: 1.15rem; color: #fff; min-height: 136px; height: 100%;
    display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem;
    box-shadow: 0 14px 34px rgba(7, 20, 41, .14);
}
.hero-stat .stat-label { font-weight: 700; font-size: .95rem; }
.hero-stat h3 { font-size: 1.85rem; font-weight: 800; margin: .2rem 0; }
.hero-stat p { margin: 0; opacity: .86; font-size: .9rem; }
.hero-stat > i { font-size: 2.3rem; opacity: .8; }
.dashboard-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .75rem; }
.dashboard-actions .btn {
    --bs-btn-padding-y: .15rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .75rem;
    color: #fff; border: 1px solid rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .1);
}
.dashboard-actions .btn:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.stat-navy { background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); }
.stat-teal { background: linear-gradient(135deg, #0f8f86, var(--teal-500)); }
.stat-cyan { background: linear-gradient(135deg, #1b87b5, var(--cyan-400)); }
.stat-amber { background: linear-gradient(135deg, #d9891c, var(--amber-400)); }
.stat-rose { background: linear-gradient(135deg, #c43c52, var(--rose-500)); }
.stat-violet { background: linear-gradient(135deg, #4f3fc4, var(--violet-500)); }
.stat-ink { background: linear-gradient(135deg, var(--navy-950), #1c3c63); }
.stat-green { background: linear-gradient(135deg, #0a7a63, #1fb58c); }

.module-panel .nav-tabs .nav-link { font-weight: 700; color: var(--muted); white-space: nowrap; }
/* Many tabs on a phone scroll sideways instead of widening the page (NFR-04). */
.module-panel .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.module-panel .nav-tabs .nav-link.active { color: var(--navy-800); border-bottom: 3px solid var(--teal-500); }
.mini-stat { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; height: 100%; background: #fff; }
.mini-stat .kicker { font-size: .72rem; font-weight: 800; letter-spacing: .06rem; text-transform: uppercase; color: var(--muted); }
.mini-stat .value { font-size: 1.6rem; font-weight: 800; color: var(--navy-900); }
.mini-stat .hint { font-size: .85rem; color: var(--muted); }
.mini-stat .links { margin-top: .5rem; display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- Tables ---------- */
table.dataTable thead th { background: #f3f8fd; color: var(--navy-900); font-weight: 700; white-space: nowrap; }
table.dataTable td { vertical-align: middle; }
.dt-buttons .btn { background: #fff; border: 1px solid var(--line); color: var(--navy-800); }
.dt-buttons .btn:hover { background: #eef5fb; }
.badge-soft-success { background: rgba(22, 182, 169, .14); color: #0b7d74; }
.badge-soft-muted { background: #eef2f6; color: var(--muted); }
.badge-soft-danger { background: rgba(228, 88, 108, .14); color: #b7283e; }
.badge-soft-warning { background: rgba(245, 184, 75, .2); color: #8f5d07; }
.badge-soft-info { background: rgba(70, 199, 238, .16); color: #11688a; }

.alert-row { display: flex; gap: .8rem; align-items: flex-start; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .dot { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 34px; }

/* Select2 alignment with Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection { border-color: var(--line); min-height: 38px; }
.select-with-add .select2-container { flex: 1 1 auto; min-width: 0; }
.select-with-add .select2-selection { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.select-with-add .quick-add-btn { border-color: var(--line); }

.guide-nav { position: sticky; top: 1rem; }
@media (max-width: 991px) { .guide-nav { position: static; } }

/* ---------- Booking workflow ---------- */
.wf-steps { display: flex; list-style: none; padding: 0; margin: 0 0 1.2rem; gap: .25rem; overflow-x: auto; }
.wf-steps li { flex: 1 1 0; min-width: 84px; display: flex; flex-direction: column; align-items: center; gap: .35rem; position: relative; color: var(--muted); font-size: .82rem; font-weight: 700; }
.wf-steps li::before { content: ""; position: absolute; top: 17px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.wf-steps li:first-child::before { display: none; }
.wf-steps .wf-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #eef3f8; border: 2px solid var(--line); position: relative; z-index: 1; }
.wf-steps li.done { color: var(--navy-800); }
.wf-steps li.done::before, .wf-steps li.current::before { background: var(--teal-500); }
.wf-steps li.done .wf-dot { background: var(--teal-500); border-color: var(--teal-500); color: #fff; }
.wf-steps li.current .wf-dot { background: var(--navy-800); border-color: var(--navy-800); color: #fff; box-shadow: 0 0 0 5px rgba(18, 56, 97, .15); }
.wf-steps li.current { color: var(--navy-900); }
.wf-steps li.cancelled .wf-dot { background: var(--rose-500); border-color: var(--rose-500); }
.wf-steps li.cancelled::before { background: var(--rose-500); }
.wf-subtitle { font-size: .75rem; font-weight: 800; letter-spacing: .06rem; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }
.wf-checklist li { display: flex; gap: .5rem; padding: .3rem 0; }
.wf-checklist li.ok i { color: var(--teal-500); }
.wf-checklist li.fail i { color: var(--rose-500); }
.wf-checklist li.todo i { color: var(--muted); }
.wf-timeline { list-style: none; padding: 0 0 0 1rem; margin: 0; border-left: 2px solid var(--line); }
.wf-timeline li { position: relative; padding: 0 0 .7rem .6rem; }
.wf-timeline li::before { content: ""; position: absolute; left: -1.42rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan-400); border: 2px solid #fff; }

/* Fields filled in by smart forms flash briefly so the change is noticed. */
.autofilled, .autofilled .select2-selection { animation: autofill-flash 1.2s ease; }
@keyframes autofill-flash { 0% { background-color: rgba(22, 182, 169, .28); } 100% { background-color: transparent; } }

.app-footer { background: transparent; border-top: 1px solid var(--line); }

/* ---------- Login ---------- */
.login-shell {
    min-height: 100vh;
    background: radial-gradient(circle at 15% 10%, rgba(70, 199, 238, .25), transparent 30rem),
                linear-gradient(135deg, var(--navy-950), var(--navy-800) 60%, #0e6f73);
}
.login-wrap {
    min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem;
    align-items: center; max-width: 1100px; margin: 0 auto; padding: 2rem 1rem;
}
.login-brand { color: #fff; }
.login-brand h1 { font-weight: 800; font-size: 2.4rem; margin: .3rem 0 .8rem; }
.login-brand p { color: rgba(255, 255, 255, .78); font-size: 1.1rem; }
.login-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; }
.login-points li { display: flex; gap: .6rem; align-items: center; color: #d7eef8; }
.login-points i { color: var(--cyan-400); font-size: 1.2rem; }
.login-card { border: 0; box-shadow: 0 30px 60px rgba(0, 0, 0, .3); }
@media (max-width: 860px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-brand { text-align: center; }
    .login-points { display: none; }
}

@media (max-width: 576px) {
    .screen-hero { flex-direction: column; align-items: flex-start; }
    .hero-orbit { display: none; }
}

@media print {
    .app-sidebar, .app-header, .hero-actions, .dt-buttons, .dt-search { display: none !important; }
}

/* ---------- Tyre layout (vehicle, installation, maintenance) ---------- */
.tyre-layout .tl-sections { display: flex; flex-wrap: wrap; gap: 1rem; }
.tl-section { border: 1px dashed var(--bs-border-color); border-radius: .75rem; padding: .75rem 1rem; min-width: 260px; }
.tl-section-title { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-secondary-color); margin-bottom: .5rem; }
.tl-axle { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.tl-axle-no { font-size: .7rem; color: var(--bs-secondary-color); width: 1.6rem; }
.tl-side { display: flex; gap: .3rem; }
.tl-bar { flex: 1 1 40px; min-width: 40px; height: 6px; border-radius: 3px; background: var(--bs-secondary-bg); }
.tl-slot { display: flex; flex-direction: column; align-items: center; gap: .15rem; border: 0; background: none; padding: 0; cursor: pointer; }
.tl-slot .tl-tyre { width: 22px; height: 44px; border-radius: 6px; border: 2px solid var(--bs-border-color); background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(0,0,0,.06) 4px 6px); }
.tl-slot.fitted .tl-tyre { background-color: #2b3a4a; border-color: #2b3a4a; }
.tl-slot.empty .tl-tyre { border-style: dashed; border-color: var(--bs-warning); }
.tl-slot.selected .tl-tyre { outline: 3px solid var(--bs-primary); outline-offset: 2px; }
.tl-slot:hover .tl-tyre { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.tl-slot .tl-text { font-size: .62rem; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bs-body-color); }
.attendance-tiles .btn { min-width: 6.5rem; }

/* ---------- Form validation ---------- */
.select2.is-invalid .select2-selection { border-color: var(--bs-danger) !important; box-shadow: 0 0 0 .2rem rgba(220,53,69,.15); }

/* ---------- Phone layout: grid rows become cards ---------- */
@media (max-width: 575.98px) {
    table.data-table-server thead, table.data-table thead { display: none; }
    table.data-table-server tbody tr, table.data-table tbody tr { display: block; border: 1px solid var(--bs-border-color); border-radius: .6rem; margin-bottom: .6rem; padding: .35rem .6rem; background: var(--bs-body-bg); }
    table.data-table-server tbody td, table.data-table tbody td { display: flex; justify-content: space-between; gap: 1rem; border: 0 !important; padding: .2rem 0 !important; text-align: right !important; }
    table.data-table-server tbody td::before, table.data-table tbody td::before { content: attr(data-label); font-weight: 600; color: var(--bs-secondary-color); text-align: left; flex-shrink: 0; }
    table.data-table-server tbody td:last-child::before, table.data-table tbody td:last-child:empty::before { content: none; }
    table.data-table tfoot { display: none; }
    /* The cards use the full width of the screen (DataTables sets a fixed table width otherwise). */
    table.data-table-server, table.data-table { display: block; width: 100% !important; }
    table.data-table-server tbody, table.data-table tbody { display: block; width: 100%; }
}

/* ---------- Company branding (Company:LogoUrl / Company:MarkUrl) ---------- */
.brand-logo { width: 34px; height: 34px; border-radius: 8px; background: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-logo img { width: 28px; height: 28px; object-fit: contain; }
.login-logo { display: inline-block; background: #fff; border-radius: 1rem; padding: .6rem 1rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-logo img { height: 110px; width: auto; display: block; }
@media (max-width: 991.98px) { .login-logo img { height: 80px; } }

/* Long unbroken text (a very long name or description) wraps inside its card instead of widening the page. Table cells
   break only words that do not fit ("break-word" keeps whole words together), so a column never shrinks to one letter
   per line; wide tables scroll inside .table-responsive. Badges and dates stay on one line. */
.card-body, .list-group-item, .badge { overflow-wrap: anywhere; }
.table td, .table th { overflow-wrap: break-word; word-break: normal; }
.table td .badge, .list-group-item .badge { overflow-wrap: normal; white-space: nowrap; }
.badge { white-space: normal; }

/* Report a bug: top-bar button, dialog and the bug report pages. */
.bug-report-btn { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .28); color: inherit; font-weight: 600; }
.bug-report-btn:hover, .bug-report-btn:focus { background: rgba(255, 255, 255, .22); color: inherit; }
.bug-modal-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: rgba(228, 88, 108, .12); color: var(--rose-500); font-size: 1.2rem; flex: 0 0 auto; }
.bug-modal #bugTitle:focus { background: #fff8e1; }
.bug-drop { border: 2px dashed var(--line); border-radius: 12px; padding: 1rem; text-align: center; background: #fbfdff; }
.bug-drop.is-over { border-color: var(--teal-500); background: rgba(22, 182, 169, .06); }
.bug-drop img { max-height: 220px; }
.bug-card { transition: box-shadow .15s ease, transform .15s ease; }
.bug-card:hover { box-shadow: 0 .4rem 1.2rem rgba(11, 31, 58, .08); transform: translateY(-1px); }
.bug-status { min-width: 64px; }
.bug-last-reply { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bug-pre { white-space: pre-wrap; }
.bug-errors { white-space: pre-wrap; word-break: break-word; font-size: .78rem; background: #f6f8fb; border-radius: 8px; padding: .6rem; max-height: 320px; overflow: auto; }
.bug-shot { max-height: 520px; }
.bug-reply { border-left: 3px solid var(--line); padding: .35rem 0 .35rem .8rem; margin-bottom: .8rem; }
.bug-reply.is-dev { border-left-color: var(--teal-500); }

/* Breadcrumb trail above each screen. */
.vms-breadcrumb .breadcrumb { font-size: .82rem; background: transparent; padding: 0; }
.vms-breadcrumb .breadcrumb-item a { color: var(--navy-700); text-decoration: none; }
.vms-breadcrumb .breadcrumb-item a:hover { text-decoration: underline; }
.vms-breadcrumb .breadcrumb-item.active { color: var(--muted); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) { .vms-breadcrumb .breadcrumb-item:not(:first-child):not(:last-child):not(:nth-last-child(2)) { display: none; } }
