/*
  Driver web app (boards: canvas-driver Main, HomePhone, Loads, LoadDetail, LoadDetailPhone, Pay, Documents,
  DocumentsDelete, Companies). The driver plane has its own chrome: a light top bar with the tabs on a wide screen,
  and a top bar plus a bottom tab bar on a phone. Everything is prefixed pui-dapp-.
*/

/* ── Shell ────────────────────────────────────────────────────────────────────────────────── */
.pui-dapp { display: flex; flex-direction: column; height: 100dvh; width: 100%; min-width: 0; overflow: hidden; background: var(--background); }
.pui-dapp-top { flex: none; background: var(--card); border-bottom: 1px solid var(--border); }
.pui-dapp-wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 16px; box-sizing: border-box; display: flex; flex-direction: column; }
.pui-dapp-bar { display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 56px; }
.pui-dapp-brand { display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--foreground); }
.pui-dapp-brand svg { width: 24px; height: 24px; flex: none; }
.pui-dapp-grow { flex: 1 1 0; min-width: 0; }
.pui-dapp .cn-button.pui-dapp-b44 { height: 44px; padding: 0 16px; }
.pui-dapp .cn-button.pui-dapp-icon44 { width: 44px; height: 44px; padding: 0; }
.pui-dapp-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--secondary); color: var(--secondary-foreground); font-size: 12px; font-weight: 600; flex: none; }

.pui-dapp-nav { display: flex; flex-direction: row; gap: 0; overflow-x: auto; margin: 0 -8px; }
.pui-dapp-nav > a, .pui-dapp-nav > .sc-link {
    flex: 1 1 0; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
    padding: 0 10px; border-bottom: 2px solid transparent; color: var(--muted-foreground); font-weight: 500; font-size: 14px;
    text-decoration: none; white-space: nowrap;
}
.pui-dapp-nav > a:hover { color: var(--foreground); text-decoration: none; }
.pui-dapp-nav > a[aria-current="page"] { color: var(--foreground); border-bottom-color: var(--primary); font-weight: 600; }
.pui-dapp-nav > a[aria-current="page"] svg { color: var(--brand-orange, oklch(0.72 0.18 50)); }
.pui-dapp-nav svg, .pui-dapp-tab svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pui-dapp-scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.pui-dapp-main { width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px 48px; box-sizing: border-box; min-width: 0; }
.pui-dapp-page { display: flex; flex-direction: column; gap: 16px; width: 100%; min-width: 0; }
.pui-dapp-page .pui-page-title { font-size: 22px; }
.pui-dapp-page > [data-testid="page-header"] { gap: 4px; }

.pui-dapp-tabbar { flex: none; display: flex; flex-direction: row; background: var(--card); border-top: 1px solid var(--border); padding: 0 4px 18px; }
.pui-dapp-tab {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px;
    color: var(--muted-foreground); font-size: 11px; font-weight: 500; text-decoration: none;
}
.pui-dapp-tab[aria-current="page"] { color: var(--foreground); font-weight: 600; }
.pui-dapp-tab[aria-current="page"] svg { color: var(--brand-orange, oklch(0.72 0.18 50)); }
.pui-dapp-tab svg { width: 20px; height: 20px; }

@media (max-width: 767px) {
    .pui-dapp-main { padding: 16px 16px 24px; }
    .pui-dapp-page { gap: 14px; }
}

/* ── Shared pieces ────────────────────────────────────────────────────────────────────────── */
.pui-dapp .cn-card { overflow: visible; }
.pui-dapp .cn-card-header { display: flex; flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pui-dapp .cn-card-content { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 767px) {
    .pui-dapp .cn-card-header { padding: 14px 16px 0; }
    .pui-dapp .cn-card-content { padding: 14px 16px 16px; }
}
.pui-dapp-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-foreground); }
.pui-dapp-eyebrow.is-info { color: var(--tone-info-fg); }
.pui-dapp-xs { font-size: 12px; color: var(--muted-foreground); }
.pui-dapp-sm { font-size: 13px; }
.pui-dapp-muted { color: var(--muted-foreground); }
.pui-dapp-num { font-family: var(--font-mono, "Geist Mono", ui-monospace, monospace); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.pui-dapp-kpi { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.pui-dapp-id { font-family: var(--font-mono, "Geist Mono", ui-monospace, monospace); font-size: 13px; }
.pui-dapp-title-id { font-size: 18px; font-weight: 600; margin: 0; }
.pui-dapp-linkrow { display: inline-flex; flex-direction: row; align-items: center; gap: 4px; min-height: 44px; font-weight: 500; font-size: 13px; color: var(--primary); text-decoration: none; }
.pui-dapp-linkrow:hover { text-decoration: underline; }
.pui-dapp-linkrow svg { width: 14px; height: 14px; }
.pui-dapp-backlink { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; min-height: 44px; font-weight: 500; font-size: 14px; align-self: flex-start; color: var(--primary); text-decoration: none; }
.pui-dapp-backlink:hover { text-decoration: underline; }
.pui-dapp-badge-id { font-size: 11px; }

.pui-dapp .cn-button.pui-dapp-xl { height: 52px; padding: 0 22px; font-size: 16px; border-radius: 10px; width: 100%; gap: 6px; }
.pui-dapp .cn-button.pui-dapp-lg { height: 44px; padding: 0 20px; font-size: 15px; gap: 6px; }
.pui-dapp-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.pui-dapp-actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pui-dapp-tile { width: 40px; height: 40px; border-radius: 10px; background: var(--muted); display: flex; align-items: center; justify-content: center; flex: none; color: var(--muted-foreground); }
.pui-dapp-tile.is-warn { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.pui-dapp-row { display: flex; flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); }
.pui-dapp-row:first-child { border-top: 0; }
.pui-dapp-row-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.pui-dapp-row-title { font-weight: 600; }
@media (max-width: 767px) { .pui-dapp-row { padding: 12px 16px; } .pui-dapp-row-main { flex-basis: 140px; } }
.pui-dapp-list { display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; list-style: none; }
.pui-dapp-line { display: flex; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Load progress: one bar per step, the current one in the info colour. */
.pui-dapp-steps { display: flex; flex-direction: row; gap: 4px; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.pui-dapp-steps.has-labels { gap: 6px; }
.pui-dapp-step { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 0; }
.pui-dapp-steps.has-labels .pui-dapp-step { min-width: 72px; }
.pui-dapp-step-bar { height: 4px; border-radius: 999px; background: var(--muted); display: block; }
.pui-dapp-step.is-done .pui-dapp-step-bar { background: var(--primary); }
.pui-dapp-step.is-now .pui-dapp-step-bar { background: var(--tone-info-fg); }
.pui-dapp-step-label { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }
.pui-dapp-step.is-now .pui-dapp-step-label { color: var(--foreground); font-weight: 600; }

/* The next stop panel on Home. */
.pui-dapp-next { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 10px; background: var(--tone-info-bg); }
.pui-dapp-next .pui-dapp-eyebrow { color: var(--tone-info-fg); }
.pui-dapp-next-name { font-size: 18px; font-weight: 600; line-height: 1.25; }
.pui-dapp-next-addr { font-size: 15px; }
.pui-dapp-next-when { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.pui-dapp-next-contact { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--muted-foreground); }
@media (max-width: 767px) { .pui-dapp-next { padding: 14px; gap: 8px; } .pui-dapp-next-name { font-size: 17px; } }

/* Load rows on My loads. */
.pui-dapp-loads .pui-dapp-tabs { padding: 12px 20px 0; }
.pui-dapp-tabs .cn-tabs-list { display: flex; flex-direction: row; gap: 20px; padding: 0; background: transparent; border-radius: 0; border-bottom: 1px solid var(--border); width: 100%; height: auto; overflow-x: auto; }
.pui-dapp-tabs .cn-tabs-trigger {
    display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 2px; border: 0; border-bottom: 2px solid transparent;
    margin-bottom: -1px; border-radius: 0; background: transparent; box-shadow: none; font-size: 13px; font-weight: 500;
    color: var(--muted-foreground); flex: none;
}
.pui-dapp-tabs .cn-tabs-trigger[aria-selected="true"] { border-bottom-color: var(--primary); background: transparent; box-shadow: none; color: var(--foreground); }
.pui-dapp-tabs .cn-tabs-trigger:hover { color: var(--foreground); }
.pui-dapp-count { font-family: var(--font-mono, "Geist Mono", ui-monospace, monospace); font-size: 11px; font-weight: 500; color: var(--muted-foreground); background: var(--background); border-radius: 999px; padding: 1px 6px; }
.pui-dapp-loadrow { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 14px 20px; min-height: 76px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; box-sizing: border-box; width: 100%; }
.pui-dapp-loadrow:hover { background: oklch(0.98 0.004 250); text-decoration: none; color: inherit; }
.pui-dapp-list > li:first-child > .pui-dapp-loadrow { border-top: 0; }
.pui-dapp-loadrow-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pui-dapp-lane { font-size: 15px; }
.pui-dapp-loadrow > svg { color: var(--muted-foreground); flex: none; }
@media (max-width: 767px) { .pui-dapp-loadrow { padding: 12px 16px; } .pui-dapp-loads .pui-dapp-tabs { padding: 8px 16px 0; } }
.pui-dapp .cn-card-footer.pui-dapp-foot { min-height: 52px; box-sizing: border-box; }

/* Stops on the load page. */
.pui-dapp-stop { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.pui-dapp-stop-rail { display: flex; flex-direction: column; align-items: center; }
.pui-dapp-stop-dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; box-sizing: border-box; }
.pui-dapp-stop-dot.is-done { background: var(--primary); color: #fff; }
.pui-dapp-stop-dot.is-next { border: 2px solid var(--tone-info-fg); background: var(--card); }
.pui-dapp-stop-dot.is-later { border: 2px solid var(--input); background: var(--card); }
.pui-dapp-stop-dot svg { width: 14px; height: 14px; }
.pui-dapp-stop-line { flex: 1; width: 2px; background: var(--border); margin-top: 4px; }
.pui-dapp-stop-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-bottom: 20px; }
.pui-dapp-stop:last-child .pui-dapp-stop-body { padding-bottom: 0; }
.pui-dapp-stop-name { font-weight: 600; font-size: 15px; }
.pui-dapp-note { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: var(--muted); font-size: 13px; }
@media (max-width: 767px) { .pui-dapp-note { margin-top: 14px; padding: 10px 12px; } .pui-dapp-stop-body { padding-bottom: 18px; } }

/* Trip plan rows. */
.pui-dapp-plan { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.pui-dapp-plan-row { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.pui-dapp-plan-row.is-done { opacity: .55; }
.pui-dapp-plan-row.is-current { padding: 8px 10px; margin: -8px -10px; border: 2px solid var(--tone-info-fg); border-radius: 8px; }
.pui-dapp-plan-kind { width: 64px; flex: none; }
.pui-dapp-plan-place { flex: 1; min-width: 0; }
.pui-dapp-plan-row.is-current .pui-dapp-plan-place { font-weight: 600; }

/* Documents on the load page and the credential list. */
.pui-dapp-doc { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); min-height: 56px; }
.pui-dapp-doc-main { flex: 1; min-width: 0; }
.pui-dapp-dashed { width: 16px; height: 16px; border-radius: 50%; border: 2px dashed var(--input); flex: none; box-sizing: border-box; }
.pui-dapp-upload { display: flex; flex-direction: row; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.pui-dapp-upload > * { flex: 1 1 160px; min-width: 0; }
.pui-dapp .cn-select, .pui-dapp .cn-input { min-height: 44px; }
/* The date box sits in the same row as 44px inputs: match their height and fill the cell. */
.pui-dapp .cn-date-picker { width: 100%; }
.pui-dapp .cn-date-picker .cn-date-picker-trigger { min-height: 44px; width: 100%; justify-content: flex-start; }
.pui-dapp-grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 14px; }
.pui-dapp-cred-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pui-dapp-row.is-nowrap { flex-wrap: nowrap; }

/* Pay. */
.pui-dapp-money { display: flex; flex-direction: row; justify-content: space-between; gap: 12px; font-size: 13px; }
.pui-dapp-money.is-total { font-weight: 600; padding-top: 8px; border-top: 1px solid var(--border); }
.pui-dapp-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr)); gap: 12px; }
.pui-dapp-sum.is-ruled { padding-top: 14px; border-top: 1px solid var(--border); }
.pui-dapp-stmt { border-top: 1px solid var(--border); }
.pui-dapp-stmt:first-child { border-top: 0; }
.pui-dapp-stmt.is-open { background: oklch(0.985 0.004 250); }
.pui-dapp .cn-button.pui-dapp-stmt-btn {
    display: flex; flex-direction: row; align-items: center; gap: 12px; width: 100%; min-height: 68px; height: auto; padding: 12px 20px;
    border: 0; border-radius: 0; background: transparent; color: inherit; text-align: left; justify-content: flex-start; font: inherit; font-weight: 400;
}
.pui-dapp .cn-button.pui-dapp-stmt-btn:hover { background: oklch(0.98 0.004 250); }
.pui-dapp-stmt-body { padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.pui-dapp-stmt-section { display: flex; flex-direction: column; gap: 8px; }
.pui-dapp-stmt-amount { font-weight: 600; font-size: 15px; }
@media (max-width: 767px) { .pui-dapp .cn-button.pui-dapp-stmt-btn { padding: 12px 16px; } .pui-dapp-stmt-body { padding: 4px 16px 16px; } }

/* Companies. */
.pui-dapp-invite { border-color: var(--tone-info-fg) !important; }
.pui-dapp-avatar-lg { width: 40px; height: 40px; border-radius: 50%; background: var(--secondary); color: var(--secondary-foreground); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.pui-dapp-row.is-company { flex-wrap: nowrap; min-height: 76px; box-sizing: border-box; }

/* Card footers: the note on the left, the link on the right. */
.pui-dapp .cn-card-footer { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); }

/* Warning strip above the credential list. */
.pui-dapp-alert { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 14px; border: 1px solid oklch(0.88 0.08 80); border-radius: 10px; background: var(--tone-warning-bg); color: var(--tone-warning-fg); font-size: 13px; }
.pui-dapp-alert svg { flex: none; }

/* Nothing in the page column may shrink: the page scrolls instead (a short viewport squeezed the header). */
.pui-dapp-scroll > *, .pui-dapp-main > *, .pui-dapp-page > * { flex-shrink: 0; min-width: 0; }
.pui-dapp-scroll > .pui-dapp-main { flex: none; width: 100%; }

/* Text that flows like a sentence: a bold lead-in followed by plain text. */
.pui-dapp-flow { display: block; }
.pui-dapp-flow > * { display: inline; }
.pui-dapp-flow > *:first-child { margin-right: 4px; }

/* Fields: the board stacks a 13px label 6px above the control. */
.pui-dapp .cn-field { gap: 6px; }
.pui-dapp .cn-field > label, .pui-dapp .cn-field .cn-label { font-size: 13px; font-weight: 500; }
.pui-dapp .pui-chip { height: 44px; padding: 0 16px; }

/* Line tabs sit on the left edge, not centred. */
.pui-dapp-tabs, .pui-dapp-tabs > * { width: 100%; align-items: flex-start; justify-content: flex-start; }
.pui-dapp-tabs .cn-tabs-list { justify-content: flex-start; }

.pui-dapp-btnrow { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; }
.pui-dapp-btnrow > * { flex: 0 0 auto; }
.pui-dapp-ok { color: var(--tone-success-fg); }
.pui-dapp-stmts > .pui-dapp-stmt:first-child { border-top: 1px solid var(--border); }

/* Wide and narrow wording: both are in the page, the viewport shows one. */
.pui-dapp-short { display: none; }
@media (max-width: 767px) {
    .pui-dapp-full { display: none !important; }
    .pui-dapp-short { display: inline; }
    .pui-dapp-hide-phone { display: none !important; }
    /* The home page starts at the load on a phone, as the board does; the heading stays for screen readers. */
    .pui-dapp-sr-phone { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    /* The status card shrinks to the one big button above the stops. */
    .pui-dapp-status.cn-card { border: 0; background: transparent; }
    .pui-dapp-status .cn-card-header, .pui-dapp-status .pui-dapp-steps { display: none; }
    .pui-dapp-status .cn-card-content { padding: 0; }
}

/* A card header whose title shares its row with a link: centre the two on one line. */
.pui-dapp .pui-dapp-head-center { align-items: center; }

/* Driver alerts (board "Driver app alerts"): left-aligned text; on a phone 342px wide with the action above the dismiss. */
.pui-dapp-alertdlg .cn-dialog-header, .cn-dialog.pui-dapp-alertdlg .cn-dialog-header { text-align: left; align-items: flex-start; }
.pui-dapp-alertdlg .cn-dialog-title, .pui-dapp-alertdlg .cn-dialog-description { text-align: left; }
.pui-dapp-alertdlg .cn-dialog-footer { justify-content: space-between; }
@media (max-width: 767px) {
    .pui-confirm.pui-dapp-alertdlg .cn-dialog, .cn-dialog.pui-dapp-alertdlg { width: calc(100vw - 48px); max-width: 342px; }
    .pui-dapp-alertdlg .cn-dialog-footer { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
}

/* A list that failed to load (board "Documents, List error"). */
.pui-dapp-tile.is-danger { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.pui-dapp-err.cn-card { padding: 24px 16px; }
.pui-dapp-err-body { align-items: center; text-align: center; }
.pui-dapp-err-title { font-size: 16px; font-weight: 600; }
.pui-dapp-err-body .cn-button { margin-top: 2px; }
