/* ============================================================
   TaxFlow GUI — Styles
   ============================================================ */

:root {
    --sidebar-w: 260px;
    --bg: #f4f6f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1f2e;
    --bg-sidebar-hover: #252b3d;
    --bg-sidebar-active: #2d3548;
    --text: #2c3e50;
    --text-light: #6b7c93;
    --text-sidebar: #a0aec0;
    --text-sidebar-active: #ffffff;
    --accent: #0d9488;
    --accent-light: #ccfbf1;
    --accent-dark: #0f766e;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--accent);
    color: white;
    font-weight: 800;
    font-size: 0.9rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.5px;
}

.logo h1 {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.2;
}

.logo-sub {
    color: var(--text-sidebar);
    font-size: 0.75rem;
    font-weight: 400;
}

#main-nav {
    flex: 1;
    padding: 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #cbd5e1;
}

.nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    opacity: 0.7;
}

.nav-link.active .nav-icon {
    opacity: 1;
    color: var(--accent);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sys-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-sidebar);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.status-dot.offline {
    background: #ef4444;
}

.version {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.2);
    font-family: var(--mono);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

#content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    padding: 2rem 2.5rem;
    max-width: 1200px;
    position: relative;
}

#version-badge {
    position: fixed;
    top: 8px;
    right: 12px;
    background: #1a1a2e;
    color: #94a3b8;
    font-size: 0.65rem;
    font-family: monospace;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid #334155;
    z-index: 1000;
    letter-spacing: 0.5px;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
}

.section-desc {
    color: var(--text-light);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* ============================================================
   STATS ROW
   ============================================================ */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-dark);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.4rem;
    font-weight: 500;
}

/* ============================================================
   QUICK ACCESS GRID
   ============================================================ */

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.quick-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    cursor: pointer;
    display: block;
}

.quick-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.quick-card-icon {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.quick-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.quick-card p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* ============================================================
   MODULES GRID (Dashboard mini)
   ============================================================ */

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.module-mini {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.module-mini-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.module-mini-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

.module-mini-status.available {
    background: #d1fae5;
    color: #065f46;
}

.module-mini-status.unavailable {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================================
   CARPETAS PANEL
   ============================================================ */

.carpetas-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.carpetas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.carpetas-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
}

.carpetas-grid {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.carpeta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.carpeta-label {
    width: 90px;
    min-width: 90px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.carpeta-input {
    flex: 1;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text);
    background: white;
    outline: none;
    transition: border-color 0.15s;
}

.carpeta-input:focus {
    border-color: var(--accent);
}

.carpeta-input.changed {
    border-color: #f59e0b;
    background: #fffbeb;
}

.carpeta-status {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.carpeta-status.ok { color: #10b981; }
.carpeta-status.missing { color: #ef4444; }

.carpetas-footer {
    padding: 0.5rem 1rem 0.65rem;
    border-top: 1px solid var(--border);
    background: #fffbeb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
}

.carpetas-save-status {
    font-size: 0.78rem;
    color: var(--text-light);
}

/* ============================================================
   PIPELINE STEPS
   ============================================================ */

.pipeline-controls {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}

.period-row {
    display: flex;
    gap: 0.5rem;
}

.pipeline-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 2rem;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    transition: background 0.15s;
    cursor: default;
}

.step:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.step:last-child {
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}

.step:hover {
    background: #f8fafc;
}

.step-selected {
    background: #f0fdfa !important;
    border-color: var(--accent) !important;
    z-index: 1;
    position: relative;
}

.step-selected + .step {
    border-top-color: var(--accent);
}

.step-number {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 2px;
}

.step-body {
    flex: 1;
}

.step-body h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.step-body p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.4;
}

.step-meta {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: #f0f4f8;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tag-optional {
    background: #f59e0b;
    color: #1a1a2e;
}

.step-optional {
    border-left: 3px solid #f59e0b;
}

.conciliacion-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.conc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.conc-row label {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 140px;
}

.conc-row select, .conc-row .input-text {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
}

.conc-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.step-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 10px;
    white-space: nowrap;
    margin-top: 2px;
}

.step-status.pending {
    background: #f0f4f8;
    color: #64748b;
}

.step-status.running {
    background: #dbeafe;
    color: #1d4ed8;
}

.step-status.done {
    background: #d1fae5;
    color: #065f46;
}

.step-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.step-status.warning {
    background: #fef3c7;
    color: #92400e;
}

.step-num-done {
    background: #d1fae5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
}

.step-num-running {
    background: #dbeafe !important;
    border-color: #3b82f6 !important;
    color: #1d4ed8 !important;
    animation: pulse 1.5s ease-in-out infinite;
}

.step-num-error {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
}

.step-num-warning {
    background: #fef3c7 !important;
    border-color: #f59e0b !important;
    color: #92400e !important;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
    50% { box-shadow: 0 0 0 6px rgba(59,130,246,0); }
}

.pipeline-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 2rem;
}

.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}

.btn-accent {
    background: #f59e0b;
    color: #1a1a2e;
    border: 1px solid #d97706;
    font-weight: 600;
}

.btn-accent:hover:not(:disabled) {
    background: #d97706;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-light);
    font-size: 0.72rem;
    font-family: var(--font);
    cursor: pointer;
}

.btn-small:hover {
    background: rgba(255,255,255,0.1);
}

.btn-note {
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
}

/* ============================================================
   LOG PANEL
   ============================================================ */

.log-panel {
    background: #1e293b;
    border-radius: var(--radius);
    overflow: hidden;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #0f172a;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
}

.log-output {
    padding: 1rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: #94a3b8;
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ============================================================
   MODULE CARDS (Modulos page)
   ============================================================ */

.modules-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.module-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.module-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.module-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.module-details {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.8rem;
}

.detail-row span:first-child {
    color: var(--text-light);
    font-weight: 500;
}

.detail-row span:last-child {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    font-family: var(--mono);
    font-size: 0.75rem;
}

/* ============================================================
   CATALOG TABLE
   ============================================================ */

.catalog-table-wrap {
    overflow-x: auto;
}

.catalog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.catalog-table th {
    text-align: left;
    padding: 0.6rem 1rem;
    background: #f0f4f8;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}

.catalog-table td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.catalog-table td:first-child {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-dark);
}

.catalog-table tr:hover td {
    background: #f8fafc;
}

/* ============================================================
   CONFIGURACION PAGE
   ============================================================ */

.config-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.config-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.config-section-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.config-section-header p {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.config-form {
    padding: 1rem 1.25rem;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.config-row label {
    width: 140px;
    min-width: 140px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
}

.config-input {
    flex: 1;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text);
    background: white;
    outline: none;
    transition: border-color 0.15s;
}

.config-input:focus {
    border-color: var(--accent);
}

.config-input[readonly] {
    background: #f8fafc;
    color: var(--text-light);
}

select.config-input {
    font-family: var(--font);
}

.config-status {
    width: 24px;
    min-width: 24px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.config-status.ok { color: #10b981; }
.config-status.missing { color: #ef4444; }

.config-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.config-subtitle {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-dark);
    margin: 1rem 0 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.config-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.config-save-msg {
    text-align: right;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.config-save-msg.success { color: #10b981; }
.config-save-msg.error { color: #ef4444; }

/* Contrib list cards */

.contrib-list {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contrib-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
    cursor: pointer;
}

.contrib-card:hover {
    border-color: var(--accent);
}

.contrib-card-alias {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: var(--accent-light);
    color: var(--accent-dark);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: -0.5px;
}

.contrib-card-info {
    flex: 1;
}

.contrib-card-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.contrib-card-rfc {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-light);
}

.contrib-card-tipo {
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
    border-radius: 8px;
    background: #f0f4f8;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
}

.contrib-card-actions {
    display: flex;
    gap: 0.4rem;
}

/* ============================================================
   REPORTS PAGE
   ============================================================ */

.report-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.report-type-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.report-type-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.report-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: #dbeafe;
    color: #1e40af;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.report-type-card > p {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.report-sheets {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.report-sheets h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.report-sheets ol,
.report-sheets ul {
    padding-left: 1.25rem;
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.8;
}

.config-preview {
    margin-top: 2rem;
}

.config-note {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.config-placeholder {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
}

.placeholder-icon {
    font-size: 2.5rem;
    color: var(--border);
    margin-bottom: 0.75rem;
}

.config-placeholder p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
}

.placeholder-sub {
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    color: #94a3b8 !important;
    margin-top: 0.25rem;
}

.placeholder-text {
    color: var(--text-light);
    font-style: italic;
}

/* ============================================================
   DOCUMENTATION
   ============================================================ */

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.doc-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    color: var(--text);
}

.doc-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.doc-item.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.doc-item-info {
    display: flex;
    flex-direction: column;
}

.doc-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    font-family: var(--mono);
}

.doc-item-origin {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.doc-item-size {
    font-size: 0.7rem;
    color: var(--text-light);
    font-family: var(--mono);
}

.doc-viewer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.doc-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.doc-viewer-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.doc-viewer-content {
    padding: 1.5rem 2rem;
    max-height: 70vh;
    overflow-y: auto;
    line-height: 1.7;
    font-size: 0.9rem;
}

/* Markdown rendered styles */
.doc-viewer-content h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border);
}

.doc-viewer-content h1:first-child {
    margin-top: 0;
}

.doc-viewer-content h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 1.5rem 0 0.5rem;
    color: var(--accent-dark);
}

.doc-viewer-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.25rem 0 0.4rem;
}

.doc-viewer-content p {
    margin-bottom: 0.75rem;
}

.doc-viewer-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.doc-viewer-content code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: #f0f4f8;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    color: var(--accent-dark);
}

.doc-viewer-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.doc-viewer-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.doc-viewer-content th,
.doc-viewer-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.doc-viewer-content th {
    background: #f0f4f8;
    font-weight: 600;
}

.doc-viewer-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.5rem 1rem;
    margin: 0.75rem 0;
    background: var(--accent-light);
    color: var(--accent-dark);
    font-style: italic;
}

.doc-viewer-content ul,
.doc-viewer-content ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.doc-viewer-content li {
    margin-bottom: 0.25rem;
}

.doc-viewer-content hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 1.5rem 0;
}

.doc-viewer-content strong {
    font-weight: 700;
}

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

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #content {
        margin-left: 0;
        padding: 1.25rem;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-grid {
        grid-template-columns: 1fr;
    }

    .modules-detail-grid {
        grid-template-columns: 1fr;
    }

    .report-overview {
        grid-template-columns: 1fr;
    }

    .doc-viewer-content {
        padding: 1rem;
    }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.log-confirm {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.75rem 0;
    padding: 0.6rem 0.75rem;
    background: #1e293b;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
}

.log-confirm-text {
    font-size: 0.8rem;
    color: #fbbf24;
    font-weight: 600;
    margin-right: 0.25rem;
}

.log-confirm .btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
    white-space: nowrap;
}

.log-output::-webkit-scrollbar-thumb {
    background: #475569;
}

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

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.dialog-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 480px;
    overflow: hidden;
}

.dialog-header {
    padding: 1rem 1.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: white;
}

.dialog-header-error {
    background: #dc2626;
}

.dialog-header-warning {
    background: #d97706;
}

.dialog-body {
    padding: 1.25rem 1.5rem;
}

.dialog-body p {
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
}

.dialog-body p:last-child {
    margin-bottom: 0;
    color: var(--text-light);
    font-size: 0.85rem;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.75rem 1.5rem 1.25rem;
}

/* ============================================================
   NAV DIVIDER
   ============================================================ */

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.5rem 0.75rem;
}

/* ============================================================
   IA — TOOLBAR
   ============================================================ */

.ia-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.ia-selectors {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.ia-toggle-group {
    justify-content: flex-end;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text);
    user-select: none;
}

.toggle input { display: none; }

.toggle-slider {
    width: 36px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.ia-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-light);
}

.ia-context-bar {
    margin-top: -0.5rem;
    border-top: 1px dashed var(--border);
    padding-top: 0.75rem;
}

.ia-context-hint {
    font-size: 0.72rem;
    color: var(--text-light);
    font-style: italic;
}

/* ============================================================
   IA — CHAT
   ============================================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 320px);
    min-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-welcome {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
}

.chat-welcome-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.chat-welcome h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.chat-welcome p {
    font-size: 0.85rem;
    max-width: 500px;
    margin: 0 auto 1.25rem;
    line-height: 1.5;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.suggestion {
    padding: 0.45rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.78rem;
    font-family: var(--font);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}

.suggestion:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent-dark);
}

/* Messages */

.chat-msg {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: white;
    margin-top: 2px;
}

.chat-msg.user .chat-msg-avatar {
    background: #6366f1;
}

.chat-msg.assistant .chat-msg-avatar {
    background: var(--accent);
}

.chat-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 0.88rem;
}

.chat-msg.user .chat-msg-bubble {
    background: #6366f1;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-bubble {
    background: #f0f4f8;
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* Markdown inside assistant messages */

.chat-msg.assistant .chat-msg-bubble p {
    margin-bottom: 0.5rem;
}

.chat-msg.assistant .chat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.chat-msg.assistant .chat-msg-bubble pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.8rem;
    margin: 0.5rem 0;
}

.chat-msg.assistant .chat-msg-bubble code {
    font-family: var(--mono);
    font-size: 0.83em;
    background: #e2e8f0;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.chat-msg.assistant .chat-msg-bubble pre code {
    background: transparent;
    padding: 0;
}

.chat-msg.assistant .chat-msg-bubble ul,
.chat-msg.assistant .chat-msg-bubble ol {
    padding-left: 1.25rem;
    margin: 0.3rem 0;
}

.chat-msg.assistant .chat-msg-bubble table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.82rem;
}

.chat-msg.assistant .chat-msg-bubble th,
.chat-msg.assistant .chat-msg-bubble td {
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
}

.chat-msg.assistant .chat-msg-bubble th {
    background: #e2e8f0;
}

.chat-msg.assistant .chat-msg-bubble strong {
    font-weight: 700;
}

/* Error messages */

.chat-msg.error .chat-msg-bubble {
    background: #fee2e2;
    color: #991b1b;
    border-left: 3px solid #ef4444;
}

/* Typing indicator */

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */

.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    background: #fafbfc;
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    resize: none;
    min-height: 40px;
    max-height: 150px;
    line-height: 1.5;
    background: white;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

#chat-input:focus {
    border-color: var(--accent);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.send-icon {
    font-size: 0.9rem;
}

.chat-input-hint {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.3rem;
    padding-left: 0.25rem;
}

/* ============================================================
   IA — CONFIG HELP
   ============================================================ */

.ia-config-help {
    margin-top: 2rem;
}

.config-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.75rem;
}

.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.config-card h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.config-card code {
    display: block;
    background: #1e293b;
    color: #10b981;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 0.72rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
    white-space: pre;
}

.config-card p {
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.4;
}

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

.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 1rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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