/* =========================================================
   Nexus Paperless · design tokens
   Brand: Nexus red #E81633, charcoal #18181B
   ========================================================= */
:root {
    --red: #e81633;
    --red-600: #c4102a;
    --red-700: #a00d22;
    --red-50: #fdecef;
    --red-100: #fbd5db;

    --ink: #18181b;
    --ink-2: #27272a;
    --ink-3: #3f3f46;
    --muted: #6b6b73;
    --line: #e7e5e4;
    --line-2: #d6d3d1;
    --bg: #f5f4f2;
    --card: #ffffff;

    --green: #15803d;
    --green-50: #eaf7ef;
    --amber: #b45309;
    --amber-50: #fff5e6;
    --blue: #1d4ed8;
    --blue-50: #eef3ff;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 4px 16px rgba(24, 24, 27, .05);
    --chamfer: 10px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

    --sidebar-w: 256px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 750; }
h2 { font-size: 1.125rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
h1:focus { outline: none; }
img { max-width: 100%; display: block; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .9em; }
.text-danger { color: var(--red-600); }
.link { color: var(--red-600); font-weight: 600; font-size: .9rem; }
.link:hover { text-decoration: underline; }

.eyebrow {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 6px;
}

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 650;
    font-size: .95rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .stepper-btn:focus-visible {
    outline: 3px solid rgba(232, 22, 51, .35);
    outline-offset: 2px;
}
.btn .icon { width: 18px; height: 18px; }

/* Primary buttons borrow the cut corners of the Nexus logo */
.btn-primary {
    background: var(--red);
    color: #fff;
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}
.btn-primary:hover:not(:disabled) { background: var(--red-600); }
.btn-primary:focus-visible { outline: none; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55); }

.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-3); }

.btn-ghost-danger { background: transparent; color: var(--red-600); border-color: var(--red-100); }
.btn-ghost-danger:hover:not(:disabled) { background: var(--red-50); }

.btn-lg { min-height: 52px; padding: 0 24px; font-size: 1rem; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink-3);
    cursor: pointer;
}
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn.is-spinning .icon { animation: spin 1s linear infinite; }

.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.field label { font-size: .875rem; font-weight: 650; color: var(--ink-2); }
.label-hint { font-weight: 400; color: var(--muted); }

.input, .input-wrap input, .stepper input {
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--card);
}
.input {
    width: 100%;
    min-height: 52px;
    padding: 0 14px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
}
.input:focus, .input-wrap:focus-within, .stepper:focus-within {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, .08);
}

.input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 0 6px 0 14px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--card);
    transition: border-color .15s, box-shadow .15s;
}
.input-wrap > .icon { color: var(--muted); }
.input-wrap input { flex: 1; min-width: 0; height: 52px; border: 0; outline: 0; padding: 0; background: transparent; }
.input-action {
    display: grid; place-items: center;
    width: 42px; height: 42px;
    border: 0; border-radius: 8px;
    background: transparent; color: var(--muted);
    cursor: pointer;
}
.input-action:hover { background: var(--bg); color: var(--ink); }

.stepper {
    display: grid;
    grid-template-columns: 52px 1fr 52px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--card);
}
.stepper input {
    width: 100%;
    min-width: 0;
    height: 56px;
    border: 0;
    border-inline: 1px solid var(--line);
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    -moz-appearance: textfield;
}
.stepper input:focus { outline: none; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-btn {
    display: grid; place-items: center;
    border: 0; background: var(--bg); color: var(--ink);
    cursor: pointer;
}
.stepper-btn:hover { background: var(--line); }
.stepper-btn:active { background: var(--line-2); }

/* ---------- Notices ---------- */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    line-height: 1.45;
}
.notice .icon { width: 18px; height: 18px; margin-top: 1px; }
.notice-info { background: var(--blue-50); color: #1e3a8a; }
.notice-success { background: var(--green-50); color: #14532d; }
.notice-warn { background: var(--amber-50); color: #7c2d12; }
.notice-error { background: var(--red-50); color: var(--red-700); }

/* ---------- Pills ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 650;
    white-space: nowrap;
}
.pill .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.pill-sent { background: var(--green-50); color: var(--green); }
.pill-waiting { background: var(--amber-50); color: var(--amber); }
.pill-failed { background: var(--red-50); color: var(--red-600); }
.pill-draft { background: #f1f1f2; color: var(--ink-3); }

.soon {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, .08);
    color: #a1a1aa;
}

/* =========================================================
   Login
   ========================================================= */
.auth {
    display: grid;
    grid-template-columns: minmax(380px, 44%) 1fr;
    min-height: 100dvh;
    background: var(--card);
}

.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    padding: 48px;
    background: var(--ink);
    color: #fff;
    overflow: hidden;
    isolation: isolate;
}
/* Angular red slash, echoing the cut shapes in the logo */
.auth-brand::before, .auth-brand::after {
    content: "";
    position: absolute;
    z-index: -1;
    background: var(--red);
}
.auth-brand::before {
    width: 140%;
    height: 220px;
    right: -55%;
    bottom: 90px;
    transform: rotate(-24deg);
    opacity: .95;
}
.auth-brand::after {
    width: 140%;
    height: 26px;
    right: -55%;
    bottom: 340px;
    transform: rotate(-24deg);
    opacity: .5;
}

.auth-brand-logo { width: min(300px, 80%); }
.auth-brand-copy { max-width: 420px; }
.auth-brand-copy .eyebrow { color: #fda4af; }
.auth-brand-copy h2 { font-size: 2.1rem; line-height: 1.15; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 28px; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: #d4d4d8; }
.auth-points .icon {
    width: 36px; height: 36px; padding: 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
}
.auth-brand-foot { font-size: .85rem; color: #e4e4e7; }

.auth-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 24px;
}
.auth-card { width: 100%; max-width: 420px; margin: auto 0; }
.auth-card-logo { display: none; width: 240px; margin: 0 auto 36px; }
.auth-card h1 { font-size: 2rem; margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 28px; }
.auth-form { margin-top: 8px; }
.auth-form .btn { margin-top: 8px; }
.auth-help { margin-top: 20px; text-align: center; font-size: .875rem; color: var(--muted); }
.auth-foot { margin-top: 32px; font-size: .8rem; color: var(--muted); }

@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-card-logo { display: block; }
    .auth-card { text-align: left; }
    .auth-card h1 { text-align: center; }
    .auth-card > .muted { text-align: center; }
}

/* =========================================================
   App shell
   ========================================================= */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    height: 100dvh;
    flex: none;
    padding: 24px 14px 16px;
    background: var(--ink);
    color: #d4d4d8;
}
.sidebar-brand { display: block; padding: 4px 10px 26px; }
.sidebar-brand img { width: 160px; }
.sidebar-brand span {
    display: inline-block;
    margin-top: 10px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: #fff;
    padding: 3px 8px;
    background: var(--red);
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    font-weight: 550;
    font-size: .95rem;
    color: #d4d4d8;
    transition: background-color .15s, color .15s;
}
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: rgba(232, 22, 51, .16); color: #fff; }
.side-link.active::before {
    content: "";
    position: absolute;
    left: -14px; top: 10px; bottom: 10px;
    width: 4px;
    background: var(--red);
}
.side-link.active .icon { color: #ff4d64; }
.sidebar-divider { height: 1px; margin: 14px 12px; background: rgba(255, 255, 255, .08); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    margin-top: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
}
.sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    padding: 6px;
    border-radius: 8px;
}
.sidebar-user-link:hover { background: rgba(255, 255, 255, .07); }
.sidebar-signout {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #a1a1aa;
    cursor: pointer;
}
.sidebar-signout:hover { background: rgba(232, 22, 51, .18); color: #fff; }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-text strong { color: #fff; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text small { color: #a1a1aa; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    flex: none;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .02em;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-height: 68px;
    padding: 0 32px;
    padding-top: env(safe-area-inset-top, 0px);
    background: rgba(245, 244, 242, .86);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-brand { display: none; margin-right: auto; }
.topbar-brand img { height: 30px; width: auto; }

.content { width: 100%; padding: 32px; }

/* Sync pill */
.sync { display: flex; align-items: center; gap: 8px; }
.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-3);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-50); }
.sync-pill.is-offline .sync-dot { background: #a1a1aa; box-shadow: 0 0 0 3px #f1f1f2; }
.sync-pill.has-failed { border-color: var(--red-100); color: var(--red-600); }
.sync-pill.has-failed .sync-dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-50); }

/* Account menu (phones and portrait tablets; the sidebar has its own on desktop) */
.account { position: relative; display: none; }
.account-btn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.account-btn:focus-visible { outline: 3px solid rgba(232, 22, 51, .35); outline-offset: 2px; }
.avatar-sm { width: 40px; height: 40px; font-size: .8rem; }
.menu-backdrop { position: fixed; inset: 0; z-index: 40; }
.menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 41;
    width: 260px;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(24, 24, 27, .16);
}
.menu-head { display: flex; flex-direction: column; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    font: inherit;
    font-size: .95rem;
    font-weight: 550;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.menu-item:hover { background: var(--bg); }
.menu-item .icon { color: var(--muted); }
.menu-danger, .menu-danger .icon { color: var(--red-600); }

/* Confirmation dialog */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(24, 24, 27, .5); animation: fade .15s ease-out; }
.modal {
    position: fixed;
    z-index: 61;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 32px));
    padding: 28px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(24, 24, 27, .25);
    animation: pop .18s ease-out;
}
.modal h2 { font-size: 1.3rem; margin: 14px 0 12px; }
.modal .notice { margin-bottom: 12px; }
.modal-icon {
    display: grid; place-items: center;
    width: 48px; height: 48px;
    border-radius: 12px;
    background: var(--red-50);
    color: var(--red);
}
.modal-icon-neutral { background: var(--blue-50); color: var(--blue); }
.modal p.muted { line-height: 1.5; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%); } }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-600); }

/* Bottom navigation (phones and portrait tablets) */
.bottom-nav { display: none; }

@media (max-width: 1023px) {
    .sidebar { display: none; }
    .topbar { justify-content: space-between; padding-inline: 16px; min-height: 60px; }
    .topbar-brand { display: block; }
    .account { display: block; }
    .content { padding: 20px 16px calc(96px + var(--safe-bottom)); }

    .bottom-nav {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding: 6px 6px calc(6px + var(--safe-bottom));
        background: var(--ink);
        border-top: 3px solid var(--red);
    }
    .bottom-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 8px 4px;
        border-radius: 10px;
        font-size: .7rem;
        font-weight: 600;
        color: #a1a1aa;
    }
    .bottom-link .icon { width: 22px; height: 22px; }
    .bottom-link.active { color: #fff; }
    .bottom-link.active .icon { color: #ff4d64; }
}

@media (max-width: 520px) {
    .sync-text { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-brand img { height: 24px; }
}

/* =========================================================
   Page furniture
   ========================================================= */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head .muted { margin-top: 6px; max-width: 60ch; }

.back-link {
    display: inline-flex; align-items: center; gap: 4px;
    margin-bottom: 14px;
    font-size: .9rem; font-weight: 600; color: var(--muted);
}
.back-link:hover { color: var(--ink); }
.back-link .icon { width: 18px; height: 18px; }

.panel {
    padding: 24px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel-title { margin-bottom: 14px; }

.section-title { font-size: 1rem; margin-bottom: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }

.footnote { margin-top: 16px; font-size: .8rem; color: var(--muted); }

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 48px 24px;
    text-align: center;
    background: var(--card);
    border: 1px dashed var(--line-2);
    border-radius: var(--radius);
}
.empty > .icon { width: 44px; height: 44px; padding: 10px; border-radius: 12px; background: var(--bg); color: var(--muted); margin-bottom: 4px; }
.empty p { color: var(--muted); max-width: 46ch; }
.empty .btn { margin-top: 10px; }
.empty-sm { padding: 28px 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 28px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* =========================================================
   Dashboard
   ========================================================= */
.hero {
    position: relative;
    padding: 28px;
    background: var(--ink);
    color: #fff;
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
    overflow: hidden;
    isolation: isolate;
}
.hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    right: -80px; top: -40px;
    width: 320px; height: 90px;
    background: var(--red);
    transform: rotate(-24deg);
    opacity: .9;
}
.hero-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.hero-label { font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #a1a1aa; }
.hero-figure { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; margin-top: 6px; }
.hero-figure span { font-size: 1rem; font-weight: 500; letter-spacing: 0; color: #a1a1aa; margin-left: 8px; }
.hero-done {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-radius: 999px;
    background: rgba(34, 197, 94, .14); color: #86efac;
    font-weight: 650; font-size: .9rem;
}

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 4px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .06);
    transition: background-color .15s;
}
a.day[href]:hover { background: rgba(255, 255, 255, .1); }
.day-name { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #a1a1aa; }
.day-num { font-size: 1.25rem; font-weight: 750; }
.day-mark { display: grid; place-items: center; width: 28px; height: 28px; margin-top: 4px; border-radius: 50%; }
.day-mark .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.day-hours { font-size: .75rem; color: #d4d4d8; margin-top: 2px; }
.day.is-today { border-color: var(--red); }
.day.is-future { opacity: .4; pointer-events: none; }
.day.is-sent .day-mark { background: #16a34a; color: #fff; }
.day.is-waiting .day-mark { background: #f59e0b; color: #fff; }
.day.is-failed .day-mark { background: var(--red); color: #fff; }
.day.is-draft .day-mark { border: 1.5px dashed #a1a1aa; color: #d4d4d8; }
.day.is-empty .day-mark { color: #71717a; border: 1.5px solid rgba(255, 255, 255, .12); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.stat {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    align-items: center;
    padding: 18px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: var(--line-2); transform: translateY(-1px); }
.stat-icon {
    grid-row: span 2;
    display: grid; place-items: center;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--bg);
    color: var(--ink-3);
}
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-alert { border-color: var(--red-100); }
.stat-alert .stat-icon { background: var(--red-50); color: var(--red-600); }
.stat-alert .stat-value { color: var(--red-600); }

@media (max-width: 720px) {
    .stats { grid-template-columns: 1fr; gap: 10px; }
    .hero { padding: 22px 18px; }
    .hero-figure { font-size: 2.4rem; }
    .week { gap: 5px; }
    .day { padding: 10px 2px; }
    .day-num { font-size: 1.05rem; }
    .hero-top .btn { width: 100%; }
}

.actions { display: grid; gap: 10px; }
.action {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color .15s;
}
.action:hover { border-color: var(--ink-3); }
.action-icon {
    display: grid; place-items: center;
    width: 44px; height: 44px; flex: none;
    border-radius: 12px;
    background: var(--red-50);
    color: var(--red);
}
.action-text { display: flex; flex-direction: column; min-width: 0; }
.action-text small { color: var(--muted); font-size: .85rem; }
.action-chevron { margin-left: auto; color: var(--muted); }
.action.is-soon .action-icon { background: var(--bg); color: var(--muted); }
.action.is-soon strong { color: var(--ink-3); }
.action .soon { background: var(--bg); color: var(--muted); }

.activity, .list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.activity li, .list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.activity li:last-child, .list-item:last-child { border-bottom: 0; }
.activity-text, .list-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.activity-text strong, .list-text strong { font-size: .92rem; font-weight: 600; }
.activity-text small, .list-text small { font-size: .8rem; color: var(--muted); }
.list-text small.text-danger { color: var(--red-600); }
.activity-dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; flex: none; background: #a1a1aa; }
.status-sent { background: #16a34a; }
.status-pending { background: #f59e0b; }
.status-failed { background: var(--red); }
.list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* =========================================================
   Timesheets
   ========================================================= */
.tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    background: #ebe9e6;
    border-radius: 12px;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 9px;
    font-weight: 650;
    font-size: .92rem;
    color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(24, 24, 27, .1); }
.tab-count {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .75rem;
    background: rgba(24, 24, 27, .08);
    color: var(--ink-3);
}
.tab.active .tab-count { background: var(--ink); color: #fff; }
.tab-count-warn, .tab.active .tab-count-warn { background: var(--amber-50); color: var(--amber); }

.cards { display: grid; gap: 10px; }
.ts-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.ts-card.is-failed { border-color: var(--red-100); background: #fffafa; }
.ts-main {
    display: grid;
    grid-template-columns: 56px 1fr;
    column-gap: 16px;
    align-items: center;
    min-width: 0;
    flex: 1;
}
.ts-date {
    grid-row: span 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
    border-radius: 10px;
    background: var(--bg);
    line-height: 1.1;
}
.ts-day, .ts-month { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ts-num { font-size: 1.35rem; font-weight: 800; }
.ts-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.ts-total { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 1.1rem; font-weight: 750; line-height: 1.25; }
.ts-breakdown { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; color: var(--ink-3); }
.ts-meta { grid-column: 2; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.ts-error { grid-column: 2; display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--red-600); margin-top: 6px; }
.ts-error .icon { width: 15px; height: 15px; }
/* Status and button side by side, centred against the card */
.ts-actions { display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 12px; flex: none; }
a.ts-main:hover .ts-total { color: var(--red-600); }

.week-group + .week-group { margin-top: 28px; }
.week-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.week-head h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.week-head span { font-size: .9rem; font-weight: 700; }

@media (max-width: 600px) {
    .ts-card { flex-direction: column; align-items: stretch; }
    .ts-actions { flex-direction: row; align-items: center; justify-content: space-between; }
    .tabs { display: flex; }
    .tab { flex: 1; justify-content: center; padding: 0 8px; }
    .page-head .btn { width: 100%; }
}

/* Timesheet form */
.form-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.hours-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.panel-summary { position: sticky; top: 92px; }
.summary-figure { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; margin: 6px 0 4px; }
.summary-figure span { font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.summary-date { margin-bottom: 20px; }
.summary-actions { display: grid; gap: 10px; }

@media (max-width: 1100px) { .hours-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
    .form-layout { grid-template-columns: 1fr; }
    .panel-summary { position: static; }
    .hours-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .hours-grid .stepper { grid-template-columns: 40px 1fr 40px; }
}
@media (max-width: 560px) {
    .hours-grid { grid-template-columns: 1fr; }
    .hours-grid .stepper { grid-template-columns: 56px 1fr 56px; }
    .panel { padding: 18px; }
}

/* =========================================================
   Annual leave
   ========================================================= */
.small { font-size: .8rem; }
.pill-info { background: var(--blue-50); color: var(--blue); }
.chip { padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 650; background: var(--bg); color: var(--ink-3); }

.leave-summary {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 2fr;
    gap: 16px;
    margin-bottom: 24px;
}
.leave-balance {
    padding: 24px;
    background: var(--ink);
    color: #fff;
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.leave-balance-sub { margin-top: 8px; font-size: .85rem; color: #a1a1aa; }
.meter { height: 8px; margin-top: 18px; background: rgba(255, 255, 255, .12); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--red); border-radius: 999px; }
.leave-facts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.leave-facts > div { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 20px; }
.leave-facts > div + div { border-left: 1px solid var(--line); }
.stat-value-sm { font-size: 1rem; line-height: 1.3; }

.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.list-toolbar .tabs { margin-bottom: 0; }
.list-refresh { display: flex; align-items: center; gap: 10px; }
.tabs-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs-scroll::-webkit-scrollbar { display: none; }

.leave-card {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 16px;
    align-items: start;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.leave-card.is-failed { border-color: var(--red-100); background: #fffafa; }
.leave-card.is-past { opacity: .72; }
.leave-date {
    display: flex; flex-direction: column; align-items: center;
    padding: 6px 0; border-radius: 10px;
    background: var(--red-50); color: var(--red-700); line-height: 1.1;
}
.leave-date .ts-day, .leave-date .ts-month { color: var(--red-600); }
.leave-card.is-past .leave-date { background: var(--bg); color: var(--ink-3); }
.leave-card.is-past .leave-date .ts-day, .leave-card.is-past .leave-date .ts-month { color: var(--muted); }
.leave-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.leave-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.leave-days { font-size: .88rem; color: var(--ink-3); }
.leave-notes { margin-top: 6px; font-size: .88rem; color: var(--ink-3); }
.leave-reason { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: .85rem; }
.leave-body .ts-meta, .leave-body .ts-error { grid-column: auto; }

.date-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-label { font-size: .875rem; font-weight: 650; color: var(--ink-2); }
.segmented { display: flex; gap: 4px; padding: 4px; background: #ebe9e6; border-radius: 12px; }
.segment {
    flex: 1;
    min-height: 44px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    font: inherit;
    font-weight: 650;
    font-size: .92rem;
    color: var(--muted);
    cursor: pointer;
}
.segment.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(24, 24, 27, .1); }
.textarea { min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.rows-compact { margin: 0 0 16px; }
.rows-compact > div { padding: 8px 0; }
.rows .row-total { border-top: 2px solid var(--ink); }
.rows .row-total dt { color: var(--ink); font-weight: 650; }

@media (max-width: 860px) {
    .leave-summary { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .leave-facts { grid-template-columns: 1fr; }
    .leave-facts > div + div { border-left: 0; border-top: 1px solid var(--line); }
    .leave-facts > div { flex-direction: row-reverse; justify-content: space-between; align-items: center; padding: 14px 18px; }
    .leave-card { grid-template-columns: 56px 1fr; }
    .leave-card .ts-actions { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
    .date-pair { grid-template-columns: 1fr; gap: 0; }
    .list-toolbar { flex-direction: column-reverse; align-items: stretch; }
    .list-refresh { justify-content: flex-end; }
}

/* ---- Team calendar ---- */
.avatar-xs { width: 28px; height: 28px; font-size: .68rem; }
.spinner-dark { display: inline-block; width: 14px; height: 14px; border-color: var(--line-2); border-top-color: var(--ink); vertical-align: -2px; }

.whos-off {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 20px;
    background: var(--ink);
    color: #fff;
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.whos-off-col { padding: 20px 24px; }
.whos-off-col + .whos-off-col { border-left: 1px solid rgba(255, 255, 255, .1); }
.whos-off ul { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.whos-off li { display: flex; align-items: center; gap: 10px; }
.whos-off li > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.whos-off li small { color: #a1a1aa; font-size: .8rem; }
.whos-off li.is-pending .avatar { background: transparent; border: 1.5px dashed #fda4af; color: #fda4af; }
.whos-off-none { margin-top: 10px; color: #d4d4d8; font-weight: 600; }

.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-month { font-size: 1.35rem; min-width: 200px; text-align: center; }
.cal-status { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 14px; font-size: .82rem; color: var(--ink-3); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 18px; height: 12px; border-radius: 4px; }
.key-confirmed { background: var(--red); }
.key-pending { background: repeating-linear-gradient(135deg, var(--red-100) 0 3px, #fff 3px 6px); border: 1.5px solid var(--red); }
.key-holiday { background: repeating-linear-gradient(135deg, #e7e5e4 0 2px, #f5f4f2 2px 5px); border: 1px solid var(--line-2); }
.key-weekend { background: #f0efed; border: 1px solid var(--line); }

.cal-scroll {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-overflow-scrolling: touch;
}
.cal { border-collapse: separate; border-spacing: 0; width: 100%; min-width: max-content; font-size: .85rem; }
.cal th, .cal td { padding: 0; }
.cal thead th { position: sticky; top: 0; z-index: 2; background: #fafaf9; border-bottom: 1px solid var(--line); }
.cal-name-col {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 190px;
    max-width: 220px;
    padding: 8px 14px !important;
    background: var(--card);
    border-right: 1px solid var(--line);
    text-align: left;
    font-weight: 600;
}
.cal thead .cal-name-col { z-index: 4; background: #fafaf9; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.cal-name-inner { display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.cal-name { overflow: hidden; text-overflow: ellipsis; }
.cal-day { width: 34px; min-width: 34px; height: 48px; text-align: center; font-weight: 600; }
.cal-dow { display: block; font-size: .65rem; color: var(--muted); text-transform: uppercase; }
.cal-num { display: block; font-size: .9rem; }
.cal-day.is-today .cal-num {
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--red); color: #fff;
}
.cal-total-col { width: 52px; min-width: 52px; text-align: center; font-weight: 700; color: var(--ink-3); border-left: 1px solid var(--line); }
.cal thead .cal-total-col { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.cal tbody tr { height: 44px; }
.cal tbody td, .cal tbody th { border-bottom: 1px solid var(--line); }
.cal tbody tr:last-child td, .cal tbody tr:last-child th { border-bottom: 0; }
.cal tbody tr:hover td:not(.has-leave), .cal tbody tr:hover .cal-name-col { background-color: #fafaf9; }
.cal tr.is-me .cal-name-col { box-shadow: inset 4px 0 0 var(--red); }
.cal tr.is-me td, .cal tr.is-me .cal-name-col { background-color: #fff8f8; }

.cal-cell { position: relative; }
.cal-cell.is-weekend, .cal-day.is-weekend { background-color: #f5f4f2; }
.cal-cell.is-holiday, .cal-day.is-holiday { background-image: repeating-linear-gradient(135deg, rgba(0,0,0,.05) 0 2px, transparent 2px 6px); }
.cal-cell.is-today { box-shadow: inset 1px 0 0 var(--red-100), inset -1px 0 0 var(--red-100); }

.cal-bar { position: absolute; top: 9px; bottom: 9px; left: 0; right: 0; }
.cal-cell.solo .cal-bar { left: 4px; right: 4px; border-radius: 6px; }
.cal-cell.start .cal-bar { left: 4px; border-radius: 6px 0 0 6px; }
.cal-cell.end .cal-bar { right: 4px; border-radius: 0 6px 6px 0; }
.cal-cell.is-confirmed .cal-bar { background: var(--red); }
.cal-cell.is-pending .cal-bar {
    background: repeating-linear-gradient(135deg, var(--red-100) 0 4px, #fff 4px 8px);
    border-top: 1.5px solid var(--red);
    border-bottom: 1.5px solid var(--red);
}
.cal-cell.is-pending.start .cal-bar, .cal-cell.is-pending.solo .cal-bar { border-left: 1.5px solid var(--red); }
.cal-cell.is-pending.end .cal-bar, .cal-cell.is-pending.solo .cal-bar { border-right: 1.5px solid var(--red); }

@media (max-width: 720px) {
    .whos-off { grid-template-columns: 1fr; }
    .whos-off-col + .whos-off-col { border-left: 0; border-top: 1px solid rgba(255, 255, 255, .1); }
    .cal-name-col { min-width: 132px; max-width: 132px; }
    .cal-name-inner .avatar { display: none; }
    .cal-month { min-width: 0; font-size: 1.15rem; flex: 1; }
    .cal-status { width: 100%; margin-left: 0; }
}

/* =========================================================
   Vehicle checks
   ========================================================= */
.text-ok { color: var(--green); display: inline-flex; align-items: center; gap: 4px; }
.text-ok .icon { width: 16px; height: 16px; }
/* Styled like a UK rear number plate */
.reg-plate {
    display: inline-block;
    padding: 3px 12px;
    border: 1.5px solid #1a1a1a;
    border-radius: 5px;
    background: #ffd500;
    color: #111;
    font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    line-height: 1.2;
    white-space: nowrap;
}
.autosave { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.autosave .icon { width: 16px; height: 16px; color: var(--green); }

.vc-details { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.vc-details .field { margin-bottom: 0; }
.input-static { display: flex; align-items: center; background: var(--bg); color: var(--ink-3); }
.input-reg { text-transform: uppercase; font-weight: 700; letter-spacing: .06em; }
.input:disabled { background: var(--bg); color: var(--ink); opacity: 1; }
.vc-intro { margin: 0 0 20px; }
.vc-intro em { font-style: normal; font-weight: 600; }

.vc-section {
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.vc-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: #fafaf9;
}
.vc-section-head h2 { font-size: 1rem; }
.vc-section-count { margin-right: auto; font-size: .85rem; font-weight: 650; }
.vc-items { list-style: none; margin: 0; padding: 0; }
.vc-item {
    display: grid;
    grid-template-columns: minmax(160px, 1.2fr) auto minmax(180px, 2fr);
    align-items: center;
    gap: 16px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
}
.vc-item:last-child { border-bottom: 0; }
.vc-item.is-fault { background: #fff8f8; }
.vc-item.is-missing { background: var(--amber-50); }
.vc-issue { font-weight: 600; }
.vc-comment { min-height: 44px; }
.vc-item.is-fault .vc-comment { border-color: var(--red-100); }
.vc-comment-text { color: var(--ink-3); font-size: .9rem; }

.yesno { display: inline-flex; gap: 6px; }
.yesno-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 84px;
    min-height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--line-2);
    border-radius: 10px;
    background: var(--card);
    font: inherit;
    font-weight: 650;
    color: var(--ink-3);
    cursor: pointer;
    transition: background-color .12s, border-color .12s, color .12s;
}
.yesno-btn .icon { width: 16px; height: 16px; stroke-width: 2.4; opacity: .5; }
.yesno-btn.yes.active { background: var(--green); border-color: var(--green); color: #fff; }
.yesno-btn.no.active { background: var(--red); border-color: var(--red); color: #fff; }
.yesno-btn.active .icon { opacity: 1; }
.yesno-btn:disabled { cursor: default; }
.yesno-btn:disabled:not(.active) { opacity: .45; }

.vc-sign { margin: 4px 0 16px; }
.sigpad { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.sigpad-surface {
    position: relative;
    width: 100%;
    height: 200px;
    border: 1.5px dashed var(--line-2);
    border-radius: var(--radius-sm);
    background: #fff;
    overflow: hidden;
}
.sigpad-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 1; }
.sigpad-line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1.5px solid var(--line-2); }
.sigpad-line span { position: absolute; left: 0; bottom: 4px; color: var(--muted); font-size: .9rem; }
.sigpad-hint { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center; font-size: .82rem; color: var(--muted); pointer-events: none; }
.sigpad-saved, .sigpad-empty { display: grid; place-items: center; border-style: solid; }
.sigpad-saved img { max-width: 90%; max-height: 170px; object-fit: contain; }

.action-bar {
    position: sticky;
    bottom: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 16px -32px -32px;
    padding: 14px 32px calc(14px + var(--safe-bottom));
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
}
.action-bar-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.action-bar-info small { flex-basis: 100%; }
.action-bar-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 1023px) {
    .action-bar { bottom: calc(66px + var(--safe-bottom)); margin: 16px -16px 0; padding: 12px 16px; }
}
@media (max-width: 900px) {
    .vc-details { grid-template-columns: 1fr 1fr; }
    .vc-item { grid-template-columns: 1fr auto; }
    .vc-comment, .vc-comment-text { grid-column: 1 / -1; }
    .vc-comment-text:empty { display: none; }
}
@media (max-width: 560px) {
    .vc-details { grid-template-columns: 1fr; }
    .vc-section-head { flex-wrap: wrap; }
    .yesno-btn { min-width: 64px; padding: 0 10px; }
    .action-bar { flex-direction: column; align-items: stretch; }
    .action-bar-buttons .btn { flex: 1; }
}

/* =========================================================
   Purchase orders
   ========================================================= */
.input-po { font-family: var(--mono); font-weight: 700; letter-spacing: .02em; }
.po-number { font-family: var(--mono); font-weight: 800; letter-spacing: .02em; margin-right: 6px; }
.req { color: var(--red); }
.input-upper { text-transform: uppercase; }

.po-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 22px 24px;
    background: var(--ink);
    color: #fff;
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.po-banner-number { margin-top: 6px; font-family: var(--mono); font-size: 2.4rem; font-weight: 800; letter-spacing: .04em; line-height: 1; }
.po-banner-sub { margin-top: 8px; color: #86efac; font-weight: 600; font-size: .9rem; }

.po-details { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; margin-bottom: 16px; }
.po-span-2 { grid-column: span 2; }
.po-span-all { grid-column: 1 / -1; }

.po-lines { list-style: none; margin: 0; padding: 8px 18px; }
.po-line { display: grid; grid-template-columns: 1fr 160px 40px; gap: 10px; align-items: center; padding: 6px 0; }
.po-price { min-height: 52px; padding-left: 12px; }
.po-price input { height: 50px; text-align: right; padding-right: 8px; }
.po-currency { color: var(--muted); font-weight: 600; }
.po-remove { border-radius: 10px; }
.po-items-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--line);
}
.po-total { font-size: 1rem; color: var(--ink-3); }
.po-total strong { font-size: 1.25rem; color: var(--ink); margin-left: 6px; }

@media (max-width: 900px) {
    .po-details { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .po-details { grid-template-columns: 1fr; }
    .po-span-2 { grid-column: auto; }
    .po-line { grid-template-columns: 1fr 120px 40px; }
    .po-banner-number { font-size: 1.9rem; }
}

/* =========================================================
   Worksheets
   ========================================================= */
.ws-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; margin-bottom: 16px; }
.ws-grid-3 { grid-template-columns: repeat(3, 1fr); }
.ws-span-2 { grid-column: span 2; }
.ws-span-all { grid-column: 1 / -1; }
.ws-block { margin-bottom: 16px; }
.ws-block .panel-title label { font: inherit; }
.textarea-lg { min-height: 180px; }
.field-help { font-size: .8rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
    min-height: 44px;
    padding: 0 18px;
    border: 1.5px solid var(--line-2);
    border-radius: 999px;
    background: var(--card);
    font: inherit;
    font-weight: 650;
    color: var(--ink-3);
    cursor: pointer;
}
.chip-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-btn:disabled { cursor: default; }
.chip-btn:disabled:not(.active) { opacity: .45; }

.ws-risk { grid-template-columns: 1fr auto; }
.ws-risk-answers { min-width: 260px; }
.multi-select { position: relative; width: 320px; max-width: 100%; justify-self: end; }
.multi-select-box {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    text-align: left; cursor: pointer;
}
.multi-select-box > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-select-box .icon { flex: none; color: var(--muted); transition: transform .15s; }
.multi-select.is-open .multi-select-box { border-color: var(--ink); }
.multi-select.is-open .multi-select-box .icon { transform: rotate(180deg); }
.multi-select-box:disabled { cursor: default; background: var(--bg); color: var(--ink); }
.multi-select-backdrop { position: fixed; inset: 0; z-index: 20; }
.multi-select-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 21;
    list-style: none; margin: 0; padding: 6px;
    background: var(--card);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow), 0 12px 32px rgba(24, 24, 27, .12);
}
.multi-select-option {
    display: flex; align-items: center; gap: 12px;
    min-height: 46px; padding: 0 10px;
    border-radius: 8px; cursor: pointer;
}
.multi-select-option:hover { background: var(--bg); }
.multi-select-option.is-checked { font-weight: 600; }
.multi-select-option input { width: 20px; height: 20px; accent-color: var(--red); flex: none; }
.ws-risk-stop { grid-column: 1 / -1; margin: 0; }
.segment:disabled { cursor: default; }
.segmented .segment.active { background: var(--ink); color: #fff; }

.ws-material { grid-template-columns: 1fr 1fr 40px; }
.ws-engineer {
    display: grid;
    grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(80px, 1fr)) 40px;
    gap: 10px;
    align-items: end;
    padding: 6px 0;
}
.ws-engineer .field { margin-bottom: 8px; }
.ws-engineer .po-remove { margin-bottom: 14px; }
select.input { appearance: auto; padding-right: 10px; }

.ws-empty { padding: 16px 18px; font-size: .9rem; }
.ws-po-list { list-style: none; margin: 0; padding: 8px 18px 14px; display: grid; gap: 8px; }
.ws-po {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 0 14px;
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.ws-po input { width: 20px; height: 20px; accent-color: var(--red); }
.ws-po.is-attached { border-color: var(--red); background: var(--red-50); }
.ws-po-name { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-po-total { font-weight: 700; }

.switch { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 16px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--line-2); transition: background-color .15s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--red); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(232, 22, 51, .35); outline-offset: 2px; }
.ws-signed-by { max-width: 420px; }

.combo { position: relative; }
.combo .input-wrap.is-disabled { background: var(--bg); }
.combo-list {
    position: absolute;
    z-index: 25;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(24, 24, 27, .16);
}
.combo-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.combo-option:hover, .combo-option.active { background: var(--bg); }
.combo-option small { color: var(--muted); font-size: .8rem; }
.combo-empty { padding: 12px; color: var(--muted); font-size: .9rem; }

@media (max-width: 900px) {
    .ws-grid, .ws-grid-3 { grid-template-columns: 1fr 1fr; }
    .ws-risk { grid-template-columns: 1fr; }
    .ws-risk-answers { min-width: 0; }
    .multi-select { width: 100%; justify-self: stretch; }
    .ws-engineer { grid-template-columns: 1fr 1fr 1fr 40px; }
    .ws-engineer > .field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    .ws-grid, .ws-grid-3 { grid-template-columns: 1fr; }
    .ws-span-2 { grid-column: auto; }
    .ws-material { grid-template-columns: 1fr 40px; }
    .ws-material input:nth-child(2) { grid-column: 1; }
    .ws-po { grid-template-columns: auto 1fr auto; }
    .ws-po-name { display: none; }
}

/* =========================================================
   Support
   ========================================================= */
.tab-dot { width: 8px; height: 8px; border-radius: 50%; }
.tab-dot.on { background: #16a34a; }
.tab-dot.off { background: #a1a1aa; }

.support { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.support-hero { grid-column: 1 / -1; display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: center; }
.support-logo { width: 100%; max-width: 260px; height: auto; }
.support-status { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.support-status p { color: var(--ink-3); max-width: 60ch; }
.support-ref {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.support-ref .hero-label { color: var(--muted); }
.support-ref-value { font-family: var(--mono); font-size: 1.3rem; font-weight: 800; letter-spacing: .04em; }
.support-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.support-details {
    margin: 12px 0 14px;
    padding: 14px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: .82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
@media (max-width: 1100px) {
    .support { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .support-hero { grid-template-columns: 1fr; gap: 20px; }
    .support-logo { max-width: 200px; }
    .support-actions .btn { width: 100%; }
    .support .rows > div { flex-direction: column; gap: 2px; }
    .support .rows dd { text-align: left; }
}

/* =========================================================
   Settings
   ========================================================= */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings > .profile { grid-column: 1 / -1; }
.settings > .settings-signout { grid-column: 1 / -1; }
/* Links in the rows look like values, not warnings */
.rows dd .link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.rows dd .link:hover { text-decoration-color: var(--ink); }
@media (max-width: 1100px) {
    .settings { grid-template-columns: 1fr; }
}
.profile { display: flex; align-items: center; gap: 18px; }
.profile h2 { font-size: 1.3rem; }
.rows { margin: 0 0 16px; }
.rows > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.rows > div:last-child { border-bottom: 0; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; text-align: right; display: inline-flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.on { background: #16a34a; }
.status-dot.off { background: #a1a1aa; }
.settings .notice { margin: 0 0 12px; }

/* =========================================================
   Blazor template plumbing (loading + error UI)
   ========================================================= */
.validation-message { color: var(--red-600); font-size: .85rem; }

#blazor-error-ui {
    color-scheme: light only;
    background: #fff4d6;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: var(--red-700); padding: 1rem 1.25rem; color: white; border-radius: var(--radius-sm); }
.blazor-error-boundary::after { content: "Something went wrong on this screen."; }

.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 32vh 0 auto 0;
    margin: 0 auto;
}
.loading-progress circle {
    fill: none;
    stroke: #e7e5e4;
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--red);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 700;
    font-size: .85rem;
    color: var(--muted);
    inset: calc(32vh + 7rem) 0 auto 0;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }
.loading-logo { position: absolute; inset: calc(32vh - 5.5rem) 0 auto 0; margin: 0 auto; width: 180px; }

/* Update available */
.update-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--ink);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: .92rem;
}
.update-banner > .icon { color: #ff4d64; }
.update-banner span { flex: 1; }
.update-banner strong { margin-right: 4px; }
.login-update .update-banner { margin: 0; border-radius: 0; }

/* Forced update: covers the whole app until the new version takes over */
.update-required {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background: rgba(24, 24, 27, .82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.update-required-card {
    width: 100%;
    max-width: 380px;
    padding: 28px 24px;
    background: var(--card);
    border-radius: var(--radius);
    text-align: center;
    display: grid;
    gap: 10px;
    justify-items: center;
}
.update-required-logo { width: 150px; margin-bottom: 6px; }
.update-required-card h2 { font-size: 1.25rem; }
.update-required-card .btn { width: 100%; margin-top: 6px; }
.update-required-spinner {
    width: 28px; height: 28px; margin-top: 8px;
    border: 3px solid var(--line-2);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@media (max-width: 560px) {
    .update-banner { flex-wrap: wrap; }
    .update-banner .btn { width: 100%; }
}

/* =========================================================
   Mobile hardening: nothing wider than the screen
   ========================================================= */
.main { overflow-x: clip; }
.field, .panel, .vc-section, .cards, .ts-card, .leave-card { min-width: 0; }
.input, select.input, textarea.input { min-width: 0; max-width: 100%; }
.rows dd { min-width: 0; overflow-wrap: anywhere; }

/* iOS gives date inputs their own width and centres the text; make them behave like other boxes */
input[type="date"].input {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    text-align: left;
}
input[type="date"].input::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"].input::-webkit-calendar-picker-indicator { opacity: .6; }

@media (max-width: 600px) {
    .btn { white-space: normal; text-align: center; line-height: 1.2; }
    .page-head > .btn-row { width: 100%; }
    .page-head > .btn-row .btn { flex: 1; }
    .page-head > .pill, .page-head > .autosave { width: 100%; }

    /* Action bar: full-width buttons, main action on its own row */
    .action-bar-buttons { display: flex; flex-wrap: wrap; width: 100%; }
    .action-bar-buttons > .btn { flex: 1 1 40%; }
    .action-bar-buttons > .btn-primary { flex-basis: 100%; order: 2; }
}

@media (max-width: 560px) {
    /* Vehicle check: everything stacked and full width */
    .vc-section-head { padding: 12px 14px; }
    .vc-item { grid-template-columns: 1fr; gap: 8px; padding: 12px 14px; }
    .yesno { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .yesno-btn { min-width: 0; width: 100%; }
    .vc-comment, .vc-comment-text { grid-column: auto; }

    /* Worksheet risk answers and chips full width */
    .ws-risk-answers { width: 100%; }
    .chips { display: grid; grid-template-columns: 1fr 1fr; }
    .chip-btn { width: 100%; padding: 0 10px; }

    /* Item/material rows: description full width, the rest underneath */
    .po-lines { padding: 8px 14px; }
    .po-line { grid-template-columns: 1fr 40px; }
    .po-line > .input:first-child { grid-column: 1 / -1; }
    .po-items-foot { flex-wrap: wrap; padding: 12px 14px 14px; }
    .po-items-foot .btn { flex: 1; }

    /* Engineers: name full width, hours in three columns */
    .ws-engineer { grid-template-columns: 1fr 1fr 1fr; }
    .ws-engineer > .po-remove { grid-column: 1 / -1; width: 100%; border-radius: 10px; margin-bottom: 8px; }

    .settings .rows > div { flex-direction: column; gap: 2px; }
    .settings .rows dd { text-align: left; }
}

@media (max-width: 520px) {
    /* Top bar: logo, sync status and account must fit a small phone */
    .topbar { gap: 8px; }
    .topbar-brand img { height: 22px; }
    .sync .icon-btn { display: none; }
    .sync-pill { padding: 0 10px; height: 36px; }
    .sync-text { max-width: 110px; }
}

/* ---------- Mobile/tablet pass (pre-publish) ---------- */

/* Long names and email addresses wrap instead of pushing past the screen */
.profile > div { min-width: 0; }
.profile h2, .profile p { overflow-wrap: anywhere; }

/* Bigger tap targets for small text links */
.back-link { padding: 10px 0; margin: -10px 0 4px; }
.section-head .link { padding: 10px 0 10px 12px; }

/* Bottom nav: extra links appear when there is room (tablet portrait) */
.bottom-link.bn-wide { display: none; }
@media (max-width: 1023px) {
    .bottom-nav { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
}
@media (min-width: 600px) and (max-width: 1023px) {
    .bottom-link.bn-wide { display: flex; }
}

/* Tablet portrait: quick actions in two columns instead of one long list */
@media (min-width: 600px) and (max-width: 1023px) {
    .actions { grid-template-columns: 1fr 1fr; }
}

/* Phones: a slim save/send bar so the form isn't buried under buttons */
@media (max-width: 600px) {
    .action-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 16px; }
    .action-bar-info { flex-wrap: nowrap; gap: 8px; min-width: 0; white-space: nowrap; font-size: .9rem; }
    .action-bar-info > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .action-bar-info > strong { flex: 0 1 auto; }
    .action-bar-info small { flex: 1 1 0; }
    .action-bar-buttons { flex-wrap: nowrap; gap: 8px; }
    .action-bar-buttons > .btn { flex: 1 1 0; min-width: 0; padding: 0 10px; white-space: nowrap; order: 0; }
    .action-bar-buttons > .btn-primary { flex: 1.4 1 0; order: 0; }
    .action-bar-buttons > .btn-ghost-danger { flex: 0 0 48px; padding: 0; font-size: 0; gap: 0; }
    .action-bar-buttons > .btn-ghost-danger .icon { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
