/* [TAG: APP_FONT_FACE_V1] */
@font-face {
    font-family: 'AstroNasa';
    src: url('../fonts/nasa.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* [TAG: APP_ROOT_THEME_V1] */
:root {
    --app-bg: #f3f4f6;
    --panel-bg: #ffffff;
    --panel-border: #cbd5e1;
    --header-bg: #111827;
    --header-bg-2: #1e293b;
    --header-text: #f9fafb;
    --muted-text: #6b7280;
    --body-text: #111827;
    --line: #e5e7eb;
    --accent: #2563eb;
    --accent-2: #0ea5e9;
    --success: #16a34a;
    --danger: #dc2626;
    --warn: #ea580c;
    --due-soft: #eff6ff;
    --due-today-soft: #fff7ed;
    --past-due-soft: #fef2f2;
    --radius: 8px;
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.08);
    --font-ui: "Segoe UI", Arial, sans-serif;
    --font-brand: "AstroNasa", "Segoe UI", Arial, sans-serif;
    --font-mono: Consolas, "Courier New", monospace;
}

/* [TAG: APP_PAGE_BASE_V1] */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-ui);
    background: var(--app-bg);
    color: var(--body-text);
}

/* [TAG: APP_LAYOUT_V1] */
.app-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px;
}

/* [TAG: APP_BREADCRUMBS_V1] — see docs/NAVIGATION_CONVENTION.md
 *
 * Breadcrumbs are rendered as a second row INSIDE the first `.app-section-header`
 * dark band on every page (the "Customer Hub", "Filters", "Item", etc. band).
 * `.app-breadcrumbs-fallback` covers pages that don't open a section header — it
 * renders the same trail in an identical dark band at the top of the page content
 * so navigation never goes missing.
 */
.app-section-header--with-crumbs {
    padding-top: 8px;
    padding-bottom: 10px;
}

.app-section-header__title {
    /* Preserve the original `.app-section-header` text styling for the first row. */
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.25;
}

.app-section-header.brand .app-section-header__title {
    font-family: var(--font-brand);
    letter-spacing: 0.08em;
}

.app-section-header__crumbs,
.app-breadcrumbs-fallback {
    margin-top: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    text-transform: none;
    letter-spacing: 0;
}

.app-breadcrumbs-fallback {
    /* Mirror the `.app-section-header` band so the bar visually feels like an
       extension of the page's primary section header. */
    background: linear-gradient(90deg, var(--header-bg), var(--header-bg-2));
    color: var(--header-text);
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow-soft);
}

.app-breadcrumbs-list {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.3;
}

.app-breadcrumb-item {
    display: inline-flex;
    align-items: center;
}

.app-breadcrumb-link {
    color: #cfe2ff;
    text-decoration: none;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background .12s ease;
}

.app-breadcrumb-link:hover,
.app-breadcrumb-link:focus {
    background: rgba(255, 255, 255, 0.10);
    text-decoration: underline;
    outline: none;
}

.app-breadcrumb-sep {
    color: #94a3b8;
    font-weight: 700;
    user-select: none;
    padding: 0 2px;
    font-size: 13px;
}

.app-breadcrumb-current {
    color: #f8fafc;
    font-weight: 700;
    padding: 2px 6px;
    max-width: 22em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: bottom;
}

@media (max-width: 640px) {
    .app-breadcrumbs-list {
        font-size: 11px;
    }
    .app-breadcrumb-link,
    .app-breadcrumb-current {
        padding: 2px 5px;
    }
    .app-breadcrumb-current {
        max-width: 14em;
    }
    .app-breadcrumbs-fallback {
        padding: 6px 10px;
        margin-bottom: 10px;
    }
}

.app-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.app-brand-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-brand {
    font-family: var(--font-brand);
    font-size: 30px;
    line-height: 1;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0f172a;
}

.app-subbrand {
    font-size: 12px;
    color: var(--muted-text);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-page-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.app-page-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.app-page-title-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.app-page-title-row .app-page-title {
    min-width: 0;
    text-align: right;
}

.hub-topbar-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
}

.hub-topbar-edit:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

.hub-topbar-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none;
}

.hub-topbar-attach:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

.hub-customer-card-name--placeholder {
    color: #64748b;
    font-size: 1.15rem;
}

.hub-customer-card--attach .hub-customer-card-name-actions {
    margin-left: auto;
}

.hub-topbar-merge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
}

.hub-topbar-merge:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

.ac-ffl-licenses-history {
    font-size: 13px;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    background: #f8fafc;
}

.ac-ffl-lic-row + .ac-ffl-lic-row {
    margin-top: 6px;
}

.ac-ffl-lic-active {
    font-size: 11px;
    font-weight: 600;
    color: #166534;
}

.hub-ffl-expired-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fee2e2;
    color: #b91c1c;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.app-page-context {
    font-size: 13px;
    color: var(--muted-text);
}

.app-topbar-right--stack {
    text-align: right;
    max-width: min(440px, 100%);
}

.app-topbar-right--stack .app-page-title {
    text-align: right;
}

.app-topbar-below-title {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--body-text);
}

.app-topbar-below-title a {
    color: var(--accent);
    text-decoration: none;
}

.app-topbar-below-title a:hover {
    text-decoration: underline;
}

.app-topbar-contact-name {
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 4px;
    color: var(--body-text);
}

.app-topbar-invoice-actions {
    margin-top: 12px;
}

/* [TAG: HUB_TOPBAR_SHARED_V1] — Customer Hub, Transaction top-right block */
.hub-topbar-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
    max-width: min(520px, 100%);
    margin-left: auto;
}
.hub-topbar-line {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--body-text, #0f172a);
    word-break: break-word;
}
.hub-topbar-placeholder {
    color: #6b7280;
    font-weight: 500;
    font-style: italic;
}

.hub-customer-card {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    color: #f8fafc;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.hub-customer-card-body {
    min-width: 0;
}

.hub-customer-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 4px;
}

.hub-customer-card-party {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 2px 8px;
}

.hub-customer-card-id {
    font-size: 11px;
    font-weight: 600;
    color: rgba(248, 250, 252, 0.75);
    letter-spacing: 0.02em;
}

.hub-customer-card-name {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    margin: 0;
    color: #f8fafc;
}

.hub-customer-card-name-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 100%;
    margin-bottom: 4px;
}

.hub-customer-card-name-row .hub-customer-card-name {
    flex: 0 1 auto;
    min-width: 0;
}

.hub-customer-card-name-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.hub-customer-card .hub-topbar-edit,
.hub-customer-card .hub-topbar-merge {
    width: 28px;
    height: 28px;
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    border-radius: 6px;
}

.hub-customer-card .hub-topbar-edit:hover,
.hub-customer-card .hub-topbar-merge:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.hub-customer-card .hub-topbar-merge {
    color: #fed7aa;
    border-color: rgba(251, 146, 60, 0.45);
    background: rgba(251, 146, 60, 0.12);
}

.hub-customer-card .hub-topbar-merge:hover {
    background: rgba(251, 146, 60, 0.22);
    border-color: rgba(251, 146, 60, 0.6);
    color: #ffedd5;
}

.hub-customer-card-credential {
    font-size: 12px;
    font-weight: 600;
    color: rgba(248, 250, 252, 0.9);
    margin-bottom: 4px;
}

.hub-customer-card-meta {
    font-size: 12px;
    line-height: 1.4;
    color: rgba(248, 250, 252, 0.88);
}

.hub-customer-card-line + .hub-customer-card-line {
    margin-top: 1px;
}

.hub-customer-card .hub-topbar-placeholder {
    color: rgba(248, 250, 252, 0.55);
    font-weight: 500;
    font-style: italic;
}

.hub-customer-card-ffl-expired {
    margin-top: 6px;
}

@media (max-width: 640px) {
    .hub-customer-card-name {
        font-size: 16px;
    }
}

.app-modal.invoice-result-modal {
    max-width: min(720px, 100%);
}
.app-modal.invoice-result-modal.is-e4473 {
    max-width: min(800px, 100%);
}
.hub-e4473-handoff {
    margin-top: 4px;
    padding: 14px;
    border: 3px solid #0f172a;
    background: #fff;
}
.hub-e4473-handoff-wait {
    margin: 0;
    font-weight: 700;
    color: #1d4ed8;
}
.hub-e4473-handoff-grid {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 20px;
    align-items: center;
}
.hub-e4473-kicker {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1d4ed8;
    margin-bottom: 8px;
}
.hub-e4473-qr {
    width: 220px;
    height: 220px;
    background: #fff;
    border: 2px solid #0f172a;
    padding: 8px;
    box-sizing: border-box;
}
.hub-e4473-qr img,
.hub-e4473-qr canvas,
.hub-e4473-qr table {
    width: 100% !important;
    height: 100% !important;
}
.hub-e4473-pin {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: 0.22em;
    line-height: 1;
    color: #0f172a;
}
.hub-e4473-hint {
    margin: 10px 0 0;
    color: #4b5563;
    font-weight: 600;
    font-size: 14px;
}
@media (max-width: 640px) {
    .hub-e4473-handoff-grid {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
    .hub-e4473-pin {
        font-size: 44px;
    }
}

/* [TAG: APP_SECTION_V1] */
.app-section {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.app-section-header {
    background: linear-gradient(90deg, var(--header-bg), var(--header-bg-2));
    color: var(--header-text);
    padding: 10px 12px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-section-header.brand {
    font-family: var(--font-brand);
    letter-spacing: 0.08em;
}

.app-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.app-toolbar-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted-text);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* [TAG: APP_TABLE_V1] */
.table-wrap {
    overflow-x: auto;
}

.app-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    font-size: 14px;
}

.app-table th,
.app-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.app-table th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted-text);
    letter-spacing: 0.03em;
}

.app-table .num,
.app-table .money {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.row-past-due {
    background: var(--past-due-soft);
}

.row-due-today {
    background: var(--due-today-soft);
}

.row-due-soon {
    background: var(--due-soft);
}

.status-text {
    font-weight: 700;
    font-size: 12px;
}

/* [TAG: APP_INPUTS_V1] */
.app-input,
.app-select,
.app-date,
.app-button {
    font: inherit;
}

.app-input,
.app-select,
.app-date {
    padding: 6px 8px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: #fff;
    color: var(--body-text);
}

.app-input.amount {
    width: 105px;
}

.app-date {
    width: 155px;
}

.app-select {
    min-width: 180px;
}

.inline-control-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-x-btn {
    border: 1px solid var(--panel-border);
    background: #fff;
    color: var(--body-text);
    padding: 5px 9px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

/* [TAG: APP_BUTTONS_V1] */
.app-button {
    border: 1px solid #1f2937;
    background: #fff;
    color: #111827;
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.app-button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.app-button.success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.app-button.subtle {
    background: #fff;
    border-color: var(--panel-border);
}

.info-btn {
    border: 1px solid var(--panel-border);
    background: #fff;
    color: var(--body-text);
    padding: 4px 8px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

/* [TAG: APP_STICKY_BAR_V1] */
.app-sticky-bar {
    position: sticky;
    bottom: 0;
    background: linear-gradient(90deg, #111827, #0f172a);
    color: #fff;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 3px solid var(--accent);
    z-index: 50;
}

.app-sticky-brand {
    font-family: var(--font-brand);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* [TAG: APP_MODAL_V1] */
.app-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.app-modal-backdrop.active {
    display: flex;
}

.app-modal {
    background: #fff;
    width: 100%;
    max-width: 560px;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    overflow: hidden;
    border: 1px solid #cbd5e1;
}

.app-modal-head {
    background: linear-gradient(90deg, var(--header-bg), var(--header-bg-2));
    color: #fff;
    padding: 12px 14px;
    font-weight: 700;
}

.app-modal-head.brand {
    font-family: var(--font-brand);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-modal-body {
    padding: 14px;
    line-height: 1.45;
    max-height: 70vh;
    overflow-y: auto;
}

.app-modal-foot {
    padding: 0 14px 14px 14px;
}

/* [TAG: APP_UTILITIES_V1] */
.text-muted {
    color: var(--muted-text);
}

.font-brand {
    font-family: var(--font-brand);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.font-mono {
    font-family: var(--font-mono);
}

@media (max-width: 700px) {
    .app-brand {
        font-size: 24px;
    }

    .app-page-title {
        font-size: 20px;
    }

    .app-page {
        padding: 10px;
    }
}

/* [TAG: APP_CALLS_WORKFLOW_V1] */
.app-section .custName {
    text-align: left;
    font-size: 18px;
    font-weight: 700;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.app-section .custInfo {
    text-align: left;
    padding: 6px 12px;
    font-size: 14px;
}

.app-section .custInfo a {
    color: var(--accent);
    text-decoration: none;
}

.app-section .custInfo a:hover {
    text-decoration: underline;
}

.app-section .head {
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted-text);
    letter-spacing: 0.03em;
}

.app-section table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.app-section table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--line);
}

.app-section textarea {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    width: 100%;
    max-width: 500px;
    min-height: 100px;
}