/* ============================================================
   CPITechBilling — field-tech billing applet
   Aesthetic: industrial job ticket. Warm paper, ink, safety
   orange. Condensed display type, mono numbers, cut-corner
   cards, stamp-style status chips. Portrait-first, sunlight-
   readable, glove-sized touch targets.
   ============================================================ */

:root {
    --ink: #16232d;
    --ink-soft: #3c4c58;
    --paper: #f3efe6;
    --card: #fffdf7;
    --line: #d9d2c0;
    --line-hard: #b9b09a;
    --accent: #e8590c;
    --accent-deep: #b23e00;
    --accent-soft: #fdeee3;
    --steel: #4e6e81;
    --ok: #2b8a3e;
    --danger: #c92a2a;
    --font-body: 'Barlow', system-ui, sans-serif;
    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-mono: 'IBM Plex Mono', Consolas, monospace;
    --corner: 14px;
    --tap: 56px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

/* Subtle blueprint-grid atmosphere on the paper */
body {
    background-image:
        linear-gradient(var(--paper) 0 0),
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(78, 110, 129, 0.07) 31px 32px),
        repeating-linear-gradient(90deg, transparent 0 31px, rgba(78, 110, 129, 0.07) 31px 32px);
    background-blend-mode: normal, multiply, multiply;
}

#app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ------------------------------------------------------------
   Splash (pre-Blazor boot)
   ------------------------------------------------------------ */

.tb-splash {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--ink);
}

.tb-splash__mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 40px;
    color: var(--accent);
    border: 3px solid var(--accent);
    padding: 4px 14px;
    transform: rotate(-4deg);
}

.tb-splash__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: 0.35em;
    color: var(--paper);
}

.tb-splash__bar {
    width: 180px;
    height: 4px;
    background: rgba(243, 239, 230, 0.2);
    overflow: hidden;
}

.tb-splash__bar span {
    display: block;
    width: 40%;
    height: 100%;
    background: var(--accent);
    animation: tb-scan 1.1s ease-in-out infinite alternate;
}

@keyframes tb-scan {
    from { transform: translateX(-30%); }
    to { transform: translateX(280%); }
}

/* ------------------------------------------------------------
   App bar
   ------------------------------------------------------------ */

.tb-bar {
    background: var(--ink);
    color: var(--paper);
    padding: 10px 16px calc(10px + 2px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 3px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tb-bar__brand {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
    min-width: 0;
}

.tb-bar__co {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.28em;
    color: rgba(243, 239, 230, 0.65);
    white-space: nowrap;
}

.tb-bar__app {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.06em;
    color: var(--paper);
    white-space: nowrap;
}

.tb-bar__who {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    min-width: 0;
}

.tb-chip {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    background: rgba(243, 239, 230, 0.12);
    border: 1px solid rgba(243, 239, 230, 0.3);
    color: var(--paper);
    padding: 2px 8px;
    white-space: nowrap;
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-chip--accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ------------------------------------------------------------
   Page scaffold
   ------------------------------------------------------------ */

.tb-main {
    flex: 1;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}

.tb-h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 34px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 4px 0 2px;
}

.tb-h1::after {
    content: "";
    display: block;
    width: 56px;
    height: 5px;
    margin-top: 6px;
    background: var(--accent);
}

.tb-sub {
    color: var(--ink-soft);
    margin: 8px 0 20px;
    font-size: 15px;
}

/* ------------------------------------------------------------
   Cards — job-ticket look: cut corner + hard shadow
   ------------------------------------------------------------ */

.tb-card {
    background: var(--card);
    border: 1.5px solid var(--line-hard);
    clip-path: polygon(0 0, calc(100% - var(--corner)) 0, 100% var(--corner), 100% 100%, 0 100%);
    box-shadow: 4px 4px 0 rgba(22, 35, 45, 0.12);
    margin-bottom: 14px;
}

.tb-card--pad {
    padding: 18px 16px;
}

.tb-perf {
    border: none;
    border-top: 2px dashed var(--line);
    margin: 14px 0;
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */

.tb-label {
    display: block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin: 0 0 6px;
}

.tb-input {
    display: block;
    width: 100%;
    min-height: var(--tap);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 20px;
    color: var(--ink);
    background: #fff;
    border: 2px solid var(--line-hard);
    border-radius: 0;
    margin-bottom: 16px;
}

.tb-input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.tb-input::placeholder {
    color: #b3ac9b;
    font-weight: 500;
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */

.tb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: var(--tap);
    padding: 12px 18px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fff;
    background: var(--accent);
    border: none;
    border-bottom: 4px solid var(--accent-deep);
    cursor: pointer;
    touch-action: manipulation;
}

.tb-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.tb-btn:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.tb-btn:disabled {
    background: #a9a293;
    border-bottom-color: #8d8677;
    cursor: not-allowed;
}

.tb-btn--ghost {
    background: transparent;
    color: var(--ink);
    border: 2px solid var(--ink);
    border-bottom-width: 2px;
    font-size: 17px;
}

.tb-btn--ghost:active {
    transform: none;
    background: rgba(22, 35, 45, 0.06);
}

/* ------------------------------------------------------------
   Tap rows (trucks, dispatches)
   ------------------------------------------------------------ */

.tb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: var(--tap);
    padding: 14px 14px;
    background: transparent;
    border: none;
    border-radius: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}

.tb-row + .tb-row {
    border-top: 2px dashed var(--line);
}

.tb-row:active {
    background: var(--accent-soft);
}

.tb-row:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
}

.tb-row__code {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 15px;
    background: var(--ink);
    color: var(--paper);
    padding: 4px 8px;
    white-space: nowrap;
}

.tb-row__body {
    flex: 1;
    min-width: 0;
}

.tb-row__title {
    font-weight: 600;
    font-size: 17px;
}

.tb-row__meta {
    color: var(--ink-soft);
    font-size: 14px;
}

.tb-row__chev {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    color: var(--accent);
}

/* ------------------------------------------------------------
   Dispatch tickets
   ------------------------------------------------------------ */

.tb-ticket {
    padding: 14px 16px 16px;
}

.tb-ticket__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.tb-ticket__wo {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.02em;
}

.tb-stamp {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-deep);
    border: 2px solid var(--accent-deep);
    padding: 1px 8px;
    transform: rotate(-3deg);
    white-space: nowrap;
}

.tb-stamp--steel {
    color: var(--steel);
    border-color: var(--steel);
}

.tb-ticket__cust {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.tb-ticket__addr {
    color: var(--ink-soft);
    font-size: 15px;
    margin-top: 2px;
}

.tb-ticket__desc {
    font-size: 15px;
    margin-top: 10px;
}

.tb-ticket__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 2px dashed var(--line);
}

.tb-ticket__time {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 14px;
    color: var(--ink-soft);
}

/* ------------------------------------------------------------
   Notices
   ------------------------------------------------------------ */

.tb-error {
    background: #fdecec;
    border: 2px solid var(--danger);
    color: #7d1a1a;
    padding: 12px 14px;
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 16px;
}

.tb-note {
    background: var(--accent-soft);
    border-left: 5px solid var(--accent);
    color: var(--ink);
    padding: 12px 14px;
    font-size: 14px;
    margin: 14px 0 0;
}

.tb-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 26px 4px;
    justify-content: center;
}

.tb-loading::before {
    content: "";
    width: 18px;
    height: 18px;
    border: 3px solid var(--line-hard);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: tb-spin 0.8s linear infinite;
}

@keyframes tb-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .tb-splash__bar span,
    .tb-loading::before {
        animation-duration: 2.5s;
    }
}

/* ------------------------------------------------------------
   Blazor error bar (kept ugly on purpose - it means a crash)
   ------------------------------------------------------------ */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--danger);
    color: #fff;
    padding: 12px 44px 12px 16px;
    font-weight: 600;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
    margin-left: 10px;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 14px;
    top: 12px;
    cursor: pointer;
}

/* ------------------------------------------------------------
   Selects, search, chips
   ------------------------------------------------------------ */

.tb-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
        linear-gradient(135deg, var(--ink) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 40px;
}

.tb-label__opt {
    text-transform: none;
    letter-spacing: 0;
    color: #98917f;
    font-weight: 500;
}

.tb-searchrow {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tb-search {
    margin-bottom: 0;
    font-size: 16px;
}

.tb-btn--sq {
    width: auto;
    min-width: 72px;
    flex-shrink: 0;
}

.tb-vstoggle {
    flex-shrink: 0;
    min-height: var(--tap);
    padding: 6px 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    background: var(--card);
    border: 2px solid var(--line-hard);
    cursor: pointer;
    touch-action: manipulation;
}

.tb-vstoggle--on {
    background: var(--accent);
    border-color: var(--accent-deep);
    color: #fff;
}

.tb-chiprow {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tb-chiprow::-webkit-scrollbar {
    display: none;
}

.tb-chip-f {
    flex-shrink: 0;
    min-height: 40px;
    padding: 6px 14px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.08em;
    color: var(--ink);
    background: var(--card);
    border: 2px solid var(--line-hard);
    cursor: pointer;
    touch-action: manipulation;
}

.tb-chip-f--on {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

.tb-tag {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.1em;
    padding: 1px 7px;
    border: 1.5px solid var(--steel);
    color: var(--steel);
    white-space: nowrap;
}

.tb-tag--warn {
    border-color: var(--accent-deep);
    color: var(--accent-deep);
}

.tb-tag--ok {
    border-color: var(--ok);
    color: var(--ok);
}

.tb-ticket__loc {
    font-weight: 600;
    font-size: 15px;
    color: var(--ink-soft);
}

/* ------------------------------------------------------------
   Job context bar (invoice + parts pages)
   ------------------------------------------------------------ */

.tb-jobbar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--ink);
    color: var(--paper);
    margin: -20px -16px 18px;
    padding: 10px 12px;
}

.tb-back {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
    background: transparent;
    border: 2px solid rgba(243, 239, 230, 0.25);
    cursor: pointer;
    touch-action: manipulation;
}

.tb-jobbar__body {
    min-width: 0;
}

.tb-jobbar__cust {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-jobbar__meta {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 12px;
    color: rgba(243, 239, 230, 0.7);
}

/* ------------------------------------------------------------
   Invoice items
   ------------------------------------------------------------ */

.tb-item + .tb-item {
    border-top: 2px dashed var(--line);
}

.tb-item__main {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: var(--tap);
    padding: 12px 14px;
    background: transparent;
    border: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}

.tb-item--open {
    background: var(--accent-soft);
}

.tb-item__part {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    background: var(--ink);
    color: var(--paper);
    padding: 3px 6px;
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.tb-item__desc {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-item__math {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink-soft);
}

.tb-item__wh {
    color: var(--steel);
    font-weight: 600;
}

.tb-item__notes {
    font-size: 13px;
    font-style: italic;
    color: var(--steel);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-item__amt {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
}

.tb-edit {
    padding: 4px 14px 14px;
    border-top: 2px dashed var(--line);
    background: var(--accent-soft);
}

.tb-edit__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.tb-edit__row .tb-label {
    margin: 0;
}

.tb-edit__actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.tb-input--slim {
    margin-bottom: 0;
    max-width: 160px;
    min-height: 48px;
    font-size: 18px;
    text-align: right;
}

.tb-stepper {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--line-hard);
    background: #fff;
}

.tb-stepper button {
    width: 48px;
    min-height: 48px;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-deep);
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
}

.tb-stepper button:active {
    background: var(--accent-soft);
}

.tb-stepper input {
    width: 72px;
    border: none;
    border-left: 2px solid var(--line);
    border-right: 2px solid var(--line);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 18px;
    text-align: center;
}

.tb-stepper input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
}

.tb-btn--sm {
    min-height: 48px;
    font-size: 16px;
    flex: 1;
}

.tb-btn--danger {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
    border-bottom-width: 2px;
}

.tb-btn--danger:active {
    transform: none;
    background: #fdecec;
}

.tb-totals {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ink);
    color: var(--paper);
    padding: 12px 16px;
    margin-bottom: 14px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tb-totals__sum {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 22px;
    color: var(--accent);
}

/* ------------------------------------------------------------
   Part picker
   ------------------------------------------------------------ */

.tb-partrow {
    align-items: center;
}

.tb-partrow__no {
    display: block;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    color: var(--steel);
}

.tb-partrow__desc {
    display: block;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.25;
}

.tb-partrow__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.tb-partrow__cat {
    font-size: 12px;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tb-partrow__price {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
}

.tb-morehint {
    text-align: center;
    color: var(--ink-soft);
    font-size: 14px;
    margin: 4px 0 16px;
}

.tb-stockline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    margin: -6px 0 14px;
}

.tb-stockline__wait {
    font-size: 13px;
    font-style: italic;
    color: var(--ink-soft);
}

.tb-addsheet__part {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 15px;
    background: var(--ink);
    color: var(--paper);
    display: inline-block;
    padding: 4px 10px;
    margin-bottom: 14px;
}

.tb-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Input + trailing picker button (sign-in warehouse row) */

.tb-inputrow {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.tb-inputrow .tb-input {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.tb-btn--pick {
    width: 56px;
    min-height: var(--tap);
    flex-shrink: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--paper);
    background: var(--ink);
    border: none;
    border-bottom: 4px solid #000;
    cursor: pointer;
    touch-action: manipulation;
}

.tb-btn--pick:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.tb-btn--pick:disabled {
    background: #a9a293;
    border-bottom-color: #8d8677;
}
