/* C-N Double Links Invoice System - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #1a478a;
    --primary-dark: #0f2d5e;
    --primary-light: #2a5fa8;
    --accent: #10b981;
    --accent-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f0f2f5;
    --card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    height: 100vh;
    max-height: 100vh;
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-logo h1 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.sidebar-logo span {
    font-size: 12px;
    color: #94a3b8;
    display: block;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,0.45) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.35);
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(148,163,184,0.6);
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-item .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item-text {
    flex: 1;
    min-width: 0;
}

.nav-group {
    margin-bottom: 2px;
}

.nav-group-parent {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-group-parent .nav-item {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.nav-group.has-active:not(.open) .nav-group-parent .nav-item {
    background: rgba(26, 71, 138, 0.55);
    color: #fff;
}

.nav-group-toggle {
    width: 32px;
    height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.nav-group-toggle:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-group-toggle .chevron {
    display: block;
    font-size: 12px;
    line-height: 1;
    transition: transform 0.18s ease;
}

.nav-group.open .nav-group-toggle .chevron {
    transform: rotate(90deg);
}

.nav-submenu {
    display: none;
    margin: 5px 0 8px 34px;
    padding-left: 10px;
    border-left: 1px solid rgba(148,163,184,0.25);
}

.nav-group.open .nav-submenu {
    display: block;
}

.nav-subitem {
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
    margin-bottom: 3px;
}

.nav-subitem .icon {
    font-size: 15px;
    width: 20px;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-user .info {
    flex: 1;
}

.sidebar-user .info .name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.sidebar-user .info .role {
    color: #64748b;
    font-size: 11px;
}

.sidebar-user .logout-btn {
    color: #64748b;
    text-decoration: none;
    font-size: 18px;
    transition: var(--transition);
}

.sidebar-user .logout-btn:hover { color: var(--danger); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
}

.page-header {
    background: var(--card);
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.page-header .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.page-body {
    padding: 24px 32px;
}

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

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

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue { background: rgba(26,71,138,0.1); color: var(--primary); }
.stat-icon.green { background: rgba(16,185,129,0.1); color: var(--accent); }
.stat-icon.orange { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }

.stat-info .label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-info .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--accent);
    color: #fff;
}
.btn-success:hover { background: var(--accent-dark); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); border-color: var(--text-secondary); }

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    background: #f8fafc;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-voided { background: #fee2e2; color: #991b1b; }
.badge-credit { background: #fef3c7; color: #92400e; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-partial { background: #fef3c7; color: #92400e; }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,71,138,0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.password-admin-layout {
    display: grid;
    grid-template-columns: minmax(320px, 520px) 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1100px) {
    .password-admin-layout {
        grid-template-columns: 1fr;
    }
}

/* ===== INVOICE FORM SPECIFIC ===== */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.invoice-items-table thead th {
    padding: 10px 12px;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.invoice-items-table thead th:first-child { text-align: left; border-radius: 8px 0 0 0; }
.invoice-items-table thead th:last-child { border-radius: 0 8px 0 0; }

.invoice-items-table tbody td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.invoice-items-table .form-control {
    padding: 8px 10px;
    font-size: 13px;
}

.invoice-items-table .remove-row {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 20px;
    border-radius: 50%;
    transition: var(--transition);
}

.invoice-items-table .remove-row:hover {
    background: #fee2e2;
}

.totals-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.totals-box {
    min-width: 300px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.totals-row.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding: 12px 0;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #2a5fa8 100%);
}

.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 48px 40px;
    width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    color: var(--primary);
}

.login-card .company-chinese {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-card .form-control {
    padding: 14px 16px;
    font-size: 15px;
}

.login-card .btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    justify-content: center;
}

.captcha-row {
    display: grid;
    grid-template-columns: 1fr 178px;
    gap: 10px;
    align-items: stretch;
}

.captcha-question {
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    border-radius: var(--radius-sm);
    background: #f8fbff;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 600;
}

.captcha-image-btn {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #eef4ff;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    height: 56px;
}

.captcha-image-btn img {
    display: block;
    width: 100%;
    height: 100%;
}

.captcha-tip {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.login-security-note {
    margin: 10px 0 14px;
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 12px;
    line-height: 1.6;
}

.anna-unlock-panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.anna-unlock-panel h3 {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 16px;
}

.anna-unlock-panel p {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.anna-unlock-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
}

.login-card .anna-unlock-actions .btn {
    width: auto;
    min-width: 88px;
    padding: 12px 14px;
    font-size: 14px;
}

.anna-unlock-msg {
    min-height: 20px;
    margin-top: 10px;
    font-size: 13px;
}

/* ===== FLASH MESSAGES ===== */
.flash-messages {
    padding: 0 32px;
    margin-top: 16px;
}

.alert {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ===== FINANCE CUSTOMER DETAIL WORKBENCH ===== */
.finance-customer-header {
    gap: 16px;
}

.finance-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.finance-customer-workbench {
    padding-top: 16px;
}

.finance-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.finance-kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    min-height: 78px;
    box-shadow: var(--shadow);
}

.finance-kpi .kpi-label,
.finance-kpi .kpi-sub {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.35;
}

.finance-kpi .kpi-value {
    display: block;
    margin: 2px 0;
    font-size: 20px;
    line-height: 1.15;
    letter-spacing: 0;
}

.text-green { color: #16a34a !important; }
.text-red { color: #ef4444 !important; }

.finance-currency-strip {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.finance-currency-strip table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.finance-currency-strip th,
.finance-currency-strip td {
    padding: 6px 10px;
    border-right: 1px solid #e5edf7;
    border-bottom: 1px solid #e5edf7;
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
}

.finance-currency-strip th:first-child,
.finance-currency-strip td:first-child {
    text-align: left;
}

.finance-currency-strip th {
    background: #edf2f7;
    color: #334155;
    font-weight: 700;
}

.finance-filter-panel {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.finance-quick-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.finance-filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid #dbe4ef;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

.finance-filter-chip:hover,
.finance-filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.finance-filter-form {
    display: grid;
    grid-template-columns: repeat(7, minmax(104px, 1fr)) minmax(220px, 1.8fr) auto;
    gap: 8px;
    align-items: end;
}

.filter-field label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.filter-field select,
.filter-field input {
    width: 100%;
    height: 32px;
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font-size: 12px;
}

.filter-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.finance-sheet-shell {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: auto;
    max-height: calc(100vh - 360px);
    min-height: 320px;
    box-shadow: var(--shadow);
}

.finance-sheet-table {
    width: 100%;
    min-width: 1860px;
    border-collapse: collapse;
    table-layout: fixed;
}

.finance-sheet-table th,
.finance-sheet-table td {
    height: 30px;
    padding: 4px 7px;
    border-right: 1px solid #dfe7f1;
    border-bottom: 1px solid #dfe7f1;
    font-size: 12px;
    line-height: 1.25;
    color: #243145;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.finance-sheet-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 32px;
    background: #eaf0f7;
    color: #1f2937;
    font-weight: 700;
    text-align: left;
}

.finance-sheet-table tbody tr:nth-child(even) td {
    background: #fbfdff;
}

.finance-sheet-table tbody tr:hover td {
    background: #eaf4ff;
}

.finance-sheet-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #ffffff;
    box-shadow: 1px 0 0 #dfe7f1;
}

.finance-sheet-table th.sticky-col {
    z-index: 4;
    background: #eaf0f7;
}

.finance-sheet-table .col-type { width: 68px; }
.finance-sheet-table .col-fee-name { width: 190px; }
.finance-sheet-table .col-party { width: 220px; }
.finance-sheet-table .col-note { width: 190px; }
.finance-sheet-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.finance-sheet-table .strong {
    font-weight: 700;
}

.direction-badge,
.settle-badge,
.badge-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

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

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

.settle-badge.unsettled {
    background: #fff7ed;
    color: #c2410c;
}

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

.settle-badge.settled {
    background: #dbeafe;
    color: #1d4ed8;
}

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

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

.badge-status.badge-paid {
    background: #dbeafe;
    color: #1d4ed8;
}

.sheet-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.sheet-link:hover {
    text-decoration: underline;
}

.actions-cell {
    text-align: center;
}

.actions-cell .btn {
    min-width: 52px;
    padding: 4px 8px;
    font-size: 11px;
}

.compact-empty {
    padding: 34px 16px;
}

.modal-box {
    width: 440px;
    max-width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 12px;
    padding: 22px;
    box-shadow: var(--shadow-lg);
}

.modal-box h3 {
    margin-bottom: 14px;
    font-size: 18px;
}

.settle-brief {
    display: grid;
    gap: 4px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f1f5f9;
    font-size: 13px;
}

.settle-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.settle-attach-btn {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 14px;
    color: #64748b;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.settle-attach-btn div {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 11px;
}

.settle-attach-btn:hover,
.settle-attach-btn.dragging {
    border-color: var(--primary);
    background: #eff6ff;
}

.settle-attach-preview {
    display: none;
    position: relative;
    margin-top: 8px;
}

.settle-attach-preview img {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.settle-attach-preview button {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: #ef4444;
    color: #ffffff;
    cursor: pointer;
    line-height: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

@media (max-width: 1280px) {
    .finance-kpi-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .finance-filter-form {
        grid-template-columns: repeat(4, minmax(110px, 1fr));
    }

    .filter-actions {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .finance-header-actions {
        width: 100%;
    }

    .finance-kpi-grid,
    .finance-filter-form {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        grid-column: auto;
    }
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--card);
    border-radius: var(--radius);
    width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .main-content { margin-left: 0; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ===== EXPENSE BATCH IMPORT ===== */
.expense-import-header {
    gap: 20px;
}

.expense-import-page {
    padding-bottom: 110px;
}

.expense-upload-card {
    margin-bottom: 22px;
}

.expense-upload-toolbar,
.expense-review-heading,
.expense-save-bar,
.expense-import-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.expense-upload-toolbar h3,
.expense-review-heading h3 {
    margin: 0 0 5px;
    font-size: 17px;
}

.expense-upload-toolbar p,
.expense-review-heading p,
.expense-save-bar span {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.expense-upload-actions,
.expense-save-actions,
.expense-card-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.expense-drop-zone {
    margin-top: 18px;
    min-height: 205px;
    border: 2px dashed #9db5d7;
    border-radius: 15px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef5ff 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #183b6b;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.expense-drop-zone:hover,
.expense-drop-zone:focus,
.expense-drop-zone.dragging {
    outline: none;
    border-color: #2563a8;
    background: #e6f0ff;
}

.expense-drop-zone.dragging {
    transform: scale(1.006);
}

.expense-drop-zone strong {
    font-size: 17px;
}

.expense-drop-zone span {
    font-size: 13px;
    color: #607795;
}

.expense-drop-icon {
    font-size: 40px;
    line-height: 1;
}

.expense-progress-panel {
    margin-top: 16px;
    padding: 13px 15px;
    border-radius: 10px;
    background: #f1f5f9;
}

.expense-progress-copy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #334155;
    font-size: 13px;
}

.expense-progress-track {
    height: 8px;
    border-radius: 999px;
    background: #dbe4ef;
    overflow: hidden;
}

.expense-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #1e4f91, #3b82f6);
    transition: width .25s ease;
}

.expense-review-section {
    margin-top: 6px;
}

.expense-review-summary {
    padding: 7px 12px;
    border-radius: 999px;
    background: #e8eef7;
    color: #37506f;
    font-size: 12px;
    font-weight: 700;
}

.expense-import-items {
    display: grid;
    gap: 16px;
    margin-top: 14px;
}

.expense-import-card {
    border: 1px solid #dce5f0;
    border-radius: 13px;
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(26, 59, 99, .06);
    overflow: hidden;
}

.expense-import-card.has-error {
    border-color: #f4b7b7;
}

.expense-import-card-head {
    padding: 14px 17px;
    border-bottom: 1px solid #e5ebf3;
    background: #f8fafc;
}

.expense-import-card-head > div:first-child,
.expense-file-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.expense-file-title label,
.expense-import-card-head strong {
    min-width: 0;
    max-width: 630px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
    font-size: 14px;
    font-weight: 700;
}

.expense-status,
.expense-method,
.expense-confidence,
.expense-match-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
}

.expense-status {
    padding: 4px 9px;
}

.expense-status.processing { color: #1d4ed8; background: #dbeafe; }
.expense-status.review { color: #047857; background: #d1fae5; }
.expense-status.failed { color: #b91c1c; background: #fee2e2; }
.expense-status.saved { color: #475569; background: #e2e8f0; }

.expense-method {
    padding: 4px 8px;
    color: #64748b;
    background: #eef2f7;
}

.expense-processing-copy {
    padding: 28px 18px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}

.expense-card-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #bfdbfe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: expense-spin .8s linear infinite;
}

@keyframes expense-spin {
    to { transform: rotate(360deg); }
}

.expense-review-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 16px;
    padding: 17px;
}

.expense-review-grid .form-group {
    margin: 0;
}

.expense-review-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.expense-confidence {
    padding: 2px 6px;
}

.expense-confidence.high { color: #047857; background: #d1fae5; }
.expense-confidence.medium { color: #a16207; background: #fef3c7; }
.expense-confidence.low { color: #b91c1c; background: #fee2e2; }

.expense-match-badge {
    padding: 2px 7px;
}

.expense-match-badge.matched { color: #047857; background: #d1fae5; }
.expense-match-badge.new { color: #a16207; background: #fef3c7; }

.expense-customer-field {
    grid-column: span 2;
}

.expense-description-field {
    grid-column: span 2;
}

.expense-new-customer {
    margin-top: 7px;
    color: #9a6700;
    font-weight: 600 !important;
    font-size: 12px;
}

.expense-new-customer input,
.expense-file-title input,
.expense-item-duplicate input {
    accent-color: #22589d;
}

.expense-item-warning,
.expense-item-error,
.expense-item-duplicate,
.expense-commit-error {
    margin: 13px 17px 0;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.55;
}

.expense-item-warning {
    color: #8a5a00;
    background: #fff7dc;
    border: 1px solid #f7d884;
}

.expense-item-error,
.expense-commit-error {
    color: #a51d1d;
    background: #fff0f0;
    border: 1px solid #f4b7b7;
}

.expense-item-duplicate {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: #9f1239;
    background: #fff1f2;
    border: 1px solid #fecdd3;
}

.expense-item-duplicate label {
    margin-left: auto;
    font-weight: 700;
}

.money-check {
    display: block;
    margin-top: 5px;
    font-size: 11px;
}

.money-check.ok { color: #047857; }
.money-check.bad { color: #b91c1c; }

.expense-save-bar {
    position: fixed;
    right: 24px;
    bottom: 18px;
    left: 284px;
    z-index: 90;
    padding: 14px 18px;
    border: 1px solid rgba(139, 163, 193, .7);
    border-radius: 13px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 15px 38px rgba(15, 35, 61, .18);
    backdrop-filter: blur(8px);
}

.expense-save-bar > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

@media (max-width: 1100px) {
    .expense-review-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .expense-customer-field,
    .expense-description-field {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .expense-upload-toolbar,
    .expense-review-heading,
    .expense-import-card-head,
    .expense-save-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .expense-review-grid {
        grid-template-columns: 1fr;
    }

    .expense-customer-field,
    .expense-description-field {
        grid-column: auto;
    }

    .expense-save-bar {
        left: 12px;
        right: 12px;
        bottom: 10px;
    }

    .expense-card-actions {
        justify-content: flex-start;
    }
}
