/* Invoice Scanner Design System */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #16a34a;
    --success-hover: #15803d;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-hover: #b45309;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fef2f2;
    --info: #0284c7;
    --info-hover: #0369a1;
    --info-light: #f0f9ff;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;

    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1 { font-size: 1.5rem; font-weight: 600; color: var(--gray-900); }
h2 { font-size: 1.25rem; font-weight: 600; color: var(--gray-900); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); }
h4 { font-size: 1rem; font-weight: 500; color: var(--gray-700); }
small { font-size: 0.8rem; color: var(--gray-500); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: var(--warning-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; font-size: inherit; }
.btn-link:hover { text-decoration: underline; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}
.required {
    color: var(--danger);
    font-weight: 600;
}
.form-control {
    width: 100%;
    padding: 7px 10px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--gray-800);
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.form-control::placeholder { color: var(--gray-400); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-inline { display: flex; align-items: center; gap: 8px; }
.form-help { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* Cards */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: 16px; }
.card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}
.alert-info { background: var(--info-light); color: var(--info); border-color: #bae6fd; }
.alert-success { background: var(--success-light); color: var(--success); border-color: #bbf7d0; }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: #fde68a; }
.alert-danger { background: var(--danger-light); color: var(--danger); border-color: #fecaca; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 999px;
    line-height: 1.4;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Tables */
.table-wrap-outer {
    position: relative;
}
.table-wrap-outer::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 32px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.85));
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s;
}
.table-wrap-outer.scrolled-end::after {
    opacity: 0;
}
.table-wrap {
    overflow-x: auto;
    scrollbar-width: auto;
    scrollbar-color: var(--gray-400) var(--gray-100);
}
.table-wrap::-webkit-scrollbar {
    height: 12px;
    -webkit-appearance: none;
}
.table-wrap::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 6px;
}
.table-wrap::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 6px;
    border: 2px solid var(--gray-100);
}
.table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.table th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}
table.table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
table.table tbody tr:hover { background: var(--gray-50); }
.row-action-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font-size: 12px;
}
.row-action-link:hover { opacity: 0.7; }
.row-action-link.danger { color: var(--danger); }
.row-actions-cell { white-space: nowrap; }
table.table .cell-input {
    padding: 4px;
}
table.table .cell-input .form-control {
    padding: 4px 6px;
    font-size: 12px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}
.modal-backdrop.active { opacity: 1; visibility: visible; }
.modal {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(10px);
    transition: transform var(--transition);
}
.modal:has(.combobox) {
    overflow-y: visible;
}
.modal-backdrop.active .modal { transform: translateY(0); }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-600); }

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 16px;
}
.tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Spinner / Loading */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* Tooltip */
.tooltip-wrap { position: relative; }
.tooltip-wrap .tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: #fff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: 100;
    pointer-events: none;
}
.tooltip-wrap:hover .tooltip { opacity: 1; visibility: visible; }

/* ============================================
   Scanner-Specific Styles
   ============================================ */

.scanner-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 56px);
}

/* File Sidebar */
.file-sidebar {
    width: 260px;
    min-width: 260px;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

.sidebar-dropzone {
    padding: 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-200);
    transition: background var(--transition);
}
.sidebar-dropzone:hover,
.sidebar-dropzone.drag-over {
    background: var(--primary-light);
}
.sidebar-dropzone-icon {
    font-size: 20px;
    color: var(--gray-400);
    flex-shrink: 0;
}
.sidebar-dropzone-text {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.4;
}
.sidebar-dropzone-text strong {
    color: var(--primary);
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.sidebar-tab {
    flex: 1;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
    white-space: nowrap;
}
.sidebar-tab:hover { color: var(--gray-700); }
.sidebar-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #fff;
}
.sidebar-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--gray-200);
    color: var(--gray-600);
    margin-left: 3px;
}
.sidebar-tab.active .sidebar-tab-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* Sidebar File List */
.sidebar-file-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}
.sidebar-file-list::-webkit-scrollbar { width: 6px; }
.sidebar-file-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-file-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.sidebar-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition);
    font-size: 12px;
}
.sidebar-file-item:hover { background: var(--gray-50); }
.sidebar-file-item.selected {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    padding-left: 9px;
}
.sidebar-file-item .file-check {
    flex-shrink: 0;
}
.sidebar-file-item .file-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.sidebar-file-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.sidebar-file-name {
    display: block;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}
.sidebar-file-detail {
    display: block;
    font-size: 11px;
    color: var(--gray-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-file-status {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.sidebar-file-status .status-ready { color: var(--success); }
.sidebar-file-status .status-processing { color: var(--primary); }
.sidebar-file-status .status-failed { color: var(--danger); }
.sidebar-file-status .spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
}
.sidebar-retry-btn {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 16px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all var(--transition);
}
.sidebar-retry-btn:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger-hover);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-500);
    background: var(--gray-50);
}
.sidebar-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 11px;
    color: var(--gray-600);
}
.sidebar-select-all input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.sidebar-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--gray-400);
    font-size: 12px;
}

.panel-center {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    background: #fff;
}

.panel-right {
    width: 50%;
    overflow-y: auto;
    padding: 16px 20px;
}

/* Top bar */
.top-bar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
}
.top-bar h1 { font-size: 1.1rem; }
.top-bar-nav { display: flex; gap: 4px; align-items: center; }
.top-bar-nav a {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.top-bar-nav a:hover { color: var(--gray-800); background: var(--gray-100); }
.top-bar-nav a.active { color: var(--primary); background: var(--primary-light); }
.top-bar-actions { display: flex; gap: 8px; align-items: center; }

/* Dropzone */
.dropzone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    cursor: pointer;
    transition: all var(--transition);
}
.dropzone.drag-over { background: var(--primary-light); }
.dropzone-icon {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 24px;
    color: var(--gray-400);
}
.dropzone-text { color: var(--gray-500); text-align: center; font-size: 13px; }
.dropzone-text strong { color: var(--primary); }

/* File preview */
.file-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.file-info-bar {
    padding: 8px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray-600);
}
.file-info-bar .file-name { font-weight: 500; color: var(--gray-800); }
.file-viewer {
    flex: 1;
    overflow: auto;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-viewer iframe { width: 100%; height: 100%; border: none; }
.file-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Confidence badge */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 999px;
    cursor: default;
}
.confidence-high { background: var(--success-light); color: var(--success); }
.confidence-medium { background: var(--warning-light); color: var(--warning); }
.confidence-low { background: var(--danger-light); color: var(--danger); }

/* Confidence cell borders */
.cell-confidence-high { border-left: 3px solid var(--success) !important; }
.cell-confidence-medium { border-left: 3px solid var(--warning) !important; }
.cell-confidence-low { border-left: 3px solid var(--danger) !important; }

/* Header fields section */
.header-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.header-fields .form-group.full-width { grid-column: 1 / -1; }
.field-with-confidence {
    position: relative;
}
.field-with-confidence .confidence-badge {
    position: absolute;
    top: 0;
    right: 0;
}
.field-candidates {
    margin-top: 4px;
}
.field-candidate {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-right: 4px;
    color: var(--gray-600);
    transition: all var(--transition);
}
.field-candidate:hover { background: var(--primary-light); color: var(--primary); }

/* Line items section */
.line-items-section { margin-bottom: 20px; }
.line-items-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.line-items-table {
    font-size: 12px;
}
.line-items-table th { font-size: 10px; }
.line-items-table td { padding: 4px 6px; }
.line-items-table .form-control {
    padding: 3px 6px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    width: 100%;
    min-width: 0;
}
.line-items-table input[type="number"] {
    text-align: right;
}
.line-items-table .row-num {
    width: 30px;
    text-align: center;
    color: var(--gray-400);
    font-size: 11px;
}
.line-items-table .col-item-code { width: 130px; min-width: 130px; }
.line-items-table .col-product { min-width: 180px; }
.line-items-table .col-category { min-width: 130px; }
.line-items-table .col-desc { min-width: 140px; }
.line-items-table .col-qty { width: 80px; min-width: 80px; }
.line-items-table .col-price { width: 110px; min-width: 110px; }
.line-items-table .col-total { width: 110px; min-width: 110px; }
.line-items-table .col-actions { width: 120px; white-space: nowrap; }
.amount-mismatch {
    background: var(--danger-light);
    border-color: var(--danger) !important;
}
.validation-error {
    background: var(--danger-light) !important;
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}

/* Actions bar */
.actions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--gray-200);
    margin-top: 12px;
}
.actions-bar-right { margin-left: auto; display: flex; gap: 8px; }

/* Debug panel */
.debug-panel {
    margin-top: 16px;
    border-top: 1px solid var(--gray-200);
}
.debug-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}
.debug-toggle:hover { color: var(--gray-700); }
.debug-content {
    display: none;
    padding: 12px;
    background: var(--gray-900);
    color: var(--gray-300);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.debug-content.active { display: block; }
.debug-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.debug-tab {
    padding: 3px 10px;
    font-size: 11px;
    background: var(--gray-800);
    color: var(--gray-400);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.debug-tab.active { background: var(--primary); color: #fff; }

/* Supplier settings page */
.supplier-page { max-width: 960px; margin: 0 auto; padding: 24px 20px; }
.supplier-header { margin-bottom: 20px; }
.supplier-header h1 { margin-bottom: 4px; }

/* Inline list with actions */
.item-list { list-style: none; }
.item-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}
.item-list li:hover { background: var(--gray-50); }
.item-list .item-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.item-list li:hover .item-actions { opacity: 1; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}
.empty-state p { margin-top: 8px; font-size: 13px; }

/* Search input */
.search-input {
    position: relative;
    margin-bottom: 12px;
}
.search-input input {
    padding-left: 32px;
}
.search-input::before {
    content: '\1F50D';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--gray-400);
}

/* Permissions grid */
.permissions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
}
.permission-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 400;
    color: var(--gray-700);
    cursor: pointer;
    margin-bottom: 0;
}
.permission-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    vertical-align: middle;
    margin-top: -2px;
}

/* Tab links (anchor-based tabs) */
a.tab {
    text-decoration: none;
    color: var(--gray-500);
}
a.tab:hover {
    text-decoration: none;
    color: var(--gray-700);
}
a.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ============================================
   Sidebar Navigation
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    z-index: 90;
    transition: width 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.sidebar-section {
    padding: 16px 12px 8px;
}
.sidebar-section + .sidebar-section {
    border-top: 1px solid var(--gray-100);
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    padding: 0 8px 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}
.sidebar-link:hover {
    color: var(--gray-800);
    background: var(--gray-100);
    text-decoration: none;
}
.sidebar-link.active {
    color: var(--primary);
    background: var(--primary-light);
}
.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
}

/* Sidebar toggle button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--gray-500);
    transition: all var(--transition);
    flex-shrink: 0;
    margin-right: 12px;
}
.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Main content area */
.main-content {
    margin-left: 220px;
    transition: margin-left 0.2s ease;
}

/* Collapsed state */
.sidebar-collapsed .sidebar {
    width: 56px;
}
.sidebar-collapsed .sidebar-label {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}
.sidebar-collapsed .sidebar-link span {
    display: none;
}
.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px;
}
.sidebar-collapsed .main-content {
    margin-left: 56px;
}

/* Collapsed tooltip on hover */
.sidebar-collapsed .sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-800);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: 100;
    pointer-events: none;
}
.sidebar-collapsed .sidebar-link:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 56px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 80;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 220px;
        z-index: 95;
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-collapsed .main-content {
        margin-left: 0;
    }

    .scanner-layout { flex-direction: column; height: auto; }
    .file-sidebar { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--gray-200); max-height: 280px; }
    .sidebar-file-list { max-height: 120px; }
    .panel-center { width: 100%; min-height: 300px; border-right: none; border-bottom: 1px solid var(--gray-200); }
    .panel-right { width: 100%; }
    .header-fields { grid-template-columns: 1fr; }
}

/* Utility classes */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-1 { gap: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.relative { position: relative; }

/* Combobox dropdown */
.combobox-wrapper { position: relative; }
.combobox-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.combobox-dropdown.hidden { display: none; }
.combobox-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}
.combobox-option:hover,
.combobox-option.active {
    background: var(--primary-light);
    color: var(--primary);
}
.combobox-empty {
    padding: 8px 12px;
    color: var(--gray-400);
    font-size: 13px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 300ms ease, transform 300ms ease;
}
.toast.show {
    opacity: 1;
    transform: translateX(0);
}
.toast-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #bbf7d0;
}
.toast-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}
.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    padding: 0 0 0 4px;
    line-height: 1;
    opacity: 0.6;
}
.toast-close:hover {
    opacity: 1;
}

/* Bulk Select */
.bulk-select-th,
.bulk-select-td {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    text-align: center;
    padding-left: 10px !important;
    padding-right: 4px !important;
}
.bulk-select-cb {
    width: 15px;
    height: 15px;
    cursor: pointer;
    vertical-align: middle;
}
.bulk-select-li-cb {
    margin-right: 8px;
    display: flex;
    align-items: center;
}
.bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}
.bulk-action-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}
