/* ==================================================================
   MIDSOFT APP UI – styles
   ------------------------------------------------------------------
   Phone-first app styles on top of Bootstrap 5.3, from Skiptrak Solo.
   Colours are set once in the BRAND block below.
   Generic components (shell, cards, lists, sheets, forms…) are listed
   in references/components.md. Some sections are named after the app
   they came from (e.g. "JOBS LIST", .job-card) – the classes work for
   any kind of item and are documented that way.
   ================================================================== */

:root {
    /* ----------------------------------------------------------------
       BRAND – change these four (and the two -rgb lines to match) and
       the whole app follows. Defaults: Midsoft teal / red / grey.
       ---------------------------------------------------------------- */
    --app-primary:      #309CAE;   /* main colour: links, highlights, tints */
    --app-primary-dark: #23808F;   /* darker main colour: buttons (readable with white text) */
    --app-alert:        #E30613;   /* second colour: warnings, "on stop", urgent */
    --app-grey:         #575756;   /* main text */
    --app-primary-rgb:  48 156 174;   /* --app-primary as "R G B" (for see-through tints) */
    --app-alert-rgb:    227 6 19;     /* --app-alert as "R G B" */

    /* Supporting colours */
    --app-ink:      var(--app-grey);
    --app-muted:    #85857F;   /* hints, small print */
    --app-field:    #F1F3F3;   /* input background */
    --app-field-readonly: #E4E7E7;   /* read-only input background (a touch darker) */
    --app-surface:  #FFFFFF;   /* card / page background */
    --app-line:     #DDE1E2;   /* borders */
    --app-page:     #F4F6F6;   /* background behind app pages */
    --app-accent-text: var(--app-primary-dark);   /* main colour used for text / icons */

    --radius-field:  14px;

    /* Hand our colours to Bootstrap */
    --bs-body-font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color:   var(--app-ink);
    --bs-body-bg:      var(--app-surface);
    --bs-border-color: var(--app-line);
    --bs-focus-ring-color: rgb(var(--app-primary-rgb) / .35);
    --bs-danger:       var(--app-alert);
}

/* Tell the browser which mode is showing (form controls, scrollbars, and no forced darkening) */
:root                   { color-scheme: light; }
[data-bs-theme="dark"]  { color-scheme: dark; }

[data-bs-theme="dark"] {
    --app-ink:      #ECEDED;
    --app-muted:    #A3A6A6;
    --app-field:    #2A2D2E;
    --app-field-readonly: #222526;
    --app-surface:  #1D1F20;
    --app-line:     #383C3D;
    --app-page:     #141617;
    --app-accent-text: #5EC0D1;

    --bs-body-color: var(--app-ink);
    --bs-body-bg:    var(--app-surface);
}

/* Keep content clear of the phone home bar */
:root {
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; }

body {
    background: var(--app-surface);
    font-feature-settings: "tnum" 1;   /* numbers line up neatly */
    -webkit-tap-highlight-color: transparent;
}


/* ==================================================================
   LOGIN PAGE LAYOUT
   Phone: logo panel on top, form below.
   PC:    logo panel on the left, form on the right.
   ================================================================== */

.login-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* ---- Brand panel ---- */
.brand-panel {
    position: relative;
    background: var(--app-surface);
    padding: calc(env(safe-area-inset-top, 0px) + 2rem) 1.5rem 2.5rem;
}

.brand-inner { max-width: 26rem; }

.brand-logo {
    width: 104px;
    height: auto;
    display: block;
    margin-bottom: 1rem;
    animation: logo-in .8s cubic-bezier(.3, 1.3, .5, 1) both;
}

/* The one bit of motion: the logo turns into place when the page opens */
@keyframes logo-in {
    from { transform: rotate(-90deg) scale(.85); opacity: 0; }
    to   { transform: rotate(0)      scale(1);   opacity: 1; }
}

.brand-name {
    font-stretch: 125%;                   /* Archivo's wide cut */
    font-weight: 800;
    font-size: clamp(2.4rem, 9vw, 3.6rem);
    line-height: .95;
    letter-spacing: -.02em;
    color: var(--app-ink);
    margin: 0;
    display: inline;
}

.brand-edition {
    display: inline-block;
    vertical-align: .55em;
    margin-left: .4rem;
    padding: .15rem .55rem;
    background: var(--app-alert);
    color: #FFFFFF;
    border-radius: 6px;
    font-weight: 700;
    font-size: .95rem;
    font-stretch: 100%;
}

.brand-line {
    margin: .9rem 0 0;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--app-muted);
    max-width: 22rem;
}

/* Divider split teal | red, like the two halves of the logo rings */
.brand-split {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 8px;
    background: linear-gradient(90deg, var(--app-primary) 50%, var(--app-alert) 50%);
}

/* ---- Form ---- */
.login-sheet {
    flex: 1;
    background: var(--app-surface);
    padding: 2rem 1.5rem 1.5rem;
}

.login-sheet form,
.login-sheet .alert,
.sheet-title { max-width: 26rem; }

.sheet-title {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}

.app-version {
    margin: 2rem 0 0;
    font-size: .8rem;
    color: var(--app-muted);
}


/* ==================================================================
   FORM CONTROLS
   ================================================================== */

.login-sheet .form-control {
    background: var(--app-field);
    border: 2px solid transparent;
    border-radius: var(--radius-field);
    color: var(--app-ink);
    min-height: 3.75rem;                  /* big enough for thumbs */
    font-size: 1.05rem;
}

.login-sheet .form-control:focus {
    background: var(--app-surface);
    border-color: var(--app-primary);
    box-shadow: 0 0 0 4px var(--bs-focus-ring-color);
}

.login-sheet .form-floating > label { color: var(--app-muted); }
.login-sheet .form-text { color: var(--app-muted); }

/* Serial number: slightly spaced digits so they're easy to check */
.serial-input {
    letter-spacing: .12em;
    font-weight: 600;
}

/* Password field + eye button share one rounded box */
.login-sheet .input-group .form-floating .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-reveal {
    background: var(--app-field);
    border: 2px solid transparent;
    border-left: 0;
    border-radius: 0 var(--radius-field) var(--radius-field) 0 !important;
    color: var(--app-muted);
    padding: 0 1.1rem;
    font-size: 1.2rem;
}
.btn-reveal:hover,
.btn-reveal:focus-visible { color: var(--app-primary); background: var(--app-field); }

/* Red edge when a field fails the check */
.was-validated .form-control:invalid { border-color: var(--app-alert); }
.was-validated .input-group:has(.form-control:invalid) .btn-reveal { border-color: var(--app-alert); }
.was-validated .input-group:has(.form-control:invalid) > .invalid-feedback { display: block; }
.invalid-feedback { color: var(--app-alert); }

.form-check-input:checked {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}
.form-check-input:focus { box-shadow: 0 0 0 4px var(--bs-focus-ring-color); border-color: var(--app-primary); }

/* Sign-in button */
.btn-signin {
    background: var(--app-primary-dark);
    color: #FFFFFF;
    border: 0;
    border-radius: var(--radius-field);
    min-height: 3.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
}
.btn-signin:hover,
.btn-signin:disabled { background: var(--app-primary-dark); color: #FFFFFF; filter: brightness(1.1); }
.btn-signin:active   { transform: scale(.985); }
.btn-signin:focus-visible { box-shadow: 0 0 0 4px var(--bs-focus-ring-color); }

/* Error message box */
.login-sheet .alert-danger {
    border-radius: var(--radius-field);
    border: 0;
    border-left: 4px solid var(--app-alert);
    background: rgb(var(--app-alert-rgb) / .08);
    color: var(--app-ink);
}
.login-sheet .alert-danger .bi { color: var(--app-alert); }


/* ==================================================================
   BIGGER SCREENS (tablet landscape / PC)
   ================================================================== */
@media (min-width: 992px) {
    .login-shell {
        flex-direction: row;
        height: 100%;
    }

    .brand-panel {
        flex: 1 1 50%;
        display: flex;
        align-items: center;
        padding: 4rem;
        background: var(--app-field);
    }

    .brand-logo { width: 180px; margin-bottom: 2rem; }

    /* split runs down the edge on PC: teal top, red bottom */
    .brand-split {
        left: auto; top: 0; right: 0; bottom: 0;
        width: 8px; height: auto;
        background: linear-gradient(180deg, var(--app-primary) 50%, var(--app-alert) 50%);
    }

    .login-sheet {
        flex: 1 1 50%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 4rem 5rem;
        overflow-y: auto;
    }

    .app-version { margin-top: 3rem; }
}


/* ==================================================================
   ACCESSIBILITY
   ================================================================== */
@media (prefers-reduced-motion: reduce) {
    .brand-logo { animation: none; }
    .btn-signin:active { transform: none; }
}


/* ==================================================================
   APP PAGES (after login)
   Phone: top bar + bottom bar.   PC: sidebar on the left.
   ================================================================== */

.app-page { background: var(--app-page); }

.app-shell {
    min-height: 100%;
    display: flex;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    /* bottom space so the phone bottom bar never covers content */
    padding: 1.25rem 1rem calc(6rem + env(safe-area-inset-bottom, 0px));
}

/* Round badge with the user's initials */
.avatar {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: var(--app-primary-dark);
    color: #FFFFFF;
    font-weight: 700;
    font-size: .9rem;
    display: grid;
    place-items: center;
}


/* ---- Phone top bar ---- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 0px) + .6rem) 1rem .6rem;
    background: color-mix(in srgb, var(--app-surface) 90%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
/* teal | red line under the bar, like the logo */
.app-topbar::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--app-primary) 50%, var(--app-alert) 50%);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--app-ink);
    text-decoration: none;
}
.app-brand img { width: 34px; height: 34px; }
.app-brand .brand-name { font-size: 1.35rem; }


/* ---- Phone bottom bar ---- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1030;
    display: flex;
    padding: .4rem .25rem calc(.4rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--app-surface) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--app-line);
}

.bottom-nav a,
.bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .2rem 0;
    background: none;
    border: 0;
    color: var(--app-muted);
    font-size: .72rem;
    font-weight: 600;
    text-decoration: none;
}

.bottom-nav .bi {
    font-size: 1.3rem;
    line-height: 1;
    padding: .3rem 1.15rem;
    border-radius: 999px;
    transition: background-color .2s;
}

.bottom-nav .active { color: var(--app-accent-text); }
.bottom-nav .active .bi { background: rgb(var(--app-primary-rgb) / .16); }


/* ---- Phone "More" sheet ---- */
.more-sheet {
    height: auto !important;
    border-radius: 24px 24px 0 0;
    border: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-handle {
    width: 40px;
    height: 4px;
    margin: .6rem auto 0;
    border-radius: 2px;
    background: var(--app-line);
}
.more-sheet .offcanvas-header { gap: .75rem; }
.more-user { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.more-user small { color: var(--app-muted); }
.more-sheet .offcanvas-body { padding-top: 0; }

.more-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .95rem 1rem;
    border-radius: 14px;
    color: var(--app-ink);
    font-weight: 600;
    text-decoration: none;
}
.more-link .bi { font-size: 1.25rem; color: var(--app-muted); }
.more-link:hover,
.more-link.active { background: var(--app-field); }
.more-link.signout,
.more-link.signout .bi { color: var(--app-alert); }


/* ---- PC sidebar ---- */
.app-sidebar {
    position: sticky;
    top: 0;
    width: 264px;
    height: 100vh;
    flex-shrink: 0;
    flex-direction: column;
    padding: 1.5rem 1rem;
    background: var(--app-surface);
    border-right: 1px solid var(--app-line);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 .5rem 1.75rem;
    color: var(--app-ink);
    text-decoration: none;
}
.sidebar-brand img { width: 40px; height: 40px; }
.sidebar-brand .brand-name { font-size: 1.45rem; }
.sidebar-brand .brand-edition { margin-left: 0; vertical-align: middle; font-size: .72rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: .2rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .7rem .85rem;
    border-radius: 12px;
    color: var(--app-ink);
    font-weight: 500;
    text-decoration: none;
}
.sidebar-link .bi { font-size: 1.2rem; color: var(--app-muted); }
.sidebar-link:hover { background: var(--app-field); }
.sidebar-link.active {
    background: rgb(var(--app-primary-rgb) / .12);
    color: var(--app-accent-text);
    font-weight: 700;
}
.sidebar-link.active .bi { color: var(--app-accent-text); }

.sidebar-user {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem .5rem 0;
    border-top: 1px solid var(--app-line);
}
.sidebar-user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-user-text small { color: var(--app-muted); }
.sidebar-signout {
    color: var(--app-muted);
    font-size: 1.25rem;
    padding: .25rem .4rem;
    border-radius: 8px;
}
.sidebar-signout:hover { color: var(--app-alert); background: var(--app-field); }


/* ==================================================================
   DASHBOARD
   ================================================================== */

.dash-greeting { margin: .5rem 0 1.5rem; }
.dash-greeting h1,
.page-head h1 {
    margin: 0;
    font-stretch: 115%;
    font-weight: 800;
    font-size: clamp(1.7rem, 6vw, 2.4rem);
    letter-spacing: -.02em;
    line-height: 1.1;
}
.dash-greeting p,
.page-head p {
    margin: .35rem 0 0;
    color: var(--app-muted);
    font-weight: 500;
}

.dash-grid { display: grid; gap: 1rem; }

/* ---- Big Jobs tile ---- */
.dash-hero {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 210px;
    padding: 1.5rem;
    border-radius: 24px;
    background: var(--app-primary-dark);
    color: #FFFFFF;
    text-decoration: none;
}
.dash-hero:hover { color: #FFFFFF; }

/* Two half-red rings in the corner, echoing the logo */
.dash-hero::before,
.dash-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    border-style: solid;
    transform: rotate(45deg);
}
.dash-hero::before {               /* outer ring: red on the right */
    width: 300px; height: 300px;
    right: -110px; bottom: -170px;
    border-width: 22px;
    border-color: var(--app-alert) var(--app-alert) rgba(255,255,255,.14) rgba(255,255,255,.14);
}
.dash-hero::after {                /* inner ring: red on the left */
    width: 196px; height: 196px;
    right: -58px; bottom: -118px;
    border-width: 16px;
    border-color: rgba(255,255,255,.14) rgba(255,255,255,.14) var(--app-alert) var(--app-alert);
}

.hero-icon {
    width: 3.5rem;
    height: 3.5rem;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, .16);
    font-size: 1.75rem;
}

.hero-go {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 2.75rem;
    height: 2.75rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #FFFFFF;
    color: var(--app-primary-dark);
    font-size: 1.25rem;
    transition: transform .2s;
}
.dash-hero:hover .hero-go { transform: translateX(4px); }

.hero-text h2 {
    margin: 1.75rem 0 .3rem;
    font-stretch: 125%;
    font-weight: 800;
    font-size: 2.4rem;
    line-height: 1;
}
.hero-text p { margin: 0; max-width: 16rem; opacity: .9; }

/* ---- Section rows ---- */
.dash-list { display: flex; flex-direction: column; gap: .75rem; }

.dash-row {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    color: var(--app-ink);
    text-decoration: none;
    transition: border-color .2s;
}
.dash-row:hover { border-color: var(--app-primary); color: var(--app-ink); }

.row-icon {
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 1.35rem;
    background: var(--app-field);
    color: var(--app-ink);
}
.tone-teal .row-icon { background: rgb(var(--app-primary-rgb) / .14); color: var(--app-accent-text); }
.tone-red  .row-icon { background: rgb(var(--app-alert-rgb) / .09);   color: var(--app-alert); }

.row-text  { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 700; font-size: 1.08rem; }
.row-desc  { display: block; color: var(--app-muted); font-size: .9rem; }
.row-chevron { color: var(--app-muted); }

/* ---- Business details reminder ---- */
.setup-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1.1rem 1.25rem;
    border-radius: 18px;
    border: 1.5px dashed var(--app-line);
}
.setup-note .row-icon { background: rgb(var(--app-alert-rgb) / .09); color: var(--app-alert); }
.setup-text { flex: 1 1 14rem; display: flex; flex-direction: column; }
.setup-text span { color: var(--app-muted); font-size: .92rem; }

.btn-setup {
    border: 1.5px solid var(--app-primary-dark);
    border-radius: 12px;
    color: var(--app-accent-text);
    font-weight: 700;
    padding: .55rem 1.1rem;
}
.btn-setup:hover { background: var(--app-primary-dark); border-color: var(--app-primary-dark); color: #FFFFFF; }

@media (max-width: 575.98px) {
    .setup-note .btn-setup { width: 100%; }
}

/* ---- Placeholder section pages ---- */
.page-head { margin: .5rem 0 1.5rem; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 1.5rem;
    border-radius: 24px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
}
.empty-state .row-icon { width: 4rem; height: 4rem; font-size: 1.8rem; background: rgb(var(--app-primary-rgb) / .14); color: var(--app-accent-text); }
.empty-state h2 { margin: 1.25rem 0 .35rem; font-size: 1.25rem; font-weight: 700; }
.empty-state p  { color: var(--app-muted); margin-bottom: 1.5rem; }


/* ---- PC sizes ---- */
@media (min-width: 768px) {
    .dash-grid { grid-template-columns: 1.15fr 1fr; }
    .dash-hero { min-height: 280px; padding: 2rem; }
    .hero-go   { top: 2rem; right: 2rem; }
    .hero-text h2 { font-size: 3rem; }
}

@media (min-width: 992px) {
    .app-content { padding: 2.5rem 3rem; }
    .dash-greeting { margin-bottom: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .dash-hero:hover .hero-go { transform: none; }
}


/* ==================================================================
   MESSAGES ("Job completed" etc.)
   ================================================================== */
.flash {
    border: 0;
    border-left: 4px solid;
    border-radius: 14px;
    color: var(--app-ink);
    font-weight: 500;
}
.flash.alert-success { background: rgb(var(--app-primary-rgb) / .12); border-color: var(--app-primary); }
.flash.alert-danger  { background: rgb(var(--app-alert-rgb) / .08);   border-color: var(--app-alert); }


/* ==================================================================
   SHARED: little status labels and slide-up sheets
   ================================================================== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    background: var(--app-field);
    color: var(--app-ink);
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}
.chip-teal { background: rgb(var(--app-primary-rgb) / .15); color: var(--app-accent-text); }
.chip-red  { background: rgb(var(--app-alert-rgb) / .1);    color: var(--app-alert); }

.job-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.job-chips:empty { display: none; }

.action-sheet {
    height: auto !important;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    border: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.action-sheet .offcanvas-title { font-weight: 800; font-stretch: 110%; font-size: 1.3rem; }
.action-sheet .form-label { font-weight: 600; }
.sheet-intro { color: var(--app-muted); font-size: .92rem; }

.sheet-input {
    background-color: var(--app-field);
    border: 2px solid transparent;
    border-radius: 14px;
    min-height: 3.25rem;
    font-size: 1.05rem;
}
.sheet-input:focus {
    background-color: var(--app-surface);
    border-color: var(--app-primary);
    box-shadow: 0 0 0 4px var(--bs-focus-ring-color);
}

/* Read-only boxes: light grey text on a slightly darker box, so it's clear they can't be typed in */
input[readonly],
textarea[readonly],
input[readonly]:focus,
textarea[readonly]:focus { color: var(--app-muted); background-color: var(--app-field-readonly); }
input[readonly]::placeholder,
textarea[readonly]::placeholder { color: var(--app-muted); }

/* Big teal button for the main thing to do */
.btn-main-action {
    min-height: 3.5rem;
    border: 0;
    border-radius: 14px;
    background: var(--app-primary-dark);
    color: #FFFFFF;
    font-weight: 700;
    font-size: 1.05rem;
}
.btn-main-action:hover,
.btn-main-action:focus-visible { background: var(--app-primary-dark); color: #FFFFFF; filter: brightness(1.1); }
.btn-main-action .bi { margin-right: .35rem; }

@media (min-width: 992px) {
    /* On a PC the sheets sit in the middle rather than full width */
    .action-sheet,
    .more-sheet { width: 560px; margin: 0 auto; }
}


/* ==================================================================
   JOBS LIST
   ================================================================== */
.list-hint {
    margin: -.75rem 0 1rem;
    color: var(--app-muted);
    font-size: .82rem;
}

.job-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}

.job-card {
    position: relative;
    overflow: hidden;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: 18px;
    transition: border-color .15s, box-shadow .15s;
}
/* coloured stripe down the left = the job's label colour */
.job-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 7px;
    background: var(--job-colour);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .15);   /* keeps pale colours visible */
}

.job-main {
    padding: .9rem 1rem .9rem 1.35rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;    /* stops double-tap zooming the page */
}
.job-main:focus-visible { outline: 3px solid var(--bs-focus-ring-color); outline-offset: -3px; }

.job-top { display: flex; align-items: baseline; gap: .75rem; }
.job-title { flex: 1; font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.job-no { color: var(--app-muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }

.job-customer { margin-top: .15rem; color: var(--app-accent-text); font-weight: 600; }

.job-site {
    color: var(--app-muted);
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-card.is-done .job-title,
.job-card.is-done .job-customer { opacity: .6; }
.job-card.is-void .job-title { text-decoration: line-through; opacity: .6; }

.job-card.is-selected {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
}

/* Quick actions, shown after one tap */
.job-actions {
    display: none;
    border-top: 1px solid var(--app-line);
    margin-left: 7px;
}
.job-card.is-selected .job-actions { display: flex; animation: actions-in .18s ease-out; }

@keyframes actions-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

.job-actions > a,
.job-actions > form { flex: 1; display: flex; }

.job-actions a,
.job-actions button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .7rem .25rem;
    background: none;
    border: 0;
    color: var(--app-ink);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
}
.job-actions .bi { font-size: 1.25rem; color: var(--app-accent-text); }
/* thin line between each action */
.job-actions > * + * { border-left: 1px solid var(--app-line) !important; }
.job-actions a:hover,
.job-actions button:hover { background: var(--app-field); }


/* ---- Day switcher: floats above the bottom bar ---- */
.day-switcher-space { height: 6rem; }

.day-switcher {
    position: fixed;
    z-index: 1025;
    left: 50%;
    bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: .25rem;
    padding: .35rem;
    border-radius: 999px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}

.day-btn {
    width: 3.25rem;
    height: 3.25rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--app-alert);
    color: #FFFFFF;
    font-size: 1.35rem;
    text-decoration: none;
    transition: transform .12s;
}
.day-btn:hover  { color: #FFFFFF; filter: brightness(1.08); }
.day-btn:active { transform: scale(.92); }

.day-label {
    position: relative;
    min-width: 8.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 .75rem;
    line-height: 1.2;
    cursor: pointer;
}
.day-label strong { font-size: 1rem; }
.day-label small  { color: var(--app-muted); font-size: .78rem; font-weight: 600; }

/* The real date box is invisible and covers the label, so tapping opens the calendar */
.day-label input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

@media (min-width: 992px) {
    .day-switcher { bottom: 1.5rem; left: calc(50% + 132px); }   /* 132px = half the sidebar */
}


/* ==================================================================
   ONE JOB
   ================================================================== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-bottom: 1rem;
    color: var(--app-accent-text);
    font-weight: 700;
    text-decoration: none;
}

.job-hero {
    position: relative;
    overflow: hidden;
    padding: 1.25rem 1.25rem 1.25rem 1.6rem;
    border-radius: 22px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
}
.job-hero::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 8px;
    background: var(--job-colour);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .15);
}
.job-hero-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.job-hero .job-no { font-size: .98rem; }
.job-type {
    font-size: .98rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--app-muted);
}
.job-hero h1 {
    margin: .35rem 0 .2rem;
    font-stretch: 112%;
    font-weight: 800;
    font-size: clamp(1.45rem, 5.5vw, 2rem);
    line-height: 1.15;
    letter-spacing: -.01em;
}
.job-service {
    display: flex;
    align-items: flex-start;
    gap: .4rem;
    margin: .35rem 0 .3rem;
    padding: .45rem .7rem;
    border-radius: 10px;
    background: var(--app-field);
    font-weight: 700;
    line-height: 1.3;
}
.job-service .bi { color: var(--app-accent-text); margin-top: .1rem; }
.job-card .job-service { display: inline-flex; padding: .2rem .55rem; font-size: .88rem; margin: .3rem 0 .15rem; }

.job-hero-customer { margin: 0; color: var(--app-accent-text); font-weight: 600; font-size: 1.05rem; }

.job-actions-panel {
    display: flex;
    flex-direction: column;
    gap: .65rem;
    margin: 1rem 0;
}
.follow-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.follow-buttons .btn { min-height: 3.25rem; }
.undo-form { text-align: center; }
.undo-form .btn-link { color: var(--app-muted); font-size: .9rem; }

.linked-jobs { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1rem; }

.detail-grid { display: grid; gap: 1rem; }

.detail-card {
    padding: 1.15rem 1.25rem;
    border-radius: 20px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
}
.detail-card h2 {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .85rem;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--app-muted);
}
.detail-card h2 .count {
    padding: .05rem .5rem;
    border-radius: 999px;
    background: var(--app-field);
    color: var(--app-ink);
    letter-spacing: 0;
}

.site-address { margin: 0 0 .5rem; font-size: 1.05rem; font-weight: 500; line-height: 1.45; }

/* Navigation links: an address opens Google Maps, ///words open what3words */
.address-link { color: inherit; text-decoration: underline; text-decoration-color: var(--app-line);
                text-underline-offset: 3px; }
.address-link:hover, .address-link:focus { color: var(--app-accent-text); text-decoration-color: currentColor; }
.site-w3w { display: block; margin-top: .3rem; }
.w3w-link { color: var(--app-ink); font-weight: 600; text-decoration: none; }
.w3w-link:hover, .w3w-link:focus { text-decoration: underline; }
.w3w-slashes { color: var(--app-alert); font-weight: 700; margin-right: 1px; }
.site-contact { color: var(--app-muted); margin-bottom: .5rem; }
.site-note {
    margin-bottom: .5rem;
    padding: .6rem .8rem;
    border-radius: 12px;
    background: var(--app-field);
    font-size: .92rem;
}
.site-note .bi { color: var(--app-accent-text); margin-right: .25rem; }
.site-missing { color: var(--app-muted); margin: 0; }
.site-buttons { margin-top: .75rem; }
.site-buttons { display: flex; gap: .65rem; flex-wrap: wrap; }
.site-buttons .btn { flex: 1; min-height: 3rem; }

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .55rem 1.25rem;
    margin: 0;
}
.detail-list dt { color: var(--app-muted); font-weight: 500; }
.detail-list dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.job-comments {
    margin-top: 1rem;
    padding: .85rem 1rem;
    border-radius: 12px;
    background: var(--app-field);
    white-space: normal;
}

/* ---- Signatures ---- */
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.sig-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 7.5rem;
    padding: .75rem;
    border-radius: 16px;
    border: 2px dashed var(--app-line);
    background: transparent;
    color: var(--app-muted);
    font-weight: 600;
}
.sig-tile .bi { font-size: 1.6rem; color: var(--app-accent-text); }
.sig-tile:hover { border-color: var(--app-primary); }
.sig-tile.has-sig { border-style: solid; padding: .5rem; }
.sig-tile img {
    width: 100%;
    aspect-ratio: 5 / 2;
    object-fit: contain;
    border-radius: 10px;
    background: #FFFFFF;
}
.sig-label { font-size: .85rem; text-align: center; }

.sig-pad-wrap { position: relative; }
.sig-pad {
    display: block;
    width: 100%;
    height: 220px;
    border-radius: 16px;
    border: 2px dashed var(--app-line);
    background: #FFFFFF;
    touch-action: none;        /* drawing mustn't scroll the page */
    cursor: crosshair;
}
.sig-pad-hint {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    color: #B3B7B8;
    font-weight: 600;
    pointer-events: none;
}
.sig-error { min-height: 1.5rem; margin: .4rem 0; color: var(--app-alert); font-size: .9rem; font-weight: 600; }
.sig-buttons { display: grid; grid-template-columns: 1fr 2fr; gap: .65rem; }
.sig-buttons .btn { min-height: 3.5rem; }

/* ---- Photos ---- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: .6rem;
}
.photo-tile { position: relative; }
.photo-tile img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 14px;
    background: var(--app-field);
}
.photo-delete {
    position: absolute;
    top: .35rem;
    right: .35rem;
    width: 1.9rem;
    height: 1.9rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #FFFFFF;
    font-size: .8rem;
}

.photo-add {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    border-radius: 14px;
    border: 2px dashed var(--app-line);
    color: var(--app-accent-text);
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
}
.photo-add .bi { font-size: 1.6rem; }
.photo-add:hover { border-color: var(--app-primary); }
.photo-add { position: relative; }
/* The real file box: invisible but still "there", because some phones won't open a display:none file box */
.photo-add input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}
.photo-add.is-busy { opacity: .5; pointer-events: none; }
.photo-status { margin: .6rem 0 0; color: var(--app-muted); font-size: .9rem; }
.photo-status:empty { display: none; }

@media (min-width: 768px) {
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .job-actions-panel { flex-direction: row; flex-wrap: wrap; }
    .job-actions-panel > form:first-child { flex: 1 1 100%; }
    .follow-buttons { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .job-card.is-selected .job-actions { animation: none; }
    .day-btn:active { transform: none; }
}


/* ---- Waste card ---- */
.ewc-desc {
    margin: .4rem 0 1rem;
    color: var(--app-muted);
    font-size: .88rem;
    line-height: 1.35;
}
.ewc-desc:empty { margin-bottom: .75rem; }
.weight-group .form-control { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.weight-group .form-control:only-child { border-radius: 14px; }
.weight-group .input-group-text {
    border: 0;
    border-radius: 0 14px 14px 0;
    background: var(--app-line);
    color: var(--app-ink);
    font-weight: 600;
}
.weight-group .form-control:focus { z-index: 3; }

/* ---- Collection / exchange, below the photos ---- */
.follow-panel {
    margin-top: 1rem;
    padding: 1.15rem 1.25rem;
    border-radius: 20px;
    border: 1.5px dashed var(--app-line);
}
.follow-panel h2 {
    margin: 0 0 .85rem;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--app-muted);
}


/* ---- Waste & charges card ---- */
.field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin-bottom: .9rem;
}
.field-pair .form-label { white-space: nowrap; }
.per-unit { color: var(--app-muted); font-weight: 500; font-size: .85em; }

.money-group .input-group-text {
    border: 0;
    border-radius: 14px 0 0 14px;
    background: var(--app-line);
    color: var(--app-ink);
    font-weight: 700;
}
.money-group .form-control { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.money-group .form-control:focus { z-index: 3; }


.locked-note {
    padding: .6rem .8rem;
    border-radius: 12px;
    background: rgb(var(--app-alert-rgb) / .08);
    font-size: .9rem;
    font-weight: 600;
}
.locked-note .bi { color: var(--app-alert); margin-right: .25rem; }

.totals {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .45rem 1rem;
    margin: .5rem 0 0;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    background: var(--app-field);
}
.totals dt { color: var(--app-muted); font-weight: 500; }
.totals dt small { font-weight: 500; }
.totals dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals dd.is-zero { color: var(--app-muted); font-weight: 500; }
.totals .totals-line { padding-top: .5rem; border-top: 1px solid var(--app-line); color: var(--app-ink); font-weight: 700; }
.totals .totals-grand { font-size: 1.2rem; font-weight: 800; color: var(--app-ink); }


/* ---- Permit row (in Waste & charges) ---- */
.permit-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin-top: 1rem;
    padding: .85rem 1rem;
    border-radius: 14px;
    border: 1.5px dashed var(--app-line);
}
.permit-row .row-icon { width: 2.5rem; height: 2.5rem; font-size: 1.15rem; background: rgb(var(--app-alert-rgb) / .09); color: var(--app-alert); }
.permit-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.permit-info span { font-size: .9rem; }
.permit-row { flex-wrap: wrap; }
.permit-row .btn { flex: 1 1 100%; min-height: 3rem; }   /* button on its own line underneath */
.permit-details dd .chip { margin-left: .35rem; }


/* ---- Time on site ---- */
.btn-site {
    min-height: 3.5rem;
    border-radius: 14px;
    border: 2px solid var(--app-primary-dark);
    color: var(--app-accent-text);
    font-weight: 700;
    font-size: 1.05rem;
}
.btn-site:hover { background: var(--app-primary-dark); color: #FFFFFF; }
.btn-site .bi { margin-right: .35rem; }

.on-site-bar {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .75rem .75rem .75rem 1rem;
    border-radius: 16px;
    background: rgb(var(--app-primary-rgb) / .12);
    border: 1.5px solid var(--app-primary);
}
.on-site-text { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.on-site-text span { color: var(--app-muted); font-size: .9rem; }
.btn-finish {
    min-height: 3rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: 12px;
    background: var(--app-alert);
    color: #FFFFFF;
    font-weight: 700;
}
.btn-finish:hover { background: var(--app-alert); color: #FFFFFF; filter: brightness(1.08); }

/* gently pulsing dot = "you're on the clock" */
.on-site-pulse {
    width: .8rem;
    height: .8rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--app-primary);
    animation: on-site-pulse 1.6s ease-out infinite;
}
@keyframes on-site-pulse {
    0%   { box-shadow: 0 0 0 0 rgb(var(--app-primary-rgb) / .6); }
    100% { box-shadow: 0 0 0 .7rem rgb(var(--app-primary-rgb) / 0); }
}

.on-site-done {
    margin: 0;
    padding: .7rem 1rem;
    border-radius: 14px;
    background: var(--app-field);
    font-weight: 600;
}
.on-site-done .bi { color: var(--app-accent-text); margin-right: .3rem; }

.time-sum {
    margin: .75rem 0 0;
    padding: .6rem .8rem;
    border-radius: 12px;
    background: var(--app-field);
    font-size: .9rem;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .on-site-pulse { animation: none; }
}


/* ---- Folding card (Time on site): tap the heading to open ---- */
.fold-card { padding: 0; }
.fold-card summary {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.15rem 1.25rem;
    cursor: pointer;
    list-style: none;                 /* hide the browser's own triangle */
    -webkit-tap-highlight-color: transparent;
}
.fold-card summary::-webkit-details-marker { display: none; }
.fold-card summary h2 { margin: 0; flex: 1; }
.fold-summary { color: var(--app-ink); font-weight: 700; font-size: .92rem; }
.fold-chevron { color: var(--app-muted); transition: transform .2s; }
.fold-card[open] .fold-chevron { transform: rotate(180deg); }
.fold-card summary:focus-visible { outline: 3px solid var(--bs-focus-ring-color); outline-offset: -3px; border-radius: 20px; }
.fold-body { padding: 0 1.25rem 1.15rem; }

@media (prefers-reduced-motion: reduce) {
    .fold-chevron { transition: none; }
}


/* ---- Additional items ---- */
.item-list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.item-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--app-line);
}
.item-list li:first-child { padding-top: 0; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.item-text span { color: var(--app-muted); font-size: .88rem; }
.item-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.item-remove {
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--app-field);
    color: var(--app-muted);
}
.item-remove:hover { background: rgb(var(--app-alert-rgb) / .1); color: var(--app-alert); }
.item-sum { margin: 0 0 1rem; color: var(--app-muted); font-size: .92rem; }
.item-sum strong { color: var(--app-ink); }

.linked-jobs-bottom { margin: 1rem 0 0; }
.fold-card { scroll-margin-top: 5rem; }   /* not hidden under the top bar when jumped to */


/* ---- Service: big and clear on the job page ---- */
.service-block {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    margin: .6rem 0 .5rem;
    padding: .75rem .95rem;
    border-radius: 14px;
    background: rgb(var(--app-primary-rgb) / .12);
    border-left: 4px solid var(--app-primary);
}
.service-label {
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--app-accent-text);
}
.service-label .bi { margin-right: .2rem; }
.service-block strong { font-size: 1.2rem; line-height: 1.25; }
.service-block.is-missing { background: var(--app-field); border-left-color: var(--app-line); }
.service-block.is-missing strong { font-size: 1rem; color: var(--app-muted); font-weight: 600; }

/* ---- Site contact list ---- */
.contact-list { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.contact-list li { display: flex; align-items: baseline; gap: .5rem; overflow-wrap: anywhere; }
.contact-list .bi { color: var(--app-accent-text); }
.contact-list a { color: var(--app-ink); font-weight: 600; text-decoration: none; border-bottom: 1px dotted var(--app-muted); }
.contact-list small { color: var(--app-muted); }


/* ---- Wasted journey / void ---- */
.chip-purple { background: rgba(160, 64, 192, .13); color: #8A32A8; }
[data-bs-theme="dark"] .chip-purple { color: #CB8BE0; }

.status-banner {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .75rem .75rem .75rem 1rem;
    border-radius: 16px;
    border-left: 5px solid;
}
.status-banner > .bi { font-size: 1.4rem; }
.status-banner > div { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.status-banner span { color: var(--app-muted); font-size: .92rem; }
.status-banner .btn-link { font-weight: 700; color: var(--app-accent-text); }
.status-banner.is-void   { background: rgb(var(--app-alert-rgb) / .08);  border-color: var(--app-alert); }
.status-banner.is-void > .bi { color: var(--app-alert); }
.status-banner.is-wasted { background: rgba(160, 64, 192, .1); border-color: #A040C0; }
.status-banner.is-wasted > .bi { color: #A040C0; }

.problem-buttons { display: flex; gap: .65rem; }
.btn-problem {
    flex: 1;
    min-height: 2.75rem;
    border-radius: 12px;
    border: 1.5px solid var(--app-line);
    color: var(--app-muted);
    font-weight: 600;
    font-size: .92rem;
}
.btn-problem:hover { border-color: var(--app-alert); color: var(--app-alert); background: transparent; }


/* ---- Sub-headings inside a card (Tipping, Charges) ---- */
.form-subhead {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 1.4rem 0 .8rem;
    padding-top: 1rem;
    border-top: 1px solid var(--app-line);
    font-size: .95rem;
    font-weight: 800;
}
.form-subhead .bi { color: var(--app-accent-text); }
.same-ticket-row { display: flex; justify-content: flex-end; }
.same-ticket {
    /* Bootstrap's link-button colours, set to the app's teal in every state */
    --bs-btn-color: var(--app-accent-text);
    --bs-btn-hover-color: var(--app-accent-text);
    --bs-btn-active-color: var(--app-accent-text);
    padding: .3rem 0 0;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}


/* ---- Business details page ---- */
.logo-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo-preview {
    width: 9rem; height: 6rem;
    display: grid; place-items: center;
    border-radius: 14px; border: 2px dashed var(--app-line);
    background: #FFFFFF; overflow: hidden;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview span { color: #85857F; font-size: .85rem; }
.logo-controls { flex: 1; min-width: 12rem; }
.profile-form textarea.sheet-input { min-height: 0; }
.profile-save { margin-top: 1rem; }
@media (min-width: 768px) {
    .wide-card { grid-column: 1 / -1; }
    .profile-save { max-width: 26rem; margin-left: auto; }
}


/* ---- Email: who to send to ---- */
.send-to-list { display: flex; flex-direction: column; gap: .5rem; }
.send-to {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem .9rem;
    border-radius: 14px;
    border: 1.5px solid var(--app-line);
    cursor: pointer;
}
.send-to .form-check-input { width: 1.3rem; height: 1.3rem; margin: 0; flex-shrink: 0; }
.send-to span { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.send-to small { color: var(--app-muted); overflow-wrap: anywhere; }
.send-to:has(input:checked) { border-color: var(--app-primary); background: rgb(var(--app-primary-rgb) / .08); }
.send-to.is-empty { opacity: .55; cursor: default; }


/* ==================================================================
   CUSTOMERS
   ================================================================== */

/* Search box */
.search-bar {
    position: relative;
    margin-bottom: 1.25rem;
}
.search-bar > .bi {
    position: absolute;
    left: 1rem; top: 50%;
    transform: translateY(-50%);
    color: var(--app-muted);
    pointer-events: none;
}
.search-bar .form-control {
    min-height: 3.25rem;
    padding-left: 2.75rem;
    padding-right: 2.75rem;
    border-radius: 14px;
    border: 2px solid transparent;
    background-color: var(--app-surface);
    box-shadow: 0 0 0 1px var(--app-line);
}
.search-bar .form-control:focus { border-color: var(--app-primary); box-shadow: 0 0 0 4px var(--bs-focus-ring-color); }
.search-clear {
    position: absolute;
    right: .75rem; top: 50%;
    transform: translateY(-50%);
    color: var(--app-muted);
    padding: .25rem .4rem;
}

/* Account code badge */
.account-code {
    padding: .1rem .5rem;
    border-radius: 6px;
    background: var(--app-field);
    color: var(--app-ink);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .03em;
    white-space: nowrap;
}

.customer-card { --job-colour: var(--app-primary); }
.customer-card.is-on-stop { --job-colour: var(--app-alert); }
.customer-card .job-actions a { font-size: .7rem; line-height: 1.15; text-align: center; }
.customer-hero { --job-colour: var(--app-primary); }

/* Previous / next pages */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    color: var(--app-muted);
    font-weight: 600;
}

.onstop-switch .form-check-input { width: 2.6em; height: 1.4em; }
.onstop-switch .form-check-input:checked { background-color: var(--app-alert); border-color: var(--app-alert); }
.onstop-switch label { padding-left: .35rem; padding-top: .1rem; }
.onstop-switch small { color: var(--app-muted); }

/* Lists of sites / agreements, with buttons on the right */
.record-list { list-style: none; margin: 0 0 .9rem; padding: 0; }
.record-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--app-line);
}
.record-list li:first-child { padding-top: 0; }
.record-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.record-text span { font-size: .92rem; }
.record-text small { color: var(--app-muted); }
.record-buttons { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.record-buttons .btn-sm { border-radius: 10px; font-weight: 700; white-space: nowrap; }

.icon-btn {
    width: 2.4rem;
    height: 2.4rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--app-field);
    color: var(--app-ink);
    text-decoration: none;
}
.icon-btn:hover { color: var(--app-accent-text); }
.icon-btn.is-danger:hover { color: var(--app-alert); background: rgb(var(--app-alert-rgb) / .1); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Lists of jobs / invoices that link through */
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list a {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 0 .65rem .9rem;
    border-bottom: 1px solid var(--app-line);
    color: var(--app-ink);
    text-decoration: none;
}
.link-list a::before {             /* job colour stripe */
    content: "";
    position: absolute;
    left: 0; top: .6rem; bottom: .6rem;
    width: 4px;
    border-radius: 2px;
    background: var(--job-colour, var(--app-line));
}
.link-list a:hover strong { color: var(--app-accent-text); }
.link-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.link-main small { color: var(--app-muted); }
.link-side { display: flex; align-items: center; gap: .4rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Cards in a grid must never grow wider than their column (long drop-down
   options, e.g. waste code descriptions, would otherwise push the page sideways) */
.detail-grid > * { min-width: 0; }
.sheet-input, .form-select { max-width: 100%; }
/* Side-by-side boxes (and date boxes, which browsers give a minimum width) shrink to fit */
.field-pair > * { min-width: 0; }
.sheet-input[type="date"], .sheet-input[type="time"] { min-width: 0; width: 100%; }

/* ---- Customer page: summary in the heading, edit form folded away ---- */
.customer-summary { display: grid; gap: .75rem; margin-top: .75rem; }
@media (min-width: 576px) { .customer-summary { grid-template-columns: 1fr 1fr; } }
.edit-grid { gap: 0 2rem; }
.edit-block .form-subhead.mt-0 { margin-top: 0; padding-top: 0; border-top: 0; }
@media (max-width: 767.98px) { .edit-block + .edit-block .form-subhead { margin-top: 1.4rem; } }


/* ---- Jobs list: "Hide done jobs" switch ---- */
.hide-done {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin: -.5rem 0 1rem;
    color: var(--app-ink);
    font-weight: 600;
    font-size: .92rem;
    text-decoration: none;
}
.hide-done small { color: var(--app-muted); font-weight: 500; }
.hide-done-switch {
    position: relative;
    width: 2.6rem;
    height: 1.45rem;
    border-radius: 999px;
    background: var(--app-line);
    transition: background-color .15s;
}
.hide-done-switch::after {
    content: "";
    position: absolute;
    top: .2rem; left: .2rem;
    width: 1.05rem; height: 1.05rem;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: transform .15s;
}
.hide-done.is-on .hide-done-switch { background: var(--app-primary-dark); }
.hide-done.is-on .hide-done-switch::after { transform: translateX(1.15rem); }
.hide-done:hover { color: var(--app-accent-text); }
@media (prefers-reduced-motion: reduce) {
    .hide-done-switch, .hide-done-switch::after { transition: none; }
}


/* ---- Customer page: agreements select which jobs / invoices show ---- */
.agreement-list li {
    margin: 0 -.6rem;
    padding: .7rem .6rem;
    border-radius: 14px;
    border-bottom: 0;
    border: 1.5px solid transparent;
}
.agreement-list li + li { margin-top: .35rem; }
.agreement-list li.is-selected { border-color: var(--app-primary); background: rgb(var(--app-primary-rgb) / .08); }
.agreement-select { color: var(--app-ink); text-decoration: none; }
.agreement-select:hover strong { color: var(--app-accent-text); }
.agreement-select small { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .2rem; }
.agreement-select .chip { font-size: .7rem; padding: .1rem .45rem; }
.agreement-footer { display: flex; gap: .6rem; margin-top: .9rem; }
.agreement-footer .btn { flex: 1; }
.agreement-footer .btn.is-active { background: var(--app-primary-dark); color: #FFFFFF; border-color: var(--app-primary-dark); }

.history-column { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.showing-for { margin: -.5rem 0 .75rem; color: var(--app-muted); font-size: .9rem; }
.showing-for strong { color: var(--app-accent-text); }
#jobs, #invoices, #agreements, #sites { scroll-margin-top: 5rem; }
/* Phones: an agreement's buttons go on their own line under its details */
@media (max-width: 575.98px) {
    .agreement-list li { flex-wrap: wrap; }
    .agreement-list .agreement-select { flex: 1 1 100%; }
    .agreement-list .record-buttons { flex: 1 1 100%; justify-content: flex-end; }
}
.agreement-footer .btn { font-size: .92rem; white-space: nowrap; padding-left: .5rem; padding-right: .5rem; }

.last-job { margin-top: .3rem; color: var(--app-muted); font-size: .8rem; font-weight: 600; }
.last-job .bi { margin-right: .2rem; }

.new-customer-btn { display: flex; align-items: center; justify-content: center; gap: .4rem; width: 100%; margin-bottom: .9rem; }
@media (min-width: 768px) { .new-customer-btn { width: auto; display: inline-flex; padding: 0 1.5rem; } }


/* ---- Customers list: recent jobs inside a tapped card ---- */
.card-panel { display: none; margin-left: 7px; padding: .2rem 1rem .9rem; border-top: 1px solid var(--app-line); }
.job-card.is-selected .card-panel { display: block; animation: actions-in .18s ease-out; }
.recent-title { margin: .8rem 0 .4rem; font-size: .75rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--app-muted); }
.recent-empty { margin: .7rem 0 0; color: var(--app-muted); font-size: .9rem; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li {
    position: relative;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 0 .5rem .75rem;
    border-bottom: 1px solid var(--app-line);
}
.recent-list li:last-child { border-bottom: 0; }
.recent-list li::before {
    content: "";
    position: absolute;
    left: 0; top: .5rem; bottom: .5rem;
    width: 4px; border-radius: 2px;
    background: var(--job-colour, var(--app-line));
}
.recent-job { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; color: var(--app-ink); text-decoration: none; }
.recent-job strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-job small { color: var(--app-muted); }
.clone-btn { border-radius: 10px; font-weight: 700; white-space: nowrap; }

.bottom-nav button:disabled { opacity: .45; }

/* ---- On route ---- */
.btn-route {
    min-height: 3rem;
    border-radius: 14px;
    border: 1.5px dashed var(--app-primary-dark);
    color: var(--app-accent-text);
    font-weight: 700;
}
.btn-route:hover { background: rgb(var(--app-primary-rgb) / .1); color: var(--app-accent-text); }
.btn-route .bi, .on-route-bar .bi { margin-right: .35rem; }
.on-route-bar {
    padding: .7rem 1rem;
    border-radius: 14px;
    background: rgb(var(--app-primary-rgb) / .1);
    color: var(--app-accent-text);
}
.on-route-bar span { color: var(--app-muted); }
.chip-route { background: rgb(var(--app-primary-rgb) / .15); color: var(--app-accent-text); }
#signatures, #photos { scroll-margin-top: 5rem; }


/* ==================================================================
   INVOICES
   ================================================================== */
.page-buttons { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.page-buttons .btn { flex: 1 1 10rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 3rem; }
.btn-count {
    min-width: 1.5rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--app-alert);
    color: #FFFFFF;
    font-size: .8rem;
    line-height: 1.5rem;
}

.invoice-card { --job-colour: var(--app-alert); }
.invoice-card.is-paid { --job-colour: var(--app-primary); }
.invoice-sums {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .2rem .9rem;
    margin-top: .3rem;
    color: var(--app-muted);
    font-size: .88rem;
    font-variant-numeric: tabular-nums;
}
.invoice-sums strong { margin-left: auto; color: var(--app-ink); font-size: 1.05rem; }
.invoice-items .item-text span { color: var(--app-ink); font-size: .9rem; }
.invoice-items .item-text small { color: var(--app-muted); }

.invoice-hero { --job-colour: var(--app-alert); }
.invoice-hero a { color: inherit; }
.invoice-total-big { margin: .35rem 0 .2rem; font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Batch email */
.send-all { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; color: var(--app-muted); font-size: .9rem; cursor: pointer; }
.send-all .form-check-input { width: 1.2rem; height: 1.2rem; margin: 0; }
.batch-text { flex: 1; }
.send-to .item-total { flex-shrink: 0; }

/* Jobs not invoiced report */
.report-dates { margin-bottom: 1rem; }
.report-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem;
    margin-bottom: 1rem;
}
.report-summary div {
    display: flex;
    flex-direction: column;
    padding: .7rem .8rem;
    border-radius: 14px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
}
.report-summary span { color: var(--app-muted); font-size: .78rem; font-weight: 600; }
.report-summary strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) { .report-summary { grid-template-columns: repeat(2, 1fr); } }

/* Printing a page (e.g. the report): just the content */
@media print {
    .app-sidebar, .app-topbar, .bottom-nav, .no-print, .flash, .day-switcher { display: none !important; }
    .app-page, .app-content { background: #FFFFFF !important; padding: 0 !important; }
    .detail-card, .report-summary div { border-color: #999 !important; }
    .link-list a::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.batch-customer { font-size: .92rem; overflow-wrap: anywhere; }
.batch-email { overflow-wrap: anywhere; }

/* ---- Search with a button ---- */
.search-bar.has-button .form-control { padding-right: 8.5rem; }
.search-bar.has-button .search-clear { right: 6.4rem; }
.search-go {
    position: absolute;
    right: .35rem; top: 50%;
    transform: translateY(-50%);
    min-height: 2.6rem;
    padding: 0 1rem;
    border: 0;
    border-radius: 11px;
    background: var(--app-primary-dark);
    color: #FFFFFF;
    font-weight: 700;
}
.search-go:hover, .search-go:focus-visible { background: var(--app-primary-dark); color: #FFFFFF; filter: brightness(1.1); }

/* ---- Invoice payment ---- */
.paid-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .6rem; margin-bottom: .25rem; }
.paid-note .bi { color: var(--app-accent-text); }
.paid-note span { color: var(--app-muted); font-size: .9rem; }


/* ==================================================================
   LOOKUP TABLES
   ================================================================== */
.lookup-menu { display: grid; gap: .6rem; }
@media (min-width: 768px) { .lookup-menu { grid-template-columns: 1fr 1fr; } }
.lookup-tile {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .9rem 1rem;
    border-radius: 18px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    color: var(--app-ink);
    text-decoration: none;
}
.lookup-tile:hover { border-color: var(--app-primary); }
.lookup-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.lookup-text small { color: var(--app-muted); }
.lookup-count {
    min-width: 2.2rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: var(--app-field);
    font-weight: 700;
    font-size: .85rem;
    text-align: center;
}
.lookup-tile > .bi-chevron-right { color: var(--app-muted); }
.lookup-form { max-width: 40rem; }
.lookup-delete { margin-top: 1rem; max-width: 40rem; }
@media (min-width: 768px) { .lookup-form + .profile-save { max-width: 40rem; margin-left: 0; } }


/* ---- Find address (postcode lookup) ---- */
.postcode-finder {
    margin-bottom: 1.1rem;
    padding: .9rem;
    border-radius: 14px;
    background: rgb(var(--app-primary-rgb) / .07);
    border: 1px dashed rgb(var(--app-primary-rgb) / .5);
}
.finder-row { display: flex; gap: .5rem; }
.finder-row .finder-postcode { flex: 1; min-width: 0; }
.finder-row .finder-go { flex-shrink: 0; min-height: 3rem; white-space: nowrap; }
.finder-message:empty { display: none; }
.finder-message { margin-top: .5rem; }
.finder-results {
    list-style: none;
    margin: .5rem 0 0;
    padding: 0;
    max-height: 18rem;
    overflow-y: auto;
    border-radius: 12px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
}
.finder-results button {
    display: block;
    width: 100%;
    padding: .7rem .9rem;
    border: 0;
    border-bottom: 1px solid var(--app-line);
    background: none;
    color: var(--app-ink);
    text-align: left;
    font-size: .92rem;
}
.finder-results li:last-child button { border-bottom: 0; }
.finder-results button:hover, .finder-results button:focus-visible { background: rgb(var(--app-primary-rgb) / .1); }


/* ---- Linked companies ---- */
.link-notice {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin: 0 0 1.25rem;
    padding: .9rem 1rem;
    border-radius: 18px;
    background: rgb(var(--app-primary-rgb) / .12);
    border: 1.5px solid var(--app-primary);
    color: var(--app-ink);
    text-decoration: none;
}
.link-notice .row-icon { background: var(--app-primary-dark); color: #FFFFFF; }
.link-notice-text { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.link-notice-text small { color: var(--app-accent-text); font-weight: 600; }
.link-row { flex-wrap: wrap; }
.link-buttons { display: flex; gap: .5rem; flex: 1 1 100%; }
.link-buttons form { flex: 1; }
.link-buttons .btn { width: 100%; min-height: 2.75rem; }


/* ---- Business details: serial and one-off PIN ---- */
.pin-row { display: flex; gap: .75rem; margin-bottom: .75rem; }
.pin-row > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: .7rem .9rem;
    border-radius: 14px;
    background: var(--app-field);
}
.pin-row span { color: var(--app-muted); font-size: .8rem; font-weight: 600; }
.pin-row strong { font-size: 1.3rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.pin-code { color: var(--app-accent-text); letter-spacing: .25em !important; }

/* ---- Business details: central register check ---- */
.register-check { margin-top: .9rem; border-top: 1px solid var(--app-line); padding-top: .7rem; }
.register-check summary { cursor: pointer; font-weight: 700; font-size: .92rem; }
.register-check ul { list-style: none; margin: .6rem 0 0; padding: 0; }
.register-check li { display: flex; gap: .5rem; padding: .3rem 0; font-size: .9rem; }
.register-check li span { display: flex; flex-direction: column; min-width: 0; }
.register-check small { color: var(--app-muted); overflow-wrap: anywhere; }
.register-check .is-ok { color: var(--app-accent-text); }
.register-check .is-bad, .register-check li.is-bad i { color: var(--app-alert); }
.register-check li.is-ok i { color: var(--app-accent-text); }

/* ---- Serial number and one-off PIN in the menu (More panel on a phone, sidebar on a PC) ---- */
.more-ids { display: flex; gap: .6rem; padding: 0 1.25rem .75rem; }
.more-id {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .45rem .6rem;
    border-radius: 12px;
    background: rgb(var(--app-primary-rgb) / .12);
    line-height: 1.2;
}
.more-id small { color: var(--app-muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.more-id strong { color: var(--app-accent-text); font-size: 1.2rem; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.menu-id { white-space: nowrap; }
.menu-id strong { color: var(--app-accent-text); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
