@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #f1f5f9;
}

.header-bg {
    background: linear-gradient(135deg, #0f172a 0%, #1e40af 100%);
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tab-active {
    border-bottom: 4px solid white;
    font-weight: 700;
    opacity: 1 !important;
}

/* ─── Sidebar transition ─── */
#sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Sidebar scrim ─── */
#sidebar-scrim {
    transition: opacity 0.3s ease;
}

.input-focus {
    outline: none;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.input-focus:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px #3b82f6;
}

.badge-new {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Replaced IDE warnings for inline styles */
.bg-header-gradient {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

/* ─── Role colours (owner's request, 2026-10-04; made calm 2026-10-06) ───
   The menu and the phone's top bar take a pastel of the signed-in person's role, with dark text, so everyone can tell
   at a glance which role they are using: Driver sage green, Coordinator cornflower blue, Bookkeeper soft pink (the owner's
   choice, 2026-10-06; it was a pewter grey), Admin lavender. The owner on 2026-10-06: the bold colours were "much more bold than was expecting", "50% opacity", "calming
   pastel colors", and no burnt orange for Admin ("red tones can induce stress responses"). Each is the role's colour very
   light, the "Soft" strength the owner chose from the mockup (docs/plans/2026-10-06-sidebar-calm-redesign.md; "Half",
   about 50% over white, was the other choice: #9acbaa, #9db8ec, #a9afba, #bba6ee).
   index.html (applyRoleScreens) sets body[data-role] from src/auth/permissions.js (an unknown role reads as a driver);
   with no role yet (signing in) a plain light slate shows.
   Text on these colours is dark: slate-900 (#0f172a), or slate-700 (#334155) for smaller lines; never white or a lighter
   grey. tests/menu/rolecolours.test.mjs reads this file and checks every pair is at least 4.5:1, so a later change of
   colour cannot quietly make the menu unreadable.
     --role-side  the menu, the phone's top bar and the phone browser's own bar (theme-color)
     --role-ink   the role's colour, dark, on white: the selected menu item, the role chip, the selected tab, the phone's
                  bottom bar */
body {
    --role-side: #e2e8f0;
    --role-ink: #1d4ed8;
}

body[data-role="driver"] {
    --role-side: #d7ebdd;
    --role-ink: #166534;
}

body[data-role="coordinator"] {
    --role-side: #d9e4f8;
    --role-ink: #1e40af;
}

body[data-role="bookkeeper"] {
    --role-side: #f6dce8;
    --role-ink: #9d174d;
}

body[data-role="admin"] {
    --role-side: #e6ddf9;
    --role-ink: #5b21b6;
}

#mobile-topbar {
    background: var(--role-side);
}

#sidebar {
    background: var(--role-side);
    border-right: 1px solid rgba(15, 23, 42, 0.07);
}

@media (max-width: 1023px) {
    #sidebar {
        box-shadow: 8px 0 30px rgba(15, 23, 42, 0.25);   /* the phone's menu slides over the page */
    }
}

/* The menu's items (partials/sidebar.html). The id keeps the selected item's look above Tailwind's classes, which load
   after this file. */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    border-radius: 11px;
    color: #0f172a;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.45);
}

#sidebar .sidebar-nav-active {
    background: #fff;
    color: var(--role-ink);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.05);
}

/* The Inbox count (Operations) and the trailers on the way (Facility): white on red-600 / amber-700 */
.nav-count {
    margin-left: auto;
    min-width: 1.25rem;
    padding: 2px 6px;
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
}

#sidebar .sidebar-nav-item:focus-visible,
#sidebar .sidebar-qr:focus-visible,
#sidebar .sidebar-account:focus-visible,
#sidebar .sidebar-collapse-btn:focus-visible,
#mobile-topbar button:focus-visible {
    outline: 2px solid var(--role-ink);
    outline-offset: 2px;
}

/* ─── The shift strip (partials/sidebar.html, #sidebar-shift) ───
   The clock code in index.html sets the words of #tt-status, swaps the button's colour (bg-blue-600 / bg-red-600) and
   disables the activity picker while a shift runs; this reads that last one (:has) to show the running time and
   "Edit start time" only then, and to show the activity as plain words. */
.sidebar-shift {
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

#tt-status {
    color: #0f172a;              /* over the clock code's text-gray-400 / text-emerald-500 */
}

.shift-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    flex: none;
}

.shift-time {
    font-size: 15px;
    color: #0f172a;
}

.shift-select {
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    background-color: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 0.4rem 0.5rem;
}

.shift-select:focus-visible {
    outline: 2px solid var(--role-ink);
    outline-offset: 1px;
}

.shift-edit {
    margin-top: 0.375rem;
    font-size: 12px;
    color: #334155;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.shift-edit:hover {
    color: #0f172a;
}

/* Timesheet (the person's own, opened from the strip): the strip's last row under a hairline, an icon, the word and a chevron, as it
   opens a page. Its hover reaches a little past the words on both sides, so the row is wider than the space it sits in. */
.shift-foot {
    margin-top: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.shift-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: calc(100% + 0.5rem);
    margin: 0 -0.25rem -0.25rem;
    padding: 0.375rem 0.25rem;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

.shift-link svg {
    width: 16px;
    height: 16px;
    flex: none;
    color: #334155;
}

.shift-link .shift-link-chev {
    width: 14px;
    height: 14px;
    margin-left: auto;
}

.shift-link:hover {
    background: rgba(15, 23, 42, 0.05);
}

.shift-link:focus-visible {
    outline: 2px solid var(--role-ink);
    outline-offset: 1px;
}

#sidebar-shift .shift-time,
#sidebar-shift #tt-adjust-btn {
    display: none;
}

#sidebar-shift:has(#tt-project:disabled) .shift-time {
    display: inline;
}

#sidebar-shift:has(#tt-project:disabled) #tt-adjust-btn {
    display: inline-block;
}

#sidebar-shift:has(#tt-project:disabled) .shift-dot {
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

#sidebar-shift .shift-select:disabled {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border-color: transparent;
    padding-left: 0;
    font-weight: 600;
    color: #334155;
    -webkit-text-fill-color: #334155;   /* Safari greys out a disabled control's text */
    opacity: 1;
    cursor: default;
    text-overflow: ellipsis;
}

/* Tools: QR Studio. No box or fill until hovered (a filled white box read as the page already open); its icon tile is the
   menu's only bright colour. */
.sidebar-qr {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border-radius: 12px;
    text-align: left;
    transition: background-color 0.15s;
}

.sidebar-qr:hover {
    background: rgba(255, 255, 255, 0.45);
}

.sidebar-qr-tile {
    background: linear-gradient(135deg, #67e8f9 0%, #818cf8 100%);   /* cyan-300 to indigo-400 */
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

/* Your account, at the bottom of the menu, and its role chip (white, in the role's colour) */
.sidebar-account {
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.55);
}

.sidebar-account:hover,
.sidebar-account[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.85);
}

.sidebar-role-chip {
    margin-top: 2px;
    padding: 1px 7px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 999px;
    background: #fff;
    color: var(--role-ink);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* The phone's top bar: the avatar (a plain figure until the profile has loaded) */
.topbar-account {
    box-shadow: 0 0 0 2px #fff;
}

#topbar-avatar:not(:empty) + .topbar-avatar-fallback {
    display: none;
}

/* The account menu (src/account/accountmenu.js) */
.account-item {
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.55rem 0.625rem;
    border-radius: 9px;
    color: #0f172a;
    font-size: 0.875rem;
    text-align: left;
}

.account-item svg {
    color: #475569;
}

.account-item:hover,
.account-item:focus-visible {
    background: #f1f5f9;
    outline: none;
}

/* The selected tab of a menu section (src/utils/menusections.js) */
.section-tab-on {
    color: var(--role-ink);
    box-shadow: inset 0 -2px 0 var(--role-ink), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ── Sidebar collapse: icon-rail (desktop only) ─────────── */
#sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 16rem;
    /* 256px = w-64 */
}

body.sidebar-collapsed #sidebar {
    width: 4rem;
    /* 64px = w-16 */
}

/* Hide text labels, widget, section headings when collapsed */
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-shift-widget,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-collapse-label {
    display: none;
}

/* Centre icons when collapsed */
body.sidebar-collapsed #sidebar nav button,
body.sidebar-collapsed #sidebar .sidebar-bottom-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

/* The brand row keeps only its widen button (its arrows turned round), the account button only the avatar, and the
   counts sit on the icon's corner */
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar-brand-tile {
    display: none;
}

body.sidebar-collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

body.sidebar-collapsed #sidebar .sidebar-account {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    border-color: transparent;
    background: transparent;
}

body.sidebar-collapsed #sidebar .nav-count {
    position: absolute;
    top: 2px;
    right: 6px;
}

body.sidebar-collapsed #sidebar nav button svg,
body.sidebar-collapsed #sidebar .sidebar-bottom-btn svg {
    margin: 0 auto;
}

/* Tooltip on hover when collapsed */
body.sidebar-collapsed #sidebar button[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 4.25rem;
    background: #1e293b;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 6px;
    z-index: 9999;
    pointer-events: none;
}

body.sidebar-collapsed #sidebar button[data-tooltip] {
    position: relative;
}

/* Main content fluid margin transition */
main {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1024px) {
    body.sidebar-collapsed main {
        margin-left: 4rem;
        /* 64px */
    }
}

/* ── Empty State component ───────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    text-align: center;
}

.empty-state-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.empty-state p {
    font-size: 0.75rem;
    color: #94a3b8;
    font-style: italic;
}

.empty-state-cta {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.4rem 1rem;
    border-radius: 0.5rem;
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
    cursor: pointer;
    transition: background 0.15s;
}

.empty-state-cta:hover {
    background: #dbeafe;
}

/* ── Edit Time Entry modal: slide-in from right ──────────── */
#edit-time-modal {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0;
}

#edit-time-modal>div {
    height: 100%;
    max-height: 100vh;
    border-radius: 1.5rem 0 0 1.5rem;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 28rem;
    overflow-y: auto;
}

#edit-time-modal.flex>div,
#edit-time-modal:not(.hidden)>div {
    transform: translateX(0);
}

/* On a phone the same dialog is a bottom sheet (see "Field UI" below). */
@media (max-width: 639px) {
    #edit-time-modal {
        justify-content: center;
    }

    #edit-time-modal>div {
        height: auto;
        max-height: 92vh;
        width: 100%;
        max-width: none;
        border-radius: 1.5rem 1.5rem 0 0;
        transform: none;
        animation: sheet-up 0.22s ease-out;
    }
}

/* ── QR Studio full-screen overlay ───────────────────────── */
#qr-studio-modal {
    transition: opacity 0.25s ease;
}

#qr-studio-modal.hidden {
    display: none !important;
}

/* NUMPAD BUTTON STYLE */
.numpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 0.75rem;
    font-size: 1.25rem;
    font-weight: 900;
    background: white;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-user-select: none;
    user-select: none;
}

.numpad-btn:active {
    transform: scale(0.92);
    background: #f3f4f6;
}

/* ─── Field UI: the phone-first layer used by Timesheet, Route, Inbox, History and Receipts ─── */

/* Bottom navigation (phones only; the markup is in partials/sidebar.html) */
.bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 3.5rem;
    padding: 0.375rem 0 calc(0.375rem + env(safe-area-inset-bottom));
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    -webkit-tap-highlight-color: transparent;
}

.bnav-item:active {
    background: #f1f5f9;
}

.bnav-active {
    color: var(--role-ink);
    box-shadow: inset 0 2px 0 var(--role-ink);
}

/* Dialogs slide up from the bottom on a phone (a centered card on wider screens) */
.sheet-panel {
    animation: sheet-up 0.22s ease-out;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

@keyframes sheet-up {
    from {
        transform: translateY(28px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

@media (min-width: 640px),
(prefers-reduced-motion: reduce) {
    .sheet-panel {
        animation: none;
    }
}

/* The closed menu is parked off screen; without this its shadow leaks onto the left edge of the page. (On a computer the
   menu has no shadow at all since 2026-10-06, only a thin border: "Role colours" above.) */
#sidebar.-translate-x-full {
    box-shadow: none;
}

/* Room for the bottom navigation under the last thing on a phone.
   overflow-x: clip keeps one over-wide element from widening the whole page: a phone browser then enlarges its
   layout area to fit, and the fixed bottom bar is left hanging below (or partway up) the visible screen. */
@media (max-width: 1023px) {
    main {
        padding-bottom: 5rem;
        overflow-x: clip;
    }
}

/* iOS Safari can visibly lag a `position: fixed` element behind a fast or momentum scroll -- it
   keeps painting the fixed bar at a stale on-screen position until scrolling settles, instead of
   every frame, so a screenshot mid-scroll shows it "drifted" into the middle of the page with real
   content both above and below it (reported 2026-09-25). Promoting the bar to its own compositing
   layer stops WebKit from deferring its repaint; this is a rendering hint only, no layout change. */
#bottom-nav,
#mobile-topbar {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* A visible focus ring for keyboard and switch users, on the controls people tap most */
.fu-focus:focus-visible,
.bnav-item:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* -- Encouraging message card (src/utils/celebration.js; markup #celebration-toast in partials/modals.html) --
   A dark card in the middle of the screen (the navy of the app's own header, so it stands out from the white
   Route cards it floats over): a solid badge with the moment's icon, a small heading for the moment, the message
   in large type, and a thin bar along the bottom that runs down with its time. One accent colour per moment,
   set once here: green for stops and reminders, gold for the stop that clears the Route. */
/* Centred over the page's content, not over the sidebar too: the same offsets as `main` beside the sidebar
   (lg:ml-64 in index.html, 4rem when collapsed, above). On a phone the content is the whole width. */
@media (min-width: 1024px) {
    #celebration-toast {
        left: 16rem;
    }

    body.sidebar-collapsed #celebration-toast {
        left: 4rem;
    }
}

#celebration-card {
    --cel-accent: #10b981;                  /* emerald-500: the badge and the bar */
    --cel-halo: rgba(16, 185, 129, 0.2);
    --cel-label: #6ee7b7;                   /* emerald-300 on navy */
    --cel-track: rgba(255, 255, 255, 0.1);
    background: linear-gradient(165deg, #1e293b 0%, #0f172a 55%, #0b1224 100%);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 30px 70px -18px rgba(2, 6, 23, 0.65), 0 2px 6px rgba(2, 6, 23, 0.25);
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.2s ease-out, transform 0.3s cubic-bezier(0.2, 0.9, 0.25, 1.15);
    -webkit-tap-highlight-color: transparent;
}

#celebration-card[data-kind="cleared"] {
    --cel-accent: #f59e0b;                  /* amber-500 */
    --cel-halo: rgba(245, 158, 11, 0.24);
    --cel-label: #fcd34d;                   /* amber-300 */
}

#celebration-card.is-shown {
    opacity: 1;
    transform: none;
}

#celebration-card.is-leaving {
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.18s ease-in, transform 0.18s ease-in;
}

#celebration-card .celebration-icon {
    background: var(--cel-accent);
    color: #fff;
    box-shadow: 0 0 0 7px var(--cel-halo), 0 8px 20px -6px var(--cel-accent);
}

#celebration-card.is-shown .celebration-icon {
    animation: celebration-pop 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.3) 0.06s both;
}

@keyframes celebration-pop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

#celebration-card .celebration-label {
    color: var(--cel-label);
}

#celebration-card .celebration-text {
    color: #fff;
    text-wrap: balance;                     /* even line lengths instead of one word left on the last line */
}

#celebration-card .celebration-track {
    background: var(--cel-track);
}

#celebration-card .celebration-timer {
    background: var(--cel-accent);
    transform-origin: left center;
}

@media (prefers-reduced-motion: reduce) {
    #celebration-card,
    #celebration-card.is-leaving {
        transform: none;
        transition: opacity 0.15s linear;
    }

    #celebration-card.is-shown .celebration-icon {
        animation: none;
    }
}

/* ── Receipt scan: the photo the corners are dragged on, and the four corner handles (src/receipts/scanview.js) ──
   The frame is as wide as the photo can be while staying under half the screen's height (a little more on a computer),
   so the whole photo and the Done button under it fit the sheet; --scan-ratio is the photo's width / height. The
   handles are placed by percentage over the photo, so they follow it at any size; big enough for a thumb. */
#scan-adjust-frame {
    width: min(100%, calc(var(--scan-ratio, 0.75) * 48vh));
}

@media (min-width: 640px) {
    #scan-adjust-frame {
        width: min(100%, calc(var(--scan-ratio, 0.75) * 56vh));
    }
}

.scan-handle {
    position: absolute;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border-radius: 9999px;
    background: #ffffff;
    border: 3px solid #2563eb;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
    touch-action: none;
    cursor: grab;
}

.scan-handle:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

.scan-handle.is-dragging {
    cursor: grabbing;
    background: #dbeafe;
}

/* ─── Help (src/help/helpview.js) ───
   A button name in the manual, as a small chip so it reads as something on the screen; and the "Yours" tag on the
   person's own parts of the contents. Dark text on light, like the role colours. */
.help-btn {
    display: inline-block;
    padding: 0 0.35rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    white-space: nowrap;
}
/* The contents' parts open like a book's chapters: the summary's own marker hidden, the chevron turns when open. */
.help-part > summary { list-style: none; }
.help-part > summary::-webkit-details-marker { display: none; }
.help-part[open] .help-chev { transform: rotate(180deg); }
/* A scheduled route's section on the Route (src/services/renderingservice.js, routeGroup): closed until pressed. */
.route-group > summary { list-style: none; }
.route-group > summary::-webkit-details-marker { display: none; }
.route-group[open] .route-group-chev { transform: rotate(180deg); }
