/* ============================================
   FaktuPilot - System weryfikacji faktur
   ============================================ */

:root {
    --primary: #0B7285;
    --primary-dark: #095c6a;
    --success: #22C55E;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* Navbar */
.navbar {
    background: #1B2A4A;
    color: white;
    padding: 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.nav-brand { color: white; text-decoration: none; font-weight: 700; font-size: 18px; }
.nav-menu { display: flex; align-items: center; gap: 4px; }
.nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.2s;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.15); color: white; }
.nav-logout { border-left: 1px solid rgba(255,255,255,0.2); margin-left: 8px; }
.nav-user { color: rgba(255,255,255,0.7); font-size: 13px; padding: 0 8px; }
.nav-lang { display: flex; gap: 0; }

/* Admin Sidebar */
.sidebar-toggle {
    background: none; border: none; color: white; font-size: 22px;
    cursor: pointer; padding: 4px 8px; border-radius: 4px; line-height: 1;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.15); }
.nav-topbar-right { display: flex; align-items: center; gap: 4px; }

.admin-sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0;
    width: 240px; background: var(--primary-dark, #1B2A4A);
    overflow-y: auto; z-index: 90;
    transform: translateX(-100%); transition: transform 0.25s ease;
    border-right: 1px solid rgba(255,255,255,0.08);
}
.sidebar-open .admin-sidebar { transform: translateX(0); }
.sidebar-overlay {
    display: none; position: fixed; inset: 0; top: 56px;
    background: rgba(0,0,0,0.4); z-index: 89;
}
.sidebar-open .sidebar-overlay { display: block; }

.sidebar-nav { padding: 12px 0; }
.sidebar-group-label {
    color: rgba(255,255,255,0.4); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 16px 16px 4px 16px; margin-top: 4px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    color: rgba(255,255,255,0.75); text-decoration: none;
    padding: 9px 16px; font-size: 13px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08); color: white;
}
.sidebar-link.active {
    background: rgba(255,255,255,0.12); color: white;
    border-left-color: var(--accent, #22C55E);
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }

/* Admin layout — content shifts when sidebar is open on desktop */
.admin-main { flex: 1; padding: 24px 20px; max-width: 1200px; margin: 0 auto; }
.admin-footer { margin-left: 0; }

/* Desktop: sidebar always visible, no overlay */
@media (min-width: 1024px) {
    .admin-sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-overlay { display: none; }
    .sidebar-overlay { display: none !important; }
    .admin-main { margin-left: 240px; }
    .admin-footer { margin-left: 240px; }
    .sidebar-toggle { display: none; }
}

/* Main content */
.main-content { flex: 1; padding: 24px 20px; }

/* Auth */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
}
.auth-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.auth-title { text-align: center; color: var(--primary); font-size: 28px; margin-bottom: 8px; }
.auth-subtitle { text-align: center; color: var(--gray-500); margin-bottom: 24px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }

/* Forms */
.form-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 700px;
}
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--gray-700); }
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-hint { display: block; color: var(--gray-500); font-size: 12px; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.inline-form { display: inline; }
.radio-group { display: flex; gap: 20px; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; padding: 10px 0; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
}
.btn:hover { background: var(--gray-100); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
    border-top: 3px solid var(--primary);
}
.stat-card.stat-warning { border-top-color: var(--warning); }
.stat-card.stat-success { border-top-color: var(--success); }
.stat-card.stat-error { border-top-color: var(--danger); }
.stat-value { font-size: 36px; font-weight: 700; color: var(--gray-900); word-break: break-word; overflow-wrap: break-word; }
.stat-label { font-size: 13px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table th {
    background: var(--gray-50);
    padding: 12px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}
.table td {
    padding: 12px 14px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
}
.table tbody tr:hover { background: var(--gray-50); }
.table-compact td, .table-compact th { padding: 8px 10px; font-size: 13px; }
.table-footer td { font-size: 14px; background: var(--gray-50); border-top: 2px solid var(--gray-200); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.col-check { width: 40px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-warning-orange { background: #fff7ed; color: #c2410c; }
.badge-error { background: #fef2f2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-default { background: var(--gray-100); color: var(--gray-700); }

/* Sections */
.section { margin-top: 32px; }
.section h2 { font-size: 20px; margin-bottom: 16px; color: var(--gray-700); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-header h1 { font-size: 24px; }

/* Batch Cards */
.batch-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--gray-300);
}
.batch-card.batch-pending { border-left-color: var(--warning); }
.batch-card.batch-done { border-left-color: var(--success); }
.batch-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.batch-card-header h3 { margin: 0; }
.batch-info { background: white; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }

/* Bulk Actions */
.bulk-actions { margin-bottom: 16px; }
.bulk-bar {
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* Action Buttons */
.action-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* Invoice row status */
.invoice-row.status-accepted { background: #f0fdf4; }
.invoice-row.status-rejected { background: #fef2f2; }

/* Info & Result cards */
.info-card, .result-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.error-list { list-style: none; padding: 0; }
.error-list li { padding: 4px 0; color: var(--danger); font-size: 13px; }
.error-list li::before { content: "• "; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-500);
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
}
.modal-content h3 { margin-bottom: 12px; }

/* Footer */
.footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 16px 0;
    text-align: center;
    color: var(--gray-500);
    font-size: 13px;
    margin-top: auto;
}
.footer-links { margin-top: 6px; }
.footer-links a { color: var(--gray-500); text-decoration: none; margin: 0 8px; font-size: 12px; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; }

/* Nav toggle (hamburger) for mobile */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}
.nav-logo {
    height: 32px;
    margin-right: 8px;
    vertical-align: middle;
}

/* Impersonation bar */
.impersonation-bar {
    background: #fef3c7;
    color: #92400e;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--gray-200); }
.tab-link {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    transition: all 0.2s;
}
.tab-link:hover { color: var(--gray-700); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Settings sections */
.settings-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.settings-section h3 {
    font-size: 16px;
    color: var(--gray-700);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

/* Color inputs */
.form-color {
    width: 60px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
}
.color-group { display: flex; align-items: center; gap: 12px; }

/* Privacy policy textarea */
.form-textarea-lg {
    width: 100%;
    min-height: 300px;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

/* GUS lookup button inline */
.input-group { display: flex; gap: 8px; }
.input-group .form-input { flex: 1; }

/* Password results table */
.password-table { margin-top: 16px; }
.password-table td { font-family: monospace; }

/* Filter bar */
.filter-bar {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-label { font-size: 12px; margin-bottom: 4px; }

/* Table responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Alert info */
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* Desktop/mobile visibility helpers (client panel) */
.mobile-only-client { display: none; }

/* Table cell text overflow */
.table td code { word-break: break-all; }

/* Touch-friendly sizing */
.btn { min-height: 38px; }
.btn-sm { min-height: 32px; }
.btn-xs { min-height: 28px; }
.form-input, select.form-input { min-height: 40px; font-size: 16px; } /* 16px prevents iOS zoom */

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .table { font-size: 13px; }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-menu {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--primary);
        flex-direction: column;
        padding: 8px 0;
        box-shadow: var(--shadow-md);
    }
    .nav-menu.active { display: flex; }
    .nav-link { padding: 14px 20px; border-radius: 0; font-size: 15px; }
    .nav-logout { border-left: none; margin-left: 0; border-top: 1px solid rgba(255,255,255,0.2); }
    .nav-user { padding: 10px 20px; font-size: 14px; }
    .nav-lang { padding: 0 12px; }

    /* Admin sidebar: hidden by default on mobile, toggled via hamburger */
    .admin-sidebar { width: 260px; }
    .admin-main { margin-left: 0; }

    .form-row { grid-template-columns: 1fr; }
    .form-inline .form-row { gap: 8px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .section-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .batch-card-header { flex-direction: column; gap: 8px; }
    .bulk-bar { flex-wrap: wrap; gap: 8px; }
    .action-buttons { flex-direction: column; gap: 6px; }
    .filter-bar { flex-direction: column; }

    .auth-card { margin: 16px; padding: 20px; }
    .container { padding: 0 12px; }
    .main-content { padding: 16px 12px; }

    /* Horizontal scroll for tables on mobile */
    .section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 600px; }
    .table td, .table th { padding: 10px 8px; font-size: 13px; white-space: nowrap; }
    .table-compact td, .table-compact th { padding: 6px 4px; font-size: 12px; }

    .impersonation-bar { flex-direction: column; gap: 8px; text-align: center; }

    /* Mobile-friendly buttons */
    .btn { padding: 10px 16px; font-size: 14px; }
    .section-header .btn { width: 100%; text-align: center; }
    .form-actions { gap: 8px; }

    /* Notifications */
    .notif-item { padding: 12px; }
    .notif-actions { flex-wrap: wrap; }

    /* Charts */
    .bar-chart { height: 140px; }
    .donut-chart { width: 100px; height: 100px; }

    /* Pagination */
    .pagination { flex-wrap: wrap; }

    /* Hide KSeF config on mobile for clients */
    .desktop-only-client { display: none; }
    .mobile-only-client { display: block; }

    /* Stat value scaling */
    .stat-value { font-size: 28px; }
}

/* Notifications */
.notifications-list { display: flex; flex-direction: column; gap: 12px; }
.notif-item { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-left: 4px solid var(--gray-200); }
.notif-unread { border-left-color: var(--primary); background: #f0f9ff; }
.notif-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.notif-title { font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.notif-message { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.notif-actions { display: flex; gap: 8px; }
.notif-date { font-size: 12px; }

/* Notification bell */
.nav-bell { position: relative; display: inline-flex; align-items: center; }
.notif-badge { position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Charts */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0; }
.chart-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.chart-card h3 { margin-bottom: 16px; font-size: 16px; color: var(--gray-700); }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { width: 100%; max-width: 40px; display: flex; flex-direction: column; border-radius: 4px 4px 0 0; overflow: hidden; margin-top: auto; min-height: 4px; }
.bar-segment { min-height: 2px; }
.bar-accepted { background: var(--success); }
.bar-rejected { background: var(--danger); }
.bar-pending { background: var(--warning); }
.bar-label { font-size: 11px; color: var(--gray-500); margin-top: 6px; white-space: nowrap; }
.bar-value { font-size: 12px; font-weight: 600; color: var(--gray-700); }

.chart-legend { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--gray-500); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.donut-chart-container { display: flex; align-items: center; gap: 24px; }
.donut-chart { width: 140px; height: 140px; }
.donut-text { font-size: 6px; font-weight: 700; fill: var(--gray-700); }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.donut-legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-700); }

@media (max-width: 768px) {
    .charts-row { grid-template-columns: 1fr; }
    .donut-chart-container { flex-direction: column; }
}

/* Dark mode toggle */
.theme-toggle { cursor: pointer; background: none; border: none; color: rgba(255,255,255,0.85); padding: 8px; font-size: 16px; line-height: 1; border-radius: 6px; }
.theme-toggle:hover { background: rgba(255,255,255,0.15); }

/* Dark mode */
[data-theme="dark"] {
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-500: #9ca3af;
    --gray-700: #d1d5db;
    --gray-900: #f9fafb;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
}
[data-theme="dark"] body { background: #0f172a; color: #e2e8f0; }
[data-theme="dark"] .navbar { background: #0f172a; border-bottom: 1px solid #1e293b; }
[data-theme="dark"] .auth-card,
[data-theme="dark"] .form-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .notif-item,
[data-theme="dark"] .batch-card { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .notif-unread { background: #1e3a5f; }
[data-theme="dark"] .form-input, [data-theme="dark"] .form-select, [data-theme="dark"] select.form-input { background: #0f172a; color: #e2e8f0; border-color: #374151; }
[data-theme="dark"] .table { background: #1e293b; }
[data-theme="dark"] .table th { background: #111827; color: #9ca3af; border-color: #374151; }
[data-theme="dark"] .table td { border-color: #374151; color: #e2e8f0; }
[data-theme="dark"] .table tr:hover { background: #263347; }
[data-theme="dark"] .stat-card { background: #1e293b; }
[data-theme="dark"] .stat-value { color: #f1f5f9; }
[data-theme="dark"] .footer { background: #0f172a; color: #64748b; border-top: 1px solid #1e293b; }
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .alert-success { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
[data-theme="dark"] .alert-info { background: #0c4a6e; color: #7dd3fc; border-color: #075985; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fcd34d; border-color: #92400e; }
[data-theme="dark"] .impersonation-bar { background: #78350f; }
[data-theme="dark"] .donut-text { fill: #e2e8f0; }
[data-theme="dark"] .modal-content { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .section-header { color: #e2e8f0; }
[data-theme="dark"] a { color: #38bdf8; }
[data-theme="dark"] .nav-link { color: rgba(255,255,255,0.85); }
[data-theme="dark"] .btn { border-color: #374151; }
[data-theme="dark"] .btn-secondary { background: #374151; color: #e2e8f0; border-color: #4b5563; }
[data-theme="dark"] .pagination a, [data-theme="dark"] .pagination span { background: #1e293b; color: #e2e8f0; border-color: #374151; }
[data-theme="dark"] .pagination .active { background: var(--primary); color: #fff; }

/* Responsive - Small mobile */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
    h1 { font-size: 20px; }
    h2 { font-size: 17px; }
    .batch-card { padding: 12px; }
    .btn-xs { font-size: 12px; padding: 6px 10px; }

    /* Stack notification header */
    .notif-header { flex-direction: column; gap: 4px; align-items: flex-start; }
}

/* ── Invoice Comments ────────────────────────────── */
.comment-toggle { position: relative; background: none; border: none; cursor: pointer; padding: 4px; color: #666; }
.comment-toggle:hover { color: var(--primary); }
.comment-count { position: absolute; top: -4px; right: -6px; background: var(--primary); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.comment-row td { background: #fafafa; padding: 12px 16px !important; }
.comment-thread { max-height: 300px; overflow-y: auto; }
.comment-bubble { padding: 8px 12px; margin-bottom: 6px; border-radius: 8px; font-size: 0.85em; }
.comment-mine { background: #e3f2fd; margin-left: 20%; }
.comment-other { background: #f5f5f5; margin-right: 20%; }
.comment-meta { font-size: 0.8em; margin-bottom: 2px; }
.comment-text { line-height: 1.4; }
.comment-loading { padding: 8px; color: #999; font-size: 0.85em; }
.btn-ghost { background: transparent; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; padding: 2px 6px; }
.btn-ghost:hover { background: #f0f0f0; }

/* Spinner animation */
@keyframes spin { to { transform: rotate(360deg); } }
.ksef-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.15); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }

/* Safe area insets for notch devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .footer { padding-bottom: env(safe-area-inset-bottom); }
    .navbar { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
