/* ============================================
   MIKISI DESIGN SYSTEM - Dashboard CSS
   ============================================ */

/* CSS Variables */
:root {
    /* Brand Colors */
    --blue-top: #3498C1;
    --blue-bottom: #1B4B7A;
    --orange-top: #F26522;
    --orange-bottom: #E85A1B;
    
    /* UI Colors */
    --bg: #F7F9FC;
    --bg-light: #F2F5F8;
    --card: #FFFFFF;
    --border: #E8ECF1;
    --border-light: #F2F5F8;

    /* Aliases for compatibility */
    --primary: #1B4B7A;
    --primary-dark: #153d63;
    --secondary: #F26522;
    --secondary-dark: #d9551a;
    
    /* Text */
    --text-dark: #1A1A1A;
    --text-medium: #64748B;
    --text-light: #94A3B8;
    
    /* Status Colors */
    --green: #10B981;
    --green-bg: #D1FAE5;
    --green-text: #047857;
    --yellow: #F59E0B;
    --yellow-bg: #FEF3C7;
    --yellow-text: #B45309;
    --blue-status: #3B82F6;
    --blue-status-bg: #DBEAFE;
    --blue-status-text: #1D4ED8;
    --red: #EF4444;
    --red-bg: #FEE2E2;
    --red-text: #B91C1C;
    --gray-bg: #F1F5F9;
    --gray-text: #475569;
    
    /* Fonts */
    --font-display: 'Montserrat', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    
    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text-dark); min-height: 100vh; line-height: 1.5; }

/* ============================================
   HEADER / NAVIGATION
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
    height: 72px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(27, 75, 122, 0.15);
}

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

.logo { display: flex; align-items: center; text-decoration: none; }
.logo-img { height: 44px; width: auto; }
.logo-text { 
    font-family: var(--font-display); 
    font-size: 1.5rem; 
    font-weight: 700; 
    color: white; 
    text-decoration: none;
}

.nav { display: flex; gap: 4px; }
.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-link.active { color: white; background: rgba(255,255,255,0.2); font-weight: 600; }

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 16px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-full);
}
.user-name { font-size: 0.875rem; font-weight: 500; color: white; }
.user-company { font-size: 0.75rem; color: rgba(255,255,255,0.7); }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange-top), var(--orange-bottom));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    border: 2px solid rgba(255,255,255,0.3);
}

.header .btn-ghost {
    color: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.3);
    background: transparent;
}
.header .btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--orange-top), var(--orange-bottom));
    color: white;
    box-shadow: 0 2px 8px rgba(242, 101, 34, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(242, 101, 34, 0.35); }
.btn-primary:active { transform: translateY(0); }

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

.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #059669; }

.btn-warning { background: var(--yellow); color: white; }
.btn-warning:hover { background: #D97706; }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-ghost {
    background: transparent;
    color: var(--text-medium);
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-dark); }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-medium);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text-dark); }
.btn-icon svg { width: 18px; height: 18px; }

/* ============================================
   MAIN LAYOUT
   ============================================ */
.main { max-width: 1400px; margin: 0 auto; padding: 32px; }

.dashboard-grid {
    display: grid !important;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    align-items: start;
}

/* ============================================
   UPLOAD ZONE
   ============================================ */
.upload-zone {
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    margin-bottom: 32px;
    transition: all 0.2s ease;
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--blue-bottom);
    background: rgba(27, 75, 122, 0.02);
}
.upload-zone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--blue-bottom);
}
.upload-zone-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
}
.upload-zone-subtitle { color: var(--text-medium); font-size: 0.9375rem; }
.upload-zone-subtitle span { color: var(--orange-top); font-weight: 500; cursor: pointer; }
.upload-zone-formats { font-size: 0.8125rem; color: var(--text-light); margin-top: 16px; }

/* Upload Progress */
.upload-progress {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-top: 16px;
}
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-top), var(--orange-top));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}
.progress-text { font-size: 0.875rem; color: var(--text-medium); }

/* ============================================
   MODERN PROGRESS TOAST
   ============================================ */
.progress-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 9999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.progress-toast.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.progress-toast-content {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 4px 24px rgba(27, 75, 122, 0.15),
        0 8px 48px rgba(242, 101, 34, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 16px 24px;
    min-width: 320px;
    max-width: 480px;
}

.progress-toast-spinner {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(52, 152, 193, 0.3);
    position: relative;
}

.progress-toast-spinner svg {
    width: 24px;
    height: 24px;
    stroke: white;
    position: absolute;
    transition: opacity 0.3s, transform 0.3s;
}

.progress-toast-spinner .spinner-icon {
    animation: spin 1.2s linear infinite;
    opacity: 1;
}

.progress-toast-spinner .check-icon {
    opacity: 0;
    transform: scale(0.5);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.progress-toast-info {
    flex: 1;
    min-width: 0;
}

.progress-toast-text {
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-toast-bar {
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-toast-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-top), var(--orange-top));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    position: relative;
}

.progress-toast-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-toast-percent {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--blue-bottom), var(--orange-top));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 48px;
    text-align: right;
}

/* Success state */
.progress-toast.success .progress-toast-spinner {
    background: linear-gradient(135deg, #10B981, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.progress-toast.success .progress-toast-spinner .spinner-icon {
    opacity: 0;
    animation: none;
    transform: scale(0.5);
}

.progress-toast.success .progress-toast-spinner .check-icon {
    opacity: 1;
    transform: scale(1);
}

.progress-toast.success .progress-toast-fill {
    background: linear-gradient(90deg, #10B981, #059669);
}

.progress-toast.success .progress-toast-fill::after {
    animation: none;
}

.progress-toast.success .progress-toast-percent {
    background: linear-gradient(135deg, #059669, #10B981);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Cancel button in progress toast */
.progress-toast-cancel {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.progress-toast-cancel:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
}

.progress-toast-cancel:active {
    transform: scale(0.95);
}

.progress-toast-cancel svg {
    width: 16px;
    height: 16px;
}

/* Show cancel button when batch extraction is active */
.progress-toast.batch-active .progress-toast-cancel {
    display: flex;
}

/* Hide cancel button on success */
.progress-toast.success .progress-toast-cancel {
    display: none;
}

/* Progress toast mobile */
@media (max-width: 480px) {
    .progress-toast {
        width: calc(100% - 32px);
        max-width: none;
    }
    .progress-toast-content {
        min-width: auto;
        width: 100%;
        padding: 12px 16px;
        gap: 12px;
    }
    .progress-toast-spinner {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
    .progress-toast-spinner svg {
        width: 20px;
        height: 20px;
    }
    .progress-toast-text {
        font-size: 0.875rem;
        margin-bottom: 6px;
    }
    .progress-toast-percent {
        font-size: 1rem;
        min-width: 40px;
    }
}

/* ============================================
   VALIDATION MODAL
   ============================================ */
#validation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#validation-modal.visible {
    opacity: 1;
    visibility: visible;
}

#validation-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.validation-modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

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

.validation-modal-content h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    margin: 0;
}

.validation-summary {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
}

.validation-summary .valid-count {
    color: var(--green-text);
    background: var(--green-bg);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
}

.validation-summary .invalid-count {
    color: var(--red-text);
    background: var(--red-bg);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
}

.validation-summary .warning-count {
    color: var(--yellow-text);
    background: var(--yellow-bg);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
}

.validation-errors-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    max-height: 400px;
}

.validation-doc-error,
.validation-doc-warning {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}

.validation-doc-error {
    border-left: 3px solid var(--red);
}

.validation-doc-warning {
    border-left: 3px solid var(--yellow);
}

.validation-doc-error:last-child,
.validation-doc-warning:last-child {
    margin-bottom: 0;
}

.validation-info-box {
    background: var(--yellow-bg);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 0 24px 16px 24px;
}

.validation-info-box p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--yellow-text);
}

.validation-summary .info-text {
    color: var(--text-medium);
    font-size: 0.875rem;
}

.validation-doc-error .doc-header,
.validation-doc-warning .doc-header {
    margin-bottom: 10px;
    font-size: 0.9375rem;
}

.error-list,
.warning-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.error-item {
    color: var(--red-text);
    font-size: 0.875rem;
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
}

.error-item::before {
    content: "✕";
    position: absolute;
    left: 0;
    color: var(--red);
    font-weight: bold;
}

.warning-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.warning-item {
    color: var(--yellow-text);
    font-size: 0.8125rem;
    padding: 3px 0;
    padding-left: 20px;
    position: relative;
}

.warning-item::before {
    content: "⚠";
    position: absolute;
    left: 0;
    color: var(--yellow);
}

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

.validation-actions .btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.validation-actions .btn-primary {
    background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
    color: white;
}

.validation-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 193, 0.3);
}

.validation-actions .btn-secondary {
    background: var(--gray-bg);
    color: var(--text-dark);
}

.validation-actions .btn-secondary:hover {
    background: var(--border);
}

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

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

.card-title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-dark);
}
.card-subtitle { font-size: 0.8125rem; color: var(--text-light); margin-top: 2px; }

.card-body { padding: 24px; }

/* ============================================
   STATS CARDS
   ============================================ */
.stats-grid {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    cursor: pointer;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg {
    width: 24px;
    height: 24px;
}
.stat-icon.blue { background: var(--blue-status-bg); }
.stat-icon.blue svg { stroke: var(--blue-status-text); }
.stat-icon.orange { background: #FFF7ED; }
.stat-icon.orange svg { stroke: var(--orange-top); }
.stat-icon.green { background: var(--green-bg); }
.stat-icon.green svg { stroke: var(--green-text); }
.stat-icon.yellow { background: var(--yellow-bg); }
.stat-icon.yellow svg { stroke: var(--yellow-text); }
.stat-icon.gray { background: var(--gray-bg); }
.stat-icon.gray svg { stroke: var(--gray-text); }

.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
}
.stat-label { font-size: 0.8125rem; color: var(--text-medium); margin-top: 4px; }

/* Colored stat cards for sidebar */
.stat-card-colored {
    border-radius: var(--radius-md);
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.stat-card-colored::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
}
.stat-card-colored.blue { background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom)); }
.stat-card-colored.orange { background: linear-gradient(135deg, var(--orange-top), var(--orange-bottom)); }
.stat-card-colored.dark { background: linear-gradient(135deg, #475569, #1E293B); }

.stat-card-colored .stat-label { 
    font-family: var(--font-display);
    font-size: 0.875rem; 
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    margin-bottom: 8px; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card-colored .stat-value { 
    font-family: var(--font-display);
    font-size: 2.5rem; 
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.15);
    line-height: 1;
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.toolbar-group { display: flex; gap: 8px; align-items: center; }

.toolbar-search {
    flex: 1;
    min-width: 200px;
    position: relative;
}
.toolbar-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-light);
}
.search-input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    transition: all 0.15s;
}
.search-input:focus {
    outline: none;
    border-color: var(--blue-bottom);
    box-shadow: 0 0 0 3px rgba(27, 75, 122, 0.1);
}
.search-input::placeholder { color: var(--text-light); }

.select-input {
    padding: 10px 32px 10px 12px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card) 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='%2364748B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    cursor: pointer;
}

/* Segmented Control */
.segmented {
    display: inline-flex;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 4px;
    border-radius: var(--radius-sm);
    gap: 4px;
}
.segmented-btn {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-medium);
    cursor: pointer;
    transition: all 0.15s ease;
}
.segmented-btn:hover { color: var(--text-dark); }
.segmented-btn.active {
    background: var(--blue-bottom);
    color: white;
}

/* ============================================
   BULK ACTIONS BAR
   ============================================ */
.bulk-actions {
    display: none;
    position: sticky;
    top: 80px;
    z-index: 100;
    background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-lg);
}
.bulk-actions.visible { display: flex; }

.bulk-actions .selected-info { font-weight: 600; font-size: 0.875rem; }

.bulk-actions .btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 8px 14px;
    font-size: 0.8125rem;
}
.bulk-actions .btn:hover { background: rgba(255,255,255,0.25); }

/* Nabídka výběru přes všechny stránky (22. 9. 2026): „Vybrat vše“ vybere jen stránku,
   rozšíření na všechny doklady dle filtru je druhý, vědomý klik na tuto lištu. */
.select-all-banner {
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--yellow-bg);
    border: 1px solid #F0D27A;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-dark);
    line-height: 1.5;
}
.select-all-banner button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--blue-bottom);
    text-decoration: underline;
    cursor: pointer;
}
.select-all-banner button:hover { color: var(--blue-top); }

/* ============================================
   DOCUMENTS TABLE
   ============================================ */
.documents-list { display: flex; flex-direction: column; }

.document-row {
    display: grid !important;
    /* Řádek má vedle postranního panelu (340 px) reálně jen 725–925 px, takže
       počet sloupců je pevně daný rozpočet. Proto se 16. 8. 2026 „Zpracoval"
       sloučil do sloupce s účetní jednotkou jako druhý řádek — patří k sobě
       (za koho / kdo) a ušetřený sloupec vrátil místo prvnímu sloupci, který
       byl po přidání jednotky nečitelný.
       `minmax(0, …)` je u pružných sloupců schválně: bez něj má sloupec spodní
       hranici podle obsahu a dlouhý název ho roztáhne. Dokument má skoro
       dvojnásobný podíl proti jednotce.
       Šířky pevných sloupců jsou spočítané z obsahu, ne odhadem: Stav musí pobrat
       nejdelší odznak „EXPORTOVÁNO" (verzálky 11 px + prostrkání ≈ 100 px i s
       odsazením), Akce pět ikon po 26 px s mezerami. */
    grid-template-columns: 26px minmax(0, 1.9fr) minmax(0, 1.1fr) 84px 74px 102px 104px 140px;
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}
/* Buňky se nesmí bránit zúžení. Položka gridu má implicitně `min-width: auto`,
   takže dlouhá částka („29 727,40 Kč") nebo široký odznak „EXPORTOVÁNO" roztáhly
   svůj sloupec JEN ve svém řádku — a protože každý řádek je vlastní grid, rozešly
   se řádky navzájem i proti hlavičce (hlášeno 16. 8. 2026). */
.document-row > * { min-width: 0; }

.document-row:hover { background: rgba(247, 249, 252, 0.7); }
.document-row.archived { opacity: 0.6; background: var(--gray-bg); }

.document-row-header {
    background: var(--bg);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.document-row-header:hover { background: var(--bg); }

/* Popisky v hlavičce se řídí stejnými pravidly jako buňky pod nimi. Bez toho
   dlouhé „ÚČETNÍ JEDNOTKA" (verzálky + prostrkání) přeteklo do sousedního
   sloupce, zatímco data se pod ním poslušně ořezávala (hlášeno 16. 8. 2026).
   Celý název je dostupný v titulku buňky. */
.document-row-header > div {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--blue-bottom);
}

.doc-main { display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0; }
.doc-number {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-number:hover { color: var(--blue-bottom); }
.doc-supplier { font-size: 0.75rem; color: var(--text-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Účetní jednotka. Na širokém displeji vlastní sloupec, na mobilu se sloupec
   skrývá a název se vrací drobným písmem vedle dodavatele — proto ta dvě
   zobrazení: .doc-unit-cell (sloupec) a .doc-unit-inline (v řádku). */
.doc-unit-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.doc-unit-name {
    font-size: 0.8125rem;
    color: var(--text-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Kdo doklad nahrál (dřív samostatný sloupec „Zpracoval") */
.doc-unit-by {
    font-size: 0.6875rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-unit-link { cursor: pointer; }
.doc-unit-link:hover { color: var(--blue-bottom); text-decoration: underline; }
.doc-unit-none { color: var(--text-light); font-style: italic; }
.doc-unit-inline { display: none; }

.doc-date { font-size: 0.8125rem; color: var(--text-medium); white-space: nowrap; }

.doc-amount {
    font-weight: 600;
    font-feature-settings: 'tnum';
    color: var(--text-dark);
    font-size: 0.875rem;
    text-align: right;
    white-space: nowrap;
    /* Sloupec je dimenzovaný na běžné částky; výjimečně dlouhá se radši ořízne,
       než aby přelezla do sousedního sloupce. */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Odznak stavu se do své buňky vejde vždycky — buňka ho nesmí přerůst.
   Odsazení je v řádku o dva pixely na stranu menší než u odznaků jinde: ušetřené
   místo je přesně to, co „EXPORTOVÁNO" chybělo k poslednímu písmenu. */
.doc-status { overflow: hidden; }
.doc-status .badge { max-width: 100%; padding: 4px 8px; }

.doc-type {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dobropis (opravný daňový doklad) - příznak vedle typu dokladu */
/* Číslo z exportu vedle čísla dokladu (Ekonom pro lidi, 31.8.2026) */
.doc-evidence {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-medium);
    background: var(--bg-light, #f1f5f9);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 4px;
}

.doc-credit-note {
    color: var(--yellow-text);
    font-weight: 600;
}

/* Štítky DOBROPIS / RCH v přehledu (feedback #44 Ekonom pro lidi, 4. 9. 2026):
   účetní si příznaku před exportem nevšimla, malé žluté slovo nestačilo. */
.doc-flags {
    white-space: normal;
    margin-top: 2px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.doc-flag {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid transparent;
}
.doc-flag-credit {
    background: var(--yellow-bg);
    color: var(--yellow-text);
    border-color: var(--yellow-text);
}
.doc-flag-rch {
    background: var(--blue-status-bg);
    color: var(--blue-status-text);
    border-color: var(--blue-status-text);
}

/* Varování z extrakce v detailu dokladu — dřív se ukázalo jen v hlášce po jednotlivé
   extrakci a u dávek nikdy (feedback #44). */
.detail-warning {
    background: var(--yellow-bg);
    color: var(--yellow-text);
    border-left: 4px solid var(--yellow-text);
    padding: 8px 12px;
    margin: 0 0 12px 0;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.doc-processed {
    font-size: 0.75rem;
    color: var(--text-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ikon může být až pět (dva exportní + archiv, smazat, detail). Při 30 px se
   nevešly a přetékaly doleva přes sloupec Stav; 26 px je pořád pohodlný cíl a
   na dotykových displejích je přebíjí pravidlo min-width 40 px níže. */
.doc-actions { display: flex; gap: 3px; justify-content: flex-end; flex-wrap: nowrap; }
.doc-actions .btn-icon { width: 26px; height: 26px; padding: 0; }
.doc-actions .btn-icon svg { width: 15px; height: 15px; }

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-blue { background: var(--blue-status-bg); color: var(--blue-status-text); }
.badge-gray { background: var(--gray-bg); color: var(--gray-text); }
.badge-red { background: var(--red-bg); color: var(--red-text); }

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
}
.pagination-info { font-size: 0.8125rem; color: var(--text-medium); }
.pagination-buttons { display: flex; gap: 4px; }

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text-medium);
    cursor: pointer;
    transition: all 0.15s;
}
.page-btn:hover { background: var(--bg); color: var(--text-dark); }
.page-btn.active { background: var(--blue-bottom); border-color: var(--blue-bottom); color: white; }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar { display: flex; flex-direction: column; gap: 20px; }

.quick-actions {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.quick-actions-title {
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.quick-actions-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px; }

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body);
}
.quick-action-btn:hover { background: var(--border-light); transform: translateY(-1px); }
.quick-action-btn svg { width: 24px; height: 24px; color: var(--blue-bottom); }
.quick-action-btn span { font-size: 0.75rem; font-weight: 500; color: var(--text-medium); }

/* Activity Chart */
.activity-card {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.activity-title { font-size: 0.875rem; font-weight: 600; margin-bottom: 16px; }

.chart { display: flex; align-items: flex-end; height: 80px; gap: 8px; }
.chart-bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    transition: all 0.2s ease;
    cursor: pointer;
}
.chart-bar:hover { filter: brightness(1.1); transform: scaleY(1.05); transform-origin: bottom; }
.chart-bar.blue { background: linear-gradient(180deg, var(--blue-top), var(--blue-bottom)); }
.chart-bar.orange { background: linear-gradient(180deg, var(--orange-top), var(--orange-bottom)); }

.chart-labels { display: flex; margin-top: 8px; }
.chart-label { flex: 1; font-size: 0.625rem; color: var(--text-light); text-align: center; }

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}
.modal.visible { display: flex; }

.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    z-index: 10;
}
.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}
.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text-dark); }

.modal-body { padding: 24px; }

/* Detail Tables */
.detail-section { margin-bottom: 24px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h3 {
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th {
    text-align: left;
    padding: 8px 12px;
    width: 40%;
    color: var(--text-medium);
    font-weight: 500;
    font-size: 0.875rem;
    background: var(--bg);
}
.detail-table td { padding: 8px 12px; font-size: 0.875rem; }
.detail-table tr { border-bottom: 1px solid var(--border-light); }
.detail-table tr:last-child { border-bottom: none; }

.items-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.items-table th {
    background: var(--bg);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-medium);
}
.items-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); }
.items-table tbody tr:last-child td { border-bottom: none; }

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */
.loading { text-align: center; padding: 48px; }
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--blue-bottom);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-medium); font-size: 0.875rem; }

.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon { margin-bottom: 16px; color: var(--text-light); }
.empty-icon svg { width: 64px; height: 64px; stroke: var(--text-light); }
.empty-state h3 { font-family: var(--font-display); font-size: 1.125rem; margin-bottom: 8px; }
.empty-state p { color: var(--text-medium); }

/* ============================================
   ONBOARDING OVERLAY
   ============================================ */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.onboarding-modal {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: onboardingSlideIn 0.3s ease;
}

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

.onboarding-header {
    background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
    color: white;
    padding: 32px;
    text-align: center;
}

.onboarding-logo {
    height: 40px;
    margin-bottom: 16px;
    filter: brightness(0) invert(1);
}

.onboarding-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.onboarding-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.onboarding-steps {
    padding: 32px;
}

.onboarding-step {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.onboarding-step:last-child {
    margin-bottom: 0;
}

.onboarding-step-number {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange-top), var(--orange-bottom));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.onboarding-step-content h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-dark);
}

.onboarding-step-content p {
    color: var(--text-medium);
    font-size: 0.9rem;
    line-height: 1.5;
}

.onboarding-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.onboarding-skip {
    color: var(--text-medium);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 16px;
}

.onboarding-skip:hover {
    color: var(--text-dark);
}

.onboarding-start {
    background: linear-gradient(135deg, var(--orange-top), var(--orange-bottom));
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: transform 0.15s, box-shadow 0.15s;
}

.onboarding-start:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(242, 101, 34, 0.3);
}

.onboarding-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-medium);
}

.onboarding-checkbox input {
    accent-color: var(--orange-top);
}

/* Enhanced empty state */
.empty-state-enhanced {
    text-align: center;
    padding: 48px 24px;
    max-width: 500px;
    margin: 0 auto;
}

.empty-state-enhanced .empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, rgba(52, 152, 193, 0.1), rgba(27, 75, 122, 0.1));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-enhanced .empty-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--blue-top);
}

.empty-state-enhanced h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.empty-state-enhanced p {
    color: var(--text-medium);
    margin-bottom: 24px;
    line-height: 1.6;
}

.empty-state-enhanced .btn-upload {
    background: linear-gradient(135deg, var(--orange-top), var(--orange-bottom));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.empty-state-enhanced .btn-upload:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(242, 101, 34, 0.3);
}

.empty-state-enhanced .btn-upload svg {
    width: 20px;
    height: 20px;
}

.empty-state-tips {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: left;
}

.empty-state-tips h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.empty-state-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.empty-state-tips li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-medium);
    margin-bottom: 8px;
}

.empty-state-tips li svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    stroke: var(--green);
    margin-top: 2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
/* Nejtěsnější případ vůbec: okno 1201–1340 px, kde vedle seznamu ještě stojí
   postranní panel (340 px), takže na řádek zbývá jen ~725–865 px. Pod 1201 px se
   panel skládá pod seznam a místa je zase dost. Typ dokladu tady ustoupí — dá se
   filtrovat v liště a je vidět v detailu, kdežto číslo a dodavatel jsou to hlavní. */
@media (min-width: 1201px) and (max-width: 1340px) {
    .document-row {
        grid-template-columns: 26px minmax(0, 1.9fr) minmax(0, 1.1fr) 74px 102px 104px 140px;
    }
    .document-row .doc-type,
    .document-row-header > div:nth-child(4) { display: none; }
}

@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .sidebar { 
        display: grid !important; 
        grid-template-columns: repeat(3, 1fr); 
        gap: 16px; 
    }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .document-row {
        grid-template-columns: 40px 1fr 100px;
        gap: 12px;
    }
    .document-row .doc-type,
    .document-row .doc-date,
    .document-row .doc-unit-cell,
    .document-row .doc-amount { display: none; }
    /* Sloupec Klient se nevejde → jméno se vrací vedle dodavatele */
    .doc-unit-inline { display: inline; }
    /* Hlavička má popisky i pro skryté sloupce, takže se na mobilu lámala do tří
       řádků pod sebe. Ve třísloupcovém rozvržení stejně nic nepopisuje. */
    .document-row-header { display: none !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar { grid-template-columns: 1fr 1fr !important; }
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.mobile-menu-btn:hover { background: var(--bg-light); }
.mobile-menu-btn svg { width: 24px; height: 24px; stroke: var(--text-dark); }

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 104;
}
.mobile-menu-overlay.active { display: block; }
.mobile-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: white;
    z-index: 105;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    overflow-y: auto;
}
.mobile-menu.active { right: 0; }
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
}
.mobile-menu-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.mobile-menu-close:hover { background: var(--bg-light); }
.mobile-menu-close svg { width: 24px; height: 24px; stroke: var(--text-dark); }
.mobile-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    text-decoration: none;
    border-radius: var(--radius-sm);
}
.mobile-menu a:hover { background: var(--bg-light); }
.mobile-menu a.active { background: rgba(27, 75, 122, 0.08); color: var(--blue-bottom); }
.mobile-menu a.active svg { stroke: var(--blue-bottom); }
.mobile-menu a svg { width: 20px; height: 20px; stroke: var(--text-medium); }
.mobile-menu-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}
.mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
}
.mobile-menu-user .avatar { width: 40px; height: 40px; font-size: 1rem; }
.mobile-menu-user-info { flex: 1; }
.mobile-menu-user-email { font-weight: 500; font-size: 0.9375rem; }
.mobile-menu-user-company { font-size: 0.8125rem; color: var(--text-medium); }

@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .header { padding: 0 16px; height: 64px; }
    .header-left { gap: 12px; }
    .nav { display: none; }
    .logo-img { height: 36px; }
    .header-right .btn span { display: none; }
    .header-right .btn svg { margin: 0; }
    .user-info { display: none; }
    /* Spodní padding kvůli plovoucímu tlačítku foťáku */
    .main { padding: 16px 16px 96px; }
    .upload-zone { padding: 32px 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .sidebar { grid-template-columns: 1fr; }
    /* Toolbar jako kompaktní 2sloupcový grid místo dlouhého sloupce */
    .toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
    }
    .toolbar-search { grid-column: 1 / -1; width: 100%; }
    .toolbar-group { width: 100%; }
    .toolbar-group .select-input { flex: 1; width: 100%; min-width: 0; }
    /* 16px font zabrání iOS Safari přiblížení při fokusu, 44px = dotykový cíl */
    .select-input, .search-input, #default-document-type {
        font-size: 16px !important;
        min-height: 44px;
    }
    .default-type-selector { flex-wrap: wrap; }
    .default-type-selector select { flex: 1; min-width: 0; }
    /* Ikonová tlačítka akcí v řádku dokumentu — dotykový cíl */
    .doc-actions .btn-icon {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .document-row {
        grid-template-columns: 32px 1fr auto;
        padding: 12px 16px;
    }
    .bulk-actions { flex-direction: column; align-items: stretch; text-align: center; }
}

@media (max-width: 480px) {
    .stat-card { padding: 16px; gap: 12px; }
    .stat-value { font-size: 1.5rem; }
    .segmented { width: 100%; }
    .segmented-btn { flex: 1; text-align: center; }
}

/* Draggable Modals */
.draggable-modal {
  pointer-events: none;
}

.draggable-modal.visible {
  display: flex;
  background: transparent;
}

.draggable-modal .modal-content {
  pointer-events: auto;
  position: absolute;
  margin: 0;
  cursor: default;
  max-height: 90vh;
  overflow: hidden;
  resize: both;
}

.draggable-modal .drag-handle {
  cursor: move;
  user-select: none;
}

.draggable-modal .modal-body {
  overflow: auto;
  max-height: calc(90vh - 60px);
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

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

/* Side by side positioning */
#document-modal.draggable-modal .modal-content {
  left: 1%;
  top: 5%;
  width: 48%;
}

#original-modal .modal-content {
  right: 1%;
  left: auto;
  top: 5%;
  width: 48%;
}

#original-image {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Fix: oba modaly viditelné současně */
.modal.draggable-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent !important;
  pointer-events: none;
  z-index: 1000;
}

.modal.draggable-modal.visible {
  display: block !important;
}

#document-modal.draggable-modal {
  z-index: 1001;
}

#original-modal.draggable-modal {
  z-index: 1002;
}

.modal.draggable-modal .modal-content {
  pointer-events: auto;
  position: fixed;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  border: 1px solid var(--border);
}

/* Lepší tlačítka v modal header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-actions .btn {
  padding: 8px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-download {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-download:hover {
  background: var(--primary-dark, #15405f);
}

.btn-zoom {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
}

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

/* Zoom container - see FINAL section at end of file */

/* Zoom controls */
.zoom-controls {
  position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 360px);
    max-width: 900px;
  top: 0;
  background: white;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: center;
  z-index: 10;
}

.zoom-level {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-medium);
}

/* ============================================
   FIX: Modal z-index a tlačítka design
   ============================================ */

/* Document modal musí být viditelný */
#document-modal.visible {
  display: flex !important;
  z-index: 1001 !important;
}

#document-modal .modal-content {
  background: white;
  z-index: 1002;
}

/* Original modal nad document modal */
#original-modal.visible {
  display: block !important;
  z-index: 1003 !important;
}

#original-modal .modal-content {
  z-index: 1004;
  background: white;
}

/* Tlačítka v našem designu - navy/orange */
.btn-zoom {
  background: var(--bg-light, #f5f5f5);
  color: var(--primary, #1a4f6e);
  border: 2px solid var(--primary, #1a4f6e);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  min-width: 40px;
  transition: all 0.2s;
}

.btn-zoom:hover {
  background: var(--primary, #1a4f6e);
  color: white;
}

.btn-download {
  background: var(--secondary, #e85a1e);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-download:hover {
  background: var(--secondary-dark, #d04a0e);
  transform: translateY(-1px);
}

#zoom-level {
  font-weight: 600;
  color: var(--primary, #1a4f6e);
  min-width: 55px;
}

/* Original container - see FINAL section at end of file */

/* ============================================
   ORIGINAL MODAL - FINAL FIX
   ============================================ */

/* Oba modaly vedle sebe */
#document-modal.visible {
  display: flex !important;
}

#document-modal.visible .modal-content {
  position: fixed;
  left: 1%;
  top: 5%;
  width: 48%;
  max-width: none;
  max-height: 90vh;
  margin: 0;
}

#original-modal.visible {
  display: flex !important;
  background: rgba(0,0,0,0.1) !important;
}

#original-modal .modal-content,
#original-modal-content {
  position: fixed;
  right: 1%;
  left: auto;
  top: 5%;
  width: 48%;
  max-width: none;
  max-height: 90vh;
  margin: 0;
}

/* Zoom label */
.zoom-label {
  padding: 0 12px;
  min-width: 55px;
  text-align: center;
  font-weight: 600;
  color: var(--primary);
}

/* Tlačítka v modal-actions - konzistentní velikost */
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-actions .btn-sm {
  padding: 6px 12px;
  font-size: 14px;
  min-height: 32px;
}

.modal-actions .btn-outline {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  font-weight: 600;
  font-size: 16px;
  min-width: 32px;
  padding: 4px 10px;
}

.modal-actions .btn-outline:hover {
  background: var(--primary);
  color: white;
}

/* Original container - see FINAL section at end of file */

/* ============================================
   DUAL MODAL FIX - oba viditelné vedle sebe
   ============================================ */

#original-modal {
  background: transparent !important;
  pointer-events: none;
}

#original-modal.visible {
  display: flex !important;
}



/* Přetahování - kurzor na headeru */
#document-modal .modal-header,
#original-modal .modal-header {
  cursor: move;
  user-select: none;
}

/* ============================================
   FINAL FIX - dual modal bez blur
   ============================================ */

/* Document modal - když je original otevřený, žádný blur */
body.dual-modal #document-modal.visible {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
}



/* Original modal - bez overlay */
#original-modal {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
}

#original-modal.visible .modal-content {
  pointer-events: auto;
}

/* Modal positioning - bez fixed pozic pro drag */
#document-modal .modal-content,
#original-modal .modal-content {
  position: fixed;
  max-height: 90vh;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  cursor: move;
}

/* Fix pro rotovaný obrázek - see FINAL section */

/* ============================================
   FINAL: Original modal - scroll a zoom fix
   ============================================ */

/* Modaly vždy vedle sebe - nikdy se nepřekrývají */
#document-modal.visible .modal-content {
  left: 0.5% !important;
  width: 49% !important;
  max-width: 49% !important;
}

#original-modal .modal-content,
#original-modal-content {
  right: 0.5% !important;
  left: auto !important;
  width: 49% !important;
  max-width: 49% !important;
}

/* Original modal - scroll POUZE na modal-body */
#original-modal .modal-content,
#original-modal-content {
  overflow: hidden !important;
}

#original-modal .modal-body {
  overflow: auto !important;
  max-height: calc(90vh - 100px) !important;
  min-height: 200px;
  padding: 10px !important;
}

/* Container - žádný scroll */
#original-container {
  display: inline-block !important;
  overflow: visible !important;
}

#original-container img {
  display: block !important;
}

/* ============================================
   INLINE EDIT STYLES
   ============================================ */
.editable {
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.editable:hover {
  background: var(--bg-light, #f5f5f5);
}

.editable:hover::after {
  content: '✏️';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.5;
}

.inline-edit-input {
  width: 100%;
  padding: 4px 8px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  font-size: inherit;
  font-family: inherit;
  box-sizing: border-box;
}

.inline-edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 79, 110, 0.2);
}

.edit-success {
  animation: successFlash 0.5s;
}

.edit-error {
  animation: errorFlash 0.5s;
}

@keyframes successFlash {
  0%, 100% { background: transparent; }
  50% { background: rgba(40, 167, 69, 0.2); }
}

@keyframes errorFlash {
  0%, 100% { background: transparent; }
  50% { background: rgba(220, 53, 69, 0.2); }
}

.editable-vat {
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.editable-vat:hover {
  background: var(--bg-light, #f5f5f5);
}

.editable-vat:hover::after {
  content: '✏️';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.5;
}

.editable-item {
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.editable-item:hover {
  background: var(--bg-light, #f5f5f5);
}

.editable-item:hover::after {
  content: '✏️';
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.5;
}

.items-table .editable-item {
  min-width: 60px;
}

.items-table td:first-child.editable-item {
  min-width: 150px;
}

/* ============================================
   ARCHIVE TREE STYLES
   Přidej na konec /data/mikisi/frontend/css/dashboard.css
   ============================================ */

/* Breadcrumb navigace */
.archive-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    color: var(--text);
}

.breadcrumb-link {
    color: var(--primary);
    cursor: pointer;
    transition: color 0.15s;
}

.breadcrumb-link:hover {
    color: var(--secondary);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-light);
    margin: 0 4px;
}

.documents-breadcrumb {
    margin-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

/* Archive Tree Container */
.archive-tree {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 0;
    margin-top: 16px;
}

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

.archive-tree-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.archive-tree-filters {
    display: flex;
    gap: 12px;
}

.archive-tree-content {
    padding: 0;
}

/* Folder styles - společné pro jednotky, roky i měsíce */
.archive-unit-folder,
.archive-year-folder,
.archive-month-folder {
    border-bottom: 1px solid var(--border);
}

.archive-unit-folder:last-child,
.archive-year-folder:last-child,
.archive-month-folder:last-child {
    border-bottom: none;
}

.archive-folder-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.15s;
    gap: 12px;
}

.archive-folder-header:hover {
    background: var(--bg);
}

.archive-toggle {
    font-size: 10px;
    color: var(--text-medium);
    width: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.archive-folder-icon {
    font-size: 18px;
}

.archive-folder-label {
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.archive-count {
    font-size: 13px;
    color: var(--text-medium);
    min-width: 70px;
}

.archive-amount {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    min-width: 120px;
    text-align: right;
}

/* Archive Actions */
.archive-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    background: var(--bg-light);
}

/* Empty Archive State */
.empty-archive {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-medium);
}

.empty-archive svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-archive p {
    margin: 0;
    font-size: 14px;
}

/* Unit indicator in document list */
.doc-unit {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 400;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .archive-folder-header {
        padding: 10px 12px;
    }
    
    .archive-amount {
        display: none;
    }
    
    .archive-tree-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .archive-breadcrumb {
        padding: 10px 12px;
    }
}

/* Tlačítka s ikonami */
.btn svg {
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Sticky bulk actions při scrollování */
.bulk-actions.is-sticky {
    position: fixed;
    top: 88px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 64px);
    max-width: 920px;
    z-index: 999;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Navigation buttons for document modal */
.nav-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-btn:hover:not(:disabled) {
    background: #e5e7eb;
    border-color: #9ca3af;
}
.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* ===========================================
   Two-column layout for document detail modal
   =========================================== */

/* Dvousloupcové zobrazení extrakce */
.modal-body.two-column-layout {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 24px;
}

.modal-body.two-column-layout .extraction-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-body.two-column-layout .extraction-full-width {
    grid-column: 1 / -1;
}

/* Kompaktnější tabulky v dvousloupcovém režimu */
.modal-body.two-column-layout .detail-table th,
.modal-body.two-column-layout .detail-table td {
    padding: 6px 10px;
    font-size: 0.8125rem;
}

.modal-body.two-column-layout .detail-section h3 {
    font-size: 0.875rem;
    margin-bottom: 8px;
}

/* Drag & drop indikátory */
.extraction-column .detail-section {
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.extraction-column .detail-section.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.extraction-column .detail-section[draggable="true"]:hover {
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.extraction-column .detail-section[draggable="true"]:active {
    cursor: grabbing;
}

/* Drop zone indikátor */
.extraction-column.drag-over {
    background: rgba(59, 130, 246, 0.05);
    border: 2px dashed var(--blue-top, #3b82f6);
    border-radius: var(--radius-md, 8px);
}

/* Responsive - na menších obrazovkách zpět na jeden sloupec */
@media (max-width: 1000px) {
    .modal-body.two-column-layout {
        grid-template-columns: 1fr !important;
        display: block !important;
    }
    .modal-body.two-column-layout .extraction-column {
        margin-bottom: 16px;
    }
    .modal-body.two-column-layout .extraction-full-width {
        grid-column: 1;
    }
}

/* Mobile - always single column */
@media (max-width: 768px) {
    .modal-body.two-column-layout {
        display: block !important;
        grid-template-columns: none !important;
    }
    .modal-body.two-column-layout .extraction-column,
    .modal-body.two-column-layout .extraction-full-width {
        display: block !important;
        width: 100% !important;
    }
}

/* ============================================
   MOBILE MODAL RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    /* Modaly na fullscreen na mobilu */
    #document-modal.draggable-modal .modal-content,
    #original-modal .modal-content {
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0;
        margin: 0;
    }

    .modal-content {
        width: 95% !important;
        max-width: 100% !important;
        margin: 16px auto;
        max-height: calc(100vh - 32px);
    }

    .modal-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-header h2 {
        font-size: 1rem;
        flex: 1 1 100%;
    }

    .modal-actions {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
        justify-content: flex-end;
    }

    .modal-actions .btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .modal-body {
        padding: 16px;
        max-height: calc(100vh - 140px);
    }

    /* Zoom controls na mobilu */
    .zoom-controls {
        width: 100% !important;
        left: 0 !important;
        transform: none !important;
        padding: 6px;
        flex-wrap: wrap;
    }

    .zoom-controls .btn-zoom {
        padding: 4px 10px;
        font-size: 14px;
        min-width: 36px;
    }

    .zoom-level {
        font-size: 12px;
        padding: 6px 8px;
    }

    /* Detail tables na mobilu */
    .detail-table th,
    .detail-table td {
        padding: 8px 10px;
        font-size: 0.8125rem;
    }

    .detail-table th {
        width: 35%;
    }

    .detail-section {
        margin-bottom: 16px;
    }

    .detail-section h3 {
        font-size: 0.875rem;
        padding: 8px 12px;
    }

    /* Upload zone na mobilu */
    .upload-zone {
        min-height: 150px;
    }

    .upload-zone h3 {
        font-size: 1rem;
    }

    .upload-zone p {
        font-size: 0.875rem;
    }

    /* Bulk actions */
    .bulk-actions span {
        font-size: 0.8125rem;
    }

    .bulk-actions .btn {
        font-size: 0.8125rem;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .modal-header h2 {
        font-size: 0.9375rem;
    }

    .modal-actions .btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .detail-table th,
    .detail-table td {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .btn-download {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Skrýt text v toolbar na malých mobilech */
    .toolbar .btn span {
        display: none;
    }

    .toolbar .btn svg {
        margin: 0;
    }
}

/* ============================================
   MOBILE DOCUMENT DETAIL - TABBED VIEW
   ============================================ */

/* Mobile tabs for switching between data and original */
.mobile-doc-tabs {
    display: none;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.mobile-doc-tabs-inner {
    display: flex;
    padding: 0;
}

.mobile-doc-tab {
    flex: 1;
    padding: 14px 16px;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-medium);
    cursor: pointer;
    position: relative;
    transition: color 0.15s ease;
}

.mobile-doc-tab.active {
    color: var(--blue-bottom);
}

.mobile-doc-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
    border-radius: 3px 3px 0 0;
}

.mobile-doc-tab:hover:not(.active) {
    color: var(--text-dark);
    background: rgba(0,0,0,0.02);
}

/* Mobile original panel - hidden by default */
.mobile-original-panel {
    display: none !important;
}

.mobile-original-panel.active {
    display: block !important;
}

/* Hide modal body when viewing original on mobile */
.modal-body.hidden-mobile {
    display: none !important;
}

/* Mobile: Combined document modal */
@media (max-width: 768px) {
    /* Show mobile tabs */
    .mobile-doc-tabs {
        display: block;
    }

    /* Hide original modal completely on mobile - content integrated in document modal */
    #original-modal.visible {
        display: none !important;
    }

    /* Document modal fullscreen on mobile */
    #document-modal.visible .modal-content,
    #document-modal.draggable-modal .modal-content {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0;
        margin: 0;
    }

    /* Modal body takes remaining space */
    #document-modal .modal-body {
        max-height: calc(100vh - 170px) !important;
        overflow-y: auto;
    }

    /* Original panel styling on mobile */
    .mobile-original-panel {
        padding: 16px;
        text-align: center;
        max-height: calc(100vh - 170px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-original-panel .zoom-controls-mobile {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-bottom: 16px;
        flex-wrap: wrap;
        position: sticky;
        top: 0;
        background: var(--card);
        padding: 8px 0;
        z-index: 10;
    }

    .mobile-original-panel .zoom-controls-mobile .btn {
        padding: 8px 14px;
        font-size: 14px;
    }

    .mobile-original-panel #mobile-original-container {
        overflow: visible;
    }

    .mobile-original-panel #mobile-original-container img {
        display: block;
        margin: 0 auto;
        transition: transform 0.2s ease;
    }

    .mobile-original-panel #mobile-original-container iframe {
        width: 100%;
        height: calc(100vh - 240px);
        border: none;
    }

    /* Hide nav buttons on mobile header */
    #document-modal .nav-btn {
        display: none;
    }

    /* Simplify header on mobile */
    #document-modal .modal-header {
        padding: 12px 16px;
        justify-content: space-between;
    }

    #document-modal .modal-header h2 {
        font-size: 1rem;
        margin: 0;
    }

    /* Hide "Zobrazit originál" button on mobile since we have tabs */
    #document-modal .modal-body button[onclick*="viewOriginalFile"] {
        display: none;
    }
}

/* ============================================
   MOBILE UPLOAD — focení dokladů (v115)
   ============================================ */

/* Tlačítka v upload zóně a plovoucí foťák — na desktopu skryté */
.upload-mobile-actions { display: none; }
#fab-camera { display: none; }

@media (max-width: 768px) {
    /* Upload zóna: místo drag&drop textu velká dotyková tlačítka */
    .upload-zone { padding: 20px 16px; margin-bottom: 20px; }
    .upload-zone-icon { width: 40px; height: 40px; margin: 0 auto 8px; }
    .upload-zone-title { display: none; }
    .upload-zone-subtitle { display: none; }
    .upload-zone-formats { margin-top: 12px; font-size: 0.75rem; }

    .upload-mobile-actions {
        display: flex;
        gap: 10px;
        justify-content: center;
        flex-wrap: wrap;
        margin-top: 4px;
    }
    .upload-action-btn {
        flex: 1;
        min-width: 140px;
        min-height: 48px;
        padding: 12px 16px;
        font-size: 1rem;
        font-weight: 600;
    }
    .upload-action-btn svg { margin-right: 8px; flex-shrink: 0; }

    /* Plovoucí tlačítko foťáku vlevo dole (vpravo dole je AI chat) */
    #fab-camera {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        border: none;
        background: linear-gradient(135deg, var(--blue-top), var(--blue-bottom));
        color: white;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
        z-index: 103;
        cursor: pointer;
    }
    #fab-camera svg { width: 26px; height: 26px; stroke: white; }
    #fab-camera:active { transform: scale(0.94); }
}

/* ==========================================================================
   Úpravy rozložení 6. 8. 2026 — víc místa pro doklady
   Naměřeno: první doklad začínal na 996 px při okně 900 px, tedy pod okrajem.
   Největší bloky: plocha pro nahrávání 286 px, lišta filtrů 175 px.
   ========================================================================== */

/* Plocha pro nahrávání: kompromis mezi původními 286 px a příliš úsporným pruhem.
   Zůstává přerušovaný rámeček a svislé uspořádání s ikonou — podle toho se plocha
   pozná jako místo pro přetažení souboru. Na mobilu zůstává původní podoba
   i s tlačítky „Vyfotit doklad" / „Vybrat z galerie", tam je nahrávání hlavní cesta. */
@media (min-width: 900px) {
    .upload-zone {
        padding: 22px 24px;
        margin-bottom: 18px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    .upload-zone-icon { width: 38px; height: 38px; margin: 0 0 2px; }
    .upload-zone-title { font-size: 1.05rem; margin: 0; }
    .upload-zone-subtitle { margin: 0; font-size: 0.9rem; }
    .upload-zone-formats { margin: 2px 0 0; font-size: 0.75rem; opacity: .7; }
}

/* Karta, která hlásí nulu, nenese informaci. */
.stat-card.is-zero { display: none; }

/* Ukazatel úložiště až při blížícím se limitu (viz DashboardLayout.STORAGE_THRESHOLD). */
.stat-card-colored.is-hidden { display: none; }

/* Méně používané filtry se rozbalují. Na úzkých displejích zůstává původní
   chování — tam se lišta stejně láme do sloupce. */
@media (min-width: 900px) {
    .toolbar-group.toolbar-extra { display: none; }
    .toolbar-group.toolbar-extra.is-open { display: flex; }
    /* Výběr účetní jednotky zůstává v liště vidět, jakmile má uživatel víc než
       jednu jednotku — pro účetní kancelář je to hlavní filtr, ne „další"
       (přišpendluje DashboardUnits.populateFilters). */
    .toolbar-group.toolbar-extra.is-pinned { display: flex; }
}
@media (max-width: 899px) {
    .toolbar-group.toolbar-more-toggle { display: none; }
}

/* Štítek DUPLIKÁT (22. 9. 2026): stejný soubor nahraný podruhé. Jen upozornění —
   uživatel duplikát smaže, nebo v detailu potvrdí, že je to záměr. */
.doc-flag-dup {
    background: var(--red-bg);
    color: var(--red-text);
    border-color: var(--red-text);
}
.detail-warning-dup {
    background: var(--red-bg);
    color: var(--red-text);
    border-left-color: var(--red-text);
}
.detail-warning-dup a { color: inherit; font-weight: 600; }
.btn-link-dup {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

/* Hlášení chyb vytěžení v detailu dokladu (14. 10. 2026) */
.hlaseni-box { background: #EEF4FC; color: #1e3a5f; border-left-color: #3E6EB5; margin-bottom: 12px; font-size: 13px; }
.hlaseni-titulek { font-weight: 600; margin-bottom: 4px; }
.hlaseni-radek + .hlaseni-radek { margin-top: 8px; padding-top: 8px; border-top: 1px solid #C6D6EC; }
.hlaseni-stav-ok { color: #166534; font-weight: 600; }
.hlaseni-stav-ceka { color: #92400e; font-weight: 600; }
.hlaseni-odpoved { margin-top: 4px; white-space: pre-line; }
.hlaseni-odpoved-ceka { color: #475569; }
