/* JTA-CPA brand tokens — verified against the live site's Elementor Global
   Colors (OneNote: _JTA Website Standards). Keep this app visually
   consistent with jta-cpa.com since it links from there. */
:root {
    --primary: #00338D;
    --blue: #0365C3;
    --terracotta: #E35336;
    --text: #000000;
    --heading: #111111;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --bg: #F8F9FA;
    --bg-light: #F2F4F5;
    --accent-bg: #E8F1FF;
    --surface: #FFFFFF;
    --green: #0A7B60;
    --amber: #B8860B;
    --red: #C62828;
    --gray: #8A8A8A;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 17px;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Type scale -- Desktop/Tablet/Mobile sizes match the JTA-CPA brand
   standard (OneNote: _JTA Website Standards > Typography) exactly, at
   the same 1024px/767px breakpoints used everywhere else in this file
   (iPad landscape ~1024px, iPad portrait/iPhone land inside the
   mobile tier). Desktop values live on the bare selector; tablet/
   mobile override below so a 48px H1 doesn't dominate an iPhone
   screen. */
h1 {
    font-size: 48px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--heading);
    margin: 0 0 8px 0;
}

h2 {
    font-size: 32px;
    font-weight: 500;
    line-height: 1.25;
    color: var(--heading);
    margin: 0 0 20px 0;
}

h3 {
    font-size: 24px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--heading);
    margin: 20px 0 10px 0;
}

.subtitle {
    color: var(--text-muted);
    margin: 0 0 24px 0;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 48px 32px 80px 32px;
}
@media (max-width: 1024px) {
    .container { padding: 40px 28px 64px 28px; }
    body { font-size: 16px; }
    h1 { font-size: 38px; }
    h2 { font-size: 28px; }
    h3 { font-size: 22px; }
}
@media (max-width: 767px) {
    .container { padding: 32px 20px 48px 20px; }
    body { font-size: 16px; }
    h1 { font-size: 30px; }
    h2 { font-size: 24px; }
    h3 { font-size: 20px; }
    .auth-intro h1, .auth-panel h1 { font-size: 30px; }
    /* Bigger touch targets for the small action buttons packed into
       table rows (Edit/Delete/Approve/Reject) and the Excel-style
       picker's checkboxes -- both stay compact on desktop, where a
       mouse pointer doesn't need the extra room. */
    .btn-small { padding: 10px 16px; }
    .select-table input[type="checkbox"] { width: 22px; height: 22px; }
}

/* Top bar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.brand {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    flex: none;
}
.brand:hover { text-decoration: none; }
.brand-accent { color: var(--primary); }
.topbar-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
}
.user-email {
    color: var(--text-muted);
    font-size: 15px;
    white-space: nowrap;
}

/* Second nav row — account/admin functions kept visually separate from
   the primary workflow buttons above, since they're used far less often
   and mixing them made the top row overflow onto 3+ lines. A shaded
   strip (not a hairline + gap) reads as one continuous header instead
   of two stacked, disconnected boxes. */
.topbar-secondary {
    background: var(--bg-light);
    border-top: 1px solid var(--border);
}
.topbar-secondary-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 9px 24px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}
.topbar-secondary-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-right: 4px;
}
.topbar-secondary .btn { padding: 5px 12px; font-size: 13px; }

/* Mobile nav toggle -- CSS-only (checkbox hack), no JS. The checkbox
   sits as the first child of <header>, hidden, so its :checked state
   can be targeted via sibling selectors from both .topbar-right
   (nested inside .topbar-inner) and .topbar-secondary (a direct
   sibling of .topbar-inner) at once -- one hamburger controls both
   nav rows together instead of leaving the admin row to wrap messily
   on its own. The visible <label for="nav-toggle"> lives wherever
   makes sense in the markup (next to the brand) since label/checkbox
   association works by id, not DOM position. */
.nav-toggle-checkbox { display: none; }
.nav-toggle-btn { display: none; }
@media (max-width: 767px) {
    .nav-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-left: auto;
        font-size: 22px;
        line-height: 1;
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text);
        cursor: pointer;
    }
    .nav-toggle-btn:hover { border-color: var(--blue); }
    .topbar-right {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin-top: 12px;
        gap: 8px;
    }
    .topbar-right .btn,
    .topbar-right form,
    .topbar-right form .btn {
        width: 100%;
        text-align: center;
    }
    .topbar-right form { display: block; }
    .user-email { order: -1; padding: 4px 0; }
    #nav-toggle:checked ~ .topbar-inner .topbar-right { display: flex; }
    .topbar-secondary { display: none; }
    #nav-toggle:checked ~ .topbar-secondary { display: block; }
    .topbar-secondary-inner { flex-direction: column; align-items: stretch; }
    .topbar-secondary .btn { width: 100%; text-align: center; padding: 10px 12px; font-size: 14px; }
}

/* Flash messages */
.flash {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 15px;
}
.flash-error {
    background: #FDECEA;
    color: var(--red);
    border: 1px solid #F5C6C0;
}
.flash-success {
    background: #E6F4EA;
    color: var(--green);
    border: 1px solid #BFE3C6;
}
.flash code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
}

/* Buttons — filled blue, hover terracotta, matching the jta-cpa.com button
   treatment (Buttons #0365C3, hover #E35336). Danger buttons stay red as
   the destructive-action signal. */
.btn {
    display: inline-block;
    font-size: 16px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--blue);
    color: #fff;
}
.btn:hover { background: var(--terracotta); text-decoration: none; }
.btn-primary {
    background: var(--blue);
    color: #fff;
}
.btn-primary:hover { background: var(--terracotta); text-decoration: none; }
.btn-ghost {
    background: var(--blue);
    color: #fff;
}
.btn-ghost:hover { background: var(--terracotta); text-decoration: none; }
.btn-danger {
    background: #fff;
    color: var(--red);
    border-color: #F5C6C0;
}
.btn-danger:hover { background: #FDECEA; text-decoration: none; }
.btn-block { width: 100%; text-align: center; }
.btn-small { padding: 6px 14px; font-size: 14px; }

/* Forms */
.stacked-form { display: flex; flex-direction: column; }
.stacked-form label {
    font-size: 14px;
    font-weight: 500;
    margin: 16px 0 6px 0;
}
.stacked-form label:first-child { margin-top: 0; }
.stacked-form input,
.stacked-form select {
    font-size: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}
.stacked-form input:focus,
.stacked-form select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(3, 101, 195, 0.15);
}
.stacked-form button { margin-top: 24px; }
/* Checkbox rows (e.g. "Require MFA") shouldn't inherit the text-input
   box styling above -- reset to a normal small checkbox instead. */
.stacked-form label.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
}
.stacked-form input[type="checkbox"] {
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid var(--border);
    background: none;
    flex: none;
}
.hint { font-size: 13px; color: var(--text-muted); margin: 4px 0 0 0; }
.inline-form { display: inline; }

/* Compact 2-column form layout — used for the Inputs tab so entry forms
   read as organized field groups instead of one long stacked column. */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.form-grid .field { display: flex; flex-direction: column; }
.form-grid .field label { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.form-grid .field input,
.form-grid .field select {
    font-size: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}
.form-grid .field input:focus,
.form-grid .field select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(3, 101, 195, 0.15);
}
.form-grid .field-full { grid-column: 1 / -1; }
.form-grid button { grid-column: 1 / -1; margin-top: 8px; }
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* Job Overview / Inputs tab nav — outlined for the inactive tab so it
   still reads as unselected now that .btn-ghost is solid blue everywhere else. */
.job-tab-nav { display: flex; gap: 10px; margin-bottom: 20px; }
.job-tab-nav a { background: var(--surface); color: var(--blue); border: 1px solid var(--border); }
.job-tab-nav a:hover { background: var(--accent-bg); }
.job-tab-nav a.active,
.job-tab-nav a.active:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Dashboard workflow listing — actions grouped by stage of use instead
   of one flat row of buttons. */
.workflow-steps { display: flex; flex-direction: column; gap: 14px; }
.workflow-step { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.workflow-step-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    min-width: 140px;
}
.workflow-warning { color: var(--amber); font-weight: 600; }

/* Auth pages */
.auth-panel {
    max-width: 420px;
    margin: 40px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
}
.auth-panel h1 { font-size: 32px; }
.auth-switch { margin-top: 24px; text-align: center; font-size: 15px; color: var(--text-muted); }

/* Login page marketing panel — explains what the app is next to the
   login form, since this is often a client's first look at the product. */
.auth-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 420px);
    gap: 48px;
    align-items: start;
    max-width: 1100px;
    margin: 24px auto 40px auto;
}
.auth-layout .auth-panel { margin: 0; min-width: 0; }
.auth-intro { padding-top: 8px; min-width: 0; }
.auth-intro h1 { font-size: 38px; }
.auth-panel-title { font-size: 32px; font-weight: 600; line-height: 1.1; color: var(--heading); margin: 0 0 8px 0; }

.feature-list {
    list-style: none;
    margin: 28px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.feature-list li { display: flex; align-items: flex-start; gap: 12px; font-size: 16px; }
.feature-icon {
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

/* Stylized preview of the real Jobs dashboard (job rows, budget bars,
   status badges) rather than a literal screenshot, so it stays accurate
   as the UI evolves and doesn't need re-capturing on every change. */
.app-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 51, 141, 0.10);
}
.app-preview-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
}
.app-preview-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.app-preview-url { margin-left: 10px; font-size: 12px; color: var(--text-muted); }
.app-preview-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.app-preview-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 140px) auto;
    align-items: center;
    gap: 12px;
}
.app-preview-job { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-preview-bar-track { height: 8px; border-radius: 999px; background: var(--bg-light); overflow: hidden; }
.app-preview-bar-fill { display: block; height: 100%; border-radius: 999px; }

.auth-intro-cta { margin: 4px 0 0 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.auth-intro-cta .hint { max-width: 420px; }
.auth-intro-footer { margin-top: 24px; font-size: 14px; color: var(--text-muted); }

@media (max-width: 900px) {
    .auth-layout { grid-template-columns: 1fr; gap: 32px; max-width: 480px; }
    .app-preview { display: none; }
}

/* Dashboard */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
}
/* Right-side button clusters in a page header — without this, a block-level
   <details> toggle stacks flush against the buttons next to it with no gap. */
.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.breadcrumb { font-size: 14px; color: var(--text-muted); margin: 0 0 8px 0; }

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-on-track { background: #E6F4EA; color: var(--green); }
.badge-caution { background: #FBF0DD; color: var(--amber); }
.badge-over-budget { background: #FBE4E1; color: var(--red); }
.badge-no-budget { background: #EFEFEF; color: var(--gray); }

/* Job detail */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 24px;
}
.panel-narrow { max-width: 480px; }
.empty-note { color: var(--text-muted); }

/* Dashboard search box */
.search-form { display: flex; gap: 10px; margin-bottom: 24px; }
.search-form input {
    flex: 1;
    max-width: 420px;
    font-size: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

/* Report filter bars */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 24px;
}
.filter-bar label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    font-weight: 500;
    gap: 4px;
}
.filter-bar input,
.filter-bar select {
    font-size: 16px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}
.filter-bar .btn { margin-bottom: 1px; }

/* Reports landing page */
.report-list { display: flex; flex-direction: column; gap: 16px; }
.report-card {
    display: block;
    padding: 20px 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}
.report-card:hover { border-color: var(--terracotta); text-decoration: none; }
.report-card h3 { margin: 0 0 6px 0; }
.report-card p { margin: 0; color: var(--text-muted); font-size: 15px; }

/* Dashboard "Needs Attention" strip -- headline numbers from the
   cross-order reports, surfaced where the day starts instead of only
   existing once you navigate to Reports. */
.needs-attention { border-color: var(--amber); }
.needs-attention h2 { color: var(--amber); }
.needs-attention-items { display: flex; flex-wrap: wrap; gap: 14px; }
.needs-attention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}
.needs-attention-item:hover { border-color: var(--amber); text-decoration: none; }
.needs-attention-count { font-size: 22px; font-weight: 700; color: var(--amber); }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 800px) {
    .two-col { grid-template-columns: 1fr; }
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}
.data-table th {
    text-align: left;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
}
.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--bg); }
.clickable-row td a { color: inherit; }
.clickable-row td a:hover { text-decoration: none; }

/* Spreadsheet-style multi-select picker (e.g. BOM "Add Components") --
   click a row to check it, like highlighting rows in Excel. */
.select-table-scroll { max-height: 420px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.select-table .select-cell { width: 32px; }
.select-table .selectable-row { cursor: pointer; user-select: none; }
.select-table .selectable-row:hover { background: var(--bg); }
.select-table .selectable-row.row-selected { background: var(--accent-bg); }
.select-table .selectable-row.row-selected:hover { background: var(--accent-bg); }
.select-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.select-table-submit { margin-top: 14px; }

.select-toolbar { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.select-toolbar input[type="text"] {
    flex: 1;
    min-width: 220px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}
.selected-chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 12px;
    border-radius: 999px;
    background: var(--accent-bg);
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
}
.selected-chip-remove {
    border: none;
    background: none;
    color: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}
.selected-chip-remove:hover { color: var(--terracotta); }
.review-actions,
.budget-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
/* Space between an <details> "Edit" toggle and the form it reveals —
   otherwise the edit form renders flush against the button above it. */
.budget-edit-form { margin-top: 12px; }

.subtotal-row td {
    font-weight: 600;
    background: var(--bg);
    border-top: 2px solid var(--border);
}
.detail-grand-total {
    text-align: right;
    font-size: 18px;
    font-weight: 700;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--text);
}

.detail-group-heading {
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 8px 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    scroll-margin-top: 80px;
}
.detail-group-heading:first-of-type { border-top: none; padding-top: 0; }

/* Charts (Chart.js, vendored locally at /static/js/chart.umd.min.js) */
.chart-canvas-wrap { position: relative; width: 100%; }

/* Billing */
.billing-row {
    display: flex;
    align-items: flex-end;
    gap: 32px;
    flex-wrap: wrap;
}
.billing-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.billing-value { display: block; font-size: 22px; font-weight: 600; margin-top: 2px; }
.billing-form { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.billing-form input {
    font-size: 16px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 200px;
}

.acting-as-banner {
    background: #FFF3E0;
    color: #8A5A00;
    font-size: 14px;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid #F0D9A8;
}

/* WIP report */
.wip-flagged { background: #FDECEA; }
.wip-over { color: var(--red); font-weight: 600; }
.wip-under { color: var(--amber); font-weight: 600; }

/* Print / PDF export */
.print-only { display: none; }

@media print {
    .topbar, .no-print { display: none !important; }
    .print-only { display: block; }
    body { background: #fff; }
    .container { padding: 0; max-width: 100%; }
    .panel { border: none; padding: 0; margin-bottom: 24px; page-break-inside: avoid; }
    h1 { font-size: 28px; }
    h2 { font-size: 20px; }
    .job-card { border: 1px solid #ccc; box-shadow: none; }
    .job-card:hover { transform: none; box-shadow: none; }
    a[href]:after { content: ""; }
}
