/* TJA Portal - shared styles (tp- prefix). Restyled 2026-08-18: sidebar app shell + surface
   layering + pill badges, Kimai/Nextcloud-inspired but fully our own. Light palette on :root,
   dark overrides under prefers-color-scheme - no framework, no build step. */

:root {
    color-scheme: light dark; /* native controls (date picker etc.) follow theme */

    --tp-bg: #f2f4f8;
    --tp-surface: #ffffff;
    --tp-surface-2: #f6f8fb;
    --tp-sidebar-bg: #ffffff;
    --tp-text: #1c2530;
    --tp-text-dim: #5d6b7a;
    --tp-border: #e2e7ee;
    --tp-primary: #2f6bdf;
    --tp-primary-text: #ffffff;
    --tp-primary-soft: rgba(47, 107, 223, 0.12);
    --tp-error: #c62f28;
    --tp-error-bg: #fdeceb;
    --tp-success: #177245;
    --tp-success-bg: #e6f6ec;
    --tp-info-bg: #e9f1fd;
    --tp-warn-bg: #fff4d6;
    --tp-warn-text: #7a5b00;
    --tp-neutral-bg: #eceff3;
    --tp-neutral-text: #5d6b7a;
    /* The one "no team" grey - shared by crew avatars (board + My Jobs) and no-team dots.
       Deliberately a single value for both themes: it reads against light and dark surfaces
       alike, and having two greys for one concept is what this token replaced. */
    --tp-no-team: #6b7280;
    --tp-radius: 12px;
    --tp-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --tp-bg: #0e1217;
        --tp-surface: #151b23;
        --tp-surface-2: #1b232d;
        --tp-sidebar-bg: #11161d;
        --tp-text: #e7ecf2;
        --tp-text-dim: #93a1b1;
        --tp-border: #27303c;
        --tp-primary: #6b97f2;
        --tp-primary-text: #0d1117;
        --tp-primary-soft: rgba(107, 151, 242, 0.16);
        --tp-error: #ff7b72;
        --tp-error-bg: #3a2020;
        --tp-success: #57d38c;
        --tp-success-bg: #1b3325;
        --tp-info-bg: #1e2a3d;
        --tp-warn-bg: #3a2f10;
        --tp-warn-text: #f0c667;
        --tp-neutral-bg: #252e39;
        --tp-neutral-text: #93a1b1;
        --tp-shadow: none;
    }
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--tp-bg);
    color: var(--tp-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

h1 { font-size: 1.4em; margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 1.02em; margin: 0 0 10px; }

/* ---- App shell: sidebar + content ---------------------------------------------------- */

.tp-shell { display: flex; min-height: 100vh; }

.tp-sidebar {
    width: 232px; flex-shrink: 0;
    background: var(--tp-sidebar-bg);
    border-right: 1px solid var(--tp-border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.tp-sidebar-brand {
    font-weight: 700; font-size: 1.15em; letter-spacing: -0.01em;
    padding: 20px 20px 16px;
}
.tp-sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; overflow-y: auto; }
.tp-sidebar-group {
    padding: 14px 12px 4px; font-size: 0.68em; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.07em; color: var(--tp-text-dim);
}
.tp-sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--tp-text-dim); text-decoration: none; font-size: 0.95em; font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}
.tp-sidebar-nav a:hover { background: var(--tp-surface-2); color: var(--tp-text); }
.tp-sidebar-nav a.active { background: var(--tp-primary-soft); color: var(--tp-primary); font-weight: 600; }
.tp-sidebar-nav svg { width: 18px; height: 18px; flex-shrink: 0; }

.tp-sidebar-foot {
    margin-top: auto;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-top: 1px solid var(--tp-border);
}
.tp-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--tp-primary); color: var(--tp-primary-text);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8em; font-weight: 700; letter-spacing: 0.02em;
}
.tp-sidebar-user { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.tp-sidebar-user strong { font-size: 0.88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-sidebar-user small { color: var(--tp-text-dim); font-size: 0.75em; text-transform: capitalize; }
.tp-logout-btn {
    margin-left: auto; background: none; border: none; cursor: pointer;
    color: var(--tp-text-dim); padding: 6px; border-radius: 8px; display: flex;
}
.tp-logout-btn:hover { background: var(--tp-surface-2); color: var(--tp-error); }
.tp-logout-btn svg { width: 18px; height: 18px; }

.tp-content { flex: 1; min-width: 0; }
.tp-content-inner { max-width: 1200px; margin: 0 auto; padding: 28px 32px 60px; }

.tp-brand { font-weight: 700; font-size: 1.1em; }

/* Mobile top bar + slide-in sidebar */
.tp-mobilebar { display: none; }
.tp-backdrop { display: none; }

@media (max-width: 900px) {
    .tp-mobilebar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 30;
        background: var(--tp-sidebar-bg); border-bottom: 1px solid var(--tp-border);
        padding: 12px 16px;
    }
    .tp-menu-btn {
        background: none; border: none; cursor: pointer; color: var(--tp-text);
        padding: 4px; display: flex;
    }
    .tp-menu-btn svg { width: 22px; height: 22px; }

    .tp-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; height: 100%;
        transform: translateX(-100%); transition: transform 0.2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }
    .tp-sidebar.open { transform: none; }
    .tp-backdrop.visible {
        display: block; position: fixed; inset: 0; z-index: 40;
        background: rgba(0, 0, 0, 0.45);
    }
    .tp-content-inner { padding: 18px 14px 50px; }
}

/* ---- Auth pages (login, forgot/reset password, 404) ---------------------------------- */

.tp-auth-main {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
}
.tp-auth-box { width: 100%; max-width: 420px; }
.tp-auth-brand {
    text-align: center; font-weight: 700; font-size: 1.5em; letter-spacing: -0.01em;
    margin-bottom: 18px;
}

/* ---- Cards ---------------------------------------------------------------------------- */

.tp-card {
    background: var(--tp-surface); border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius); box-shadow: var(--tp-shadow);
    padding: 20px 24px; margin-bottom: 20px;
}
.tp-card-narrow { max-width: 420px; }
/* A card holding a table scrolls horizontally itself at in-between widths (sidebar visible but
   window not wide enough for the table's nowrap columns) - without this, the table bleeds
   straight through the card's border and forces the whole page to scroll sideways. */
.tp-card:has(.tp-table) { overflow-x: auto; }
.tp-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.tp-card-head h1 { margin-bottom: 8px; }
.tp-subform { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--tp-border); }

/* Multi-section forms: cards in a 2-col grid on desktop, single column on phones. */
.tp-form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 20px; }
.tp-form-grid .tp-card { margin-bottom: 0; }
.tp-form-grid .tp-card-span2 { grid-column: 1 / -1; }
@media (min-width: 700px) {
    .tp-form-grid { grid-template-columns: 1fr 1fr; }
}

/* Clickable dashboard tile (Home page). */
.tp-tile {
    display: block; background: var(--tp-surface); border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius); box-shadow: var(--tp-shadow);
    padding: 20px 24px; text-decoration: none; color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.tp-tile:hover { border-color: var(--tp-primary); transform: translateY(-1px); }
.tp-tile h2 { margin: 0 0 6px; color: var(--tp-primary); }
.tp-tile .tp-hint { margin: 0; }

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

label { display: block; margin-bottom: 14px; font-size: 0.88em; color: var(--tp-text-dim); font-weight: 500; }
label.tp-checkbox { display: flex; align-items: center; gap: 8px; color: var(--tp-text); font-weight: 400; }
/* KEEP THIS SELECTOR IN SYNC when a new input type appears anywhere in the app - a missing
   type silently renders at browser-default width instead of the app's field styling. That
   bug has now shipped four times: time, datetime-local, textarea, tel. */
input[type=email], input[type=password], input[type=text], input[type=date],
input[type=datetime-local], input[type=time], input[type=file], input[type=search],
input[type=tel], input[type=url], input[type=number],
select, textarea {
    display: block; width: 100%; margin-top: 5px; padding: 9px 12px;
    border: 1px solid var(--tp-border); border-radius: 8px;
    background: var(--tp-surface-2); color: var(--tp-text);
    font-size: 0.97rem; font-family: inherit;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--tp-primary);
    box-shadow: 0 0 0 3px var(--tp-primary-soft);
}
label.tp-checkbox input { width: auto; margin: 0; accent-color: var(--tp-primary); }

button[type=submit], .tp-button {
    display: inline-block; background: var(--tp-primary); color: var(--tp-primary-text);
    border: none; border-radius: 8px; padding: 9px 18px;
    font-size: 0.93em; font-weight: 600; font-family: inherit; cursor: pointer;
    text-decoration: none; transition: opacity 0.12s ease;
}
button[type=submit]:hover, .tp-button:hover { opacity: 0.88; }

/* Destructive per-row action styled as a bare button (e.g. "Remove") - plain text in the
   error color; element-qualified so button[type=submit] styling doesn't leak in. */
button.tp-row-action-danger {
    background: none; border: none; color: var(--tp-error); cursor: pointer; padding: 0;
    font: inherit; font-size: 0.93em; font-weight: 600; text-decoration: none;
}
button.tp-row-action-danger:hover { text-decoration: underline; }

.tp-inline-form { display: inline; }

/* ---- Alerts, hints, links ------------------------------------------------------------- */

.tp-alert {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 10px 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9em;
    transition: opacity 0.25s ease;
}
.tp-alert-error { background: var(--tp-error-bg); color: var(--tp-error); }
.tp-alert-success { background: var(--tp-success-bg); color: var(--tp-success); }
.tp-alert-info { background: var(--tp-info-bg); color: var(--tp-text); }
.tp-alert-close {
    background: none; border: none; cursor: pointer; font-size: 1.2em; line-height: 1;
    color: inherit; opacity: 0.6; padding: 2px 6px; flex-shrink: 0;
}
.tp-alert-close:hover { opacity: 1; }

.tp-hint { color: var(--tp-text-dim); font-size: 0.85em; margin: -8px 0 14px; }

.tp-form-footer { margin: 16px 0 0; font-size: 0.9em; }
.tp-form-footer a, .tp-form-footer a:visited { color: var(--tp-primary); text-decoration: none; font-weight: 500; }
.tp-form-footer a:hover { text-decoration: underline; }

/* ---- Badges --------------------------------------------------------------------------- */

.tp-badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 0.75em; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
}
.tp-badge-success { background: var(--tp-success-bg); color: var(--tp-success); }
.tp-badge-warn { background: var(--tp-warn-bg); color: var(--tp-warn-text); }
.tp-badge-danger { background: var(--tp-error-bg); color: var(--tp-error); }
.tp-badge-info { background: var(--tp-primary-soft); color: var(--tp-primary); }
.tp-badge-neutral { background: var(--tp-neutral-bg); color: var(--tp-neutral-text); }

/* ---- Tables --------------------------------------------------------------------------- */

.tp-table { width: 100%; border-collapse: collapse; }
.tp-table th, .tp-table td {
    text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--tp-border);
    vertical-align: middle;
}
.tp-table th {
    color: var(--tp-text-dim); font-weight: 600; font-size: 0.72em;
    text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.tp-table tbody tr { transition: background 0.1s ease; }
.tp-table tbody tr:hover { background: var(--tp-surface-2); }
.tp-table tbody tr:last-child td { border-bottom: none; }
.tp-row-inactive { opacity: 0.55; }

/* Sticky save bar for long multi-card forms - rides the bottom of the viewport while the
   form is on screen, so saving never requires scrolling; unsticks past the form's end. */
.tp-savebar {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; align-items: center; gap: 14px;
    background: var(--tp-bg); border-top: 1px solid var(--tp-border);
    padding: 12px 0; margin-top: 4px;
}

/* Live table filter box */
.tp-table-search { max-width: 320px; margin-bottom: 14px; }

/* Group header rows inside tables (e.g. employees grouped by team) */
.tp-table .tp-group-row td {
    font-weight: 700; font-size: 0.95em;
    padding-top: 18px; border-bottom: 1px solid var(--tp-border);
    background: transparent;
}
.tp-table tbody tr.tp-group-row:hover { background: transparent; }
@media (max-width: 700px) {
    .tp-table.tp-stack tr.tp-group-row { border: none; background: transparent; padding: 12px 2px 0; margin-bottom: 4px; }
}

/* Small inline color swatch (team colors etc.) */
.tp-color-dot {
    display: inline-block; width: 11px; height: 11px; border-radius: 50%;
    margin-right: 7px; vertical-align: baseline;
}
/* No team: a muted dot still renders, so name columns stay aligned. Follows the theme
   (darker grey on light, lighter grey on dark) rather than a fixed hex. */
.tp-color-dot-none { background: var(--tp-no-team); }

.tp-row-action, .tp-row-action:visited { color: var(--tp-primary); text-decoration: none; font-weight: 600; font-size: 0.93em; }
.tp-row-action:hover { text-decoration: underline; }

/* Sortable headers */
.tp-sortable-header { cursor: pointer; user-select: none; }
.tp-sortable-header:hover { color: var(--tp-text); }
.tp-sortable-header::after { content: '\2195'; opacity: 0.35; margin-left: 4px; }
.tp-sort-asc::after { content: '\2191'; opacity: 1; }
.tp-sort-desc::after { content: '\2193'; opacity: 1; }

/* Desktop: dates/names/phones read badly wrapped mid-value - keep on one line. */
@media (min-width: 701px) {
    .tp-table td[data-label="Last login"], .tp-table td[data-label="Name"],
    .tp-table td[data-label="Issued"], .tp-table td[data-label="Expires"],
    .tp-table td[data-label="Phone"], .tp-table td[data-label="Status"] { white-space: nowrap; }
}

/* ---- Dispatch board ------------------------------------------------------------------- */

.tp-board-toolbar { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; margin-bottom: 14px; }
/* Filters: one row, horizontally scrollable when narrow instead of wrapping into a pile. */
.tp-board-pills {
    display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; flex: 1; min-width: 240px;
    scrollbar-width: none; padding-bottom: 2px;
}
.tp-board-pills::-webkit-scrollbar { display: none; }
.tp-board-pills .tp-pill { flex-shrink: 0; }
.tp-board-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.tp-pill {
    background: var(--tp-surface); border: 1px solid var(--tp-border); border-radius: 999px;
    padding: 6px 14px; font-size: 0.87em; font-weight: 600; color: var(--tp-text-dim);
    cursor: pointer; font-family: inherit;
}
.tp-pill:hover { color: var(--tp-text); }
.tp-pill.active { background: var(--tp-primary); border-color: var(--tp-primary); color: var(--tp-primary-text); }

.tp-teamweek { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tp-teamchip {
    border: 2px solid; border-radius: 999px; padding: 3px 12px;
    font-size: 0.82em; font-weight: 700;
}
.tp-teamchip small { font-weight: 500; opacity: 0.85; }
.tp-teamweek { align-items: center; }
.tp-teamweek-note { margin-left: auto; font-size: 0.85em; font-weight: 600; color: var(--tp-text-dim); }

.tp-board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
@media (max-width: 600px) { .tp-board-grid { grid-template-columns: 1fr; } }

.tp-jobcard {
    background: var(--tp-surface); border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius); box-shadow: var(--tp-shadow);
    padding: 14px 16px; cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.tp-jobcard:hover { border-color: var(--tp-primary); transform: translateY(-1px); }
/* Active jobs pop on the board: success-green edge stripe (same green as the Active
   badge; user tried the tinted-background version and preferred the stripe alone). */
.tp-jobcard-live { border-left: 4px solid var(--tp-success); }
.tp-jobcard-readonly { cursor: default; }
.tp-jobcard-readonly:hover { border-color: var(--tp-border); transform: none; }
.tp-jobcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tp-jobnumber { font-weight: 700; color: var(--tp-primary); }
.tp-jobcard-customer { font-size: 1.03em; font-weight: 600; margin: 6px 0 4px; }
.tp-jobcard-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.85em; color: var(--tp-text-dim); }
.tp-leaveby { font-weight: 700; margin-left: auto; } /* pins to the card's right edge */
.tp-jobcard-crew { margin-top: 10px; border-top: 1px solid var(--tp-border); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.tp-jobcard-note { margin-top: 10px; border-top: 1px solid var(--tp-border); padding-top: 8px; }
.tp-jobcard-note-body {
    font-size: 0.88em; white-space: pre-wrap;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tp-jobcard-note-meta { font-size: 0.78em; color: var(--tp-text-dim); margin-top: 3px; }

/* Collapsible sections inside modal cards */
.tp-modal-details { margin-top: 10px; }
.tp-modal-details summary {
    cursor: pointer; color: var(--tp-text-dim); font-size: 0.88em; font-weight: 600;
    user-select: none;
}
.tp-modal-details summary:hover { color: var(--tp-text); }
.tp-modal-history { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.tp-modal-history-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.9em; }

/* Full notes feed inside the board's edit modal */
.tp-modal-notes { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.tp-modal-note { border-top: 1px solid var(--tp-border); padding-top: 8px; }
.tp-modal-note .tp-jobcard-note-body { -webkit-line-clamp: unset; }

.tp-crewrow { display: flex; align-items: center; gap: 9px; }
.tp-crew-avatar {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.tp-avatar-inline { display: inline-flex; vertical-align: middle; margin-right: 8px; }
.tp-crewname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.93em; }
.tp-double-booked { display: block; font-size: 0.82em; font-weight: 700; color: var(--tp-warn-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Advisory customer/location flag lines - crew rows on cards + the modal's warning list */
.tp-flag-warn { display: block; font-size: 0.82em; font-weight: 700; color: var(--tp-error); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-flag-good { display: block; font-size: 0.82em; font-weight: 600; color: var(--tp-success); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-flag-warns { margin: 6px 0 2px; }
.tp-flag-warns .tp-flag-warn, .tp-flag-warns .tp-flag-good { white-space: normal; }
/* Clickable employee names on the board (open the read-only reference card) */
.tp-emplink { cursor: pointer; border-bottom: 1px dotted var(--tp-text-dim); }
.tp-emplink:hover { color: var(--tp-primary); border-bottom-color: var(--tp-primary); }
/* Employee reference card rows */
.tp-empcard-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-empcard-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 4px 0; font-size: 0.93em; }
.tp-empcard-row + .tp-empcard-row { border-top: 1px solid var(--tp-border); }
.tp-empcard-dim { color: var(--tp-text-dim); font-size: 0.9em; }
.tp-empcard-note { flex-basis: 100%; color: var(--tp-text-dim); font-size: 0.88em; }
/* Expandable roster rows (employees list accordion) */
tr[data-toggle-detail] { cursor: pointer; }
.tp-chevron {
    display: inline-block; width: 7px; height: 7px; margin-right: 9px;
    border-right: 2px solid var(--tp-text-dim); border-bottom: 2px solid var(--tp-text-dim);
    transform: rotate(-45deg); transition: transform 0.15s; vertical-align: 2px;
}
tr.tp-detail-open .tp-chevron { transform: rotate(45deg); }
.tp-detail-row > td { background: var(--tp-surface-2); padding: 14px 16px 16px; }
.tp-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
@media (max-width: 900px) { .tp-detail-grid { grid-template-columns: 1fr; } }
.tp-detail-section h4 {
    margin: 0 0 6px; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--tp-text-dim); font-weight: 600;
}
.tp-detail-section .tp-hint { margin: 0; }
.tp-detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-detail-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 3px 0; font-size: 0.93em; }
.tp-detail-line + .tp-detail-line { border-top: 1px solid var(--tp-border); }
.tp-detail-dim { color: var(--tp-text-dim); font-size: 0.9em; }
.tp-detail-note { flex-basis: 100%; }
/* Inline grant form in the certification-types accordion */
.tp-cert-grant { margin-top: 12px; }
.tp-cert-grant h4, .tp-detail-section-h4 {
    margin: 0 0 6px; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--tp-text-dim); font-weight: 600;
}
.tp-cert-grant-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tp-cert-grant-row select, .tp-cert-grant-row input { width: auto; flex: 1; min-width: 150px; margin: 0; }
.tp-cert-grant-row button { flex-shrink: 0; }
/* Multi-select grant in the skills accordion - a skill is a bare boolean, so it batches */
.tp-skill-grant { margin-top: 12px; }
.tp-skill-pick {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2px 14px; margin: 0 0 10px;
}
.tp-skill-pick label.tp-checkbox { padding: 5px 6px; border-radius: 8px; font-size: 0.93em; cursor: pointer; }
.tp-skill-pick label.tp-checkbox:hover { background: var(--tp-primary-soft); }

/* File-viewer dialog (certificate PDFs/images) */
.tp-modal.tp-fileview { width: min(92vw, 900px); max-width: none; }
.tp-fileview-body { height: min(75vh, 800px); display: flex; align-items: center; justify-content: center; }
.tp-fileview-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.tp-fileview-body iframe { width: 100%; height: 100%; border: none; border-radius: 8px; background: #fff; }
/* Tasks page */
.tp-tasks-body { display: flex; gap: 16px; align-items: flex-start; }
.tp-tasklists { width: 260px; flex-shrink: 0; position: sticky; top: 16px; }
.tp-tasks-main { flex: 1; min-width: 0; }
@media (max-width: 900px) {
    .tp-tasks-body { flex-direction: column; }
    .tp-tasklists { width: 100%; position: static; }
}
.tp-tasklist-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
    cursor: pointer; font-size: 0.95em;
}
.tp-tasklist-item:hover { background: var(--tp-surface-2); }
.tp-tasklist-item.active { background: var(--tp-primary-soft); color: var(--tp-primary); font-weight: 600; }
.tp-tasklist-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-tasklist-count { color: var(--tp-text-dim); font-size: 0.85em; }
.tp-tasklist-tools { display: none; gap: 2px; }
.tp-tasklist-item:hover .tp-tasklist-tools { display: inline-flex; }
.tp-tasklist-tool {
    border: none; background: none; color: var(--tp-text-dim); cursor: pointer;
    font-size: 0.95em; padding: 0 4px; border-radius: 4px;
}
.tp-tasklist-tool:hover { color: var(--tp-text); background: var(--tp-neutral-bg); }
.tp-tasklist-new { margin: 8px 0 0; }
.tp-tasklists-others { margin-top: 12px; border-top: 1px solid var(--tp-border); padding-top: 10px; }
.tp-tasklists-owner {
    font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--tp-text-dim); font-weight: 600; padding: 6px 10px 2px;
}
.tp-task-add { margin: 0 0 12px; }
.tp-task { border-bottom: 1px solid var(--tp-border); }
.tp-task:last-child { border-bottom: none; }
.tp-task-main { display: flex; align-items: center; gap: 10px; padding: 9px 4px; cursor: pointer; }
.tp-task-main:hover { background: var(--tp-surface-2); }
.tp-task-main input[type=checkbox] { margin: 0; flex-shrink: 0; width: 17px; height: 17px; }
.tp-task-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-task.done .tp-task-title { text-decoration: line-through; color: var(--tp-text-dim); }
.tp-task-subcount { color: var(--tp-text-dim); font-size: 0.85em; }
.tp-task-repeat { color: var(--tp-text-dim); font-size: 0.95em; }
/* Inline nested subtasks + collapse caret */
.tp-task-caret {
    border: none; background: none; cursor: pointer; padding: 2px 4px; flex-shrink: 0;
    width: 18px; height: 18px; position: relative;
}
.tp-task-caret::before {
    content: ''; position: absolute; top: 5px; left: 5px; width: 6px; height: 6px;
    border-right: 2px solid var(--tp-text-dim); border-bottom: 2px solid var(--tp-text-dim);
    transform: rotate(-45deg); transition: transform 0.15s;
}
.tp-task-caret.open::before { transform: rotate(45deg); }
.tp-task-kids { padding: 0 0 6px 52px; }
.tp-task-kids .tp-task-sub { cursor: pointer; border-radius: 6px; padding: 3px 6px; }
.tp-task-kids .tp-task-sub:hover { background: var(--tp-surface-2); }
.tp-modal-subhead {
    margin: 4px 0 2px; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--tp-text-dim); font-weight: 600;
}
.tp-task-star { border: none; background: none; cursor: pointer; font-size: 1.05em; color: var(--tp-border); padding: 0 2px; }
.tp-task-star.on { color: #e8a53a; }
.tp-task-star:hover { color: #e8a53a; }
.tp-task-drag { color: var(--tp-text-dim); cursor: grab; touch-action: none; padding: 0 2px; user-select: none; }
.tp-task.dragging { opacity: 0.55; }
.tp-task-editor { padding: 4px 8px 12px 34px; display: flex; flex-direction: column; gap: 8px; }
.tp-task-editor-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tp-task-editor-row > label { min-width: 150px; }
.tp-task-editor-actions { display: flex; align-items: center; gap: 10px; }
.tp-task-subs { display: flex; flex-direction: column; gap: 2px; }
.tp-task-sub { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 0.93em; }
.tp-task-sub.done .tp-task-title { text-decoration: line-through; color: var(--tp-text-dim); }
.tp-task-sub input[type=checkbox] { margin: 0; width: 15px; height: 15px; }
@media (max-width: 600px) { .tp-task-editor-row { flex-direction: column; gap: 8px; } }
.tp-call {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: var(--tp-success-bg); color: var(--tp-success); text-decoration: none;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.tp-call:hover { filter: brightness(1.1); }
@media (max-width: 600px) { .tp-call { width: 38px; height: 38px; font-size: 16px; } }

/* Board body: hands panel stacks on top (phones) or docks right of the job grid (desktop). */
.tp-board-body { display: flex; flex-direction: column; gap: 14px; }
.tp-board-body .tp-board-grid { flex: 1; min-width: 0; }
.tp-hands-card { margin-bottom: 0; }
@media (min-width: 1000px) {
    .tp-board-body { flex-direction: row-reverse; align-items: flex-start; }
    .tp-hands-card { width: 360px; flex-shrink: 0; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
}

/* Hands panels (Available / All), grouped by team */
.tp-hands-group { margin-top: 12px; }
.tp-hands-group-label {
    font-size: 0.7em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--tp-text-dim); margin-bottom: 6px; display: flex; align-items: center;
}
.tp-hands { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 20px; margin-top: 8px; }
.tp-hand { display: flex; align-items: flex-start; gap: 9px; }
.tp-hand-name { font-weight: 600; font-size: 0.95em; }
.tp-hand-job { font-size: 0.83em; color: var(--tp-text-dim); margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tp-hand-job .tp-jobnumber { font-size: 1em; }

/* Board modal */
.tp-modal-backdrop {
    position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.tp-modal {
    background: var(--tp-surface); border: 1px solid var(--tp-border); border-radius: var(--tp-radius);
    width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 20px 22px;
}
/* Card sections inside a modal - one shade deeper than the modal surface for separation. */
.tp-modal-card {
    background: var(--tp-surface-2); border: 1px solid var(--tp-border);
    border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.tp-modal-card > h3 { margin: 0 0 10px; font-size: 0.95em; }
.tp-modal-card input, .tp-modal-card select { background: var(--tp-surface); }
.tp-modal-body { display: flex; flex-direction: column; }
.tp-modal-label { display: block; margin-bottom: 12px; font-size: 0.88em; color: var(--tp-text-dim); font-weight: 500; }
.tp-modal-label select, .tp-modal-label input { margin-top: 5px; }
.tp-modal-actions { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.tp-modal-error { background: var(--tp-error-bg); color: var(--tp-error); border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 0.9em; }
.tp-modal-delete {
    background: none; border: none; color: var(--tp-error); cursor: pointer;
    font: inherit; font-weight: 600; padding: 6px 8px;
}
.tp-crew-editor-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tp-crew-editor-row select { margin: 0; }
.tp-crew-editor-row select:first-child { flex: 2; }
.tp-crew-editor-row select:nth-child(2) { flex: 1; }

/* Toast */
.tp-toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200;
    background: var(--tp-text); color: var(--tp-bg); border-radius: 999px;
    padding: 9px 20px; font-size: 0.9em; font-weight: 600;
    transition: opacity 0.3s ease; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.tp-toast.error { background: var(--tp-error); color: #fff; }
.tp-toast.gone { opacity: 0; }

/* Phones: tables collapse to stacked cards (data-label becomes each field's mini-header). */
@media (max-width: 700px) {
    .tp-table.tp-stack, .tp-table.tp-stack thead, .tp-table.tp-stack tbody,
    .tp-table.tp-stack th, .tp-table.tp-stack td, .tp-table.tp-stack tr { display: block; }
    .tp-table.tp-stack thead { display: none; }
    .tp-table.tp-stack tr {
        border: 1px solid var(--tp-border); border-radius: 10px; margin-bottom: 10px;
        padding: 10px 12px; background: var(--tp-surface);
    }
    .tp-table.tp-stack tbody tr:hover { background: var(--tp-surface); }
    .tp-table.tp-stack td { border-bottom: none; padding: 4px 0; }
    .tp-table.tp-stack tbody tr:last-child td { border-bottom: none; }
    .tp-table.tp-stack td[data-label]:not([data-label=""])::before {
        content: attr(data-label); display: block; font-size: 0.7em; text-transform: uppercase;
        letter-spacing: 0.05em; color: var(--tp-text-dim); margin-bottom: 1px; font-weight: 600;
    }
}

/* My Jobs (employee-facing) */
.tp-attention-row {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
    border-top: 1px solid var(--tp-border); text-decoration: none; color: inherit;
}
.tp-attention-row:first-of-type { border-top: none; }
.tp-attention-row:hover strong { color: var(--tp-primary); }
.tp-attention-note { display: block; font-size: 0.86em; font-weight: 600; color: var(--tp-warn-text); margin-top: 3px; }
.tp-ticket-row { border-top: 1px solid var(--tp-border); padding: 10px 0; }
.tp-ticket-row:first-of-type { border-top: none; }
.tp-ticket-row-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tp-jobcard-sheets { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.tp-jobcard-sheets a { text-decoration: none; }
.tp-jobcard-equip { margin-top: 8px; font-size: 0.85em; color: var(--tp-text-dim); }
.tp-equip-conflict { color: #d97706; font-weight: 600; }
.tp-wellrow { display: flex; gap: 8px; margin-bottom: 8px; }
.tp-wellrow input { margin: 0; }
.tp-wellrow input[name="afe[]"] { max-width: 130px; }
.tp-ticket-wells { font-size: 0.86em; color: var(--tp-text-dim); margin-top: 3px; }
.tp-reported-well { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--tp-border); font-size: 0.92em; flex-wrap: wrap; }
/* A badge that is also a button (inline toggles in admin tables) */
button.tp-badge-btn { border: none; cursor: pointer; font: inherit; font-size: 0.78em; font-weight: 600; }
button.tp-badge-btn:hover { filter: brightness(1.15); }
/* Inline add row on the Locations page */
.tp-loc-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tp-loc-add select, .tp-loc-add input { margin: 0; width: auto; flex: 1; min-width: 170px; }
.tp-loc-add button { flex-shrink: 0; }
/* Location contact strip on job cards - rig phone + map pin */
.tp-jobcard-site { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.tp-sitelink {
    display: inline-flex; align-items: center; gap: 4px; text-decoration: none;
    font-size: 0.85em; font-weight: 600; padding: 3px 9px; border-radius: 999px;
    background: var(--tp-success-bg); color: var(--tp-success);
}
.tp-sitelink:hover { filter: brightness(1.12); }
@media (max-width: 600px) { .tp-sitelink { font-size: 0.95em; padding: 6px 12px; } }
/* Job driving directions - free text, pasted pins become links */
.tp-directions { margin-top: 10px; border-top: 1px solid var(--tp-border); padding-top: 8px; }
.tp-directions-label { font-size: 0.72em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tp-text-dim); margin-bottom: 3px; }
.tp-directions-body { font-size: 0.92em; white-space: pre-wrap; word-break: break-word; }
.tp-directions-body a { color: var(--tp-primary); }
/* Collapsible sidebar groups */
.tp-sidebar-group-items { display: flex; flex-direction: column; gap: 2px; }
.tp-sidebar-group-items.collapsed { display: none; }
button.tp-sidebar-group-btn {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: none; border: none; cursor: pointer; font-family: inherit; text-align: left;
}
button.tp-sidebar-group-btn:hover { color: var(--tp-text); }
.tp-nav-caret {
    width: 6px; height: 6px; flex-shrink: 0; margin-right: 4px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg); transition: transform 0.15s ease;
}
button.tp-sidebar-group-btn.collapsed .tp-nav-caret { transform: rotate(-45deg); }
