/* ============================================================
   DocAuto – Sistema de Automatización Documental y Contable
   Consultores Diferentes | Deveco IT
   ============================================================ */

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

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #eff6ff;
    --secondary:     #0f172a;
    --success:       #16a34a;
    --warning:       #d97706;
    --danger:        #dc2626;
    --info:          #0891b2;
    --bg:            #f1f5f9;
    --surface:       #ffffff;
    --border:        #e2e8f0;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --text-light:    #94a3b8;
    --sidebar-w:     260px;
    --sidebar-bg:    #0f172a;
    --topbar-h:      64px;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:     0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:     0 8px 32px rgba(0,0,0,.14);
    --transition:    .22s cubic-bezier(.4,0,.2,1);
}

html { font-size: 15px; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; overflow-x: hidden; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo-icon {
    width: 38px; height: 38px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px;
    flex-shrink: 0;
}
.logo-title { color: #f1f5f9; font-weight: 700; font-size: 1rem; display: block; }
.logo-sub   { color: #64748b; font-size: .72rem; display: block; }

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

.nav-section-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #475569;
    padding: 10px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    position: relative;
    margin-bottom: 2px;
    white-space: nowrap;
}
.nav-item i { font-size: .95rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.07);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-name  { color: #e2e8f0; font-size: .82rem; font-weight: 600; display: block; }
.user-role  { color: #64748b; font-size: .72rem; display: block; }

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

/* ── TOPBAR ── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 100;
    gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.sidebar-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1.1rem;
    padding: 6px; border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text); }
.breadcrumb { color: var(--text-muted); font-size: .88rem; font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-size: .85rem; color: var(--text-muted);
}
.search-box input { background: none; border: none; outline: none; color: var(--text); width: 200px; font-size: .85rem; font-family: inherit; }
.search-box i { color: var(--text-light); }

.topbar-icons { display: flex; gap: 4px; }
.icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1rem;
    padding: 7px 8px; border-radius: 6px;
    position: relative;
    transition: color var(--transition), background var(--transition);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.notif-dot {
    width: 7px; height: 7px;
    background: var(--danger);
    border-radius: 50%;
    position: absolute; top: 5px; right: 5px;
    border: 1.5px solid var(--surface);
}
.deveco-badge {
    font-size: .73rem; color: var(--text-muted);
    border-left: 1px solid var(--border);
    padding-left: 12px;
}
.deveco-badge strong { color: var(--primary); }

/* ── PAGE CONTAINER ── */
.page-container { flex: 1; padding: 28px 28px 40px; }

.page { display: none; }
.page.active { display: block; animation: fadeIn .28s ease; }

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

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-header p  { color: var(--text-muted); font-size: .88rem; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: .85rem; font-weight: 600;
    cursor: pointer; border: none;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* ══════════════════════════════════════
   DASHBOARD
══════════════════════════════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.kpi-icon.blue   { background: #eff6ff; color: #2563eb; }
.kpi-icon.green  { background: #f0fdf4; color: #16a34a; }
.kpi-icon.purple { background: #faf5ff; color: #7c3aed; }
.kpi-icon.orange { background: #fff7ed; color: #d97706; }
.kpi-info { display: flex; flex-direction: column; }
.kpi-value { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.kpi-label { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.kpi-trend { font-size: .75rem; margin-top: 5px; font-weight: 500; }
.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

.charts-row {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 18px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.chart-card.wide { }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.chart-header h3 { font-size: .95rem; font-weight: 600; }
.chart-legend { display: flex; gap: 14px; font-size: .78rem; color: var(--text-muted); align-items: center; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.legend-dot.blue   { background: #2563eb; }
.legend-dot.green  { background: #16a34a; }
.legend-dot.orange { background: #d97706; }

.bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.activity-card, .pipeline-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: .95rem; font-weight: 600; }
.link-more { font-size: .8rem; color: var(--primary); text-decoration: none; }
.link-more:hover { text-decoration: underline; }

.activity-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem; flex-shrink: 0;
}
.activity-icon.blue   { background: #eff6ff; color: #2563eb; }
.activity-icon.green  { background: #f0fdf4; color: #16a34a; }
.activity-icon.orange { background: #fff7ed; color: #d97706; }
.activity-icon.red    { background: #fef2f2; color: #dc2626; }
.activity-icon.purple { background: #faf5ff; color: #7c3aed; }
.activity-text { flex: 1; }
.activity-text strong { font-size: .83rem; font-weight: 600; display: block; }
.activity-text span   { font-size: .77rem; color: var(--text-muted); }
.activity-time { font-size: .72rem; color: var(--text-light); white-space: nowrap; }

/* Pipeline */
.pipeline-stages { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; }
.pipeline-stage { flex: 1; text-align: center; }
.stage-header { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: .75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stage-dot.blue   { background: #2563eb; }
.stage-dot.yellow { background: #eab308; }
.stage-dot.orange { background: #d97706; }
.stage-dot.green  { background: #16a34a; }
.stage-count { font-size: 1.3rem; font-weight: 700; }
.pipeline-arrow { color: var(--text-light); font-size: .8rem; }
.pipeline-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; }
.pbar { height: 100%; }
.pbar.blue   { background: #2563eb; }
.pbar.yellow { background: #eab308; }
.pbar.orange { background: #d97706; }
.pbar.green  { background: #16a34a; }

/* ══════════════════════════════════════
   DOCUMENTS
══════════════════════════════════════ */
.filters-bar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.filter-tabs { display: flex; gap: 6px; }
.filter-tab {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: .82rem; font-weight: 500;
    cursor: pointer; color: var(--text-muted);
    transition: all var(--transition);
}
.filter-tab.active, .filter-tab:hover {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.filter-right { display: flex; align-items: center; gap: 10px; }
.select-filter {
    padding: 6px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    font-size: .82rem; color: var(--text); font-family: inherit; outline: none;
}
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-btn { padding: 6px 10px; background: var(--surface); border: none; cursor: pointer; color: var(--text-muted); transition: all var(--transition); }
.view-btn.active { background: var(--primary); color: #fff; }

/* Table */
.table-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 16px; text-align: left; font-size: .77rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 16px; font-size: .84rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: .74rem; font-weight: 600;
}
.status-badge.procesado    { background: #f0fdf4; color: #16a34a; }
.status-badge.contabilizado{ background: #eff6ff; color: #2563eb; }
.status-badge.revision     { background: #fff7ed; color: #d97706; }
.status-badge.pendiente    { background: #fef2f2; color: #dc2626; }
.status-badge.auto         { background: #f0fdf4; color: #16a34a; }
.status-badge.revisado     { background: #eff6ff; color: #2563eb; }

.doc-name { display: flex; align-items: center; gap: 9px; }
.doc-icon { width: 30px; height: 30px; border-radius: 6px; background: #fef2f2; color: #dc2626; display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0; }
.doc-icon.pdf { background: #fef2f2; color: #dc2626; }
.doc-icon.img { background: #eff6ff; color: #2563eb; }
.doc-name strong { display: block; font-size: .83rem; font-weight: 600; }
.doc-name span   { font-size: .74rem; color: var(--text-muted); }

.action-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px 6px; border-radius: 5px; font-size: .85rem; transition: all var(--transition); }
.action-btn:hover { background: var(--bg); color: var(--primary); }

.table-pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 5px; cursor: pointer; font-size: .8rem; transition: all var(--transition); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active):not([disabled]) { background: var(--bg); }
.page-btn[disabled] { opacity: .4; cursor: not-allowed; }

/* Grid view */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.doc-grid-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 16px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    cursor: pointer; transition: all var(--transition);
}
.doc-grid-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.doc-grid-card .big-icon { font-size: 2.5rem; color: #dc2626; }
.doc-grid-card .gcard-name { font-size: .82rem; font-weight: 600; text-align: center; }
.doc-grid-card .gcard-meta { font-size: .73rem; color: var(--text-muted); }
.hidden { display: none !important; }

/* ══════════════════════════════════════
   OCR / IA
══════════════════════════════════════ */
.ocr-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; margin-bottom: 24px; }

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    background: var(--surface);
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-icon { font-size: 2.8rem; color: var(--text-light); margin-bottom: 10px; }
.upload-zone h3 { font-size: .95rem; font-weight: 600; margin-bottom: 4px; }
.upload-zone p  { font-size: .82rem; color: var(--text-muted); }
.upload-formats { font-size: .73rem; color: var(--text-light); margin-top: 6px; margin-bottom: 14px; }

.ocr-settings {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 18px; margin-top: 16px;
}
.ocr-settings h4 { font-size: .88rem; font-weight: 600; margin-bottom: 14px; }

.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .83rem;
    cursor: pointer;
}
.toggle-row:last-child { border-bottom: none; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1; border-radius: 999px; cursor: pointer;
    transition: background var(--transition);
}
.slider::before {
    content: ''; position: absolute;
    width: 14px; height: 14px;
    left: 3px; top: 3px;
    background: #fff; border-radius: 50%;
    transition: transform var(--transition);
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(16px); }

.ocr-result-panel {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); min-height: 400px;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.ocr-doc-preview { flex: 1; padding: 24px; display: flex; flex-direction: column; }
.ocr-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); gap: 12px; }
.ocr-placeholder i { font-size: 3.5rem; color: var(--text-light); }
.ocr-placeholder p  { font-size: .88rem; }

.ocr-processing { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.processing-animation { display: flex; gap: 6px; }
.proc-bar { width: 6px; height: 32px; background: var(--primary); border-radius: 3px; animation: procAnim 1s ease-in-out infinite; }
.proc-bar:nth-child(2) { animation-delay: .15s; }
.proc-bar:nth-child(3) { animation-delay: .30s; }
@keyframes procAnim { 0%,100% { transform: scaleY(1); opacity:.5; } 50% { transform: scaleY(1.8); opacity:1; } }
.ocr-processing h3 { font-size: 1rem; font-weight: 600; }
.proc-steps { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 320px; }
.proc-step { font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.proc-step.done { color: var(--success); }
.proc-step i { font-size: .75rem; }

.ocr-result { flex: 1; display: flex; flex-direction: column; }
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.result-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.result-badge.success { background: #f0fdf4; color: #16a34a; }
.result-confidence { font-size: .82rem; color: var(--text-muted); }
.extracted-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.field-item { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; }
.field-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.field-value { font-size: .9rem; font-weight: 600; color: var(--text); margin-top: 4px; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.ocr-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.ostat-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 18px;
    display: flex; align-items: center; gap: 14px;
}
.ostat-card i { font-size: 1.6rem; color: var(--primary); }
.ostat-val { font-size: 1.3rem; font-weight: 700; display: block; }
.ostat-lbl { font-size: .75rem; color: var(--text-muted); display: block; margin-top: 2px; }

/* ══════════════════════════════════════
   CONTABILIDAD
══════════════════════════════════════ */
.tab-bar {
    display: flex; gap: 4px; margin-bottom: 20px;
    border-bottom: 2px solid var(--border); padding-bottom: 0;
}
.tab-btn {
    padding: 9px 18px;
    background: none; border: none;
    font-size: .86rem; font-weight: 500;
    cursor: pointer; color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    font-family: inherit;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }

.contab-tab-content { display: none; }
.contab-tab-content.active { display: block; animation: fadeIn .2s ease; }

.asientos-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.asiento-legend { display: flex; gap: 16px; font-size: .8rem; color: var(--text-muted); align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.dot.green  { background: var(--success); }
.dot.orange { background: var(--warning); }
.dot.blue   { background: var(--primary); }

/* Conciliación */
.conciliacion-layout { display: grid; grid-template-columns: 1fr 120px 1fr; gap: 16px; align-items: start; }
.conc-panel { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; }
.conc-panel h3 { font-size: .88rem; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.conc-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--primary); font-size: .8rem; text-align: center; padding: 20px 0; }
.conc-center i { font-size: 1.8rem; }
.conc-match-rate { background: var(--primary); color: #fff; border-radius: var(--radius-sm); padding: 8px 12px; text-align: center; }
.conc-match-rate strong { font-size: 1.4rem; display: block; }
.conc-match-rate small { font-size: .73rem; }
.bank-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .82rem; }
.bank-item:last-child { border-bottom: none; }
.bank-item .amount { font-weight: 600; }
.bank-item .amount.neg { color: var(--danger); }
.bank-item .amount.pos { color: var(--success); }
.bank-matched { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-left: 4px; }

/* ══════════════════════════════════════
   FLUJOS DE TRABAJO
══════════════════════════════════════ */
.flujos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; margin-bottom: 24px; }
.workflow-panel, .tasks-panel {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 20px;
}
.workflow-panel h3, .tasks-panel h3 { font-size: .95rem; font-weight: 600; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.badge-red { background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; }

.workflow-diagram { display: flex; flex-direction: column; gap: 0; }
.wf-step {
    display: flex; align-items: flex-start; gap: 14px;
    position: relative;
}
.wf-connector { display: flex; flex-direction: column; align-items: center; }
.wf-node {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; font-weight: 700;
    flex-shrink: 0; border: 2.5px solid;
    z-index: 1;
}
.wf-node.done    { background: #f0fdf4; border-color: var(--success); color: var(--success); }
.wf-node.active  { background: #eff6ff; border-color: var(--primary); color: var(--primary); }
.wf-node.pending { background: #f8fafc; border-color: var(--border); color: var(--text-muted); }
.wf-line { width: 2px; background: var(--border); flex: 1; min-height: 28px; }
.wf-line.done { background: var(--success); }
.wf-content { flex: 1; padding-bottom: 24px; }
.wf-title { font-size: .88rem; font-weight: 600; margin-bottom: 3px; }
.wf-desc  { font-size: .78rem; color: var(--text-muted); }
.wf-meta  { font-size: .75rem; color: var(--text-light); margin-top: 4px; }

.task-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-priority { width: 5px; border-radius: 3px; align-self: stretch; flex-shrink: 0; }
.task-priority.high   { background: var(--danger); }
.task-priority.medium { background: var(--warning); }
.task-priority.low    { background: var(--success); }
.task-body { flex: 1; }
.task-title { font-size: .83rem; font-weight: 600; }
.task-sub   { font-size: .76rem; color: var(--text-muted); margin-top: 3px; }
.task-time  { font-size: .73rem; color: var(--text-light); white-space: nowrap; }
.task-approve {
    padding: 4px 10px; border-radius: var(--radius-sm);
    font-size: .75rem; font-weight: 600;
    background: var(--primary); color: #fff; border: none; cursor: pointer;
    transition: all var(--transition);
}
.task-approve:hover { background: var(--primary-dark); }

.section-title { margin: 8px 0 14px; }
.section-title h3 { font-size: .95rem; font-weight: 600; }
.workflow-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.wf-template-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1.5px dashed var(--border); padding: 18px;
    cursor: pointer; transition: all var(--transition);
    text-align: center;
}
.wf-template-card:hover { border-color: var(--primary); background: var(--primary-light); }
.wf-template-card i { font-size: 2rem; color: var(--primary); margin-bottom: 10px; display: block; }
.wf-template-card h4 { font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.wf-template-card p  { font-size: .75rem; color: var(--text-muted); }

/* ══════════════════════════════════════
   INTEGRACIONES
══════════════════════════════════════ */
.integrations-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.integration-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
    transition: all var(--transition);
}
.integration-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.int-header { display: flex; align-items: center; gap: 12px; }
.int-logo { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.int-info h4 { font-size: .88rem; font-weight: 600; }
.int-info p  { font-size: .75rem; color: var(--text-muted); }
.int-status { display: flex; align-items: center; justify-content: space-between; }
.int-badge { font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.int-badge.connected    { background: #f0fdf4; color: var(--success); }
.int-badge.disconnected { background: #f8fafc; color: var(--text-muted); }
.int-badge.beta         { background: #fff7ed; color: var(--warning); }
.int-action { font-size: .78rem; font-weight: 600; color: var(--primary); cursor: pointer; background: none; border: none; font-family: inherit; }
.int-desc { font-size: .8rem; color: var(--text-muted); line-height: 1.5; }

/* ══════════════════════════════════════
   REPORTES
══════════════════════════════════════ */
.reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.report-chart-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; }
.report-chart-card h3 { font-size: .92rem; font-weight: 600; margin-bottom: 16px; }
.report-chart-card.wide { grid-column: 1 / -1; }

/* ══════════════════════════════════════
   USUARIOS
══════════════════════════════════════ */
.user-row-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .73rem; font-weight: 700; color: #fff; margin-right: 8px;
}

/* ══════════════════════════════════════
   CONFIGURACIÓN
══════════════════════════════════════ */
.config-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.config-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 22px; }
.config-card h4 { font-size: .92rem; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.config-form { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.form-group label { font-size: .78rem; font-weight: 500; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: .85rem; font-family: inherit; color: var(--text);
    background: var(--surface); outline: none;
    transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group input[readonly] { background: var(--bg); color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ══════════════════════════════════════
   MODAL
══════════════════════════════════════ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: fadeIn .2s ease;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%; max-width: 540px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 4px; border-radius: 5px; transition: all var(--transition); }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: #f8fafc; }

.upload-drop-area {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 28px; text-align: center; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    cursor: pointer; transition: all var(--transition);
}
.upload-drop-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-drop-area i { font-size: 2.2rem; color: var(--text-light); }
.upload-drop-area span { color: var(--primary); font-weight: 500; cursor: pointer; }

/* ══════════════════════════════════════
   NOTIFICATIONS PANEL
══════════════════════════════════════ */
.notif-panel {
    position: fixed; top: var(--topbar-h); right: 0;
    width: 340px; background: var(--surface);
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-bottom-left-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    animation: slideLeft .2s ease;
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}
@keyframes slideLeft { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.notif-header h4 { font-size: .9rem; font-weight: 600; }
.notif-header button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: .85rem; }
.notif-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-dot-icon { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.notif-text strong { font-size: .82rem; font-weight: 600; display: block; }
.notif-text span { font-size: .77rem; color: var(--text-muted); }
.notif-time { font-size: .72rem; color: var(--text-light); white-space: nowrap; }

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; }
.toast {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 18px;
    background: var(--secondary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: .84rem;
    box-shadow: var(--shadow-lg);
    min-width: 260px;
    animation: toastIn .25s ease;
    border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--info); }
.toast i { font-size: 1rem; flex-shrink: 0; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(30px); opacity: 0; } }

/* ══════════════════════════════════════
   SIDEBAR COLLAPSED
══════════════════════════════════════ */
.sidebar.collapsed {
    width: 64px;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-details,
.sidebar.collapsed .nav-item .badge {
    display: none;
}
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .logo-icon { margin: 0 auto; }
.sidebar.collapsed .user-info { justify-content: center; }
.main-content.expanded { margin-left: 64px; }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 1100px) {
    .charts-row { grid-template-columns: 1fr; }
    .bottom-row { grid-template-columns: 1fr; }
    .flujos-layout { grid-template-columns: 1fr; }
    .conciliacion-layout { grid-template-columns: 1fr; }
    .conc-center { flex-direction: row; padding: 10px 0; }
    .ocr-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-100%); width: 240px; }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-container { padding: 18px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .reports-grid { grid-template-columns: 1fr; }
    .search-box input { width: 130px; }
}
