/* ink/teal/white/danger/success/warning come from common/_tokens.css, loaded
   before this file. Contractor skips common/_shell.css (the admin-shell sidebar
   component rules) since this is a bottom-nav mobile portal, not a desktop
   admin shell — it defines its own smaller, touch-first component set below.
   --teal/--teal-deep/--teal-pale can be overridden per-org by
   partials/_brand_theme.html, so every accent here reads from those tokens
   rather than a hardcoded hex. */
:root {
    --paper:          #F5F7F9;
    --mist:            #E6EEF2;
    --text-secondary: #6E7B87;
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --shadow-card:    0 1px 3px rgba(14,31,45,0.06), 0 4px 14px rgba(14,31,45,0.06);
    --font-display:   "Inter", system-ui, -apple-system, sans-serif;
    --topbar-h:       56px;
    --bottomnav-h:    60px;
    --app-max-width:  460px;
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Distinct from --paper (the app frame's own background) so the frame
       reads as a phone-width surface even in a full desktop browser window
       - see .app-shell's comment for the mechanism. On an actual phone
       viewport --app-max-width exceeds the screen, so this never shows. */
    background: #DCE3E8;
    color: var(--ink);
}
a { color: var(--teal-deep); }
h1, h2, h3, h4 { font-family: var(--font-display); }

/* The whole app (topbar, content) lives inside this frame rather than the
   raw <body>, capped to a phone-ish width so a desktop browser window
   doesn't stretch it edge to edge. bottom-nav/menu-backdrop/account-sheet
   are position:fixed and deliberately NOT inside anything transformed —
   an earlier version put a `transform` on .app-shell to contain them
   width-wise, but that makes the shell their containing block, so a
   fixed element ends up positioned relative to the shell's full
   (scrollable) height instead of the viewport: on a long page it renders
   near the bottom of the DOCUMENT, off-screen, not pinned to what's
   visible. Those three elements instead cap their own width individually
   (see below) while staying truly viewport-fixed. */
.app-shell {
    max-width: var(--app-max-width);
    margin: 0 auto;
    min-height: 100vh;
    background: var(--paper);
    position: relative;
    box-shadow: 0 0 0 1px rgba(14,31,45,0.06);
    padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
}
.app-shell--no-nav { padding-bottom: 0; }

.contractor-main { padding: 16px; }

/* ===================================================================
   Top bar — brand + account/menu trigger. Sticky, sits above content;
   flash + offline banner stack below it (see z-index order there).
   =================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 16px;
    background: var(--white);
    border-bottom: 1px solid var(--mist);
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    text-decoration: none;
    color: var(--ink);
}
.topbar-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}
.topbar-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--teal-pale);
    color: var(--teal-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.topbar-titles {
    display: flex;
    flex-direction: column;
    min-width: 0; /* lets both lines ellipsize inside the flex brand link */
}
.topbar-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-user {
    font-size: 11.5px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    font-size: 19px;
    cursor: pointer;
}
.topbar-icon-btn:hover { background: var(--paper); }
.topbar-back {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--ink);
    font-size: 20px;
    text-decoration: none;
    flex-shrink: 0;
}
.topbar-back:hover { background: var(--paper); }
.topbar-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===================================================================
   Flash + offline banner
   =================================================================== */
.flash-stack { position: sticky; top: var(--topbar-h); z-index: 20; }
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 16px;
    font-size: 13.5px;
    font-weight: 500;
    opacity: 1;
    transition: opacity 250ms, transform 250ms;
}
.flash--dismissing { opacity: 0; transform: translateY(-6px); }
.flash--success { background: var(--success); color: #fff; }
.flash--danger  { background: var(--danger); color: #fff; }
.flash--info    { background: var(--secondary-blue); color: #fff; }
.flash--warning { background: var(--warning); color: #6B4700; }

.flash-text { flex: 1; text-align: center; }
.flash-close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0,0,0,0.1);
    color: inherit;
    border-radius: 50%;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
}
.flash-close:hover { opacity: 1; }

.offline-banner {
    background: var(--ink); color: var(--white); text-align: center;
    padding: 8px 12px; font-size: 13px; position: sticky; top: var(--topbar-h); z-index: 24;
}

/* ===================================================================
   Bottom nav — icons only for daily-driver tasks (jobs/inspections/
   invoices/payouts). Everything else lives in the account menu opened
   from the topbar, since a mobile tab bar can't hold ~10 items.
   =================================================================== */
.bottom-nav {
    /* Fixed to the viewport (not .app-shell - see its comment), so it
       always tracks the visible screen even on a long scrolling page.
       left:50% + translateX(-50%) + max-width caps it to the same
       phone-frame width as .app-shell without borrowing its containing
       block. */
    position: fixed; bottom: 0; left: 50%; width: 100%; max-width: var(--app-max-width);
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    height: var(--bottomnav-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--white);
    border-top: 1px solid var(--mist);
    box-shadow: 0 -1px 6px rgba(14,31,45,0.05);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 600;
}
.bottom-nav a .ti { font-size: 21px; line-height: 1; }
.bottom-nav a.bottom-nav-active { color: var(--teal-deep); }

/* ===================================================================
   Account menu — bottom sheet triggered from the topbar avatar icon.
   Pure CSS/markup toggle via [hidden] + a tiny inline script in the
   layout (no framework needed for one open/close state).
   =================================================================== */
.menu-backdrop {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(14,31,45,0.4);
}
.menu-backdrop[hidden] { display: none; }

.account-sheet {
    /* Same viewport-fixed + self-capped-width approach as .bottom-nav.
       The slide-in animation also drives `transform`, so the horizontal
       centering has to live inside the keyframes too (an element can't
       have two independent `transform` sources) - see sheet-in below. */
    position: fixed; left: 50%; bottom: 0; width: 100%; max-width: var(--app-max-width);
    transform: translateX(-50%);
    z-index: 41;
    max-height: 82vh;
    overflow-y: auto;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    padding: 8px 10px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(14,31,45,0.18);
    animation: sheet-in 220ms ease;
}
@keyframes sheet-in { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.account-sheet-handle {
    width: 36px; height: 4px; border-radius: 4px;
    background: var(--mist); margin: 6px auto 12px;
}
.account-sheet-header {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 12px 16px;
}
.account-sheet-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    background: var(--teal-pale); color: var(--teal-deep);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; font-family: var(--font-display);
}
.account-sheet-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.account-sheet-email { font-size: 12.5px; color: var(--text-secondary); margin-top: 1px; }

.account-sheet-section-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
    color: var(--text-secondary); padding: 14px 12px 6px;
}
.account-sheet-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-radius: var(--radius-md);
    text-decoration: none; color: var(--ink);
    font-size: 14px; font-weight: 600;
    background: none; border: none; width: 100%; text-align: left; cursor: pointer;
    font-family: inherit;
}
.account-sheet-link:hover { background: var(--paper); }
.account-sheet-link .ti { font-size: 19px; color: var(--text-secondary); flex-shrink: 0; }
.account-sheet-link--danger { color: var(--danger); }
.account-sheet-link--danger .ti { color: var(--danger); }
.account-sheet-divider { height: 1px; background: var(--mist); margin: 8px 4px; }

/* ===================================================================
   Page header
   =================================================================== */
.page-header { margin-bottom: 18px; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 21px; color: var(--ink); margin: 0 0 4px; }
.page-sub { font-size: 13.5px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.section-title {
    font-family: var(--font-display); font-weight: 700; font-size: 14px;
    color: var(--ink); margin: 24px 2px 10px;
}
.section-title:first-child { margin-top: 2px; }

/* ===================================================================
   Tab row — e.g. Active/Previous jobs
   =================================================================== */
.tab-row {
    display: flex;
    gap: 4px;
    background: var(--mist);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: 16px;
}
.tab-link {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    border-radius: calc(var(--radius-md) - 3px);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
}
.tab-link--active { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(14,31,45,0.08); }

/* ===================================================================
   Cards
   =================================================================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-card);
    margin-bottom: 14px;
}
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); margin: 0 0 4px; }
.card-sub { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 16px; line-height: 1.5; }

.step { background: var(--white); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.step h4 { margin: 0 0 12px; font-size: 14.5px; font-family: var(--font-display); }

.job-card {
    display: block;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-card);
    text-decoration: none;
    color: inherit;
}
.job-card h3 { margin: 0 0 6px; font-size: 15.5px; font-family: var(--font-display); }
.job-card p { margin: 2px 0; font-size: 13px; color: var(--text-secondary); }
.job-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }

/* ===================================================================
   Status pills — generic; modifier maps a status keyword to a color.
   Statuses seen across jobs/invoices/inspections/credentials/invites.
   =================================================================== */
.status-pill {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 3px 9px;
    border-radius: 20px;
    text-transform: capitalize;
    white-space: nowrap;
    background: var(--mist);
    color: var(--text-secondary);
}
.status-pill--accent    { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal-deep); }
.status-pill--info      { background: color-mix(in srgb, var(--secondary-blue) 12%, transparent); color: var(--secondary-blue); }
.status-pill--warning   { background: color-mix(in srgb, var(--warning) 16%, transparent); color: #8A6400; }
.status-pill--success   { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.status-pill--danger    { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.status-pill--neutral   { background: var(--mist); color: var(--text-secondary); }

/* ===================================================================
   Buttons
   =================================================================== */
.btn-primary, .btn-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--teal);
    color: var(--white);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    margin-top: 4px;
    transition: background 120ms ease;
}
.btn-primary:hover, .btn-block:hover { background: var(--teal-deep); }
.btn-primary:disabled, .btn-block:disabled { background: var(--mist); color: var(--text-secondary); cursor: not-allowed; }

.btn-secondary, .btn-block--secondary {
    background: var(--paper);
    color: var(--ink);
    border: 1.5px solid var(--mist);
}
.btn-secondary:hover, .btn-block--secondary:hover { background: var(--mist); }

.btn-outline {
    background: var(--white);
    color: var(--teal-deep);
    border: 1.5px solid color-mix(in srgb, var(--teal) 40%, transparent);
}
.btn-outline:hover { background: var(--teal-pale); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--danger-deep); }

.btn-sm {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
    margin-top: 0;
}
.btn-block, .btn-primary, .btn-secondary, .btn-outline, .btn-danger { text-decoration: none; }

/* ===================================================================
   Forms
   =================================================================== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--mist);
    border-radius: var(--radius-md);
    background: var(--white);
    font-size: 16px;
    font-family: inherit;
    color: var(--ink);
    outline: none;
    transition: border-color 150ms ease;
}
.form-control:focus { border-color: var(--teal); }
.form-control::placeholder { color: var(--text-secondary); }
textarea.form-control { resize: vertical; min-height: 76px; }
.form-control--sm { padding: 9px 10px; font-size: 14px; }
.form-hint { margin: 6px 0 0; font-size: 12px; color: var(--text-secondary); line-height: 1.45; }

/* Amount + unit combo (e.g. "$45.00" next to a small Hourly/Callout
   picker) - the unit is still a real, changeable <select>, just styled
   as a compact suffix chip instead of its own full-width dropdown row. */
.amount-field {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--mist);
    border-radius: var(--radius-md);
    background: var(--white);
    overflow: hidden;
    transition: border-color 150ms ease;
}
.amount-field:focus-within { border-color: var(--teal); }
.amount-field input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--ink);
    background: transparent;
    outline: none;
}
.amount-field select {
    flex-shrink: 0;
    appearance: none;
    border: none;
    border-left: 1.5px solid var(--mist);
    background: var(--paper);
    padding: 0 22px 0 10px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary);
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7F8C' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7F8C' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.form-check input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--teal); cursor: pointer; }
.form-check label { font-size: 13.5px; color: var(--ink); cursor: pointer; margin: 0; font-weight: 500; }

.password-field, .pw-wrap { position: relative; }
.password-field .form-control, .pw-wrap .form-control { padding-right: 42px; }
.toggle-password {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 17px; color: var(--text-secondary); cursor: pointer; user-select: none;
}

/* Toggle switch (notification preferences etc.) */
.pref-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px; }
.pref-toggle-label { display: flex; flex-direction: column; gap: 3px; font-size: 14px; font-weight: 600; color: var(--ink); }
.pref-toggle-label .ti { color: var(--teal-deep); margin-right: 6px; }
.pref-toggle-sub { font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.pref-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.pref-switch {
    position: relative; flex-shrink: 0; width: 42px; height: 24px;
    border-radius: 24px; background: var(--mist); transition: background 150ms ease; cursor: pointer;
}
.pref-switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
    border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: transform 150ms ease;
}
.pref-checkbox:checked + .pref-switch { background: var(--teal); }
.pref-checkbox:checked + .pref-switch::after { transform: translateX(18px); }
.pref-section { border-top: 1px solid var(--mist); }
.pref-section:first-child { border-top: none; }
.pref-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-secondary); margin: 14px 2px 0; }

/* ===================================================================
   Data list — mobile-friendly replacement for desktop <table> layouts.
   Each row is a card with stacked label/value pairs so nothing needs
   horizontal scrolling on a phone.
   =================================================================== */
.data-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.data-row {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
}
.data-row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.data-row-title { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; color: var(--ink); margin: 0; }
.data-row-fields { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.data-row-field { font-size: 12.5px; color: var(--text-secondary); }
.data-row-field strong { color: var(--ink); font-weight: 600; }
.data-row-actions { display: flex; gap: 8px; margin-top: 12px; }
.data-row-actions form { flex: 1; }
.data-row-actions .btn-sm { width: 100%; }

.rates-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.rates-filter-note { font-size: 12.5px; color: var(--text-secondary); margin: 0; }
.data-row--other-trade { display: none; }

/* ===================================================================
   Empty state
   =================================================================== */
.empty-state {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-secondary);
}
.empty-state .ti { font-size: 34px; color: var(--mist); margin-bottom: 10px; display: block; }
.empty-state p { margin: 0; font-size: 13.5px; }

/* ===================================================================
   Auth pages (login/signup/reset) — centered card, no bottom nav
   =================================================================== */
.auth-wrap { max-width: 380px; margin: 8vh auto 0; padding: 0 6px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-logo .topbar-mark { width: 46px; height: 46px; border-radius: 12px; font-size: 22px; }
.auth-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 26px 22px; }
.auth-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; text-align: center; margin: 0 0 6px; }
.auth-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin: 0 0 20px; line-height: 1.5; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 18px; }

/* ===================================================================
   Home Health Assessment (inspection.css) photo capture — shared here
   since job_detail.html and inspection_detail.html both use it.
   =================================================================== */
.photo-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); margin: 4px 4px 0 0; }
.pending-sync { border: 2px dashed var(--warning); opacity: 0.75; }

/* Remove-photo cross overlaid on a thumb (job before/after photos — the
   inspection page has its own insp-photo-del variant in inspection.css). */
.photo-wrap { position: relative; display: inline-block; }
.photo-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
}
.photo-del:hover { background: var(--danger, #c0392b); }

/* Native file inputs (photo capture) were rendering as the bare browser
   default - style just the button part via ::file-selector-button so it
   matches btn-secondary, no JS/custom widget needed. */
input[type="file"] {
    display: block;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}
input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 9px 14px;
    border: 1.5px solid var(--mist);
    border-radius: var(--radius-md);
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--mist); }
