﻿/* ═══════════════════════════════════════════════════
   NexusSell — Components
   (Page Header · Cards · KPI · Tables · Forms · Buttons
    Badges · Pagination · Search · Invoice · Utilities)
   ═══════════════════════════════════════════════════ */

/* ── Page Header ───────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
}

.page-header .breadcrumb {
    font-size: .78rem;
    color: var(--text-muted);
    margin-bottom: .2rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.btn-group-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Cards ─────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 1.25rem;
}

.card-header {
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .875rem;
    color: var(--text);
    background: #F8FAFC;
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ── Premium KPI Cards ─────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    /* Increased gap for breathing room */
    margin-bottom: 2rem;
}

.kpi-card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: kpiEnter .5s cubic-bezier(0.22, 1, 0.36, 1) both;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

@keyframes kpiEnter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.kpi-card:nth-child(1) {
    animation-delay: 0.05s;
}

.kpi-card:nth-child(2) {
    animation-delay: 0.1s;
}

.kpi-card:nth-child(3) {
    animation-delay: 0.15s;
}

.kpi-card:nth-child(4) {
    animation-delay: 0.2s;
}

/* Soft Gradient Glows in Background */
.kpi-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    opacity: 0.5;
    z-index: 0;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

/* Light Mode Premium Variants */
.kpi-card.primary {
    background: linear-gradient(135deg, #ffffff 0%, #f0f6ff 100%);
    border-color: #bfdbfe;
    border-bottom: 4px solid var(--primary);
}

.kpi-card.primary:hover {
    box-shadow: var(--shadow-blue);
}

.kpi-card.success {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border-color: #bbf7d0;
    border-bottom: 4px solid var(--success);
}

.kpi-card.success:hover {
    box-shadow: var(--shadow-green);
}

.kpi-card.warning {
    background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
    border-color: #fde68a;
    border-bottom: 4px solid var(--warning);
}

.kpi-card.warning:hover {
    box-shadow: var(--shadow-orange);
}

.kpi-card.danger {
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
    border-color: #fecaca;
    border-bottom: 4px solid var(--danger);
}

.kpi-card.danger:hover {
    box-shadow: var(--shadow-red);
}

.kpi-card.purple {
    background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
    border-color: #e9d5ff;
    border-bottom: 4px solid var(--purple);
}

.kpi-card.purple:hover {
    box-shadow: var(--shadow-purple);
}

/* Content layer over gradients */
.kpi-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.kpi-label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .02em;
}

.kpi-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.primary .kpi-icon-wrap {
    color: var(--primary);
    background: var(--primary-soft);
}

.success .kpi-icon-wrap {
    color: var(--success);
    background: var(--success-soft);
}

.warning .kpi-icon-wrap {
    color: var(--warning);
    background: var(--warning-soft);
}

.danger .kpi-icon-wrap {
    color: var(--danger);
    background: var(--danger-soft);
}

.purple .kpi-icon-wrap {
    color: var(--purple);
    background: var(--purple-soft);
}

.kpi-value {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    letter-spacing: -.04em;
    margin-top: auto;
}

.kpi-sub {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: .4rem;
}


/* ── Filter Row ────────────────────────────────── */
.filter-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.filter-row .form-control,
.filter-row .form-select {
    font-size: .875rem;
    height: 36px;
    padding: .35rem .75rem;
}

/* ── Premium Data Table ────────────────────────── */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.table-card thead th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 800;
    color: #334155;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}

.table-card tbody td {
    padding: .85rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
    vertical-align: middle;
}

.table-card tbody tr:last-child td {
    border-bottom: none;
}

.table-card tbody tr {
    transition: all .2s ease;
    animation: fadeIn .3s ease both;
}

.table-card tbody tr:hover {
    background: #f8fbff;
    transform: scale(1.002);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.03);
    position: relative;
    z-index: 10;
}

.table-card tbody tr.row-clickable {
    cursor: pointer;
}

.table-card tbody tr.row-clickable:hover td:first-child {
    border-right: 4px solid var(--primary);
    padding-right: calc(1.25rem - 4px);
    color: var(--primary-dark);
    font-weight: 600;
}

.table-card tfoot td {
    padding: .85rem 1.25rem;
    border-top: 2px solid var(--border);
    font-weight: 800;
    background: #f8fafc;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-muted);
    background: #f8fafc;
}

/* ── Invoice Lines Table ───────────────────────── */
.lines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.lines-table th {
    background: #F8FAFC;
    padding: .55rem .75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 700;
    font-size: .75rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.lines-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}

.lines-table input {
    width: 100%;
    padding: .3rem .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .875rem;
    font-family: inherit;
    background: var(--surface);
    transition: border-color .15s;
}

.lines-table input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-ring);
}

/* ── Form Section ──────────────────────────────── */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.form-section-header {
    padding: .8rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: .875rem;
    background: #F8FAFC;
    border-radius: var(--radius) var(--radius) 0 0;
    letter-spacing: -.01em;
}

.form-section-body {
    padding: 1.25rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-label {
    display: block;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: .35rem;
    letter-spacing: .01em;
}

.form-control,
.form-select {
    width: 100%;
    padding: .55rem .875rem;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    font-size: .875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .18s, box-shadow .18s;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    gap: .75rem;
    align-items: center;
    z-index: 10;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -4px 12px rgba(15, 23, 42, .06);
}

/* ── Buttons ───────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1.25rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .18s cubic-bezier(.4, 0, .2, 1);
    text-decoration: none;
    letter-spacing: .01em;
}

.btn:disabled {
    opacity: .5;
    cursor: default;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--primary-ring);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    box-shadow: 0 2px 8px rgba(5, 150, 105, .25);
}

.btn-success:hover {
    background: #047857;
    box-shadow: 0 4px 14px rgba(5, 150, 105, .35);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 2px 8px rgba(220, 38, 38, .22);
}

.btn-danger:hover {
    background: #B91C1C;
    box-shadow: 0 4px 14px rgba(220, 38, 38, .32);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    background: var(--bg);
    border-color: #94A3B8;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger-soft);
    transform: translateY(-1px);
}

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

.btn-danger-outline:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.btn-sm {
    padding: .3rem .75rem;
    font-size: .8rem;
    border-radius: 7px;
}

.btn-xs {
    padding: .2rem .5rem;
    font-size: .75rem;
    border-radius: 6px;
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .65s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Badges ────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.badge-primary {
    background: var(--primary-soft);
    color: #1D4ED8;
}

.badge-success {
    background: var(--success-soft);
    color: #065F46;
}

.badge-danger {
    background: var(--danger-soft);
    color: #991B1B;
}

.badge-warning {
    background: var(--warning-soft);
    color: #92400E;
}

.badge-purple {
    background: var(--purple-soft);
    color: #5B21B6;
}

.badge-muted {
    background: var(--bg);
    color: var(--text-muted);
}

/* ── Pagination ────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
}

.page-btn {
    border: 1px solid var(--border-dark);
    background: var(--surface);
    border-radius: 7px;
    padding: .3rem .6rem;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    font-size: .8rem;
    transition: all .15s;
}

.page-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px var(--primary-ring);
}

.page-btn:disabled {
    opacity: .4;
    cursor: default;
}

/* ── Radio Options ─────────────────────────────── */
.radio-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .18s, background .18s, box-shadow .18s;
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.radio-option input {
    cursor: pointer;
}

.radio-label {
    font-weight: 600;
    font-size: .875rem;
}

.radio-desc {
    font-size: .75rem;
    color: var(--text-muted);
}

/* ── Premium Quick Actions ─────────────────────── */
.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.quick-action-btn:hover {
    border-color: #bfdbfe;
    color: var(--primary-dark);
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-soft) 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.15);
}

.quick-action-icon {
    font-size: 1.35rem;
    transition: transform 0.3s;
}

.quick-action-btn:hover .quick-action-icon {
    transform: scale(1.15) rotate(5deg);
}

/* ── Balance Info ──────────────────────────────── */
.balance-info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border-right: 4px solid var(--primary);
}

.balance-info-label {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: .35rem;
}

.balance-info-value {
    font-size: 1.9rem;
    font-weight: 700;
    margin-bottom: .25rem;
    letter-spacing: -.03em;
}

.balance-info-sub {
    font-size: .8rem;
    color: var(--text-muted);
}

/* ── Header Search ─────────────────────────────── */
.header-search {
    position: relative;
    flex: 1;
    max-width: 340px;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    right: .75rem;
    font-size: .85rem;
    pointer-events: none;
    z-index: 1;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: .45rem .875rem .45rem 2rem;
    padding-right: 2.25rem;
    border: 1px solid var(--border-dark);
    border-radius: 20px;
    font-size: .82rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all .18s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
    background: var(--surface);
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 999;
    max-height: 400px;
    overflow-y: auto;
}

.search-drop-item {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .6rem .875rem;
    cursor: pointer;
    border-bottom: 1px solid #F1F5F9;
    transition: background .1s;
    text-decoration: none;
    color: var(--text);
}

.search-drop-item:last-child {
    border-bottom: none;
}

.search-drop-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.search-drop-cat {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .4rem .875rem .2rem;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
}

.search-drop-title {
    font-size: .875rem;
    font-weight: 600;
}

.search-drop-sub {
    font-size: .75rem;
    color: var(--text-muted);
}

.search-drop-empty {
    padding: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: .875rem;
}

/* ── Invoice Detail ────────────────────────────── */
.inv-kpi-bar {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.inv-kpi {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .875rem 1rem;
    border-left: 1px solid var(--border);
    gap: .2rem;
}

.inv-kpi:last-child {
    border-left: none;
}

.inv-kpi--net {
    background: linear-gradient(135deg, var(--primary-soft), #F0FDFA);
}

.inv-kpi-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.inv-kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.inv-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.inv-info-table {
    display: flex;
    flex-direction: column;
}

.inv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    border-bottom: 1px solid #F1F5F9;
    font-size: .875rem;
    gap: .5rem;
}

.inv-row:last-child {
    border-bottom: none;
}

.inv-row>span:first-child {
    color: var(--text-muted);
    flex-shrink: 0;
}

.inv-row>strong,
.inv-row>span:last-child {
    text-align: left;
}

.inv-row--highlight {
    background: var(--primary-soft);
    margin: 0 -1.25rem;
    padding: .6rem 1.25rem;
    font-weight: 700;
    border-bottom: none;
}

/* ── Utilities ─────────────────────────────────── */
.text-danger {
    color: var(--danger) !important;
}

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

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

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

.fw-bold {
    font-weight: 700;
}

.fw-600 {
    font-weight: 600;
}

.fs-sm {
    font-size: .8rem;
}

.mb-1 {
    margin-bottom: 1rem;
}

.d-inline {
    display: inline;
}

.text-end,
.text-left {
    text-align: left;
}

.money {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ── Responsive (components) ───────────────────── */
@media (max-width: 767px) {
    .inv-info-grid {
        grid-template-columns: 1fr;
    }

    .inv-kpi-bar {
        flex-wrap: wrap;
    }

    .inv-kpi {
        flex: 0 0 50%;
        border-bottom: 1px solid var(--border);
    }
}

/* ── Statements (Customer/Vendor/Treasury) ─────── */
.cs-filter-bar,
.statement-filter-bar {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.cs-filter-field,
.statement-filter-field {
    display: flex;
    flex-direction: column;
}

.cs-filter-field .form-control,
.statement-filter-field .form-control,
.statement-filter-field .form-select {
    min-width: 160px;
}

.cs-empty,
.statement-empty {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: .875rem;
}

.cs-mov-icon,
.statement-mov-icon {
    margin-left: .4rem;
    font-size: 1rem;
}

.cs-mov-label,
.statement-mov-label {
    font-size: .875rem;
    font-weight: 500;
}

.statement-mov-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.statement-mov-link:hover {
    text-decoration: underline;
}

.reports-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.report-field {
    margin-bottom: .75rem;
}

.report-action-full {
    width: 100%;
}

.report-subtitle {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: .2rem;
}

.report-total-row {
    font-weight: 700;
    background: var(--bg-secondary);
}

.cs-open-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s, transform .12s;
}

.cs-open-link:hover {
    background: var(--primary);
    color: #fff;
    transform: scale(1.1);
}

/* ── Customer Statement Print Enhancements ─────── */
.cust-print-head,
.cust-print-summary,
.cust-print-signatures {
    display: none;
}

.cust-print-head-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.cust-print-head-date {
    font-size: .82rem;
    color: #4B5563;
    font-weight: 600;
}

.cust-print-meta-grid {
    margin-top: .75rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .55rem .9rem;
}

.cust-print-meta-item {
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: .45rem .6rem;
    background: #FAFAFA;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .7rem;
    font-size: .82rem;
}

.cust-print-meta-item .lbl {
    color: #6B7280;
    font-weight: 600;
}

.cust-print-summary {
    margin: .8rem 0 .9rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .45rem;
}

.cust-print-kpi {
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: .45rem .5rem;
    background: #fff;
    text-align: center;
}

.cust-print-kpi .kpi-lbl {
    display: block;
    font-size: .74rem;
    color: #6B7280;
    margin-bottom: .2rem;
}

.cust-print-kpi .kpi-val {
    display: block;
    font-size: .95rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.cust-print-signatures {
    margin-top: 1rem;
    display: flex;
    gap: .7rem;
}

.cust-print-signatures .sig-box {
    flex: 1;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: .45rem .55rem .65rem;
}

.cust-print-signatures .sig-title {
    font-size: .78rem;
    color: #4B5563;
    margin-bottom: .9rem;
    font-weight: 700;
}

.cust-print-signatures .sig-line {
    border-bottom: 1px solid #9CA3AF;
    height: 1.25rem;
}

/* ── Print Styles ──────────────────────────────── */
.print-only {
    display: none;
}

@media print {
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    body,
    .page-content {
        background: #fff !important;
        padding: 0 !important;
    }

    .has-sidebar .main-wrapper {
        margin-right: 0 !important;
    }

    .sidebar,
    .top-header {
        display: none !important;
    }

    .table-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    .table-card thead th {
        background: #F5F5F5 !important;
        color: #333 !important;
    }

    .table-card tbody tr:hover {
        background: none !important;
    }

    .inv-kpi-bar {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        border-radius: 6px !important;
    }

    .inv-kpi {
        border-left-color: #ddd !important;
    }

    .inv-kpi--net {
        background: #F5F7FF !important;
    }

    /* Print header */
    .cs-print-header,
    .statement-print-header {
        border-bottom: 2px solid #333;
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }

    .cs-print-logo,
    .statement-print-logo {
        font-size: 1.6rem;
        font-weight: 900;
        color: #1D4ED8;
        margin-bottom: .25rem;
    }

    .cs-print-title,
    .statement-print-title {
        font-size: 1.2rem;
        font-weight: 700;
        margin-bottom: .5rem;
    }

    .cs-print-meta,
    .statement-print-meta {
        display: flex;
        gap: 2rem;
        font-size: .8rem;
        color: #555;
    }

    .cust-statement .inv-kpi-bar {
        display: none !important;
    }

    .cust-print-head {
        display: block !important;
        border: 1px solid #D1D5DB;
        border-radius: 10px;
        padding: .7rem .8rem;
        margin-bottom: .65rem;
        page-break-inside: avoid;
    }

    .cust-print-summary {
        display: grid !important;
        page-break-inside: avoid;
    }

    .cust-print-signatures {
        display: flex !important;
        page-break-inside: avoid;
    }

    .cust-statement-table {
        border-color: #BFC4CC !important;
    }

    .cust-statement-table .card-header {
        font-size: .85rem !important;
        border-bottom: 1px solid #BFC4CC !important;
    }

    .cust-statement-table thead th {
        font-size: .68rem !important;
        padding: .45rem .4rem !important;
    }

    .cust-statement-table tbody td,
    .cust-statement-table tfoot td {
        padding: .42rem .4rem !important;
        font-size: .74rem !important;
    }

    .cust-statement-table tbody tr:nth-child(even) td {
        background: #FBFBFB !important;
    }

    .cust-statement-table .statement-mov-icon,
    .cust-statement-table .movement-code {
        display: none !important;
    }

    .cust-statement-table .statement-mov-link,
    .cust-statement-table .statement-mov-label {
        color: #111827 !important;
        text-decoration: none !important;
        font-weight: 700 !important;
    }

    .cust-statement-table tr,
    .cust-statement-table td,
    .cust-statement-table th {
        page-break-inside: avoid !important;
    }
}

/* ═══════════════════════════════════════════════════
   INVOICE FORM — Maximum Premium Design
   ═══════════════════════════════════════════════════ */

/* Global Form Tweaks */
#invoiceForm {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding-bottom: 90px;
    position: relative;
}

/* ── Hero Row (Customer & Inv No) ── */
.inv-hero-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    padding: .75rem 1.25rem;
    box-shadow: 0 10px 30px -10px rgba(37, 99, 235, 0.1);
    position: relative;
    z-index: 50;
    overflow: visible;
}

.inv-hero-row::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--purple));
}

.inv-customer-col {
    flex: 1;
}

.inv-invno-col {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.inv-invno-value {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--primary);
    background: linear-gradient(135deg, #f0f6ff, #ffffff);
    border: 2px solid #bfdbfe;
    border-radius: 10px;
    padding: .3rem 1rem;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.inv-field-label {
    display: block;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: .4rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.inv-bal-badge {
    position: absolute;
    top: -30px;
    left: 0;
    font-size: .8rem;
    padding: .3rem .8rem;
    border-radius: 99px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Searchable Customer Dropdown */
.inv-customer-search-wrap {
    position: relative;
}

.inv-customer-input {
    width: 100%;
    height: 40px;
    padding: 0 .75rem;
    font-size: .95rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    transition: all .3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.inv-customer-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    background: #fff;
}

.inv-customer-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    max-height: 320px;
    overflow-y: auto;
    animation: fadeSlideDown 0.2s ease-out;
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inv-customer-dropdown.open {
    display: block;
}

.inv-cust-opt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: all .2s;
}

.inv-cust-opt:last-child {
    border-bottom: none;
}

.inv-cust-opt:hover {
    background: #f8fafc;
    padding-right: 1.2rem;
}

.inv-cust-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.inv-cust-bal {
    font-size: .9rem;
    font-weight: 800;
}

/* ── Secondary Fields Row ── */
.inv-fields-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    position: relative;
    z-index: 40;
}

.inv-field-wide {
    grid-column: span 2;
}

.inv-fields-row .form-control {
    background: var(--surface);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    height: 36px;
    padding: 0 .6rem;
    font-weight: 600;
    font-size: .85rem;
}

.inv-fields-row .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.inv-items-card {
    border: none;
    border-radius: var(--radius-lg);
    overflow: visible;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 30;
}

.inv-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1.25rem;
    font-weight: 800;
    font-size: .95rem;
    background: linear-gradient(90deg, #f8fafc, #ffffff);
    border-bottom: 1px solid #e2e8f0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: var(--text);
}

.inv-line-count {
    background: var(--primary-soft);
    color: var(--primary);
    padding: .2rem .8rem;
    border-radius: 20px;
    font-size: .85rem;
}

/* Add Item Bar */
.inv-add-bar {
    padding: .75rem 1.25rem;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    gap: .75rem;
    align-items: stretch;
    flex-wrap: wrap;
    position: relative;
    z-index: 200;
}

.item-search-wrap {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.item-search-input {
    height: 38px;
    font-size: .9rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
}

.item-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.inv-add-bar select.form-control {
    height: 38px;
    border-radius: 8px;
    font-weight: 600;
    font-size: .85rem;
    border: 1px solid var(--border);
}

.inv-qty-big {
    height: 38px;
    font-size: 1rem !important;
    font-weight: 800;
    text-align: center;
    border-radius: 8px;
    border: 1px solid var(--border) !important;
}

.inv-add-bar .btn-success {
    height: 38px;
    padding: 0 1.25rem;
    font-size: .9rem;
    font-weight: 800;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.inv-add-bar .btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(16, 185, 129, 0.4);
}

.item-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    z-index: 300;
    max-height: 350px;
    overflow-y: auto;
    animation: fadeSlideDown 0.2s ease;
}

.item-dropdown.open {
    display: block;
}

.item-opt.is-active {
    background: #eaf2ff;
}

.ns-lookup-source {
    display: none !important;
}

.ns-lookup-wrap {
    min-width: 180px;
    position: relative;
}

.ns-lookup-wrap .item-search-input {
    font-weight: 700;
}

.ns-lookup-wrap.is-disabled .item-search-input {
    background: #f8fafc;
    color: var(--text-muted);
    cursor: not-allowed;
}

.ns-lookup-empty {
    padding: .7rem .85rem;
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 600;
}

.item-opt {
    padding: .8rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    transition: background .15s;
}

.item-opt:hover {
    background: #f0f6ff;
}

.item-opt-name {
    font-weight: 700;
    font-size: .95rem;
}

.item-opt-code {
    color: var(--text-muted);
    font-size: .8rem;
    margin-right: .5rem;
}

.item-opt-stock {
    font-size: .8rem;
    padding: .2rem .6rem;
    border-radius: 12px;
    font-weight: 700;
}

.stock-ok {
    background: #DCFCE7;
    color: #166534;
}

.stock-low {
    background: #FEF3C7;
    color: #92400E;
}

.stock-out {
    background: #FEE2E2;
    color: #991B1B;
}

.inv-stock-warn {
    padding: .75rem 1.5rem;
    font-weight: 700;
    font-size: .95rem;
    background: #FEF3C7;
    color: #92400E;
    border-bottom: 1px solid #fcd34d;
}

/* Lines Table inside Card */
.lines-table {
    width: 100%;
    border-collapse: collapse;
}

.lines-table th {
    background: #f8fafc;
    padding: .6rem .8rem;
    text-align: right;
    font-weight: 800;
    font-size: .75rem;
    color: #475569;
    border-bottom: 2px solid #cbd5e1;
    text-transform: uppercase;
}

.lines-table td {
    padding: .4rem .8rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.lines-table tr.line-row {
    transition: background .2s, transform .2s;
}

.lines-table tr.line-row:hover {
    background: #f8fbff;
}

.lines-table .form-control {
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
    transition: all .2s;
    text-align: center;
}

.lines-table .form-control:focus,
.lines-table .form-control:hover {
    border-color: var(--border-dark);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.inv-item-name {
    font-weight: 800;
    font-size: .95rem;
    color: var(--text);
}

.inv-empty-msg {
    padding: 4rem 2rem;
    text-align: center;
    color: #94a3b8;
    font-size: 1.1rem;
    font-weight: 600;
    background: #fafafa;
}

/* ── Floating Save Tray ── */
.inv-save-bar {
    position: fixed;
    bottom: 15px;
    left: 20px;
    right: 280px;
    /* leaves room for sidebar */
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: .5rem 1.25rem;
    box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(37, 99, 235, 0.1);
    transition: right .4s cubic-bezier(0.16, 1, 0.3, 1);
}

body.sidebar-collapsed .inv-save-bar {
    right: 100px;
}

.inv-totals-strip {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.inv-payment-strip {
    display: flex;
    gap: .75rem;
    align-items: center;
    background: rgba(16, 185, 129, 0.05);
    padding: .3rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.inv-t {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.inv-t-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.inv-t-val {
    font-weight: 800;
    font-size: .95rem;
    color: var(--text);
}

.inv-t-val-net {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--primary);
}

.inv-t-net {
    background: var(--primary-soft);
    padding: .5rem 1.25rem;
    border-radius: 12px;
}

.inv-t-sep,
.inv-t-sep-big {
    display: none;
}

/* Replaced by gap and styling */

.inv-t-input {
    width: 100px;
    height: 36px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    border: 2px solid var(--border);
    margin-top: .2rem;
}

.inv-paid-input {
    width: 90px;
    height: 32px;
    font-size: 1rem;
    font-weight: 800;
    color: var(--success);
    border: 2px solid var(--success) !important;
    border-radius: 8px;
    background: #fff;
    padding: 0 .4rem;
}

.inv-save-btns {
    display: flex;
    gap: .5rem;
}

.inv-save-btn {
    min-width: 120px;
    height: 38px;
    font-size: .95rem;
    font-weight: 800;
    border-radius: 10px;
    box-shadow: var(--shadow-blue);
    transition: transform .2s, box-shadow .2s;
}

.inv-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(37, 99, 235, 0.4);
}

/* Error Bar Overlay */
.inv-error-bar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(254, 226, 226, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #FCA5A5;
    color: #991B1B;
    padding: 1rem 2rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 10px 25px rgba(220, 38, 38, 0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: fadeSlideDown .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.inv-error-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
}

.inv-keyboard-hint {
    display: none;
}

/* Clean up UI */

@media (max-width: 1024px) {
    .inv-save-bar {
        left: 20px;
        right: 20px !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
        position: sticky;
        bottom: 0;
        border-radius: 0;
        padding: 1rem;
    }

    #invoiceForm {
        padding-bottom: 20px;
    }
}

/* ── Premium Auth Styles (Light Aurora) ────────── */
.auth-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    overflow: hidden;
    font-family: 'Cairo', sans-serif;
}

.auth-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

/* Aurora background layers */
.auth-bg-layers {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.auth-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.7;
    animation: auroraMove 25s infinite alternate ease-in-out;
}

.auth-blob-1 {
    width: 700px;
    height: 700px;
    background: #dcfce7;
    /* Mint */
    top: -150px;
    right: -100px;
}

.auth-blob-2 {
    width: 600px;
    height: 600px;
    background: #e0f2fe;
    /* Sky Blue */
    bottom: -200px;
    left: -100px;
    animation-delay: -7s;
}

.auth-blob-3 {
    width: 500px;
    height: 500px;
    background: #f5f3ff;
    /* Lavender */
    top: 50%;
    left: 40%;
    transform: translate(-50%, -50%);
    animation-delay: -12s;
}

@keyframes auroraMove {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    33% {
        transform: translate(50px, -30px) scale(1.1) rotate(5deg);
    }

    66% {
        transform: translate(-30px, 40px) scale(0.9) rotate(-5deg);
    }

    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
}

.auth-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 460px;
    padding: 2rem;
}

/* Light Glassmorphism Card */
.auth-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 32px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 20px 40px -4px rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    overflow: hidden;
    animation: cardFadeUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardFadeUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-card-inner {
    padding: 3.5rem 2.75rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo-wrapper {
    position: relative;
    width: 84px;
    height: 84px;
    margin: 0 auto 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-ring {
    position: absolute;
    inset: -6px;
    border: 2px dashed #3b82f6;
    border-radius: 24px;
    animation: spin 15s linear infinite;
    opacity: 0.3;
}

.logo-mark {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
    font-size: 1.85rem;
    font-weight: 800;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.25);
}

.auth-header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: #0f172a;
    margin-bottom: 0.4rem;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: #64748b;
    font-size: 1rem;
    font-weight: 500;
}

/* Light Mode Form Elements */
.form-group-custom {
    margin-bottom: 1.75rem;
}

.form-label-custom {
    display: block;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.7rem;
    margin-right: 0.5rem;
}

.input-with-icon {
    position: relative;
}

.field-icon {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: #94a3b8;
    transition: all 0.3s;
}

.form-control-custom {
    width: 100%;
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid #e2e8f0;
    border-radius: 18px;
    padding: 1rem 3rem 1rem 1.2rem;
    color: #0f172a;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control-custom:focus {
    outline: none;
    background: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-control-custom:focus+.field-icon {
    color: #3b82f6;
    transform: translateY(-50%) scale(1.1);
}

.form-control-custom::placeholder {
    color: #94a3b8;
}

/* Premium Button Light */
.btn-premium {
    width: 100%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    border-radius: 18px;
    padding: 1.2rem;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 12px 28px -6px rgba(37, 99, 235, 0.35);
}

.btn-premium:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px -8px rgba(37, 99, 235, 0.45);
    filter: brightness(1.05);
}

.btn-premium:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-arrow {
    transition: transform 0.3s ease;
}

.btn-premium:hover .btn-arrow {
    transform: translateX(-6px);
}

.auth-footer {
    margin-top: 3rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Light Glass Error */
.glass-error {
    background: rgba(254, 226, 226, 0.8);
    border: 1px solid #fecaca;
    border-radius: 16px;
    color: #b91c1c;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 600;
    margin-bottom: 2rem;
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

@media (max-width: 480px) {
    .auth-card-inner {
        padding: 3rem 1.75rem;
    }

    .auth-header h1 {
        font-size: 2.1rem;
    }
}

@media (max-width: 767px) {
    .reports-hub-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Dashboard (Home) ────────────────────────── */
.dashboard-shell {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.dash-hero {
    padding: 1.25rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background:
        radial-gradient(circle at 5% 5%, #eff6ff 0%, rgba(239, 246, 255, 0) 55%),
        radial-gradient(circle at 95% 95%, #ecfdf5 0%, rgba(236, 253, 245, 0) 55%),
        var(--surface);
    box-shadow: var(--shadow);
}

.dash-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.dash-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text);
}

.dash-subtitle {
    margin: .35rem 0 0;
    color: var(--text-muted);
    font-size: .88rem;
}

.dash-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.dash-badge {
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: .38rem .75rem;
    background: #fff;
    color: var(--text-muted);
    font-size: .77rem;
    font-weight: 700;
}

.dash-badge.is-success {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.dash-badge.is-danger {
    border-color: #fca5a5;
    background: #fef2f2;
    color: #b91c1c;
}

.dash-range-form {
    border: 1px dashed var(--border-dark);
    border-radius: 14px;
    padding: .85rem;
    background: rgba(255, 255, 255, .72);
}

.dash-range-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .65rem;
    align-items: end;
}

.dash-range-actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
}

.dash-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: .85rem;
}

.dash-quick-btn {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .5rem .85rem;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    font-size: .82rem;
    transition: all .2s ease;
}

.dash-quick-btn:hover {
    border-color: #bfdbfe;
    background: var(--primary-soft);
    color: var(--primary-dark);
    transform: translateY(-2px);
}

.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .9rem;
}

.dash-kpi-card {
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: .9rem 1rem;
    background: #fff;
    box-shadow: var(--shadow-sm);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    transition: transform .2s ease, box-shadow .2s ease;
}

.dash-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.dash-kpi-card.is-primary {
    border-color: #bfdbfe;
    background: linear-gradient(150deg, #ffffff 0%, #eff6ff 100%);
}

.dash-kpi-card.is-success {
    border-color: #bbf7d0;
    background: linear-gradient(150deg, #ffffff 0%, #ecfdf5 100%);
}

.dash-kpi-card.is-warning {
    border-color: #fde68a;
    background: linear-gradient(150deg, #ffffff 0%, #fffbeb 100%);
}

.dash-kpi-card.is-danger {
    border-color: #fca5a5;
    background: linear-gradient(150deg, #ffffff 0%, #fef2f2 100%);
}

.dash-kpi-card.is-neutral {
    border-color: #dbe4ef;
    background: linear-gradient(150deg, #ffffff 0%, #f8fafc 100%);
}

.dash-kpi-label {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
}

.dash-kpi-value {
    color: var(--text);
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.dash-kpi-sub {
    color: var(--text-muted);
    font-size: .76rem;
    margin-top: auto;
}

.dash-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.dash-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: .9rem;
}

.dash-empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
}

.dash-trend-chart {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
    gap: .35rem;
    align-items: end;
    height: 220px;
    padding: .9rem .9rem .25rem;
}

.dash-trend-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    min-width: 0;
}

.dash-trend-bars {
    width: 100%;
    height: 178px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.dash-bar {
    width: 45%;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: opacity .2s ease;
}

.dash-bar-sales {
    background: #2563eb;
}

.dash-bar-purchases {
    background: #f59e0b;
}

.dash-trend-col:hover .dash-bar {
    opacity: .8;
}

.dash-trend-day {
    color: var(--text-muted);
    font-size: .64rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dash-legend {
    display: flex;
    gap: 1rem;
    padding: 0 .9rem .9rem;
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 700;
}

.dash-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: .35rem;
}

.dash-dot.sales {
    background: #2563eb;
}

.dash-dot.purchases {
    background: #f59e0b;
}

.dash-cash-grid {
    padding: .8rem .9rem .25rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .55rem;
}

.dash-cash-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: .55rem .65rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.dash-cash-item span {
    color: var(--text-muted);
    font-size: .74rem;
    font-weight: 700;
}

.dash-cash-item strong {
    font-size: .94rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.dash-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: .2rem .55rem;
    font-size: .7rem;
    font-weight: 800;
    border: 1px solid var(--border);
    background: #fff;
}

.dash-pill.is-warning {
    color: #92400e;
    border-color: #fde68a;
    background: #fffbeb;
}

.dash-pill.is-success {
    color: #166534;
    border-color: #86efac;
    background: #f0fdf4;
}

.dash-pill.is-primary {
    color: #1d4ed8;
    border-color: #93c5fd;
    background: #eff6ff;
}

.dash-pill.is-info {
    color: #155e75;
    border-color: #99f6e4;
    background: #ecfeff;
}

.dash-open-link {
    color: var(--primary);
    font-weight: 700;
    font-size: .78rem;
}

.dash-branch-warning {
    border-radius: 16px;
    border: 1px solid #fcd34d;
    background: linear-gradient(165deg, #fff 0%, #fffbeb 100%);
    padding: 1.2rem;
}

.dash-branch-warning-title {
    color: #92400e;
    font-size: 1.05rem;
    font-weight: 900;
    margin-bottom: .45rem;
}

.dash-branch-warning-text {
    color: #78350f;
    font-size: .9rem;
}

.dash-branch-warning-actions {
    margin-top: .95rem;
}

@media (max-width: 1200px) {
    .dash-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dash-title {
        font-size: 1.15rem;
    }

    .dash-hero {
        padding: .95rem;
    }

    .dash-range-grid {
        grid-template-columns: 1fr;
    }

    .dash-range-actions {
        justify-content: stretch;
    }

    .dash-range-actions .btn {
        width: 100%;
    }

    .dash-kpi-grid {
        grid-template-columns: 1fr;
    }

    .dash-trend-chart {
        overflow-x: auto;
        grid-template-columns: repeat(16, minmax(22px, 22px));
    }

    .dash-legend {
        flex-wrap: wrap;
    }

    .dash-cash-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================================
   MOBILE RESPONSIVE ADDITIONS
   ======================================================== */

/* ── Filter Row Helper Classes (replace inline styles) ── */
.filter-date-input { width: 160px; }
.filter-select-md  { min-width: 180px; }

/* ── Invoice Lines Table Column Classes (replace inline styles) ── */
.lines-table .col-item     { min-width: 180px; }
.lines-table .col-unit     { width: 80px; }
.lines-table .col-qty      { width: 70px; }
.lines-table .col-stock    { width: 95px; }
.lines-table .col-price    { width: 90px; }
.lines-table .col-buy      { width: 85px; }
.lines-table .col-discount { width: 75px; }
.lines-table .col-bonus    { width: 55px; }
.lines-table .col-total    { width: 90px; text-align: left; }
.lines-table .col-del      { width: 32px; }

/* Purchase form specific columns */
.lines-table .col-unit-p   { width: 95px; }
.lines-table .col-qty-p    { width: 80px; }
.lines-table .col-stock-p  { width: 115px; }
.lines-table .col-buy-p    { width: 105px; }
.lines-table .col-total-p  { width: 95px; text-align: left; }

/* ── FinancialCenter Grid Classes (replace inline styles) ── */
.fc-kpi-grid     { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.fc-kpi-item     { text-align: center; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; }
.fc-summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; padding: 1rem; border-radius: 6px; }
.fc-bottom-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── 768px: Tablet & Small Desktop ────────────────────── */
@media (max-width: 768px) {

    /* Step 1: Filter rows stack vertically */
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-row > * {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Step 2: Invoice line table — reduce column widths */
    .lines-table .col-item     { min-width: 120px; }
    .lines-table .col-unit     { width: 60px; }
    .lines-table .col-qty      { width: 55px; }
    .lines-table .col-stock    { width: 70px; }
    .lines-table .col-price    { width: 70px; }
    .lines-table .col-buy      { width: 65px; }
    .lines-table .col-discount { width: 60px; }
    .lines-table .col-bonus    { width: 45px; }
    .lines-table .col-total    { width: 70px; }
    .lines-table .col-del      { width: 28px; }

    .lines-table .col-unit-p   { width: 70px; }
    .lines-table .col-qty-p    { width: 60px; }
    .lines-table .col-stock-p  { width: 85px; }
    .lines-table .col-buy-p    { width: 80px; }
    .lines-table .col-total-p  { width: 70px; }

    .table-card table,
    .lines-table {
        min-width: 480px;
    }

    /* Step 3: Invoice add bar + fields row */
    .inv-add-bar {
        flex-direction: column;
    }
    .inv-add-bar > * {
        width: 100% !important;
        min-width: 0 !important;
    }
    .inv-fields-row {
        grid-template-columns: 1fr 1fr;
    }
    .inv-hero-row {
        flex-direction: column;
        gap: .75rem;
    }

    /* Step 4: Save bar */
    .inv-save-bar {
        right: 10px !important;
        left: 10px;
        flex-direction: column;
        gap: .75rem;
        padding: .75rem;
    }
    .inv-totals-strip {
        flex-wrap: wrap;
        gap: .75rem;
        justify-content: center;
    }
    .inv-payment-strip {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    .inv-save-btns {
        width: 100%;
        justify-content: center;
    }

    /* Step 5: Report pages */
    .statement-filter-bar,
    .cs-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .statement-filter-field,
    .cs-filter-field {
        width: 100%;
    }
    .statement-filter-field .form-control,
    .statement-filter-field .form-select,
    .cs-filter-field .form-control {
        min-width: 0;
        width: 100%;
    }
    .statement-filter-bar .btn,
    .cs-filter-bar .btn {
        width: 100%;
    }
    .inv-kpi-bar {
        flex-direction: column;
    }
    .inv-kpi {
        flex: none;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }
    .inv-kpi:last-child {
        border-bottom: none;
    }
    .reports-hub-grid {
        grid-template-columns: 1fr;
    }

    /* Step 6: FinancialCenter grids */
    .fc-summary-grid {
        grid-template-columns: 1fr;
    }
    .fc-bottom-grid {
        grid-template-columns: 1fr;
    }
    .fc-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    /* Step 7: Dashboard gaps */
    .dash-quick-actions {
        flex-wrap: wrap;
    }
    .dash-quick-btn {
        flex: 1 1 calc(50% - .5rem);
        min-width: 0;
        text-align: center;
        font-size: .8rem;
        padding: .5rem .4rem;
    }
    .dash-hero-head {
        flex-direction: column;
    }
    .dash-badges {
        width: 100%;
    }

    /* Step 8: General polish */
    .item-search-wrap {
        min-width: 0;
        width: 100%;
    }
    .table-card thead th {
        padding: .6rem .75rem;
        font-size: .72rem;
    }
    .table-card tbody td {
        padding: .6rem .75rem;
        font-size: .82rem;
    }
}

/* ── 480px: Mobile Phones ─────────────────────────────── */
@media (max-width: 480px) {

    .table-card table,
    .lines-table {
        min-width: 400px;
    }

    .inv-fields-row {
        grid-template-columns: 1fr;
    }

    .fc-kpi-grid {
        grid-template-columns: 1fr;
    }

    .dash-quick-btn {
        flex: 1 1 100%;
    }

    .dash-kpi-value {
        font-size: .95rem;
    }

    .dash-kpi-sub {
        font-size: .72rem;
    }

    .dash-badge {
        font-size: .7rem;
        padding: .3rem .6rem;
    }

    .inv-kpi-label {
        font-size: .62rem;
    }
    .inv-kpi-value {
        font-size: .9rem;
    }
}

