/* ========================================
   Design System — Notion / Mercury / Stripe
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300..700&display=swap');

:root {
    /* Brand */
    --primary: #5B5BD6;
    --primary-hover: #4C4CC4;
    --primary-subtle: #F0F0FF;
    --primary-ghost: rgba(91, 91, 214, 0.06);

    /* Semantic */
    --success: #10B981;
    --success-hover: #059669;
    --success-subtle: #ECFDF5;
    --warning: #F59E0B;
    --warning-subtle: #FFFBEB;
    --danger: #EF4444;
    --danger-subtle: #FEF2F2;
    --danger-hover: #DC2626;

    /* Neutrals */
    --gray-50:  #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Surfaces */
    --bg-base: #F9FAFB;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --border-default: #E5E7EB;
    --border-subtle: #F0F0F0;

    /* Shadows — minimal, border-driven */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-card: none;
    --shadow-card-hover: none;

    /* Theme-aware */
    --modal-backdrop: rgba(0, 0, 0, 0.4);
    --primary-shadow: rgba(91, 91, 214, 0.15);
    --primary-shadow-hover: rgba(91, 91, 214, 0.25);
    --danger-shadow: rgba(239, 68, 68, 0.15);
    --danger-shadow-hover: rgba(239, 68, 68, 0.25);
    --success-shadow: rgba(16, 185, 129, 0.15);
    --success-shadow-hover: rgba(16, 185, 129, 0.25);
    --primary-ring: rgba(91, 91, 214, 0.12);
    --pink-subtle: #FDF2F8;
    --purple-subtle: #F5F3FF;

    /* Badge / status text colors */
    --success-text: #065F46;
    --warning-text: #92400E;
    --danger-text: #991B1B;
    --info-text: #2563EB;
    --purple-text: #7C3AED;
    --pink-text: #9D174D;
    --indigo-text: #3730A3;
    --deep-purple-text: #5B21B6;
    --amber-text: #D97706;

    /* Radii — tighter, Stripe-like */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;
}

/* ========================================
   Dark Theme
   ======================================== */

[data-theme="dark"] {
    /* Brand */
    --primary: #8B8BF0;
    --primary-hover: #7A7AE0;
    --primary-subtle: rgba(91, 91, 214, 0.15);
    --primary-ghost: rgba(91, 91, 214, 0.10);

    /* Semantic */
    --success: #34D399;
    --success-hover: #10B981;
    --success-subtle: rgba(16, 185, 129, 0.15);
    --warning: #FBBF24;
    --warning-subtle: rgba(245, 158, 11, 0.15);
    --danger: #F87171;
    --danger-subtle: rgba(239, 68, 68, 0.15);
    --danger-hover: #EF4444;

    /* Neutrals — inverted gray scale */
    --gray-50:  #1A1A2E;
    --gray-100: #1E1E32;
    --gray-200: #2A2A3E;
    --gray-300: #3A3A4E;
    --gray-400: #6B7280;
    --gray-500: #9CA3AF;
    --gray-600: #D1D5DB;
    --gray-700: #E5E7EB;
    --gray-800: #F3F4F6;
    --gray-900: #F9FAFB;

    /* Surfaces */
    --bg-base: #111122;
    --bg-card: #1A1A2E;
    --bg-sidebar: #151528;
    --border-default: #2A2A3E;
    --border-subtle: #222236;

    /* Shadows — border-driven in dark mode too */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-card: none;
    --shadow-card-hover: none;

    /* Theme-aware overrides */
    --modal-backdrop: rgba(0, 0, 0, 0.7);
    --primary-shadow: rgba(139, 139, 240, 0.2);
    --primary-shadow-hover: rgba(139, 139, 240, 0.3);
    --danger-shadow: rgba(248, 113, 113, 0.2);
    --danger-shadow-hover: rgba(248, 113, 113, 0.3);
    --success-shadow: rgba(52, 211, 153, 0.2);
    --success-shadow-hover: rgba(52, 211, 153, 0.3);
    --primary-ring: rgba(139, 139, 240, 0.2);
    --pink-subtle: rgba(236, 72, 153, 0.12);
    --purple-subtle: rgba(139, 92, 246, 0.12);

    /* Badge / status text colors — lighter for dark backgrounds */
    --success-text: #6EE7B7;
    --warning-text: #FCD34D;
    --danger-text: #FCA5A5;
    --info-text: #93C5FD;
    --purple-text: #C4B5FD;
    --pink-text: #F9A8D4;
    --indigo-text: #A5B4FC;
    --deep-purple-text: #C4B5FD;
    --amber-text: #FCD34D;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ========================================
   Sidebar Layout
   ======================================== */

.layout-sidebar {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-default);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border-default);
}

.sidebar-brand a {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0.5rem 1.75rem;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    margin: 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.75rem;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    font-weight: 450;
    border-left: 3px solid transparent;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.nav-link:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.nav-link.active {
    color: var(--gray-900);
    font-weight: 600;
    border-left: 3px solid var(--primary);
}

.sidebar-user {
    padding: 1rem 1.75rem;
    border-top: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-form {
    margin: 0;
    flex-shrink: 0;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast) var(--ease-in-out);
}

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

.main-wrapper {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Container
   ======================================== */

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.875rem;
    flex: 1;
}

/* ========================================
   Page Header
   ======================================== */

.page-header {
    margin-bottom: 2.5rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--gray-900);
    margin-bottom: 0.375rem;
}

.page-header .subtitle {
    color: var(--gray-500);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
}

/* ========================================
   Cards
   ======================================== */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-default);
}

.card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.card-warning {
    border-left: 4px solid var(--warning);
    background: var(--warning-subtle);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.125rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-in-out);
    letter-spacing: 0.005em;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    opacity: 0.9;
}

.btn-primary:disabled {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-sm {
    padding: 0.3rem 0.625rem;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-ghost {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.btn-ghost:hover {
    color: var(--danger);
    background: var(--danger-subtle);
}

.previous-product-select {
    font-size: 12px;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    max-width: 220px;
}

.btn-block {
    display: flex;
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    font-size: 15px;
    font-weight: 600;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}

.btn-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.btn.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
}

/* Focus rings */
.btn:focus-visible,
.search-input:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================
   Upload Zone
   ======================================== */

.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 4rem 3rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    background: var(--gray-50);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-subtle);
    transform: scale(1.005);
}

.upload-zone input {
    display: none;
}

.upload-icon {
    color: var(--gray-400);
    margin-bottom: 1.25rem;
}

.upload-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-800);
    margin-bottom: 0.375rem;
}

.upload-hint {
    color: var(--gray-500);
    font-size: 13px;
}

.file-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--primary-subtle);
    border-radius: var(--radius-md);
    border: 1px solid rgba(91, 91, 214, 0.15);
    font-weight: 500;
    color: var(--gray-800);
    margin-top: 1rem;
}

/* Format Hints */
.format-hints pre {
    background: var(--gray-100);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12px;
    margin: 1rem 0;
}

.hint {
    color: var(--gray-500);
    font-size: 13px;
}

/* ========================================
   Tables
   ======================================== */

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    background: transparent;
    padding: 0.625rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    border-top: 1px solid var(--gray-200);
    white-space: nowrap;
}

.table td {
    padding: 0.625rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--gray-700);
    font-size: 13.5px;
}

.table tbody tr {
    transition: background var(--duration-fast);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

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

.table tfoot td {
    padding: 0.875rem;
    border-top: 2px solid var(--gray-200);
    border-bottom: none;
    font-weight: 600;
    color: var(--gray-900);
}

.table-responsive {
    overflow-x: auto;
}

.row-warning {
    background: var(--warning-subtle);
}

.row-skipped td {
    opacity: 0.45;
}

.billing-freq-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.billing-select {
    padding: 0.15rem 0.25rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 11px;
}

/* ========================================
   Status Badges
   ======================================== */

.badge, .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success, .status-completed {
    background: var(--success-subtle);
    color: var(--success-text);
}

.badge-warning, .status-pending, .status-processing {
    background: var(--warning-subtle);
    color: var(--warning-text);
}

.badge-danger, .status-failed {
    background: var(--danger-subtle);
    color: var(--danger-text);
}

/* ========================================
   Progress
   ======================================== */

.progress-info {
    margin-top: 1rem;
}

.progress-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
}

.progress-bar {
    height: 5px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.6s var(--ease-out);
}

/* ========================================
   Search
   ======================================== */

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
    outline: none;
}

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

.searchable-select-wrapper {
    position: relative;
}

.searchable-select-input {
    cursor: text;
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
    animation: dropdownReveal var(--duration-fast) var(--ease-out);
}

.search-result {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--duration-fast);
}

.search-result:hover {
    background: var(--primary-ghost);
}

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

.result-name {
    font-weight: 500;
    color: var(--gray-800);
}

.result-email {
    color: var(--gray-500);
    font-size: 12px;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.result-id {
    font-size: 11px;
    color: var(--gray-500);
    font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
}

.no-results {
    padding: 1rem;
    color: var(--gray-500);
    text-align: center;
    font-size: 13px;
}

/* ========================================
   Customer Info
   ======================================== */

.stripe-customer, .customer-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.stripe-customer .email, .customer-info .email {
    color: var(--gray-500);
    font-size: 12px;
}

.stripe-customer .customer-id {
    font-size: 11px;
    color: var(--gray-400);
    font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
}

/* ========================================
   Form Elements
   ======================================== */

.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.form-group {
    position: relative;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 0.375rem;
}

.form-group select,
.form-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-card);
    color: var(--gray-800);
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
    outline: none;
}

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

.period-display {
    margin-top: 0.75rem;
    font-size: 14px;
    color: var(--gray-600);
}

.price-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 12px;
    max-width: 200px;
}

.price-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.create-price-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.custom-price-input {
    width: 100px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

/* ========================================
   Stats
   ======================================== */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.stat {
    text-align: center;
    padding: 1.25rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast);
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

.stat-danger .stat-value {
    color: var(--danger);
}

.stat-warning .stat-value {
    color: var(--warning);
}

.stat-label {
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.375rem;
}

/* ========================================
   Status Header
   ======================================== */

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.status-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
}

.status-header .progress-info {
    flex: 1;
    max-width: 300px;
    margin-top: 0;
    margin-left: 2rem;
}

/* ========================================
   Actions Bar
   ======================================== */

.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-default);
}

/* ========================================
   Modal
   ======================================== */

.modal {
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--duration-fast) var(--ease-out);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: slideUp var(--duration-normal) var(--ease-out);
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
    color: var(--gray-600);
    line-height: 1.7;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ========================================
   Create Customer Modal Form
   ======================================== */

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.modal-form-grid .form-group input,
.modal-form-grid .form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-card);
    color: var(--gray-800);
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
    outline: none;
}

.modal-form-grid .form-group input:focus,
.modal-form-grid .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.modal-form-grid .form-group label {
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

.copy-billing-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--primary);
    cursor: pointer;
}

.copy-billing-label input[type="checkbox"] {
    accent-color: var(--primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Error Cell
   ======================================== */

.error-cell {
    max-width: 200px;
    font-size: 12px;
    color: var(--danger);
}

/* ========================================
   Outstanding AR Section
   ======================================== */

.card-ar-alert {
    border-left: 4px solid var(--danger);
    background: var(--danger-subtle);
}

.card-ar-info {
    border-left: 4px solid var(--primary);
    background: var(--primary-subtle);
}

.ar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.ar-subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 1rem;
}

.row-ar-critical {
    background: var(--warning-subtle);
    border-left: 3px solid var(--danger);
}

.ar-invoice-count {
    font-weight: 600;
    font-size: 16px;
}

.ar-count-critical {
    color: var(--danger);
}

.ar-amount {
    font-weight: 600;
    color: var(--gray-900);
}

.ar-details {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.ar-invoice-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ar-invoice-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    gap: 0.5rem;
}

.ar-invoice-list li:last-child {
    border-bottom: none;
}

.invoice-id {
    font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
    color: var(--gray-700);
    flex: 1;
    font-size: 11px;
}

.invoice-amount {
    font-weight: 600;
    color: var(--gray-900);
}

.invoice-due {
    color: var(--gray-500);
    font-size: 11px;
}

.ar-details-toggle {
    padding: 0.25rem 0.5rem;
    font-size: 12px;
}

/* ========================================
   Product Change (matched rows)
   ======================================== */

.product-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-change-product {
    color: var(--gray-400);
    border-color: transparent;
    background: none;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-in-out);
}

.matched-row:hover .btn-change-product {
    opacity: 1;
}

.btn-change-product:hover {
    color: var(--primary);
    background: var(--primary-ghost);
    border-color: var(--primary);
}

.product-edit-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

/* ========================================
   Product Select
   ======================================== */

.product-select {
    width: 100%;
    max-width: 200px;
    padding: 0.25rem 0.5rem;
    font-size: 13px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--gray-800);
}

/* ========================================
   Dry Run Label
   ======================================== */

.dry-run-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
    user-select: none;
}

.dry-run-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    min-width: 320px;
    max-width: 440px;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    opacity: 0;
    transform: translateY(12px);
    transition: all var(--duration-normal) var(--ease-out);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    pointer-events: all;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-left-color: var(--success);
}

.toast-danger, .toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: var(--warning);
}

/* ========================================
   Loading Button States
   ======================================== */

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

.btn-loading::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spinner 0.65s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

.btn-primary.btn-loading::after {
    border-color: rgba(255,255,255,0.3);
    border-top-color: white;
}

/* ========================================
   Empty States
   ======================================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 1.25rem;
    opacity: 0.35;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 1.5rem;
    color: var(--gray-500);
}

/* ========================================
   Draft Review Card
   ======================================== */

#draft-actions {
    background: var(--primary-subtle);
    border: 1px solid rgba(91, 91, 214, 0.15);
}

/* ========================================
   Revenue Reports Page
   ======================================== */

/* Sticky Summary Stats */
.stats-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-base);
    padding: 1rem 0 1.25rem 0;
    margin: -0.5rem 0 1.5rem 0;
}

/* Enhanced Stat Cards */
.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    flex: 1;
    min-width: 0;
}

.stat-card .stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-card.stat-paid .stat-value {
    color: var(--success);
}

.stat-card.stat-pending .stat-value {
    color: var(--warning);
}

.stat-card.stat-neutral .stat-value {
    color: var(--primary);
}

/* Month Card */
.month-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--primary);
    padding: 0;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 0;
}

.month-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
    letter-spacing: -0.01em;
}

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

.month-total-item {
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.total-billed {
    color: var(--primary);
}

.total-outstanding {
    color: var(--warning);
}

.total-paid {
    color: var(--success);
}

/* Status Table */
.status-table {
    width: 100%;
}

.status-table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.06em;
    padding: 0.4rem 0.75rem;
    color: var(--gray-500);
}

.status-table td {
    padding: 0.3rem 0.75rem;
    vertical-align: middle;
    font-size: 13px;
}

.status-table tr:hover {
    background: var(--gray-50);
}

.status-table .customer-name {
    font-weight: 500;
    color: var(--gray-900);
}

.status-table .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Status Pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pill.paid {
    background: var(--success-subtle);
    color: var(--success-text);
}

.status-pill.pending {
    background: var(--warning-subtle);
    color: var(--warning-text);
}

/* Product Tags */
.products-cell {
    max-width: 220px;
}

.product-tag {
    display: inline-block;
    background: var(--primary-subtle);
    color: var(--primary);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    margin: 1px 2px;
    white-space: nowrap;
}

.text-muted {
    color: var(--gray-400);
}

/* Scrollable Table Container */
.table-scroll {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.table-scroll thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-scroll thead th {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-300);
}

/* Collapsible Month Sections */
.month-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.month-toggle::before {
    content: '\25BC';
    font-size: 0.75rem;
    transition: transform 0.2s var(--ease-out);
    color: var(--gray-400);
}

.month-toggle.collapsed::before {
    transform: rotate(-90deg);
}

.month-content {
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out);
}

.month-content.collapsed {
    max-height: 0;
    margin-top: 0;
}

/* Service Period Accordion */
.sp-month-row:hover { background: var(--gray-50); }
.sp-detail-table { font-size: 0.875rem; }
.sp-detail-table th { font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-500); }
.sp-detail-table td { padding: 0.4rem 0.75rem; }
.sp-invoices { font-size: 0.8rem; max-width: 280px; word-break: break-all; }
.sp-invoices a { color: var(--primary); text-decoration: none; }
.sp-invoices a:hover { text-decoration: underline; }
.sp-status-paid { background: var(--success-subtle); color: var(--success-text); padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.sp-status-open { background: var(--warning-subtle); color: var(--warning-text); padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }

/* Date Range Filter */
.date-filter {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.date-filter .form-row {
    align-items: flex-end;
}

.date-filter input[type="month"] {
    min-width: 150px;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-700);
}

.section-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 1.5rem 0;
}

/* Report Action Cells */
.action-cell {
    text-align: center;
    white-space: nowrap;
}

.bulk-resend-btn {
    margin-left: 1rem;
    white-space: nowrap;
}

/* Loading States for Reports */
.reports-loading {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
    font-size: 14px;
}

.reports-loading::after {
    content: "";
    display: block;
    width: 28px;
    height: 28px;
    margin: 1rem auto;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.75s linear infinite;
}

/* ========================================
   Invoice Detail Modal
   ======================================== */

.invoice-modal-content {
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    animation: slideUp var(--duration-normal) var(--ease-out);
}

.invoice-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-default);
}

.invoice-modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast);
}

.btn-close:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

.invoice-id-subtitle {
    font-size: 12px;
    color: var(--gray-400);
    font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
}

.invoice-modal-loading {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.invoice-modal-loading::after {
    content: "";
    display: block;
    width: 24px;
    height: 24px;
    margin: 1rem auto 0;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.75s linear infinite;
}

.invoice-modal-error {
    padding: 1rem 1.5rem;
    color: var(--danger-text);
    background: var(--danger-subtle);
    margin: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.invoice-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-default);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
}

.meta-value {
    font-size: 14px;
    color: var(--gray-900);
}

.invoice-amounts {
    display: flex;
    gap: 2rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-default);
    background: var(--gray-50);
}

.amount-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.amount-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
}

.amount-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.amount-paid {
    color: var(--success);
}

.amount-remaining {
    color: var(--warning);
}

.line-items-title {
    padding: 1rem 1.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-700);
}

.invoice-lines-table {
    margin: 0;
}

.invoice-lines-table th,
.invoice-lines-table td {
    padding: 0.5rem 1.5rem;
    font-size: 13px;
}

.invoice-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-default);
}

/* Clickable rows */
tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:hover {
    background: var(--primary-ghost);
}

/* Row highlight animation */
@keyframes rowHighlight {
    0% { background: var(--primary-subtle); }
    100% { background: transparent; }
}

tr.just-updated {
    animation: rowHighlight 1.5s var(--ease-out);
}

/* Dropdown reveal animation */
@keyframes dropdownReveal {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Chargeable Outstanding
   ======================================== */

.card-chargeable {
    border-left: 4px solid var(--warning);
    background: var(--warning-subtle);
}

.chargeable-header {
    margin-bottom: 1rem;
}

.chargeable-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.25rem;
}

.chargeable-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

/* Card on file indicators */
.card-on-file {
    color: var(--success);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.card-none {
    color: var(--gray-500);
    font-size: 12px;
    white-space: nowrap;
}

.card-status-loading {
    color: var(--gray-500);
    font-size: 12px;
}

.card-cell {
    white-space: nowrap;
}

/* Resend date label */
.resend-date-label {
    font-size: 11px;
    color: var(--gray-500);
    font-style: italic;
    white-space: nowrap;
}

/* ========================================
   Revenue Matrix
   ======================================== */

.matrix-card {
    padding: 0;
    overflow: hidden;
}

.matrix-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.matrix-table {
    margin: 0;
    white-space: nowrap;
}

.matrix-table th,
.matrix-table td {
    padding: 0.5rem 0.875rem;
    font-size: 13px;
}

.matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--gray-50);
}

.matrix-customer-col {
    position: sticky;
    left: 0;
    z-index: 20;
    background: var(--bg-card);
    min-width: 200px;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    border-right: 2px solid var(--gray-200);
}

.matrix-customer-id {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--gray-400);
    letter-spacing: 0.01em;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matrix-table thead .matrix-customer-col {
    z-index: 30;
    background: var(--gray-50);
}

.matrix-table tfoot .matrix-customer-col {
    background: var(--bg-card);
}

.matrix-total-col {
    border-left: 2px solid var(--gray-200);
    font-weight: 600;
}

.matrix-table tfoot td {
    border-top: 2px solid var(--gray-200);
    border-bottom: none;
    padding: 0.75rem 0.875rem;
    background: var(--bg-card);
}

.matrix-table tfoot .matrix-customer-col {
    position: sticky;
    left: 0;
    z-index: 20;
}

.matrix-cell-paid {
    color: var(--success);
}

.matrix-cell-pending {
    color: var(--warning);
    background-color: var(--warning-subtle);
}

.matrix-cell-empty {
    color: var(--gray-300);
}

/* Matrix status badges & context menu */
.matrix-frequency-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    margin-left: 6px;
    vertical-align: middle;
}

.matrix-badge-quarterly {
    background: rgba(59, 130, 246, 0.12);
    color: var(--info-text);
}

.matrix-badge-semi_annually {
    background: rgba(139, 92, 246, 0.12);
    color: var(--purple-text);
}

.matrix-badge-annually {
    background: rgba(245, 158, 11, 0.12);
    color: var(--amber-text);
}

.matrix-badge-cancelled {
    background: rgba(220, 53, 69, 0.12);
    color: var(--danger-text);
}

.matrix-row-cancelled .matrix-customer-col {
    text-decoration: line-through;
    opacity: 0.6;
}

.matrix-cell-cancelled-future {
    background-color: rgba(220, 53, 69, 0.10) !important;
}

.context-menu {
    position: fixed;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 160px;
    padding: 4px 0;
}

.context-menu-header {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.context-menu-item {
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-in-out);
}

.context-menu-item:hover {
    background: var(--gray-50);
}

.context-menu-item.active {
    font-weight: 600;
    color: var(--primary);
}

.context-menu-cancel {
    color: var(--danger);
}

.context-menu-cancel:hover {
    background: var(--danger-subtle);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-default);
    margin: 4px 0;
}

/* ========================================
   Reconciliation
   ======================================== */

/* Input mode tabs */
.recon-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-default);
    margin: -1.5rem -1.5rem 0 -1.5rem;
    padding: 0 1.5rem;
}

.recon-tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 550;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.recon-tab:hover {
    color: var(--gray-800);
}

.recon-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.recon-tab-panel {
    display: none;
}

.recon-tab-panel.active {
    display: block;
}

/* Discrepancy type badges */
.recon-badge-unmapped {
    background: var(--warning-subtle);
    color: var(--warning-text);
}

.recon-badge-missing_billing {
    background: var(--danger-subtle);
    color: var(--danger-text);
}

.recon-badge-amount_mismatch {
    background: var(--pink-subtle);
    color: var(--pink-text);
}

.recon-badge-frequency_mismatch {
    background: var(--primary-subtle);
    color: var(--indigo-text);
}

.recon-badge-status_mismatch {
    background: var(--purple-subtle);
    color: var(--deep-purple-text);
}

/* Filter bar */
.recon-filter-bar {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.recon-filter-btn {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    font-size: 12px;
    font-weight: 550;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.recon-filter-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.recon-filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Inline mapping in reconciliation table */
.recon-mapping-cell {
    white-space: nowrap;
}

.recon-mapping-container {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.recon-mapping-container .search-input {
    width: 200px;
    padding: 0.3rem 0.5rem;
    font-size: 12px;
}

.recon-mapping-container .search-results {
    min-width: 280px;
}

.recon-save-btn {
    margin-left: 0.375rem;
    vertical-align: middle;
}

/* ========================================
   App Footer
   ======================================== */

.app-footer {
    padding: 2rem 2.5rem;
    text-align: center;
    font-size: 12px;
    color: var(--gray-400);
    letter-spacing: 0.02em;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 100%;
        height: auto;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        border-right: none;
        border-top: 1px solid var(--border-default);
        display: flex;
        flex-direction: row;
        align-items: center;
        z-index: 100;
        background: var(--bg-sidebar);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    }

    .sidebar-brand {
        display: none;
    }

    .sidebar-user {
        padding: 0 0.75rem;
        border-top: none;
    }

    .sidebar-user-name,
    .sidebar-logout-form {
        display: none;
    }

    .sidebar-nav {
        width: 100%;
        padding: 0;
    }

    .nav-list {
        display: flex;
        justify-content: space-around;
        width: 100%;
    }

    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 12px;
        text-align: center;
        border-left: none;
        border-bottom: 2px solid transparent;
    }

    .nav-link.active {
        border-left: none;
        border-bottom: 2px solid var(--primary);
        background: transparent;
    }

    .main-wrapper {
        margin-left: 0;
        padding-bottom: 4rem;
    }

    .container {
        padding: 1.5rem 1rem;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .table th,
    .table td {
        font-size: 12px;
        padding: 0.5rem 0.625rem;
    }

    .status-table th,
    .status-table td {
        padding: 0.5rem;
        font-size: 13px;
    }

    .actions-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .actions-bar .btn {
        width: 100%;
    }

    .month-total {
        font-size: 1.25rem;
    }
}

@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-group {
        width: 100%;
    }

    .form-group select,
    .form-group input {
        width: 100%;
    }
}

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

    .upload-zone {
        padding: 2.5rem 1.5rem;
    }

    .upload-icon svg {
        width: 36px;
        height: 36px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
}

/* ========================================
   Payroll Preview
   ======================================== */

.payroll-customer-block {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-default);
}

.payroll-customer-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.payroll-customer-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.payroll-customer-header strong {
    font-size: 1rem;
}

.customer-meta {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.table-compact {
    font-size: 0.85rem;
}

.table-compact th,
.table-compact td {
    padding: 0.35rem 0.75rem;
}

.select-saved {
    outline: 2px solid var(--success);
    outline-offset: -1px;
    transition: outline 0.3s ease;
}

.add-line-item-btn {
    margin-top: 0.5rem;
    font-size: 12px;
}

.manual-line-item-row {
    background: var(--primary-subtle);
}

.manual-line-item-row:hover {
    background: var(--primary-ghost);
}

.remove-manual-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 0.375rem;
    margin-left: 0.5rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    vertical-align: middle;
}

.remove-manual-btn:hover {
    background: var(--danger-subtle);
}

/* ========================================
   Theme Toggle
   ======================================== */

.sidebar-user-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-default);
    color: var(--gray-500);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-ghost);
}

/* Show sun icon in dark mode, moon icon in light mode */
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; }

.price-source-hint {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden { display: none !important; }

/* Alert variants */
.alert { padding: 0.5rem 0.75rem; font-size: 0.85rem; border-left: 3px solid; border-radius: var(--radius-sm); margin: 0.5rem 0; }
.alert-warning { border-color: var(--warning); background: var(--warning-subtle); color: var(--gray-800); }
.alert-info { border-color: var(--primary); background: var(--primary-subtle); color: var(--gray-800); }
.alert-danger { border-color: var(--danger); background: var(--danger-subtle); color: var(--gray-800); }

/* Spacing */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mr-1 { margin-right: 0.25rem; }

/* Layout */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 0.5rem; }

/* Small form inputs */
.input-xs { width: 60px; font-size: 12px; padding: 0.2rem 0.4rem; }
.input-sm { width: 80px; font-size: 12px; padding: 0.2rem 0.4rem; }

/* Text alignment */
.text-right { text-align: right; }

/* Card flush (padding:0 + overflow:hidden) */
.card-flush { padding: 0; overflow: hidden; }
.card-flush-header { padding: 1.25rem 1.5rem; margin: 0; border-bottom: 1px solid var(--border-default); }

/* Traceback / error detail pre blocks */
.traceback-pre { font-size: 0.8rem; overflow-x: auto; margin-top: 0.5rem; }

/* Duplicate warning alert list */
.alert-list { margin: 0.25rem 0 0 1rem; padding: 0; }

/* Exclusion notice text */
.text-warning-muted { color: var(--warning-text); }

/* Section header row (upload_results) */
.section-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section-header-row h3 { margin: 0; }
.section-header-row .subtitle { margin: 0.25rem 0 0; }

/* Reconciliation re-run bar */
.recon-rerun-bar {
    display: none;
    margin-bottom: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--warning-subtle);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: space-between;
}

.recon-rerun-bar span {
    font-size: 14px;
    color: var(--gray-800);
}

/* Reconciliation date error */
.recon-date-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: none;
}

/* Reconciliation matched toggle header */
.recon-matched-header {
    padding: 1.25rem 1.5rem;
    margin: 0;
    cursor: pointer;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Monospace table cells */
.mono-cell { font-family: monospace; font-size: 12px; }

/* Detail cell */
.detail-cell { font-size: 12px; max-width: 250px; }

/* Tabular numeric cells */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* Delete button text */
.text-danger { color: var(--danger); }

/* ========================================
   Login Page
   ======================================== */

body.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px 32px;
}

.login-brand {
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 28px;
}

.login-card .form-group {
    margin-bottom: 18px;
}

.login-card .form-group input {
    width: 100%;
}

.login-card .btn-primary {
    width: 100%;
    padding: 10px 16px;
    margin-top: 4px;
}

.login-error {
    background: var(--danger-subtle);
    color: var(--danger);
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
}

/* GL Code Mapping Panel */
.gl-mapping-card {
    margin-bottom: 20px;
}

.gl-mapping-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gl-mapping-subtitle {
    font-size: 13px;
    color: var(--gray-500);
}

.gl-mapping-table th,
.gl-mapping-table td {
    padding: 8px 12px;
    font-size: 13px;
}

.gl-product-id {
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    color: var(--gray-500);
}

.gl-code-input {
    width: 80px;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
}

.gl-save-btn,
.gl-clear-btn {
    padding: 3px 10px;
    font-size: 12px;
}
