:root {
    --blue-900: #082f72;
    --blue-800: #0b3d91;
    --blue-700: #0d47a1;
    --blue-600: #0b5ed7;
    --blue-500: #1d74f5;
    --blue-100: #eaf3ff;
    --blue-050: #f4f8ff;
    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --line: #e2e8f0;
    --white: #ffffff;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --radius-lg: 22px;
    --radius-md: 16px;
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 18px 50px rgba(15, 23, 42, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink-900);
    background: linear-gradient(180deg, #eef5ff 0%, #f8fbff 38%, #ffffff 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 15px;
}

a {
    color: var(--blue-600);
}

a:hover {
    color: var(--blue-800);
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 282px;
    height: 100vh;
    padding: 22px 18px;
    color: rgba(255, 255, 255, 0.88);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 32%),
        linear-gradient(180deg, #06337f 0%, #0d47a1 52%, #0b5ed7 100%);
    box-shadow: 18px 0 55px rgba(8, 47, 114, 0.24);
    overflow-y: auto;
    scrollbar-width: thin;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 64px;
    padding: 10px 10px 18px;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-block:hover {
    color: #ffffff;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    color: var(--blue-700);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
    font-size: 20px;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand-title {
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 17px;
}

.brand-subtitle {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
}

.sidebar-section {
    margin: 22px 10px 8px;
    color: rgba(255, 255, 255, 0.56);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.82);
    border-radius: 14px;
    transition: 160ms ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: #ffffff;
    color: var(--blue-800);
    box-shadow: 0 14px 28px rgba(2, 6, 23, 0.16);
}

.sidebar-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    font-size: 15px;
}

.sidebar-link-text {
    font-weight: 650;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 26px 4px 0;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.10);
}

.sidebar-user-avatar,
.user-chip-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: var(--blue-800);
    background: #ffffff;
    border-radius: 999px;
    font-weight: 800;
}

.sidebar-user-name {
    max-width: 166px;
    overflow: hidden;
    color: #ffffff;
    font-weight: 750;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    text-transform: uppercase;
}

.app-main {
    min-height: 100vh;
    margin-left: 282px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 74px;
    padding: 14px 30px;
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(226, 232, 240, 0.82);
    backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    color: var(--blue-700);
    background: var(--blue-100);
    border: 0;
    border-radius: 14px;
    box-shadow: none;
}

.btn-icon:focus {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(29, 116, 245, 0.16);
}

.topbar-kicker {
    display: block;
    color: var(--ink-500);
    font-size: 12px;
}

.topbar-copy strong {
    color: var(--ink-900);
    font-size: 15px;
}

.user-chip {
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--blue-050);
    border: 1px solid #d8e8ff;
    border-radius: 999px;
}

.user-chip-avatar {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
}

.user-chip-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-chip-copy span {
    max-width: 140px;
    overflow: hidden;
    color: var(--ink-900);
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-chip-copy small {
    color: var(--ink-500);
    font-size: 11px;
    text-transform: uppercase;
}

.app-container {
    padding: 28px 32px 52px;
}

.page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
    padding: 24px 26px;
    background:
        radial-gradient(circle at top right, rgba(29, 116, 245, 0.14), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f5f9ff 100%);
    border: 1px solid rgba(191, 219, 254, 0.82);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.page-eyebrow {
    margin-bottom: 4px;
    color: var(--blue-600);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-hero h1 {
    margin: 0;
    color: var(--ink-900);
    font-size: 30px;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.page-hero p {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--ink-500);
}

.page-hero-main {
    flex: 1 1 auto;
    min-width: 0;
}

.page-hero-meta {
    flex: 0 0 auto;
    margin-left: auto;
    min-width: 180px;
    color: #8a5a00;
    background: #fff6df;
    border: 2px solid #f0ad2c;
    border-radius: 10px;
    padding: 12px 16px;
    text-align: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.page-hero-meta span {
    display: block;
    color: #8a5a00;
    font-size: 12px;
    font-weight: 800;
}

.page-hero-meta strong {
    display: block;
    color: #8a5a00;
    font-size: 26px;
    font-weight: 950;
    line-height: 1.1;
    margin-top: 2px;
}

.card,
.document-box {
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card {
    background: #ffffff;
}

.card-header {
    padding: 16px 20px;
    color: var(--ink-900);
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.card-header strong {
    font-weight: 800;
}

.card-body {
    padding: 20px;
}

.card-stat,
.metric-card,
.action-card {
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.metric-card {
    position: relative;
    min-height: 148px;
    padding: 20px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.92);
}

.metric-card:after {
    position: absolute;
    right: -28px;
    bottom: -34px;
    width: 122px;
    height: 122px;
    content: "";
    background: rgba(29, 116, 245, 0.10);
    border-radius: 50%;
}

.metric-card .metric-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
    border-radius: 15px;
    box-shadow: 0 12px 28px rgba(13, 71, 161, 0.18);
}

.metric-label {
    margin-top: 14px;
    color: var(--ink-500);
    font-size: 13px;
    font-weight: 750;
}

.metric-value {
    position: relative;
    z-index: 1;
    margin: 6px 0 0;
    color: var(--ink-900);
    font-size: 29px;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.metric-helper {
    position: relative;
    z-index: 1;
    margin-top: 5px;
    color: var(--ink-500);
    font-size: 12px;
}

.metric-card.metric-primary {
    color: #ffffff;
    background: linear-gradient(135deg, var(--blue-800), var(--blue-500));
    border: 0;
}

.metric-card.metric-primary:after {
    background: rgba(255, 255, 255, 0.14);
}

.metric-card.metric-primary .metric-icon {
    color: var(--blue-700);
    background: #ffffff;
}

.metric-card.metric-primary .metric-label,
.metric-card.metric-primary .metric-value,
.metric-card.metric-primary .metric-helper {
    color: #ffffff;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 92px;
    padding: 18px;
    color: var(--ink-900);
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.92);
    transition: 160ms ease;
}

.action-card:hover {
    color: var(--ink-900);
    border-color: #bfdbfe;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.action-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    color: var(--blue-700);
    background: var(--blue-100);
    border-radius: 15px;
    font-size: 18px;
}

.action-card strong {
    display: block;
    font-weight: 800;
}

.action-card span:last-child,
.action-card small {
    display: block;
    margin-top: 3px;
    color: var(--ink-500);
    font-size: 12px;
}

.table-responsive {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.table {
    margin-bottom: 0;
    color: var(--ink-700);
}

.table thead th {
    color: #475569;
    background: #f8fbff;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.table td,
.table th {
    vertical-align: middle;
    border-color: var(--line);
}

.table td {
    padding-top: 14px;
    padding-bottom: 14px;
}

.table-hover tbody tr:hover {
    background: #f5f9ff;
}

.table-bordered {
    border-color: var(--line);
}

.table-bordered td,
.table-bordered th {
    border-color: var(--line);
}

.thead-light th {
    background: #f8fbff !important;
}

.form-group label {
    color: var(--ink-700);
    font-size: 13px;
    font-weight: 750;
}

.form-control,
.custom-select {
    min-height: 42px;
    color: var(--ink-900);
    border-color: #dbe7f5;
    border-radius: 12px;
    box-shadow: none;
}

.form-control:focus,
.custom-select:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 4px rgba(29, 116, 245, 0.13);
}

textarea.form-control {
    min-height: auto;
}

.btn {
    border-radius: 12px;
    font-weight: 750;
    box-shadow: none !important;
}

.btn-sm {
    border-radius: 10px;
    font-size: 12px;
}

.btn-primary {
    border-color: var(--blue-600);
    background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--blue-800);
    background: linear-gradient(135deg, var(--blue-800), var(--blue-600));
}

.btn-outline-primary {
    color: var(--blue-700);
    border-color: #b9d7ff;
    background: #ffffff;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary.active {
    color: #ffffff;
    border-color: var(--blue-600);
    background: var(--blue-600);
}

.btn-light {
    color: var(--ink-700);
    border-color: #e2e8f0;
    background: #f8fafc;
}

.btn-outline-secondary {
    color: var(--ink-700);
    border-color: #d8e2ef;
}

.btn-outline-secondary:hover {
    color: var(--ink-900);
    background: #eef5ff;
    border-color: #bfdbfe;
}

.btn-success {
    border-color: #16a34a;
    background: #16a34a;
}

.btn-danger {
    border-color: #dc2626;
    background: #dc2626;
}

.btn-info {
    border-color: #0284c7;
    background: #0284c7;
}

.alert {
    border: 0;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    color: #166534;
    background: #dcfce7;
}

.alert-danger {
    color: #991b1b;
    background: #fee2e2;
}

.alert-warning {
    color: #92400e;
    background: #fef3c7;
}

.alert-info {
    color: #075985;
    background: #e0f2fe;
}

.badge {
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.badge-primary {
    color: #ffffff;
    background: var(--blue-600);
}

.badge-secondary,
.badge-dark {
    color: #475569;
    background: #e2e8f0;
}

.badge-success {
    color: #166534;
    background: #dcfce7;
}

.badge-warning {
    color: #92400e;
    background: #fef3c7;
}

.badge-danger {
    color: #991b1b;
    background: #fee2e2;
}

.badge-info {
    color: #075985;
    background: #e0f2fe;
}

.document-box {
    padding: 28px;
    background: #ffffff;
}

.document-box h4 {
    color: var(--ink-900);
    font-weight: 850;
}

.document-box .table-bordered thead th {
    background: #f8fbff;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 160px;
    color: var(--ink-500);
    text-align: center;
}

.empty-state i {
    color: #bfdbfe;
    font-size: 34px;
}

.text-muted {
    color: var(--ink-500) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(29, 116, 245, 0.22), transparent 28%),
        linear-gradient(135deg, #06337f 0%, #0b5ed7 52%, #eaf3ff 52%, #ffffff 100%);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.login-card {
    width: 100%;
    max-width: 980px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(8, 47, 114, 0.30);
}

.login-visual {
    height: 100%;
    min-height: 460px;
    padding: 40px;
    color: #ffffff;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.22), transparent 34%),
        linear-gradient(160deg, var(--blue-900), var(--blue-600));
}

.login-visual-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    color: var(--blue-700);
    background: #ffffff;
    border-radius: 18px;
    font-size: 24px;
}

.login-visual h1 {
    margin-top: 28px;
    font-size: 32px;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.login-visual p {
    max-width: 360px;
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.78);
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.88);
}

.login-feature i {
    width: 22px;
}

.login-form-panel {
    padding: 44px;
}

.login-form-panel h2 {
    margin: 0;
    font-size: 26px;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.login-demo-box {
    padding: 12px 14px;
    color: var(--ink-700);
    background: var(--blue-050);
    border: 1px solid #dbeafe;
    border-radius: 14px;
    font-size: 13px;
}

.print-only {
    display: none;
}

.app-backdrop {
    display: none;
}

@media (min-width: 992px) {
    .btn-icon.js-sidebar-toggle {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-105%);
        transition: transform 180ms ease;
    }

    .sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1035;
        background: rgba(15, 23, 42, 0.46);
        backdrop-filter: blur(2px);
    }

    .sidebar-open .app-backdrop {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar-copy {
        display: none;
    }

    .topbar-actions {
        gap: 8px;
    }

    .topbar-action {
        display: none;
    }

    .app-container {
        padding: 18px 14px 38px;
    }

    .page-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .page-hero h1 {
        font-size: 24px;
    }

    .page-hero-meta {
        width: 100%;
        text-align: center;
    }

    .login-visual {
        min-height: auto;
        padding: 30px;
    }

    .login-form-panel {
        padding: 30px;
    }
}

@media (max-width: 575.98px) {
    body {
        font-size: 14px;
    }

    .card-header,
    .card-body,
    .document-box {
        padding: 16px;
    }

    .metric-card {
        min-height: 132px;
    }

    .metric-value {
        font-size: 25px;
    }

    .table td,
    .table th {
        padding: 12px;
    }

    .login-form-panel {
        padding: 24px;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .app-sidebar,
    .topbar,
    .page-hero,
    .btn,
    .no-print,
    .alert,
    .app-backdrop {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
    }

    .app-container {
        padding: 0 !important;
    }

    .document-box,
    .card {
        box-shadow: none !important;
        border: 0 !important;
        border-radius: 0 !important;
    }

    .document-box {
        padding: 0 !important;
    }

    .print-only {
        display: block;
    }
}

/* Quotation product settings and old bill reference */
.metric-copy {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 14px;
}

.metric-copy span,
.metric-copy small {
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    font-weight: 700;
}

.metric-copy strong {
    color: #ffffff;
    font-size: 34px;
    font-weight: 850;
    line-height: 1;
}

.customer-summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.info-tile {
    min-height: 74px;
    padding: 14px 16px;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    border: 1px solid #dbeafe;
    border-radius: 16px;
}

.info-tile span {
    display: block;
    color: var(--ink-500);
    font-size: 12px;
    font-weight: 750;
}

.info-tile strong {
    display: block;
    margin-top: 5px;
    color: var(--ink-900);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
}

.info-tile-wide {
    grid-column: span 2;
}

.old-bill-panel {
    border-color: #bfdbfe;
}

.old-bill-panel .card-header {
    background: linear-gradient(90deg, #f4f8ff 0%, #ffffff 100%);
}

.recent-bills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.recent-bill-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    min-width: 180px;
    padding: 10px 12px;
    color: var(--blue-800);
    background: var(--blue-050);
    border: 1px solid #dbeafe;
    border-radius: 14px;
}

.recent-bill-chip strong {
    font-size: 13px;
    font-weight: 850;
}

.recent-bill-chip small {
    color: var(--ink-500);
    font-size: 12px;
}

.quotation-table-wrapper {
    border-top: 1px solid var(--line);
}

.quotation-products-table th,
.quotation-products-table td,
.table-settings th,
.table-settings td {
    vertical-align: middle;
}

.quotation-products-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: var(--ink-700);
    background: #f4f8ff;
    border-bottom: 1px solid #dbeafe;
    font-size: 13px;
    white-space: nowrap;
}

.quotation-products-table .product-cell {
    background: #ffffff;
}

.quotation-products-table tbody tr:hover .product-cell,
.quotation-products-table tbody tr:hover td {
    background: #fbfdff;
}

.totals-table th {
    color: var(--ink-500);
    font-weight: 750;
}

.totals-table .grand-row th,
.totals-table .grand-row td {
    color: var(--blue-800);
    border-top: 2px solid #bfdbfe;
    font-weight: 850;
}

.document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 0 20px;
}

.empty-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    color: var(--blue-700);
    background: var(--blue-100);
    border-radius: 24px;
    font-size: 28px;
}

.table-settings thead th {
    color: var(--ink-700);
    background: #f4f8ff;
    border-bottom: 1px solid #dbeafe;
    font-size: 13px;
    white-space: nowrap;
}

.table-settings .custom-switch .custom-control-label:before {
    background: #cbd5e1;
    border-color: #cbd5e1;
}

.table-settings .custom-switch .custom-control-input:checked ~ .custom-control-label:before {
    background: var(--blue-600);
    border-color: var(--blue-600);
}

@media (max-width: 1199.98px) {
    .customer-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .customer-summary-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .info-tile-wide {
        grid-column: span 1;
    }
}

/* Full UI refresh - compact operations theme */
:root {
    --ui-bg: #f4f6f1;
    --ui-surface: #ffffff;
    --ui-surface-2: #f8faf5;
    --ui-ink: #182018;
    --ui-muted: #687166;
    --ui-line: #dfe5d8;
    --ui-brand: #2f6f46;
    --ui-brand-dark: #1f4f33;
    --ui-brand-soft: #e6f2e8;
    --ui-rice: #f3c85b;
    --ui-rice-soft: #fff6d8;
    --ui-danger-soft: #fff0ee;
    --ui-shadow: 0 14px 34px rgba(24, 32, 24, 0.08);
    --ui-shadow-strong: 0 22px 48px rgba(24, 32, 24, 0.14);
    --radius-lg: 14px;
    --radius-md: 10px;
}

html {
    background: var(--ui-bg);
}

body {
    color: var(--ui-ink);
    background:
        linear-gradient(180deg, rgba(47, 111, 70, 0.08) 0, rgba(47, 111, 70, 0) 260px),
        var(--ui-bg);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--ui-brand);
}

a:hover {
    color: var(--ui-brand-dark);
}

.app-sidebar {
    width: 268px;
    padding: 18px 14px;
    color: rgba(255, 255, 255, 0.86);
    background: linear-gradient(180deg, #203524 0%, #24472f 52%, #183321 100%);
    box-shadow: 12px 0 36px rgba(18, 34, 22, 0.24);
}

.brand-block {
    min-height: 58px;
    padding: 8px 8px 16px;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

.brand-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    color: #203524;
    background: var(--ui-rice);
    border-radius: 12px;
    box-shadow: none;
}

.brand-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-subtitle {
    color: rgba(255, 255, 255, 0.62);
}

.sidebar-section {
    margin: 18px 10px 8px;
    color: rgba(255, 255, 255, 0.48);
    letter-spacing: 0.04em;
}

.sidebar-link {
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 9px;
    color: rgba(255, 255, 255, 0.78);
}

.sidebar-link:hover,
.sidebar-link.active {
    transform: none;
    box-shadow: none;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.09);
}

.sidebar-link.active {
    color: #172018;
    background: #ffffff;
    box-shadow: inset 4px 0 0 var(--ui-rice);
}

.sidebar-link-icon {
    width: 24px;
    color: inherit;
}

.sidebar-footer {
    margin-top: 22px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-avatar,
.user-chip-avatar {
    color: #203524;
    background: var(--ui-rice);
}

.app-main {
    margin-left: 268px;
}

.topbar {
    min-height: 66px;
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: var(--ui-line);
    backdrop-filter: blur(14px);
}

.btn-icon {
    color: var(--ui-brand-dark);
    background: var(--ui-brand-soft);
    border-radius: 10px;
}

.topbar-kicker,
.text-muted,
.user-chip-copy small {
    color: var(--ui-muted) !important;
}

.topbar-copy strong {
    color: var(--ui-ink);
}

.user-chip {
    background: var(--ui-surface-2);
    border-color: var(--ui-line);
}

.user-chip-avatar {
    color: #ffffff;
    background: var(--ui-brand);
}

.app-container {
    padding: 24px 28px 48px;
}

.page-hero {
    align-items: center;
    margin-bottom: 20px;
    padding: 20px 22px;
    background: linear-gradient(135deg, #ffffff 0%, #fbfcf7 100%);
    border-color: var(--ui-line);
    border-radius: 14px;
    box-shadow: var(--ui-shadow);
}

.page-eyebrow {
    color: var(--ui-brand);
    letter-spacing: 0.05em;
}

.page-hero h1 {
    color: var(--ui-ink);
    font-size: 28px;
    letter-spacing: 0;
}

.page-hero p {
    color: var(--ui-muted);
}

.page-hero-meta {
    color: var(--ui-brand-dark);
    background: var(--ui-rice-soft);
    border-color: #f0dc91;
    border-radius: 9px;
}

.card,
.document-box,
.metric-card,
.action-card,
.btb-summary-shell,
.payment-summary {
    border-color: var(--ui-line);
    border-radius: 12px;
    box-shadow: var(--ui-shadow);
}

.card,
.document-box,
.metric-card,
.action-card {
    background: var(--ui-surface);
}

.card-header {
    padding: 14px 18px;
    color: var(--ui-ink);
    background: linear-gradient(180deg, #ffffff 0%, #fbfcf7 100%);
    border-bottom-color: var(--ui-line);
}

.card-header strong {
    font-weight: 800;
}

.card-body {
    padding: 18px;
}

.metric-card {
    min-height: 134px;
    padding: 18px;
    overflow: hidden;
}

.metric-card:after {
    right: -42px;
    bottom: -52px;
    width: 128px;
    height: 128px;
    background: rgba(47, 111, 70, 0.08);
}

.metric-card .metric-icon {
    width: 40px;
    height: 40px;
    color: var(--ui-brand-dark);
    background: var(--ui-brand-soft);
    border-radius: 10px;
    box-shadow: none;
}

.metric-label {
    color: var(--ui-muted);
    font-size: 12px;
}

.metric-value {
    color: var(--ui-ink);
    font-size: 28px;
    letter-spacing: 0;
}

.metric-helper {
    color: var(--ui-muted);
}

.metric-card.metric-primary,
.btb-payable-card,
.payment-highlight-box {
    background: linear-gradient(135deg, var(--ui-brand-dark), var(--ui-brand));
    box-shadow: var(--ui-shadow-strong);
}

.metric-card.metric-primary .metric-icon {
    color: #203524;
    background: var(--ui-rice);
}

.action-card {
    min-height: 82px;
    padding: 16px;
    border-radius: 12px;
}

.action-card:hover {
    border-color: #c9d9c8;
    box-shadow: var(--ui-shadow-strong);
    transform: translateY(-1px);
}

.action-card-icon,
.empty-state-icon {
    color: var(--ui-brand-dark);
    background: var(--ui-brand-soft);
    border-radius: 10px;
}

.table-responsive,
.modern-table-wrapper {
    border-radius: 0 0 12px 12px;
}

.table {
    color: #334033;
}

.table thead th,
.thead-light th,
.quotation-products-table thead th,
.table-settings thead th,
#bill-to-bill-form .table th {
    color: #4c584b;
    background: #f4f7ef !important;
    border-color: var(--ui-line);
    letter-spacing: 0;
}

.table-sort-link {
    display: inline-flex;
    align-items: center;
    justify-content: inherit;
    gap: 2px;
    color: inherit;
    font-weight: inherit;
    white-space: nowrap;
}

.table-sort-link:hover,
.table-sort-link.active {
    color: var(--ui-green-800);
    text-decoration: none;
}

.table td,
.table th,
.table-bordered td,
.table-bordered th {
    border-color: var(--ui-line);
}

.table td {
    padding-top: 12px;
    padding-bottom: 12px;
}

.table-hover tbody tr:hover {
    background: #fbfcf7;
}

.form-group label {
    color: #405040;
    font-size: 12px;
}

.form-control,
.custom-select,
.input-group-text {
    border-color: #d8e0d1;
    border-radius: 9px;
}

.form-control,
.custom-select {
    min-height: 40px;
    color: var(--ui-ink);
    background-color: #ffffff;
}

.form-control:focus,
.custom-select:focus {
    border-color: var(--ui-brand);
    box-shadow: 0 0 0 4px rgba(47, 111, 70, 0.13);
}

.input-group > .form-control:not(:first-child),
.input-group > .custom-select:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > .form-control:not(:last-child),
.input-group > .custom-select:not(:last-child),
.input-group > .input-group-prepend > .input-group-text {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn {
    border-radius: 9px;
    font-weight: 750;
}

.btn-sm {
    border-radius: 8px;
}

.btn-primary {
    border-color: var(--ui-brand);
    background: var(--ui-brand);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--ui-brand-dark);
    background: var(--ui-brand-dark);
}

.btn-warning {
    color: #2a220d;
    border-color: var(--ui-rice);
    background: var(--ui-rice);
}

.btn-outline-primary {
    color: var(--ui-brand-dark);
    border-color: #b8cfb7;
    background: #ffffff;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary.active {
    color: #ffffff;
    border-color: var(--ui-brand);
    background: var(--ui-brand);
}

.btn-light,
.btn-outline-secondary {
    color: #4a5848;
    border-color: var(--ui-line);
    background: #f8faf5;
}

.btn-outline-secondary:hover {
    color: var(--ui-ink);
    border-color: #c9d7c8;
    background: #eef4eb;
}

.badge {
    border-radius: 8px;
    letter-spacing: 0;
}

.badge-primary {
    background: var(--ui-brand);
}

.badge-secondary,
.badge-dark {
    color: #435041;
    background: #e7ece2;
}

.badge-success {
    color: #1e5b32;
    background: #ddf3e3;
}

.badge-warning {
    color: #72530c;
    background: var(--ui-rice-soft);
}

.badge-danger {
    color: #8d271b;
    background: var(--ui-danger-soft);
}

.badge-info {
    color: #245b64;
    background: #e2f3f3;
}

.alert {
    border-radius: 12px;
    box-shadow: var(--ui-shadow);
}

.alert-success {
    color: #1e5b32;
    background: #ddf3e3;
}

.alert-danger {
    color: #8d271b;
    background: var(--ui-danger-soft);
}

.alert-warning {
    color: #72530c;
    background: var(--ui-rice-soft);
}

.alert-info {
    color: #245b64;
    background: #e2f3f3;
}

.empty-state {
    color: var(--ui-muted);
}

.empty-state i {
    color: #bed1bd;
}

.document-box {
    padding: 24px;
}

.info-tile,
.totals-control-box,
.btb-calc-card,
.btb-total-row,
.recent-bill-chip {
    background: var(--ui-surface-2);
    border-color: var(--ui-line);
    border-radius: 10px;
}

.btb-total-row.primary {
    background: var(--ui-brand-soft);
    border-color: #bfd6bf;
}

.btb-total-row.primary span,
.btb-total-row.primary strong,
.totals-table .grand-row th,
.totals-table .grand-row td {
    color: var(--ui-brand-dark);
}

.old-bill-panel,
.old-bill-panel .card-header {
    border-color: var(--ui-line);
}

.old-bill-panel .card-header {
    background: linear-gradient(90deg, #fbfcf7 0%, #ffffff 100%);
}

.select2-container--bootstrap4 .select2-selection {
    border-color: #d8e0d1;
    border-radius: 9px;
}

.select2-container--bootstrap4.select2-container--focus .select2-selection,
.select2-container--bootstrap4.select2-container--open .select2-selection {
    border-color: var(--ui-brand);
    box-shadow: 0 0 0 4px rgba(47, 111, 70, 0.13);
}

.select2-container--bootstrap4 .select2-dropdown {
    border-color: #d8e0d1;
    border-radius: 10px;
}

.select2-container--bootstrap4 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--ui-brand);
}

.product-colored-row[style] td {
    border-color: rgba(24, 32, 24, 0.08);
}

.login-body {
    background:
        linear-gradient(135deg, rgba(47, 111, 70, 0.95), rgba(28, 57, 36, 0.98) 48%, var(--ui-bg) 48%, var(--ui-bg) 100%);
}

.login-card {
    max-width: 940px;
    border-color: rgba(255, 255, 255, 0.38);
    border-radius: 18px;
    box-shadow: 0 28px 70px rgba(24, 32, 24, 0.28);
}

.login-visual {
    padding: 38px;
    background: linear-gradient(160deg, #183321, #2f6f46);
}

.login-visual-icon {
    color: #203524;
    background: var(--ui-rice);
    border-radius: 12px;
}

.login-visual h1,
.login-form-panel h2 {
    letter-spacing: 0;
}

.login-form-panel {
    padding: 40px;
}

.login-demo-box {
    color: #405040;
    background: var(--ui-surface-2);
    border-color: var(--ui-line);
    border-radius: 10px;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        width: 268px;
    }

    .app-main {
        margin-left: 0;
    }

    .topbar {
        padding: 10px 14px;
    }

    .app-container {
        padding: 16px 12px 34px;
    }

    .page-hero {
        align-items: flex-start;
        padding: 18px;
    }

    .page-hero h1 {
        font-size: 23px;
    }
}

@media (max-width: 575.98px) {
    .card-header,
    .card-body,
    .document-box {
        padding: 14px;
    }

    .metric-card {
        min-height: 124px;
    }

    .table td,
    .table th {
        padding: 10px;
    }

    .login-card {
        border-radius: 14px;
    }

    .login-form-panel {
        padding: 24px;
    }
}

.product-colored-row[style] td {
    background-color: var(--product-row-color, inherit);
}

.product-colored-row[style]:hover td {
    filter: brightness(.985);
}

.quotation-products-table .product-colored-row[style] .product-cell {
    background-color: var(--product-row-color, #fff);
}

.color-picker-control {
    min-width: 54px;
    height: 38px;
    padding: 4px;
}

.color-input-group .color-picker-control {
    max-width: 90px;
}

.totals-control-box {
    padding: 14px;
    background: #f8fbff;
    border: 1px solid #dbeafe;
    border-radius: 16px;
}

.totals-control-box label {
    color: var(--ink-700);
    font-size: 12px;
    font-weight: 750;
}

@media print {
    .product-colored-row[style] td {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.quotation-products-table tbody tr.product-colored-row[style]:hover td,
.quotation-products-table tbody tr.product-colored-row[style]:hover .product-cell {
    background-color: var(--product-row-color, #fff);
}

.quotation-product-settings-table .js-product-sort-row {
    cursor: grab;
}

.quotation-product-settings-table .js-product-sort-row.is-dragging {
    cursor: grabbing;
    opacity: .58;
}

.product-sort-controls {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.product-sort-controls .btn {
    width: 30px;
    height: 30px;
    padding: 0;
}

.product-sort-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    color: #758372;
    cursor: grab;
}

.quotation-product-settings-table .js-display-order[readonly] {
    color: #405040;
    background: #f8faf5;
}


/* Select2 - modern searchable selects */
.select2-container--bootstrap4 .select2-selection {
    min-height: 42px;
    border-color: #dbe7f5;
    border-radius: 12px;
    box-shadow: none;
}

.select2-container--bootstrap4.select2-container--focus .select2-selection,
.select2-container--bootstrap4.select2-container--open .select2-selection {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 4px rgba(29, 116, 245, 0.13);
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
    min-height: 40px;
    line-height: 40px;
    color: var(--ink-900);
    padding-left: 14px;
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
    height: 40px;
    right: 10px;
}

.select2-container--bootstrap4 .select2-dropdown {
    border-color: #dbe7f5;
    border-radius: 12px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.select2-container--bootstrap4 .select2-search--dropdown .select2-search__field {
    border-color: #dbe7f5;
    border-radius: 10px;
    min-height: 38px;
}

.select2-container--bootstrap4 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--blue-600);
}

.select2-container--bootstrap4 .select2-results__option {
    padding: 9px 12px;
}

.payment-summary {
    border: 1px solid #dbe7f5;
    background: #f8fbff;
    border-radius: 16px;
    padding: 16px;
}

.invoice-document {
    display: grid;
    gap: 18px;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 252, 249, 0.98));
}

.invoice-doc-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, auto);
    gap: 18px;
    align-items: start;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.invoice-doc-title {
    min-width: 0;
}

.invoice-doc-eyebrow,
.invoice-doc-type-row,
.invoice-info-panel > span,
.invoice-section-header span,
.invoice-section-amount span,
.invoice-btb-formula span {
    color: #64748b;
    font-size: 12px;
    font-weight: 850;
}

.invoice-doc-title h4 {
    margin: 2px 0 8px;
    color: #0f172a;
    font-size: 30px;
    font-weight: 950;
}

.invoice-doc-type-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.invoice-doc-side {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.invoice-doc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.invoice-focus-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 12px;
}

.invoice-focus-card {
    min-height: 112px;
    padding: 16px;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    background: #ffffff;
}

.invoice-focus-card span,
.invoice-focus-card small {
    display: block;
}

.invoice-focus-card span {
    color: #64748b;
    font-size: 12px;
    font-weight: 850;
}

.invoice-focus-card strong {
    display: block;
    margin-top: 7px;
    color: #111827;
    font-size: 28px;
    font-weight: 950;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.invoice-focus-card small {
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.invoice-focus-card-primary {
    border-color: #bfd6bf;
    background: #f4fbf7;
}

.invoice-focus-card-primary strong {
    color: #146c38;
}

.invoice-focus-card-balance {
    border-color: #f0d39a;
    background: #fffaf0;
}

.invoice-focus-card-balance strong {
    color: #8a5a00;
}

.invoice-info-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, .8fr);
    gap: 12px;
}

.invoice-info-panel {
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    background: #ffffff;
    padding: 14px;
}

.invoice-info-panel > strong {
    display: block;
    margin-top: 4px;
    color: #111827;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.35;
}

.invoice-info-panel dl {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 6px 10px;
    margin: 10px 0 0;
}

.invoice-info-panel dt,
.invoice-info-panel dd {
    margin: 0;
    line-height: 1.45;
}

.invoice-info-panel dt {
    color: #64748b;
    font-size: 12px;
    font-weight: 850;
}

.invoice-info-panel dd {
    color: #111827;
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.invoice-section {
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    background: #ffffff;
    padding: 16px;
}

.invoice-section-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.invoice-section-header h5 {
    margin: 1px 0 0;
    color: #111827;
    font-size: 18px;
    font-weight: 950;
}

.invoice-section-header small {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    font-weight: 650;
}

.invoice-section-header-split {
    align-items: center;
}

.invoice-section-amount {
    min-width: 220px;
    text-align: right;
}

.invoice-section-amount strong {
    display: block;
    color: #146c38;
    font-size: 26px;
    font-weight: 950;
    line-height: 1.15;
}

.invoice-btb-summary {
    border-color: #b8d4f4;
    background: #f7fbff;
}

.invoice-btb-body {
    display: grid;
    gap: 12px;
}

.invoice-btb-formula {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 10px;
}

.invoice-btb-formula > div {
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    background: #ffffff;
    padding: 12px 14px;
}

.invoice-btb-formula strong {
    display: block;
    margin-top: 5px;
    color: #111827;
    font-size: 21px;
    font-weight: 950;
    line-height: 1.15;
}

.invoice-btb-formula .minus strong {
    color: #a61e2c;
}

.invoice-btb-formula .total {
    border-color: #8cc5a3;
    background: #f4fbf7;
}

.invoice-btb-formula .total strong {
    color: #146c38;
}

.invoice-items-table .table,
.invoice-old-bill-section .table,
.invoice-history-section .table {
    margin-bottom: 0;
}

.invoice-total-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.invoice-total-table {
    width: min(100%, 380px);
}

.invoice-bottom-actions {
    display: flex;
    justify-content: flex-start;
    padding-top: 2px;
}

.invoice-action-card .card-header {
    background: #f7faf5;
}

.receipt-action-card .card-header {
    background: #f8fafc;
}

.receipt-cancel-form {
    display: grid !important;
    grid-template-columns: minmax(220px, 320px) auto;
    gap: 8px;
    align-items: center;
}

.receipt-cancel-form .form-control {
    width: 100%;
    min-height: 42px;
}

.invoice-payment-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 14px 12px;
    align-items: start;
}

.invoice-payment-form-grid > .form-group {
    max-width: none;
    padding: 0;
    margin-bottom: 0;
}

.invoice-payment-form-grid > .form-group:last-child {
    grid-column: span 2;
}

.payment-ledger-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
}

.payment-ledger-summary-three {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
}

.payment-ledger-card {
    border: 1px solid #d8e0ea;
    border-left: 5px solid #64748b;
    border-radius: 8px;
    background: #ffffff;
    padding: 12px 14px;
    min-height: 86px;
}

.payment-ledger-card span,
.payment-ledger-card small {
    display: block;
}

.payment-ledger-card span {
    color: #5b6878;
    font-size: 12px;
    font-weight: 800;
}

.payment-ledger-card strong {
    display: block;
    color: #111827;
    font-size: 24px;
    font-weight: 950;
    line-height: 1.15;
    margin-top: 6px;
}

.payment-ledger-card small {
    color: #64748b;
    font-size: 12px;
    font-weight: 650;
    margin-top: 4px;
}

.payment-ledger-card.current {
    border-left-color: #2c7be5;
}

.payment-ledger-card.current strong,
.payment-ledger-card.paid strong {
    color: #146c38;
}

.payment-ledger-card.paid {
    border-left-color: #37a267;
}

.payment-ledger-card.balance {
    border-left-color: #dc3545;
}

.payment-ledger-card.balance strong {
    color: #a61e2c;
}

.consignment-customer-header {
    display: grid;
    grid-template-columns: minmax(260px, 1.35fr) minmax(180px, .85fr) minmax(160px, .8fr);
    gap: 12px 22px;
    align-items: start;
    max-width: 980px;
}

.consignment-customer-field > span {
    display: block;
    color: #111827;
    font-size: 13px;
    font-weight: 850;
    margin-bottom: 3px;
}

.consignment-customer-field strong {
    display: block;
    color: #111827;
    font-size: 19px;
    font-weight: 900;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.consignment-customer-field strong span {
    color: inherit;
    font: inherit;
}

.consignment-customer-field-wide {
    min-width: 0;
}

.consignment-status-filter {
    width: 100%;
}

.consignment-status-filter-button {
    width: 100%;
    min-height: calc(1.5em + .5rem + 2px);
    padding: .25rem .5rem;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: .2rem;
    color: #334033;
    font-weight: 700;
    line-height: 1.5;
}

.consignment-status-filter-menu {
    width: 100%;
    min-width: 220px;
    padding: 6px 0;
    border-color: var(--ui-line);
    box-shadow: 0 12px 28px rgba(31, 42, 32, 0.12);
}

.consignment-status-filter-menu .dropdown-item {
    min-height: 34px;
    padding: 7px 14px 7px 36px;
    cursor: pointer;
}

.consignment-status-filter-menu .dropdown-item:active {
    color: inherit;
    background: #eef4ea;
}

.consignment-status-filter .custom-control-label {
    font-size: 13px;
    font-weight: 700;
    color: #334033;
    white-space: nowrap;
}

.payment-proof-preview {
    max-width: 260px;
    max-height: 260px;
    border-radius: 14px;
    border: 1px solid #dbe7f5;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    object-fit: contain;
    background: #fff;
}

.payment-highlight-box {
    min-height: 100%;
    border-radius: 18px;
    padding: 22px;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    box-shadow: 0 12px 28px rgba(22, 163, 74, 0.20);
}
.payment-highlight-box div {
    font-size: 1rem;
    opacity: .9;
    margin-bottom: 6px;
}
.payment-highlight-box strong {
    display: block;
    font-size: 1.65rem;
    line-height: 1.2;
}
.payment-highlight-box small {
    display: block;
    margin-top: 8px;
    opacity: .85;
}

/* Bill-to-bill UX refresh */
.btb-summary-shell {
    padding: 22px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid #dbeafe;
    border-radius: 22px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

.btb-summary-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.15fr) minmax(320px, .95fr) minmax(320px, .95fr);
    gap: 20px;
    align-items: stretch;
}

.btb-summary-grid-single {
    grid-template-columns: minmax(280px, 1fr);
}

.btb-payable-card,
.btb-calc-card {
    min-height: 100%;
    border-radius: 20px;
}

.btb-payable-card {
    padding: 30px 32px;
    color: #ffffff;
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    box-shadow: 0 22px 46px rgba(22, 163, 74, 0.22);
}

.btb-payable-card .summary-label-light,
.btb-payable-card small {
    display: block;
    color: rgba(255, 255, 255, 0.86);
    font-weight: 750;
}

.btb-payable-card strong {
    display: block;
    margin: 12px 0 10px;
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
}

.btb-calc-card {
    padding: 24px;
    background: #f8fbff;
    border: 1px solid #bfdbfe;
}

.btb-placeholder-card {
    background: rgba(248, 251, 255, 0.62);
    border-style: dashed;
    box-shadow: none;
}

.btb-final-card {
    background: #ffffff;
}

.section-title-row h5 {
    margin: 0;
    color: var(--ink-900);
    font-size: 18px;
    font-weight: 850;
}

.section-title-row p {
    margin: 4px 0 0;
    color: var(--ink-500);
    font-size: 13px;
    font-weight: 650;
}

.btb-total-list {
    display: grid;
    gap: 10px;
}

.btb-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 48px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.btb-total-row span {
    color: var(--ink-500);
    font-weight: 750;
}

.btb-total-row strong {
    color: var(--ink-900);
    font-size: 18px;
    font-weight: 900;
    white-space: nowrap;
}

.btb-total-row.danger strong {
    color: var(--danger);
}

.btb-total-row.primary {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.btb-total-row.primary span,
.btb-total-row.primary strong {
    color: var(--blue-800);
}

.btb-total-row.muted {
    background: #f1f5f9;
}

.btb-action-row {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e2e8f0;
}

#bill-to-bill-form .card-header {
    padding: 18px 22px;
}

#bill-to-bill-form .table th {
    color: var(--ink-700);
    background: #f4f8ff;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

#bill-to-bill-form .table td {
    vertical-align: middle;
}

#bill-to-bill-form .form-control {
    min-height: 42px;
}

#btb-old-invoice-help {
    color: var(--blue-700) !important;
    font-weight: 650;
}

@media (max-width: 1399.98px) {
    .btb-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .btb-payable-card {
        grid-column: span 2;
    }
}

@media (max-width: 767.98px) {
    .btb-summary-shell {
        padding: 14px;
    }

    .btb-summary-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .btb-payable-card {
        grid-column: span 1;
        padding: 24px;
    }

    .btb-calc-card {
        padding: 18px;
    }

    .btb-total-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .btb-action-row {
        flex-direction: column-reverse;
    }

    .btb-action-row .btn {
        width: 100%;
    }
}

/* Final UI refresh overrides kept at the end so module-specific CSS inherits the new theme */
.btb-summary-shell,
.btb-calc-card,
.btb-total-row,
.payment-summary,
.totals-control-box,
.info-tile,
.recent-bill-chip {
    border-color: var(--ui-line);
    border-radius: 10px;
}

.btb-summary-shell {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--ui-shadow);
}

.btb-payable-card,
.payment-highlight-box {
    background: linear-gradient(135deg, var(--ui-brand-dark), var(--ui-brand));
    box-shadow: var(--ui-shadow-strong);
}

.btb-calc-card,
.btb-total-row,
.totals-control-box,
.payment-summary,
.info-tile {
    background: var(--ui-surface-2);
}

.btb-total-row.primary {
    background: var(--ui-brand-soft);
    border-color: #bfd6bf;
}

.btb-total-row.primary span,
.btb-total-row.primary strong,
#btb-old-invoice-help {
    color: var(--ui-brand-dark) !important;
}

#bill-to-bill-form .card-header,
#bill-to-bill-form .table th {
    background: #f4f7ef !important;
    border-color: var(--ui-line);
}

#bill-to-bill-form .table th {
    color: #4c584b;
}

#bill-to-bill-form .form-control {
    min-height: 40px;
}

.consignment-items-wrapper {
    border: 1px solid var(--ui-line);
    border-radius: 10px;
    overflow: auto;
}

.consignment-items-table {
    min-width: 1260px;
    margin-bottom: 0;
}

.consignment-items-table th {
    background: #eef4ea;
    color: #334238;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    vertical-align: middle;
}

.consignment-items-table td {
    font-size: 14px;
    vertical-align: middle;
}

.consignment-items-table tbody tr:nth-child(even) td {
    background-color: #fbfcfd;
}

.consignment-items-table tbody tr:hover td {
    background-color: #f4f8ff;
}

.consignment-items-table .row-no {
    color: #6c757d;
    font-weight: 700;
    width: 42px;
}

.consignment-items-table .product-cell {
    width: 300px;
    min-width: 300px;
    max-width: 360px;
    color: #26343d;
    line-height: 1.35;
}

.consignment-items-table .product-cell .font-weight-bold {
    font-size: 15.5px;
    font-weight: 850 !important;
}

.consignment-items-table .product-cell .small {
    display: block;
    margin-top: 3px;
    font-size: 12.5px;
    line-height: 1.25;
}

.consignment-items-table .sku-cell {
    color: var(--ui-brand-dark);
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}

.consignment-items-table .description-cell {
    min-width: 220px;
    color: #2f3c45;
    font-weight: 650;
}

.consignment-items-table .number-cell,
.consignment-items-table .money-cell {
    font-variant-numeric: tabular-nums;
    font-weight: 750;
    min-width: 74px;
}

.consignment-items-table .status-group-col {
    background-color: #fff2f2;
    color: #9d2732;
}

.consignment-items-table .invoice-col.status-group-col {
    background-color: #f5f0ff;
    color: #5a3f99;
}

.consignment-items-table .balance-group-col {
    background-color: #eaf7ff;
    color: #075985;
}

.consignment-items-table .balance-group-col.has-remain {
    color: #0056b3;
    font-size: 15px;
    font-weight: 850;
}

.consignment-items-table .old-group-col {
    background-color: #fff7dc;
    color: #765315;
}

.consignment-items-table .sent-group-col {
    background-color: #ffffff;
    color: #2f3742;
}

.consignment-items-table .sale-group-col {
    background-color: #eaf6f1;
    color: #0f6848;
}

.consignment-items-table .unbilled-value {
    color: #0f6b2a;
    font-size: 16px;
    font-weight: 900;
    min-width: 110px;
}

.invoice-status-area {
    min-width: 220px;
}

.invoice-status-panel {
    border: 2px solid var(--ui-line);
    border-radius: 10px;
    padding: 12px 16px;
    text-align: center;
    background: #f6f8fb;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.invoice-status-panel span,
.invoice-status-panel small {
    display: block;
}

.invoice-status-panel span {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.invoice-status-panel strong {
    display: block;
    font-size: 28px;
    font-weight: 950;
    line-height: 1.1;
    margin-top: 2px;
}

.invoice-status-panel small {
    font-size: 12px;
    font-weight: 650;
    margin-top: 6px;
}

.invoice-status-paid {
    background: #eaf8ef;
    border-color: #37a267;
    color: #146c38;
}

.invoice-status-unpaid {
    background: #fff6df;
    border-color: #f0ad2c;
    color: #8a5a00;
}

.invoice-status-partial_paid {
    background: #e8f4ff;
    border-color: #4d9de0;
    color: #1457a8;
}

.invoice-status-cancelled {
    background: #fdecec;
    border-color: #dc3545;
    color: #a61e2c;
}

.invoice-management-page .card {
    border-color: #d8e0ea;
}

.invoice-quick-actions .btn {
    margin-left: 4px;
    margin-bottom: 4px;
}

.invoice-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 10px;
}

.invoice-summary-card {
    border: 1px solid #d8e0ea;
    border-left-width: 5px;
    border-radius: 8px;
    padding: 12px 14px;
    background: #ffffff;
    min-height: 104px;
}

.invoice-summary-card span,
.invoice-summary-card small {
    display: block;
}

.invoice-summary-card span {
    color: #5b6878;
    font-size: 12px;
    font-weight: 800;
}

.invoice-summary-card strong {
    display: block;
    color: #1f2a37;
    font-size: 24px;
    font-weight: 950;
    line-height: 1.2;
    margin-top: 6px;
}

.invoice-summary-card small {
    color: #6b7280;
    font-weight: 650;
    margin-top: 6px;
}

.invoice-summary-card.total {
    border-left-color: #2f80ed;
    background: #f4f8ff;
}

.invoice-summary-card.unpaid {
    border-left-color: #f0ad2c;
    background: #fff9ea;
}

.invoice-summary-card.overdue {
    border-left-color: #dc3545;
    background: #fff1f2;
}

.invoice-summary-card.paid {
    border-left-color: #37a267;
    background: #effaf3;
}

.invoice-summary-card.cancelled {
    border-left-color: #64748b;
    background: #f6f8fb;
}

.invoice-type-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 10px;
}

.invoice-type-tab {
    display: block;
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    padding: 11px 12px;
    background: #ffffff;
    color: #1f2a37;
    text-decoration: none;
}

.invoice-type-tab:hover {
    border-color: #2f80ed;
    color: #1457a8;
    text-decoration: none;
}

.invoice-type-tab.active {
    border-color: #2f80ed;
    background: #edf5ff;
    box-shadow: inset 0 0 0 1px #2f80ed;
}

.invoice-type-tab span,
.invoice-type-tab small,
.invoice-type-tab em {
    display: block;
}

.invoice-type-tab span {
    font-size: 13px;
    font-weight: 850;
}

.invoice-type-tab strong {
    display: block;
    font-size: 22px;
    font-weight: 950;
    line-height: 1.2;
    margin-top: 4px;
}

.invoice-type-tab small,
.invoice-type-tab em {
    color: #64748b;
    font-size: 12px;
    font-style: normal;
    font-weight: 650;
}

.invoice-customer-name {
    display: block;
    color: #0f172a;
    font-size: 15px;
    font-weight: 850;
    line-height: 1.35;
}

.invoice-customer-code {
    margin-top: 2px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.invoice-filter-form label {
    color: #526173;
    font-size: 12px;
    font-weight: 800;
}

.invoice-filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.invoice-filter-actions .btn-block + .btn-block {
    margin-top: 0;
}

.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.card-body.page-actions,
.card-footer.page-actions {
    margin-top: 0;
}

.page-actions-left,
.page-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-actions-right {
    justify-content: flex-end;
}

.page-actions form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.page-actions .btn {
    min-width: 112px;
}

@media (max-width: 575.98px) {
    .page-actions,
    .page-actions-left,
    .page-actions-right,
    .page-actions form,
    .page-actions .btn {
        width: 100%;
    }

    .page-actions-right {
        justify-content: stretch;
    }
}

.invoice-management-table thead th {
    background: #f1f5f9;
    border-bottom: 1px solid #d8e0ea;
    color: #334155;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.invoice-management-table td {
    vertical-align: middle;
}

.invoice-management-table .invoice-no {
    color: #1457a8;
    font-weight: 900;
}

.invoice-management-table .invoice-ref a {
    color: #3b4a5f;
    font-weight: 750;
}

.invoice-management-table .money-cell,
.invoice-management-table .collect-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.invoice-management-table .collect-cell {
    color: #0f5132;
    font-size: 16px;
    font-weight: 950;
}

.invoice-row.is-cancelled {
    color: #7b8794;
    background: #f7f8fa;
}

.invoice-row.is-cancelled .collect-cell,
.invoice-row.is-cancelled .invoice-no {
    color: #7b8794;
}

.invoice-due-pill,
.invoice-list-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    min-height: 26px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.invoice-due-overdue,
.invoice-list-status-cancelled {
    background: #fdecec;
    color: #a61e2c;
}

.invoice-due-today,
.invoice-list-status-unpaid {
    background: #fff2cc;
    color: #8a5a00;
}

.invoice-due-paid,
.invoice-list-status-paid {
    background: #eaf8ef;
    color: #146c38;
}

.invoice-list-status-partial_paid {
    background: #e8f4ff;
    color: #1457a8;
}

.invoice-due-normal {
    background: #edf5ff;
    color: #1457a8;
}

.invoice-due-muted {
    background: #eef2f7;
    color: #64748b;
}

.consignment-status-area {
    min-width: 240px;
    text-align: right;
}

.consignment-status-panel {
    border: 2px solid var(--ui-line);
    border-radius: 10px;
    padding: 12px 16px;
    text-align: center;
    background: #f6f8fb;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.consignment-status-panel span,
.consignment-status-panel small {
    display: block;
}

.consignment-status-panel span {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.consignment-status-panel strong {
    display: block;
    font-size: 26px;
    font-weight: 950;
    line-height: 1.1;
    margin-top: 2px;
}

.consignment-status-panel small {
    font-size: 12px;
    font-weight: 650;
    margin-top: 6px;
}

.consignment-status-open {
    background: #edf5ff;
    border-color: #2f80ed;
    color: #1457a8;
}

.consignment-status-partial {
    background: #fff6df;
    border-color: #f0ad2c;
    color: #8a5a00;
}

.consignment-status-closed {
    background: #eaf8ef;
    border-color: #37a267;
    color: #146c38;
}

.consignment-status-cancelled {
    background: #fdecec;
    border-color: #dc3545;
    color: #a61e2c;
}

.document-status-area {
    min-width: 230px;
    text-align: right;
}

.document-status-panel {
    border: 2px solid var(--ui-line);
    border-radius: 10px;
    padding: 12px 16px;
    text-align: center;
    background: #f6f8fb;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.document-status-panel span,
.document-status-panel small {
    display: block;
}

.document-status-panel span {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.document-status-panel strong {
    display: block;
    font-size: 26px;
    font-weight: 950;
    line-height: 1.1;
    margin-top: 2px;
}

.document-status-panel small {
    font-size: 12px;
    font-weight: 650;
    margin-top: 6px;
}

.document-status-draft,
.document-status-draft_bill {
    background: #f4f6f8;
    border-color: #94a3b8;
    color: #475569;
}

.document-status-open {
    background: #edf5ff;
    border-color: #2f80ed;
    color: #1457a8;
}

.document-status-partial,
.document-status-unpaid {
    background: #fff6df;
    border-color: #f0ad2c;
    color: #8a5a00;
}

.document-status-posted,
.document-status-posted_bill,
.document-status-invoiced,
.document-status-paid,
.document-status-closed {
    background: #eaf8ef;
    border-color: #37a267;
    color: #146c38;
}

.document-status-cancelled,
.document-status-rejected {
    background: #fdecec;
    border-color: #dc3545;
    color: #a61e2c;
}

@media (max-width: 767.98px) {
    .invoice-doc-header,
    .invoice-info-grid,
    .invoice-btb-formula {
        grid-template-columns: 1fr;
    }

    .invoice-doc-side {
        justify-items: stretch;
    }

    .invoice-doc-actions,
    .invoice-doc-side .btn {
        width: 100%;
    }

    .invoice-focus-grid,
    .invoice-payment-form-grid {
        grid-template-columns: 1fr;
    }

    .invoice-payment-form-grid > .form-group:last-child {
        grid-column: span 1;
    }

    .receipt-cancel-form {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .invoice-section-header,
    .invoice-section-header-split {
        display: block;
    }

    .invoice-section-amount {
        min-width: 0;
        margin-top: 10px;
        text-align: left;
    }

    .invoice-info-panel dl {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .payment-ledger-summary {
        grid-template-columns: 1fr;
    }

    .invoice-summary-grid,
    .invoice-type-tabs {
        grid-template-columns: 1fr;
    }

    .invoice-quick-actions {
        width: 100%;
    }

    .invoice-quick-actions .btn {
        margin-left: 0;
        margin-right: 4px;
    }

    .invoice-status-area {
        min-width: 100%;
        margin-top: 12px;
        text-align: left !important;
    }

    .invoice-status-panel {
        text-align: left;
    }

    .consignment-status-area {
        min-width: 100%;
        text-align: left;
    }

    .consignment-status-panel {
        text-align: left;
    }

    .document-status-area {
        min-width: 100%;
        text-align: left;
    }

    .document-status-panel {
        text-align: left;
    }
}

@media print {
    @page {
        size: A4;
        margin: 12mm 10mm;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    html,
    body {
        width: 210mm;
        min-height: 297mm;
        color: #111827 !important;
        background: #ffffff !important;
        font-size: 12px;
    }

    .app-shell,
    .app-main,
    .app-container {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    .document-box {
        position: relative;
        width: 100% !important;
        padding: 0 !important;
        color: #111827 !important;
        background: #ffffff !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .document-box::before {
        content: "ระบบโรงสี";
        display: block;
        padding-bottom: 6px;
        margin-bottom: 14px;
        color: #1f2937;
        font-size: 18px;
        font-weight: 900;
        border-bottom: 2px solid #111827;
    }

    .document-box h4 {
        margin-bottom: 2px;
        color: #111827;
        font-size: 22px;
        font-weight: 900;
    }

    .document-box .text-muted {
        color: #4b5563 !important;
    }

    .document-box .row.mb-3 {
        margin-bottom: 14px !important;
        padding-bottom: 10px;
        border-bottom: 1px solid #d1d5db;
    }

    .table-responsive {
        overflow: visible !important;
        border: 0 !important;
    }

    .document-box table {
        width: 100% !important;
        margin-bottom: 12px;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }

    .document-box thead {
        display: table-header-group;
    }

    .document-box tfoot {
        display: table-footer-group;
    }

    .document-box tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .document-box .table td,
    .document-box .table th,
    .document-box .table-bordered td,
    .document-box .table-bordered th {
        padding: 6px 7px !important;
        color: #111827 !important;
        background: #ffffff !important;
        border: 1px solid #9ca3af !important;
        font-size: 11px;
        line-height: 1.35;
    }

    .document-box .table thead th,
    .document-box .thead-light th {
        color: #111827 !important;
        background: #e5e7eb !important;
        font-weight: 900;
    }

    .document-box .h4,
    .document-box .h5,
    .document-box strong {
        color: #111827 !important;
    }

    .document-box .table-sm th,
    .document-box .table-sm td {
        padding: 5px 6px !important;
    }

    .document-box .badge,
    .invoice-status-panel,
    .consignment-status-panel,
    .document-status-panel {
        color: #111827 !important;
        background: #ffffff !important;
        border: 1px solid #111827 !important;
        box-shadow: none !important;
    }

    .invoice-status-panel strong,
    .consignment-status-panel strong,
    .document-status-panel strong {
        font-size: 16px !important;
    }

    .payment-summary,
    .invoice-section,
    .btb-summary-shell,
    .btb-calc-card,
    .btb-payable-card,
    .info-tile {
        color: #111827 !important;
        background: #ffffff !important;
        border: 1px solid #d1d5db !important;
        box-shadow: none !important;
    }

    .summary-line,
    .btb-total-row {
        border-color: #d1d5db !important;
    }

    .product-colored-row[style] td {
        background: #ffffff !important;
    }

    a {
        color: #111827 !important;
        text-decoration: none !important;
    }
}
