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

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

:root {
    --primary: #635BFF;
    --primary-dark: #5046e5;
    --primary-light: #f0efff;
    --accent: #635BFF;
    --accent-light: #f0efff;
    --success: #0CBF6E;
    --success-light: #e6faf0;
    --warning: #FF9F43;
    --warning-light: #fff5eb;
    --danger: #FF4757;
    --danger-light: #fff0f1;
    --gray-50: #fafbfc;
    --gray-100: #f4f5f7;
    --gray-200: #e8eaed;
    --gray-300: #d3d6db;
    --gray-400: #a0a4ab;
    --gray-500: #6e7380;
    --gray-600: #4a4f5b;
    --gray-700: #353a45;
    --gray-800: #1e2230;
    --gray-900: #0f1119;
    --glass: #ffffff;
    --glass-border: #ecedf0;
    --glass-shadow: 0 1px 3px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --shadow-focus: 0 0 0 3px rgba(99,91,255,0.2);
    --gradient-primary: linear-gradient(135deg, #635BFF 0%, #8B5CF6 100%);
    --gradient-success: linear-gradient(135deg, #0CBF6E 0%, #10D9B2 100%);
    --gradient-warning: linear-gradient(135deg, #FF9F43 0%, #FFBE76 100%);
    --gradient-danger: linear-gradient(135deg, #FF4757 0%, #FF6B81 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #FFFFF0;
    color: var(--gray-800);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR LAYOUT ===== */
.app-layout { display:flex; min-height:100vh; }
.sidebar {
    width:240px; min-height:100vh; background:#1e2230; color:#a0a4ab;
    padding:24px 16px; display:flex; flex-direction:column; gap:4px;
    position:fixed; left:0; top:0; bottom:0; z-index:50;
    overflow-y:auto;
}
.sidebar-logo { display:flex; align-items:center; gap:10px; padding:4px 8px 20px; color:white; font-weight:700; font-size:16px; text-decoration:none; }
.sidebar-logo svg, .sidebar-logo img { width:32px; height:32px; }
.sidebar a.nav-item {
    display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:10px;
    color:#a0a4ab; text-decoration:none; font-size:13px; font-weight:500;
    transition:all .15s; white-space:nowrap;
}
.sidebar a.nav-item:hover { background:rgba(255,255,255,0.08); color:#e0e0e0; }
.sidebar a.nav-item.active { background:#FF9F43; color:white; font-weight:600; }
.sidebar a.nav-item svg { width:18px; height:18px; flex-shrink:0; opacity:0.7; }
.sidebar a.nav-item.active svg { opacity:1; }
.sidebar .nav-section { font-size:10px; text-transform:uppercase; letter-spacing:0.08em; color:#5a5f6b; padding:16px 12px 6px; font-weight:600; }
.sidebar-spacer { flex:1; }

.main-content { margin-left:240px; flex:1; min-height:100vh; }
.main-topbar {
    display:flex; align-items:center; justify-content:space-between; gap:16px;
    padding:16px 28px; background:transparent;
}
.main-topbar .search-box {
    display:flex; align-items:center; gap:8px; background:#252d3a; border:1px solid #2f3848; border-radius:12px;
    padding:0 16px; height:40px; min-width:280px;
}
.main-topbar .search-box input { border:none; outline:none; font-size:13px; background:transparent; flex:1; font-family:inherit; color:white; }
.main-topbar .search-box input::placeholder { color:rgba(255,255,255,0.4); }
.main-topbar .search-box svg { color:var(--gray-400); flex-shrink:0; }
.main-topbar .topbar-right { display:flex; align-items:center; gap:8px; }
.main-topbar .topbar-icon { width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; background:#252d3a; border:1px solid #2f3848; cursor:pointer; transition:all .15s; color:rgba(255,255,255,0.6); }
.main-topbar .topbar-icon:hover { background:#2a3344; color:white; }

.page-content { padding:0 28px 28px; }
.page-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:24px; }
.page-header h1 { font-size:22px; font-weight:700; color:var(--gray-900); }

@media(max-width:900px) {
    .sidebar { display:none; }
    .main-content { margin-left:0; }
}

/* ===== ANIMATIONS ===== */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes bounceIn { 0% { opacity: 0; transform: scale(0.3); } 50% { transform: scale(1.05); } 70% { transform: scale(0.95); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 20px rgba(59,130,246,0.15); } 50% { box-shadow: 0 0 40px rgba(59,130,246,0.25); } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes growUp { from { height: 0 !important; opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes countUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.stagger > * { animation: fadeInUp 0.5s ease-out both; }
.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.09s; }
.stagger > *:nth-child(4) { animation-delay: 0.12s; }
.stagger > *:nth-child(5) { animation-delay: 0.15s; }
.stagger > *:nth-child(6) { animation-delay: 0.18s; }

.animate-fade-in-up { animation: fadeInUp 0.5s ease-out both; }

/* ===== LAYOUT ===== */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== LOGIN ===== */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1119 0%, #1e2230 40%, #2d2b55 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59,130,246,0.12) 0%, transparent 70%);
    top: -150px;
    right: -100px;
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
}

.login-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139,92,246,0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    border-radius: 50%;
    animation: float 8s ease-in-out infinite reverse;
}

.login-container .card {
    width: 100%;
    max-width: 440px;
    text-align: center;
    animation: slideUp 0.7s ease-out;
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.2);
}

/* ===== HEADER ===== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 14px 24px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-sm);
    animation: fadeInDown 0.3s ease-out;
}

.header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header h1 a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.header h1 a:hover { opacity: 0.8; }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 9999px;
    font-weight: 500;
    font-size: 13px;
    border: 1px solid rgba(99,102,241,0.15);
}

/* ===== CARD (glass) ===== */

.card {
    background: #252d3a;
    color: #d0d4dc;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid #2f3848;
    box-shadow: none;
    transition: box-shadow 0.2s ease;
    animation: fadeInUp 0.4s ease-out both;
}
.card h2 { color:#f0f2f5; }
.card table th { background:#2a3344; color:rgba(255,255,255,0.55); border-bottom:2px solid #3a4458; }
.card table td { color:#d0d4dc; border-bottom:1px solid #323c4e; }
.card table tbody tr:hover { background:rgba(255,255,255,0.03); }

.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }

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

/* ===== TYPOGRAPHY ===== */

h1 { font-size: 20px; font-weight: 600; color: var(--gray-900); letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.subtitle { color: var(--gray-500); margin: 8px 0 28px; font-size: 15px; font-weight: 400; }

.logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    color: white;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.logo svg { width: 32px; height: 32px; }

/* ===== FORMS ===== */

.form-group { margin-bottom: 18px; text-align: left; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    height: 40px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
    color: var(--gray-800);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

input::placeholder { color: var(--gray-400); }

.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row .form-group { flex: 1; }

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99,91,255,0.25);
}

.btn-primary:hover { opacity:0.9; box-shadow: 0 4px 12px rgba(99,91,255,0.35); }
.btn-primary:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--gray-300); border-color: var(--gray-300); cursor: not-allowed; }

.btn-secondary {
    background: #ffffff;
    color: var(--gray-700);
    border-color: var(--gray-200);
    box-shadow: none;
}

.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); box-shadow: var(--shadow-xs); }

.btn-danger { background: var(--gradient-danger); color: white; border-color: transparent; }
.btn-danger:hover { opacity:0.9; }

.btn-small { padding: 0 10px; height: 30px; font-size: 12px; border-radius: 6px; }
.btn-large { width: 100%; height: 42px; font-size: 14px; border-radius: 8px; }

/* ===== ALERTS ===== */

.alert { padding: 14px 18px; border-radius: 12px; margin-bottom: 18px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; animation: scaleIn 0.3s ease-out; }
.alert.error { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239,68,68,0.15); }
.alert.success { background: var(--success-light); color: var(--success); border: 1px solid rgba(16,185,129,0.15); }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ===== DOC TYPE WIDGETS ===== */

.doc-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
}

.doc-type-option input { display: none; }

.doc-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 14px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.doc-type-card.fd-bg { background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.doc-type-card.fv-bg { background: linear-gradient(135deg, #f0fdf4, #dcfce7); }
.doc-type-card.pd-bg { background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.doc-type-card.bv-bg { background: linear-gradient(135deg, #eef2ff, #e0e7ff); }
.doc-type-card.od-bg { background: linear-gradient(135deg, #f8fafc, #f1f5f9); }

.doc-type-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.doc-type-option input:checked + .doc-type-card {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 28px rgba(59,130,246,0.2);
}

.doc-type-option input:checked + .doc-type-card .doc-type-icon { animation: bounceIn 0.4s ease-out; }

.doc-type-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    transition: transform 0.3s ease;
}

.doc-type-icon svg { width: 26px; height: 26px; }

.doc-type-icon.fd { background: rgba(59,130,246,0.15); color: #2563eb; }
.doc-type-icon.fv { background: rgba(16,185,129,0.15); color: #059669; }
.doc-type-icon.pd { background: rgba(245,158,11,0.15); color: #d97706; }
.doc-type-icon.bv { background: rgba(99,102,241,0.15); color: #4f46e5; }
.doc-type-icon.od { background: rgba(100,116,139,0.12); color: #475569; }

.doc-type-name { font-size: 13px; font-weight: 600; text-align: center; color: var(--gray-700); }

/* ===== DROP ZONE ===== */

.drop-zone {
    border: 2px dashed var(--gray-200);
    border-radius: 16px;
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--gray-500);
    background: var(--gray-50);
}

.drop-zone:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    border-style: solid;
    transform: scale(1.01);
}

.drop-zone .drop-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 14px;
    background: var(--gray-200);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.drop-zone:hover .drop-icon { background: var(--primary); color: white; transform: translateY(-4px); }
.drop-zone .drop-icon svg { width: 24px; height: 24px; }
.drop-zone p { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.drop-zone .drop-hint { font-size: 13px; color: var(--gray-400); }
.file-input { display: none; }

.file-list { margin-top: 12px; }

.file-item {
    padding: 10px 14px;
    background: rgba(255,255,255,0.8);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInLeft 0.3s ease-out both;
}

.file-item .file-icon {
    width: 34px;
    height: 34px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-item .file-icon svg { width: 16px; height: 16px; }
.file-item .file-name { flex: 1; font-weight: 500; }
.file-item .file-size { color: var(--gray-400); font-size: 12px; }

/* ===== STATS GRID ===== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: #252d3a;
    color: white;
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    text-align: center;
    border: 1px solid #2f3848;
    box-shadow: none;
    transition: all 0.2s ease;
    animation: countUp 0.4s ease-out both;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-number { color: white; }
.stat-card .stat-label { color: rgba(255,255,255,0.5); }

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }

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

.stat-card.highlight {
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(99,91,255,0.3);
}

.stat-card.highlight .stat-number { color: white; }
.stat-card.highlight .stat-label { color: rgba(255,255,255,0.8); }

.stat-number {
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-400);
    letter-spacing: 0;
    margin-bottom:8px;
}

/* ===== CLIENT GRID ===== */

.client-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
}

.client-card {
    display: block;
    background: #252d3a;
    border: 1px solid #2f3848;
    border-radius: var(--radius-lg);
    padding: 18px;
    text-decoration: none;
    color: #d0d4dc;
    transition: all 0.2s ease;
    cursor: pointer;
}
.client-card .client-name { color:#f0f2f5; }
.client-card code { background:rgba(255,255,255,0.08); color:#a0a4ab; }

.client-card:hover {
    border-color: #3a4458;
    background: #2a3344;
}

.client-card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.client-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.client-info { flex: 1; }
.client-name { font-weight: 700; font-size: 15px; color: var(--gray-800); }
.client-info code { font-size: 12px; background: var(--gray-100); padding: 2px 8px; border-radius: 6px; }

.client-card-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.client-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-500);
}

.client-card-actions {
    border-top: 1px solid var(--gray-200);
    padding-top: 12px;
    display: flex;
    gap: 8px;
}

/* ===== DOC WIDGETS (my-documents) ===== */

.doc-widget {
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    animation: fadeInUp 0.5s ease-out both;
}

.doc-widget.fd-widget {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: rgba(59,130,246,0.15);
}

.doc-widget.fv-widget {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: rgba(16,185,129,0.15);
}

.doc-widget.pd-widget {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-color: rgba(245,158,11,0.15);
}

.doc-widget.bv-widget {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-color: rgba(99,102,241,0.15);
}

.doc-widget.od-widget {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-color: rgba(100,116,139,0.12);
}

.doc-widget h2 { margin-bottom: 16px; }

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

.widget-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    color: white;
}

.fd-widget .widget-count { background: var(--primary); }
.fv-widget .widget-count { background: var(--success); }
.pd-widget .widget-count { background: var(--warning); }
.bv-widget .widget-count { background: var(--accent); }
.od-widget .widget-count { background: var(--gray-500); }

/* ===== DOC GRID ===== */

.doc-grid { display: flex; flex-direction: column; gap: 8px; }

.doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
}

.doc-item:hover {
    background: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transform: translateX(6px);
}

.doc-item-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-item-icon svg { width: 20px; height: 20px; }

.doc-item-icon.pdf-icon { background: rgba(239,68,68,0.1); color: var(--danger); }
.doc-item-icon.img-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.doc-item-icon.default-icon { background: rgba(59,130,246,0.1); color: var(--primary); }

.doc-item-info { flex: 1; }
.doc-item-name { font-weight: 600; font-size: 14px; color: var(--gray-800); }
.doc-item-date { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.doc-item-action { color: var(--gray-400); transition: color 0.2s; }
.doc-item:hover .doc-item-action { color: var(--primary); }

/* ===== DOC BADGES ===== */

.doc-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 8px; font-size: 14px; font-weight: 700; }
.doc-badge-fd { background: rgba(59,130,246,0.1); color: #2563eb; }
.doc-badge-fv { background: rgba(16,185,129,0.1); color: #059669; }
.doc-badge-pd { background: rgba(245,158,11,0.1); color: #d97706; }
.doc-badge-bv { background: rgba(99,102,241,0.1); color: #4f46e5; }
.doc-badge-od { background: rgba(100,116,139,0.08); color: #475569; }

/* ===== SUCCESS PAGE ===== */

.success-card { text-align: center; animation: fadeInUp 0.5s ease-out; }

.success-icon {
    width: 88px;
    height: 88px;
    background: linear-gradient(135deg, var(--success), #34d399);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: bounceIn 0.6s ease-out;
    box-shadow: 0 8px 28px rgba(16,185,129,0.3);
}

.success-icon svg { width: 44px; height: 44px; color: white; }

.uploaded-files { list-style: none; margin: 20px 0; text-align: left; }

.uploaded-files li {
    padding: 12px 16px;
    background: var(--success-light);
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInLeft 0.4s ease-out both;
}

.uploaded-files li:nth-child(2) { animation-delay: 0.08s; }
.uploaded-files li:nth-child(3) { animation-delay: 0.12s; }

.uploaded-files li::before {
    content: '';
    width: 22px;
    height: 22px;
    background: var(--success);
    border-radius: 50%;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

/* ===== TABLES ===== */

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

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-400);
    border-bottom: 2px solid var(--gray-100);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 1;
}

td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

tbody tr { transition: background-color 0.15s ease; }
tbody tr:hover { background-color: #f8f9ff; }
code { background: var(--gray-100); padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--primary-dark); }

/* ===== BADGE ===== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.6;
}

.badge-success { background: var(--success-light); color: #057a4a; font-weight:500; }
.badge-primary { background: var(--primary-light); color: #4338ca; font-weight:500; }

/* ===== CHART ===== */

.chart-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding: 16px 0;
    border-bottom: 2px solid rgba(0,0,0,0.04);
}

.chart-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    max-width: 48px;
    background: var(--gradient-primary);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    position: relative;
    animation: growUp 0.6s ease-out both;
    transition: transform 0.15s ease, filter 0.15s ease;
    cursor: pointer;
}

.chart-bar:hover {
    transform: scaleY(1.05) scaleX(1.15);
    transform-origin: bottom;
    background: #DBB12A !important;
    z-index: 2;
}

.chart-bar:hover .chart-bar-value {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.chart-bar-value {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    pointer-events: none;
    white-space: nowrap;
}

.chart-bar-label { margin-top: 8px; font-size: 10px; color: var(--gray-400); white-space: nowrap; }

/* ===== SEARCH ===== */

.search-form { display: flex; gap: 12px; }

.search-input-wrap { flex: 1; position: relative; display: flex; align-items: center; }
.search-input-wrap svg { position: absolute; left: 14px; }

.search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.8);
}

.search-input:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(59,130,246,0.1); }

/* ===== MODAL ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: #252d3a;
    color: #d0d4dc;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
    border: 1px solid #2f3848;
}
.modal h3 { color:#f0f2f5; }

.modal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.duplicate-list { display: flex; flex-direction: column; gap: 6px; }

.duplicate-item {
    padding: 10px 14px;
    background: var(--warning-light);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 10px;
    font-size: 14px;
}

/* ===== LOADING ===== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-text { color: white; font-size: 16px; font-weight: 600; animation: pulse 1.5s ease-in-out infinite; }

.progress-bar { width: 200px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; margin-top: 12px; overflow: hidden; }

.progress-bar-inner {
    height: 100%;
    border-radius: 2px;
    width: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.3), white, rgba(255,255,255,0.3));
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ===== TOAST NOTIFICATIONS ===== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
    backdrop-filter: blur(12px);
    max-width: 380px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255,255,255,0.4);
    animation: toastProgress 3s linear forwards;
}

.toast.toast-hide {
    animation: toastOut 0.3s ease-in forwards;
}

.toast-success { background: linear-gradient(135deg, #10b981, #059669); }
.toast-error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast-info { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.toast-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }

.toast svg { width: 20px; height: 20px; flex-shrink: 0; }
.toast-text { flex: 1; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px) scale(0.8); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); max-height: 80px; margin-bottom: 0; }
    to { opacity: 0; transform: translateX(100px) scale(0.8); max-height: 0; margin-bottom: -10px; padding: 0; }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ===== ANIMATED COUNTERS ===== */

.stat-number {
    font-size: 30px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -1px;
    transition: transform 0.3s ease;
}

.stat-card:hover .stat-number {
    transform: scale(1.08);
}

/* ===== THUMBNAIL TOOLTIP ===== */

.thumb-tooltip {
    position: relative;
}

.thumb-tooltip .thumb-preview {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 6px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    border: 1px solid var(--gray-200);
}

.thumb-tooltip:hover .thumb-preview {
    display: block;
    animation: tooltipIn 0.25s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.thumb-preview img {
    width: 240px;
    height: auto;
    border-radius: 8px;
    display: block;
}

.thumb-preview::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: white;
}

@keyframes tooltipIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.9); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ===== COLLAPSIBLE WIDGET ===== */

.widget-header {
    cursor: pointer;
    user-select: none;
}

.widget-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.5);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.widget-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget-collapsed .widget-toggle svg {
    transform: rotate(-90deg);
}

.widget-body {
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    max-height: 2000px;
    opacity: 1;
}

.widget-collapsed .widget-body {
    max-height: 0;
    opacity: 0;
}

/* ===== SEGMENTED CONTROL ===== */

.segmented {
    display: inline-flex;
    background: var(--gray-100);
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 16px;
}

.segmented-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: transparent;
    color: var(--gray-500);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.segmented-btn:hover {
    color: var(--gray-700);
}

.segmented-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.segmented-btn .seg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
    background: var(--gray-200);
    color: var(--gray-600);
    transition: all 0.25s ease;
}

.segmented-btn.active .seg-badge {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== BADGE VARIANTS ===== */

.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* Document type color coding */
.badge-fd { background:rgba(59,130,246,0.15); color:#60a5fa; } /* Faktury došlé - blue */
.badge-fv { background:rgba(16,185,129,0.15); color:#34d399; } /* Faktury vydané - green */
.badge-pd { background:rgba(245,158,11,0.15); color:#fbbf24; } /* Pokladní doklady - amber */
.badge-bv { background:rgba(139,92,246,0.15); color:#a78bfa; } /* Bankovní výpisy - purple */
.badge-sm { background:rgba(236,72,153,0.15); color:#f472b6; } /* Smlouvy - pink */
.badge-md { background:rgba(20,184,166,0.15); color:#2dd4bf; } /* Mzdové - teal */
.badge-od { background:rgba(156,163,175,0.15); color:#9ca3af; } /* Ostatní - gray */

/* Status indicators */
.status-dot { width:8px; height:8px; border-radius:50%; display:inline-block; margin-right:4px; }
.status-dot-uploaded { background:#FF9F43; }
.status-dot-ai { background:#635BFF; }
.status-dot-reviewed { background:#00BCD4; }
.status-dot-accounted { background:#0CBF6E; }
.status-dot-rejected { background:#FF4757; }

/* Section dividers */
.section-title { font-size:11px; text-transform:uppercase; letter-spacing:0.08em; color:rgba(255,255,255,0.3); padding:16px 0 8px; border-top:1px solid rgba(255,255,255,0.06); margin-top:16px; }
.section-title:first-child { border-top:none; margin-top:0; }

/* Correction highlights */
.field-corrected { background:rgba(219,177,42,0.1); border-left:3px solid #DBB12A; padding-left:8px; border-radius:0 6px 6px 0; }
.field-original { color:#FF4757; text-decoration:line-through; font-size:12px; opacity:0.7; }
.field-new { color:#0CBF6E; font-weight:600; }

/* Body scroll lock when modal/panel is open */
body.no-scroll { overflow:hidden !important; }
body.no-scroll .main-content { overflow:hidden !important; }

/* Center page-content */
.page-content { max-width:1200px; }

/* ===== RESPONSIVE ===== */

@media (max-width: 640px) {
    .container { padding: 16px; }
    .card, .doc-widget { padding: 20px; }
    .form-row { flex-direction: column; }
    .doc-type-grid { grid-template-columns: repeat(2, 1fr); }
    .header { flex-direction: column; gap: 12px; text-align: center; }
    .user-info { flex-wrap: wrap; justify-content: center; }
    h1 { font-size: 20px; }
    .client-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-actions { flex-direction: column; }
    .search-form { flex-direction: column; }
}
