/* ===== Base & Layout ===== */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa, #eef2f7);
    min-height: 100vh;
}

/* PrintLayout routes (invoice/quote/PO print & PDF): flat white — global gradient shows through transparent PNG areas and in Puppeteer PDF */
html:has(.print-layout-page),
body:has(.print-layout-page) {
    background: #fff !important;
    min-height: auto;
}

.print-layout-page,
.print-layout-body {
    background: #fff;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
}

.navbar {
    background-color: #5a6c7d !important;
    border-bottom: 3px solid #84c441;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
}

.navbar .container {
    padding-left: 18px;
    padding-right: 18px;
}

/* Navbar logo - integrated with nav flow */
.app-logo-link {
    display: flex;
    align-items: center;
    padding: 0;
    margin-right: 14px;
    margin-bottom: 0;
}

.app-logo {
    height: 30px;
    width: auto;
    display: block;
}

.navbar-nav .nav-link {
    color: #ffffff !important;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.12);
}

.navbar-nav .nav-link.active {
    background-color: #84c441 !important;
    color: #ffffff !important;
    border-radius: 6px;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #84c441;
    border-color: #7ab53a;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: #7ab53a;
    border-color: #6ea832;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
    position: relative;
    z-index: 1;
}

.content {
    padding-top: 2rem;
}

.body-content {
    padding: 1.5rem 1.5rem 2rem;
}

/* Page container: centered, max-width, padding (app shell content area) */
.page-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px 16px 32px;
}

/* Main white content card - workspace area */
.content-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 28px;
}

/* Lighter borders on section panels (addresses, etc.) inside content card */
.content-card .card {
    border: 1px solid #e5e7eb;
}

.content-card .card-header.bg-light {
    border-bottom: 1px solid #e5e7eb;
}

.page-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
    text-align: center;
}

.page-footer p {
    margin: 0;
    font-size: 0.9rem;
    color: #777;
}

/* ===== Page header pattern ===== */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.page-header .subtitle {
    font-size: 0.95rem;
    color: #6b7280;
    margin: 0;
}

/* Page title / subtitle (detail pages) */
.page-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: #6b7280;
}

.page-tabs {
    margin-top: 16px;
    margin-bottom: 20px;
}

/* Detail rows: fixed-width label, flexible value */
.detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    padding: 4px 0;
    line-height: 1.6;
}

.detail-label {
    font-weight: 600;
}

.detail-value {
    color: #1f2937;
}

/* ===== Dashboard tiles ===== */
.dashboard-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-top: 1rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 768px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

.dashboard-tile {
    background: white;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dashboard-tile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.dashboard-tile-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a2e;
}

.dashboard-tile-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.15rem;
}

.dashboard-tile-toggle {
    display: flex;
    gap: 0.25rem;
}

.dashboard-tile-toggle button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid #e5e7eb;
    background: white;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dashboard-tile-toggle button:hover {
    background: #f3f4f6;
    color: #374151;
}

.dashboard-tile-toggle button.active {
    background: #84c441;
    border-color: #84c441;
    color: white;
}

.dashboard-tile-summary {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.dashboard-tile-summary-label {
    font-size: 0.8rem;
    color: #6b7280;
}

.dashboard-tile-chart {
    height: 140px;
    margin-top: 0.75rem;
}

.dashboard-tile-chart-drillable .e-chart {
    cursor: pointer;
}

.dashboard-tile-link {
    font-size: 0.8rem;
    color: #84c441;
    text-decoration: none;
    margin-top: 0.5rem;
    display: inline-block;
}

.dashboard-tile-link:hover {
    text-decoration: underline;
}

.reports-page .reports-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

/* Syncfusion chart overrides for enterprise/minimal look */
.dashboard-tile .e-chart {
    font-family: inherit !important;
}

.dashboard-tile .e-chart .e-axis-labels,
.dashboard-tile .e-chart .e-tick-text {
    fill: #6b7280 !important;
    font-size: 10px !important;
}

.dashboard-tile .e-chart .e-series-0 path,
.dashboard-tile .e-chart .e-series-0 rect {
    fill: #84c441 !important;
}

.dashboard-tile .e-chart .e-series-0 line {
    stroke: #84c441 !important;
}

/* ===== Nav cards (Operations Hub) ===== */
.nav-card {
    background: white;
    border-radius: 14px;
    padding: 1.5rem;
    min-height: 88px;
    cursor: pointer;
    display: flex;
    gap: 1rem;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    border: none;
    width: 100%;
    text-align: left;
}

.nav-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    color: inherit;
}

.nav-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    background: #84c441;
    flex-shrink: 0;
}

.nav-card-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1a1a2e;
    margin-bottom: 0.15rem;
}

.nav-card-subtitle {
    font-size: 0.85rem;
    color: #6b7280;
}

.nav-card-count {
    margin-left: auto;
    font-size: 1.25rem;
    font-weight: 700;
    color: #84c441;
}

/* ===== Stats / empty states ===== */
.stat-empty {
    font-size: 0.85rem;
    color: #9ca3af;
    font-style: italic;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEz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eat 1rem/1.8rem, #b32121;
}

.popover-invoice-items {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.popover-invoice-items .table-dark {
    background-color: transparent;
    color: #fff;
}

.popover-invoice-items .table-dark th {
    border-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.popover-invoice-items .table-dark td {
    border-color: rgba(255, 255, 255, 0.1);
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Home – Operations Hub */
.operations-hub {
    margin-bottom: 2.5rem;
}

.operations-hub .welcome {
    font-size: 1.25rem;
    color: #374151;
    margin-bottom: 0.5rem;
}

.operations-hub .intro {
    font-size: 0.95rem;
    color: #6b7280;
    margin-bottom: 2rem;
}

.nav-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    align-items: stretch;
}

/* ===== Form & table polish ===== */
.form-control, .form-select {
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.table {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.btn {
    border-radius: 8px;
    transition: all 0.2s ease;
}

/* Hide elements when printing (e.g. invoice print preview) */
@media print {
    .no-print {
        display: none !important;
    }
}

/* ===== Invoice document (print / PDF only) ===== */
.invoice-document-print {
    --inv-text: #111827;
    --inv-label: #6b7280;
    --inv-muted: #9ca3af;
}

html:has(.invoice-document-print),
body:has(.invoice-document-print) {
    background: #eef0f3 !important;
    min-height: auto;
}

.print-layout-page:has(.invoice-document-print),
.print-layout-body:has(.invoice-document-print) {
    background: transparent;
}

.invoice-doc-sheet {
    background: #fff;
}

.invoice-document-print #printbody > .invoice-doc-section--meta:first-child {
    padding-top: 1rem;
}

.invoice-document-print.print-page-wrap {
    background: transparent;
    padding: 16px 12px 28px;
}

@media print {
    .invoice-document-print.print-page-wrap {
        padding: 0;
    }

    html:has(.invoice-document-print),
    body:has(.invoice-document-print) {
        background: #fff !important;
    }
}

@media screen {
    .invoice-document-print .invoice-doc-sheet {
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
        border-radius: 2px;
    }
}

@media print {
    .invoice-document-print .invoice-doc-sheet {
        box-shadow: none;
        border-radius: 0;
    }
}

.invoice-document-print #printbody {
    padding-left: 28px;
    padding-right: 28px;
    padding-bottom: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--inv-text);
}

.invoice-document-print .invoice-doc-section--meta {
    margin-bottom: 1.5rem;
}

.invoice-document-print .invoice-doc-section--table {
    margin-top: 0;
    margin-bottom: 0;
}

/* Payment + totals: main content band directly above footer image */
.invoice-document-print .invoice-print-bottom {
    padding-left: 28px;
    padding-right: 28px;
    margin-top: 1.875rem;
    margin-bottom: 1.125rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--inv-text);
    break-inside: avoid;
    page-break-inside: avoid;
}

.invoice-document-print .invoice-doc-meta-row {
    --bs-gutter-x: 1.5rem;
}

.invoice-doc-stack {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

@media (min-width: 768px) {
    .invoice-doc-stack {
        gap: 0.6875rem;
    }
}

.invoice-document-print .invoice-doc-stack--commercial {
    gap: 0.625rem;
}

/* Right-hand invoice summary: stronger values, right-aligned with totals rhythm */
.invoice-document-print .invoice-doc-col--summary .invoice-doc-stack--summary {
    text-align: right;
}

.invoice-document-print .invoice-doc-col--summary .invoice-doc-label {
    text-align: right;
}

.invoice-document-print .invoice-doc-col--summary .invoice-doc-value {
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--inv-text);
}

.invoice-document-print .invoice-doc-col--summary .invoice-doc-field--invoice-number .invoice-doc-label {
    margin-bottom: 0.35rem;
}

.invoice-document-print .invoice-doc-col--summary .invoice-doc-field--invoice-number .invoice-doc-value {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.invoice-doc-field {
    margin: 0;
}

.invoice-doc-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--inv-label);
    letter-spacing: 0.01em;
    text-transform: none;
    margin-bottom: 0.28rem;
    line-height: 1.35;
}

.invoice-doc-value {
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--inv-text);
    line-height: 1.45;
}

.invoice-line-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin: 0;
    --invoice-line-border: #eef0f3;
}

.invoice-col-part {
    width: 17%;
}

.invoice-col-desc {
    width: 52%;
}

.invoice-col-qty {
    width: 9%;
}

.invoice-col-cost {
    width: 11%;
}

.invoice-col-total {
    width: 11%;
}

.invoice-line-table thead th {
    font-weight: 500;
    color: #868e96;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0.02em;
    padding: 8px 10px 8px 12px;
    border: none;
    border-bottom: 1px solid var(--invoice-line-border);
    background: transparent;
    vertical-align: bottom;
}

.invoice-line-table tbody td {
    padding: 8px 10px 8px 12px;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}

.invoice-line-table tbody tr:last-child td {
    border-bottom: 1px solid var(--invoice-line-border);
}

.invoice-line-part {
    font-size: 0.6875rem;
    color: #b0b8c2;
    word-wrap: break-word;
}

.invoice-line-desc {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--inv-text);
    line-height: 1.45;
    overflow-wrap: break-word;
}

.invoice-line-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--inv-label);
}

.invoice-doc-payment-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--inv-label);
    letter-spacing: 0.02em;
    text-transform: none;
    margin-bottom: 0.625rem;
}

.invoice-doc-payment-groups {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.invoice-doc-payment-group {
    margin: 0;
}

.invoice-doc-payment-group--bank .invoice-doc-payment-line-label {
    margin-bottom: 0.125rem;
}

.invoice-doc-payment-group--bank .invoice-doc-payment-line-value {
    line-height: 1.4;
}

.invoice-doc-payment-line-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--inv-label);
    margin-bottom: 0.3rem;
    line-height: 1.4;
}

.invoice-doc-payment-line-value {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--inv-text);
    line-height: 1.45;
}

.invoice-doc-payment-lines {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.invoice-doc-payment-lines--compact {
    gap: 0.125rem;
}

.invoice-doc-payment-line {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--inv-text);
    line-height: 1.5;
}

.invoice-doc-payment-k {
    font-weight: 500;
    color: var(--inv-label);
}

.invoice-doc-payment-k::after {
    content: ': ';
}

.invoice-print-payment-totals {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 1.25rem 1.75rem;
}

.invoice-print-payment-totals__payment {
    flex: 1 1 auto;
    max-width: min(58%, calc(100% - 12.75rem));
    min-width: 0;
}

.invoice-print-payment-totals__totals {
    flex: 0 0 auto;
    width: 12rem;
    max-width: 100%;
    margin-left: auto;
    display: flex;
    justify-content: flex-end;
    align-self: flex-start;
    box-sizing: border-box;
}

.invoice-print-payment-totals__totals .invoice-totals {
    width: 100%;
    max-width: 100%;
    padding-right: 10px;
    box-sizing: border-box;
}

.invoice-totals {
    border-top: 1px solid #e8eaee;
    padding-top: 16px;
    margin-top: 8px;
}

.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.5rem;
    padding: 0;
    border: none;
}

.invoice-totals-row--subtle {
    padding-top: 6px;
    padding-bottom: 14px;
}

.invoice-totals-row--subtle:first-of-type {
    padding-top: 0;
}

.invoice-totals-row--subtle .invoice-totals-label {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--inv-label);
}

.invoice-totals-row--subtle .invoice-totals-amt {
    font-size: 0.8125rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    color: var(--inv-muted);
}

.invoice-totals-row--grand {
    padding-top: 14px;
    margin-top: 10px;
    border-top: 1px solid #e8eaee;
}

.invoice-totals-row--grand .invoice-totals-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--inv-text);
}

.invoice-totals-row--grand .invoice-totals-amt {
    font-size: 1.1875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--inv-text);
}
