/* ============================================
   FACT_MANAGER - Premium Invoice Management UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ====== CSS Variables / Design Tokens ====== */
:root {
    /* Colors */
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #4834D4;
    --primary-glow: rgba(108, 92, 231, 0.3);

    --accent: #00CEC9;
    --accent-light: #55EFC4;
    --accent-glow: rgba(0, 206, 201, 0.3);

    --success: #00B894;
    --success-bg: rgba(0, 184, 148, 0.12);
    --warning: #FDCB6E;
    --warning-bg: rgba(253, 203, 110, 0.12);
    --danger: #E17055;
    --danger-bg: rgba(225, 112, 85, 0.12);
    --info: #74B9FF;
    --info-bg: rgba(116, 185, 255, 0.12);

    /* Dark Theme */
    --bg-primary: #0F0E17;
    --bg-secondary: #1A1928;
    --bg-tertiary: #232136;
    --bg-card: rgba(35, 33, 54, 0.7);
    --bg-glass: rgba(35, 33, 54, 0.5);
    --bg-input: rgba(15, 14, 23, 0.6);
    --bg-hover: rgba(108, 92, 231, 0.08);

    --border-color: rgba(108, 92, 231, 0.15);
    --border-light: rgba(255, 255, 255, 0.06);

    --text-primary: #FFFFFE;
    --text-secondary: #A7A5C6;
    --text-muted: #6B6990;
    --text-accent: #A29BFE;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.15);
    --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 72px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====== Reset & Base ====== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background ambient glow */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 50%, rgba(108, 92, 231, 0.06) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(0, 206, 201, 0.04) 0%, transparent 50%),
                radial-gradient(circle at 50% 80%, rgba(253, 203, 110, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary);
}

/* ====== Layout ====== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ====== Sidebar ====== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-smooth);
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.sidebar-brand h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand small {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
    -webkit-text-fill-color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

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

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    margin-bottom: 2px;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    transition: transform var(--transition-base);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link:hover::before {
    transform: translateY(-50%) scaleY(1);
}

.nav-link.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(108, 92, 231, 0.05));
    box-shadow: var(--shadow-glow);
}

.nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.nav-link-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.nav-link-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

/* ====== Main Content ====== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ====== Header ====== */
.top-header {
    height: var(--header-height);
    background: rgba(26, 25, 40, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.header-breadcrumb span {
    color: var(--text-secondary);
}

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

/* ====== Page Content ====== */
.page-content {
    flex: 1;
    padding: 32px;
}

/* ====== Cards ====== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    overflow: hidden;
}

.card:hover {
    border-color: rgba(108, 92, 231, 0.25);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

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

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.stat-primary::before { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card.stat-success::before { background: linear-gradient(90deg, var(--success), var(--accent-light)); }
.stat-card.stat-warning::before { background: linear-gradient(90deg, var(--warning), #FD9644); }
.stat-card.stat-info::before { background: linear-gradient(90deg, var(--info), var(--accent)); }
.stat-card.stat-danger::before { background: linear-gradient(90deg, var(--danger), #E55039); }

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: rgba(108, 92, 231, 0.25);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-primary .stat-card-icon { background: rgba(108, 92, 231, 0.15); color: var(--primary-light); }
.stat-success .stat-card-icon { background: var(--success-bg); color: var(--success); }
.stat-warning .stat-card-icon { background: var(--warning-bg); color: var(--warning); }
.stat-info .stat-card-icon { background: var(--info-bg); color: var(--info); }
.stat-danger .stat-card-icon { background: var(--danger-bg); color: var(--danger); }

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-card-change {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px rgba(108, 92, 231, 0.45);
    transform: translateY(-1px);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #00A085);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 25px rgba(0, 184, 148, 0.45);
    transform: translateY(-1px);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #C44532);
    color: white;
    box-shadow: 0 4px 15px rgba(225, 112, 85, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 25px rgba(225, 112, 85, 0.45);
    transform: translateY(-1px);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #E1A502);
    color: #1A1928;
    box-shadow: 0 4px 15px rgba(253, 203, 110, 0.3);
}

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

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ====== Forms ====== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all var(--transition-base);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-tertiary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

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='%23A7A5C6' d='M6 8.825L0.375 3.2l.85-.85L6 7.125l4.775-4.775.85.85z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ====== Tables ====== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

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

table thead th {
    background: rgba(108, 92, 231, 0.06);
    padding: 14px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}

table tbody tr {
    transition: all var(--transition-fast);
}

table tbody tr:hover {
    background: var(--bg-hover);
}

table tbody tr:hover td {
    color: var(--text-primary);
}

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

/* ====== Badges ====== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-draft {
    background: rgba(107, 105, 144, 0.2);
    color: var(--text-muted);
    border: 1px solid rgba(107, 105, 144, 0.2);
}

.badge-sent {
    background: rgba(52, 211, 153, 0.18);
    border-color: rgba(52, 211, 153, 0.28);
    color: #34d399;
    border: 1px solid rgba(116, 185, 255, 0.2);
}

.badge-paid {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(0, 184, 148, 0.2);
}

.badge-cancelled {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(225, 112, 85, 0.2);
}

.badge-overdue {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(253, 203, 110, 0.2);
}

/* ====== Alerts / Flash ====== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.4s ease;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(0, 184, 148, 0.2);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(225, 112, 85, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(253, 203, 110, 0.2);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(116, 185, 255, 0.2);
}

/* ====== Modal ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-smooth);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

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

/* ====== Logo Preview ====== */
.logo-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-input);
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.logo-upload-area #logoPreview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 140px;
}

.logo-upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.logo-upload-area img {
    max-width: 150px;
    max-height: 100px;
    object-fit: contain;
    margin-bottom: 0;
}

.logo-upload-area .upload-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.logo-upload-area .upload-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

/* ====== Empty State ====== */
.empty-state {
    padding: 64px 32px;
    text-align: center;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ====== Pagination ====== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.pagination a:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ====== Actions Menu ====== */
.actions-cell {
    display: flex;
    gap: 6px;
}

/* ====== Company Selector ====== */
.company-selector {
    position: relative;
}

.company-selector-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
}

.company-selector-btn:hover {
    border-color: var(--primary);
}

.company-selector-btn img {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: white;
    padding: 2px;
}

.company-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 260px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    animation: slideDown 0.2s ease;
}

.company-dropdown.show {
    display: block;
}

.company-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-secondary);
    text-decoration: none;
}

.company-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.company-dropdown-item.active {
    background: rgba(108, 92, 231, 0.1);
    color: var(--primary-light);
}

.company-dropdown-item img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: white;
    padding: 2px;
}

.company-dropdown-divider {
    border-top: 1px solid var(--border-light);
    margin: 4px 0;
}

/* ====== Charts Placeholder ====== */
.chart-container {
    height: 280px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 20px 0;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(to top, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    min-height: 8px;
    position: relative;
    transition: all var(--transition-base);
    cursor: pointer;
}

.chart-bar:hover {
    filter: brightness(1.2);
    transform: scaleY(1.02);
    transform-origin: bottom;
}

.chart-bar-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chart-bar-value {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chart-bar:hover .chart-bar-value {
    opacity: 1;
}

/* ====== Filter Bar ====== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-input-wrapper input {
    padding-left: 40px;
}

/* ====== Invoice Items Dynamic ====== */
.invoice-items-table {
    width: 100%;
    margin-bottom: 16px;
}

.invoice-items-table th {
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: rgba(108, 92, 231, 0.06);
    border-bottom: 1px solid var(--border-color);
}

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

.invoice-items-table input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    outline: none;
    transition: all var(--transition-base);
}

.invoice-items-table input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.invoice-items-table .col-desc { width: 40%; }
.invoice-items-table .col-qty { width: 12%; }
.invoice-items-table .col-unit { width: 12%; }
.invoice-items-table .col-price { width: 16%; }
.invoice-items-table .col-total { width: 14%; }
.invoice-items-table .col-actions { width: 6%; text-align: center; }

.line-total {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    text-align: right;
    padding-right: 12px;
}

/* ====== Invoice Summary ====== */
.invoice-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.invoice-summary-table {
    width: 320px;
}

.invoice-summary-table tr td {
    padding: 8px 16px;
    border: none;
}

.invoice-summary-table tr td:first-child {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.invoice-summary-table tr td:last-child {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.invoice-summary-table .total-row td {
    border-top: 2px solid var(--primary);
    font-size: 1.1rem;
    font-weight: 700;
    padding-top: 12px;
    color: var(--primary-light) !important;
}

/* ====== Color Picker ====== */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-wrapper input[type="color"] {
    width: 48px;
    height: 40px;
    padding: 2px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ====== Animations ====== */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in { animation: fadeIn 0.5s ease; }
.animate-slide-up { animation: slideUp 0.5s ease; }

/* Staggered animations */
.stats-grid .stat-card:nth-child(1) { animation: slideUp 0.5s ease 0.0s both; }
.stats-grid .stat-card:nth-child(2) { animation: slideUp 0.5s ease 0.1s both; }
.stats-grid .stat-card:nth-child(3) { animation: slideUp 0.5s ease 0.2s both; }
.stats-grid .stat-card:nth-child(4) { animation: slideUp 0.5s ease 0.3s both; }
.stats-grid .stat-card:nth-child(5) { animation: slideUp 0.5s ease 0.4s both; }

/* ====== Company Logo in Tables ====== */
.company-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-cell img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: white;
    padding: 2px;
}

.company-cell .company-info {
    display: flex;
    flex-direction: column;
}

.company-cell .company-info strong {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.company-cell .company-info small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ====== Responsive ====== */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .mobile-toggle {
        display: block;
    }

    .page-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

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

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .filter-bar {
        flex-direction: column;
    }

    .search-input-wrapper {
        min-width: 100%;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-header {
        padding: 0 16px;
    }

    .header-breadcrumb {
        display: none;
    }
}

/* ====== Print Specific ====== */
@media print {
    .sidebar, .top-header, .btn, .filter-bar, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: 0;
    }
    body {
        background: white;
        color: #333;
    }
}

/* ====== Tooltip ====== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    border: 1px solid var(--border-color);
    z-index: 999;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ====== Delete confirmation ====== */
.confirm-delete {
    display: inline-flex;
}

.confirm-delete .btn-confirm {
    display: none;
}

.confirm-delete.confirming .btn-delete-trigger {
    display: none;
}

.confirm-delete.confirming .btn-confirm {
    display: inline-flex;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1200px 500px at 20% 20%, rgba(108, 92, 231, 0.14), transparent 60%),
        radial-gradient(900px 420px at 80% 70%, rgba(0, 184, 148, 0.12), transparent 55%),
        var(--bg-secondary);
}

.auth-shell {
    width: 100%;
    max-width: 480px;
    display: grid;
    gap: 14px;
}

.auth-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    text-align: left;
}

.auth-logo {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(108, 92, 231, 0.14);
    border: 1px solid rgba(108, 92, 231, 0.22);
    border-radius: 12px;
    font-size: 22px;
}

.auth-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.3;
}

.auth-card {
    box-shadow: var(--shadow-lg);
}

.auth-form .form-group {
    margin-bottom: 14px;
}

.auth-demo {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.auth-demo-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.auth-demo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.auth-demo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-card);
    font-size: 0.86rem;
}

.auth-demo-item span {
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.82rem;
}

@media (max-width: 420px) {
    .auth-demo-grid {
        grid-template-columns: 1fr;
    }
    .auth-brand {
        justify-content: flex-start;
    }
}
