/* [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;
}

.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-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, Build Invoice 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;
}

.app-modal.invoice-result-modal {
    max-width: min(720px, 100%);
}

/* [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;
}