:root {
    color-scheme: light only !important;
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg-light: #f8fafc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f1f5f9;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    color-scheme: light only !important;
}

body { display: flex; align-items: stretch; }

/* Blindaje para que las listas desplegables (Estructura de Cobro, etc.) se vean en cualquier PC */
input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]),
select,
textarea {
    text-transform: none !important;
    font-family: inherit;
    font-size: 0.86rem;
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 7px 10px;
    width: 100%;
    color-scheme: light only !important;
}

select option, select optgroup {
    background-color: #ffffff !important;
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
    font-weight: 600 !important;
    color-scheme: light only !important;
}

input[type="checkbox"], input[type="radio"] { width: auto !important; cursor: pointer; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ZONA 1: MENÚ LATERAL */
.sidebar {
    width: 250px;
    min-width: 250px;
    background: var(--bg-dark);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    height: 100vh;
    position: sticky;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: width 0.22s ease, min-width 0.22s ease, padding 0.22s ease, opacity 0.18s ease;
    flex-shrink: 0;
}

body.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    opacity: 0;
    pointer-events: none;
    border: none;
}

.sidebar-header {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #334155;
    color: #f8fafc;
    white-space: nowrap;
}

.nav-menu { list-style: none; flex: 1; }

.nav-item {
    padding: 10px 12px;
    margin-bottom: 5px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #cbd5e1;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.nav-item.active { background: var(--accent); color: white; font-weight: 600; }

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: 0 !important;
    max-width: 100% !important;
    padding: 18px 24px;
    display: block;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}
.top-bar h2 { font-size: 1.35rem; color: var(--bg-dark); font-weight: 800; margin: 0; }

/* ZONA 2: LAS 6 TARJETAS DE COLORES */
.jc-global-dock {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
    width: 100%;
}
@media (max-width: 960px) { .jc-global-dock { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .jc-global-dock { grid-template-columns: 1fr; } }

.jc-dock-card {
    border-radius: 10px;
    padding: 12px 16px;
    min-height: 82px;
    color: #ffffff !important;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 2px solid transparent;
    min-width: 0;
}
.jc-dock-card:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(15, 23, 42, 0.2); }
.jc-dock-card.activa { border-color: #ffffff; box-shadow: 0 0 0 3px var(--accent); }

.dock-clientes   { background: linear-gradient(135deg, #026aa7, #0369a1); }
.dock-casos      { background: linear-gradient(135deg, #00794c, #047857); }
.dock-plazos     { background: linear-gradient(135deg, #d91b42, #be123c); }
.dock-tareas     { background: linear-gradient(135deg, #b85400, #9a3412); }
.dock-documentos { background: linear-gradient(135deg, #6222cc, #5b21b6); }
.dock-finanzas   { background: linear-gradient(135deg, #0a2558, #0f172a); }

.jc-dock-top { display: flex; justify-content: space-between; align-items: center; }
.jc-dock-icon { font-size: 1.4rem; line-height: 1; }
.jc-dock-badge {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 20px;
    white-space: nowrap;
}
.jc-dock-title { font-size: 1.04rem; font-weight: 800; margin-top: 5px; color: #ffffff; }
.jc-dock-sub { font-size: 0.72rem; color: rgba(255, 255, 255, 0.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ZONA 3: FORMULARIO + PANEL DERECHO */
.jc-form-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 18px;
    width: 100%;
}
@media (max-width: 1100px) { .jc-form-split { grid-template-columns: 1fr; } }

.panel {
    background: white;
    border-radius: 10px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 18px;
    width: 100%;
}

.panel-form {
    max-width: 100% !important;
    margin-bottom: 0 !important;
    padding: 16px 20px !important;
}

.jc-side-widget {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #cbd5e1;
    border-top: 4px solid #2563eb;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.04);
}

.jc-widget-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 6px 10px;
    border-radius: 6px;
    color: #0f172a;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 5px;
    transition: all 0.15s ease;
}
.jc-widget-link:hover {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    transform: translateX(2px);
}

.panel-title { font-size: 0.96rem; font-weight: 700; color: var(--bg-dark); margin-bottom: 12px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 14px;
    width: 100%;
}
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 0.78rem; font-weight: 600; color: #475569; }

.btn {
    padding: 8px 16px;
    border-radius: 7px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-pdf { background: #334155; color: white; }

.panel-form button[type="submit"],
.panel-form .btn-primary,
.modal-content form button[type="submit"] {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 190px !important;
    max-width: 260px !important;
    padding: 8px 18px !important;
    font-size: 0.84rem !important;
    font-weight: 700 !important;
    border-radius: 7px !important;
}

.panel-form button[type="reset"],
.panel-form button[type="button"]:not(.btn-termino):not(.btn-template):not(.btn-remove),
.panel-form .btn-add,
.modal-content form button[type="button"] {
    flex: 0 0 auto !important;
    width: auto !important;
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
}

/* BARRA DE FILTROS COMPACTA */
.jc-barra-filtros, .barra-busqueda-tabla {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 7px 12px;
    margin-bottom: 12px;
    width: auto !important;
    max-width: 100%;
    flex-wrap: wrap;
}

.jc-input-buscar {
    width: 280px !important;
    flex: 0 0 auto !important;
    padding: 6px 10px !important;
    font-size: 0.84rem !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
}

.jc-select-filtro {
    width: 195px !important;
    flex: 0 0 auto !important;
    padding: 6px 9px !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    border: 1px solid #93c5fd !important;
    border-radius: 6px !important;
    background: #eff6ff !important;
    color: #1e3a8a !important;
    cursor: pointer;
}

.jc-btn-limpiar {
    width: auto !important;
    flex: 0 0 auto !important;
    background: #e2e8f0;
    color: #334155;
    border: none;
    padding: 6px 11px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.jc-btn-limpiar:hover { background: #cbd5e1; }

.jc-badge-conteo { font-size: 0.78rem; font-weight: 800; color: #2563eb; white-space: nowrap; margin-left: 4px; }

/* TABLAS PROPORCIONADAS Y COMPACTAS */
.tabla-procesos { width: 100%; border-collapse: collapse; font-size: 0.86rem; table-layout: auto; }
.tabla-procesos th {
    background: #f8fafc;
    color: #475569;
    text-align: left;
    padding: 9px 11px;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.tabla-procesos td {
    padding: 9px 11px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    text-align: left;
    line-height: 1.35;
}
.tabla-procesos tr:hover { background: #f8fafc; }

#tabla-procesos td:nth-child(2),
#tabla-procesos td:nth-child(3),
#tabla-matriz td:nth-child(2),
#tabla-matriz td:nth-child(3) {
    max-width: 265px;
    white-space: normal;
    word-break: break-word;
}

#tabla-clientes td:nth-child(2) {
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
}

#tabla-tareas td:nth-child(3) {
    max-width: 290px;
    white-space: normal;
    word-break: break-word;
}

.celda-clickable { cursor: pointer; transition: background-color 0.15s ease; border-radius: 6px; }
.celda-clickable:hover { background-color: #e0f2fe !important; }

.badge-abogado-col {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.select-abogado-celda {
    background: #eff6ff !important;
    color: #1e40af !important;
    border: 1px solid #93c5fd !important;
    font-weight: 700 !important;
    font-size: 0.76rem !important;
    padding: 4px 7px !important;
    border-radius: 6px !important;
    cursor: pointer;
    width: 185px !important;
}

.texto-azul { color: #2563eb !important; font-weight: bold !important; }
.texto-verde { color: #15803d !important; font-weight: bold !important; }
.texto-rojo { color: #dc2626 !important; font-weight: bold !important; }

.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.65);
    display: none; justify-content: center; align-items: center; z-index: 1000;
}
.modal-content {
    background: white; padding: 22px 24px; border-radius: 12px;
    width: 92%; max-width: 760px; max-height: 90vh; overflow-y: auto; position: relative;
}
.cerrar-modal { position: absolute; top: 14px; right: 18px; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

.jc-toast {
    position: fixed; bottom: 25px; right: 25px;
    background: #0f172a; color: white; padding: 12px 20px;
    border-radius: 8px; font-weight: 600; font-size: 0.88rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border-left: 5px solid var(--success);
    z-index: 99999; opacity: 0; transform: translateY(20px);
    transition: all 0.3s ease;
}
.jc-toast.show { opacity: 1; transform: translateY(0); }

@media print {
    .sidebar, .jc-global-dock, .top-bar, .jc-barra-filtros, .barra-busqueda-tabla, .jc-side-widget { display: none !important; }
}