:root {
    --ec-bg: #f4f7fb;
    --ec-card: rgba(255, 255, 255, 0.92);
    --ec-text: #17324a;
    --ec-muted: #6d7f91;
    --ec-primary: #12344d;
    --ec-secondary: #1b5f7a;
    --ec-success: #2d7b63;
    --ec-warning: #b98b2f;
    --ec-danger: #a14a45;
    --ec-border: #dbe4ed;
    --ec-shadow: 0 18px 50px rgba(18, 52, 77, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ec-text);
    background:
        radial-gradient(circle at top left, rgba(27, 95, 122, 0.12), transparent 30%),
        linear-gradient(180deg, #f7fafc 0%, #eef3f8 100%);
    font-family: "Segoe UI", "SF Pro Display", sans-serif;
}
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-shell { width: 100%; max-width: 440px; }
.auth-card, .panel-card, .kpi-card, .table-card { background: var(--ec-card); border: 1px solid rgba(219,228,237,0.9); box-shadow: var(--ec-shadow); border-radius: 24px; backdrop-filter: blur(16px); }
.auth-card { padding: 36px; }
.brand-mark { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--ec-primary), var(--ec-secondary)); color: #fff; border-radius: 16px; font-weight: 700; margin-bottom: 16px; }
.auth-hint { margin-top: 18px; color: var(--ec-muted); font-size: 0.9rem; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 280px; background: rgba(11, 28, 41, 0.92); color: #f8fbff; padding: 24px 18px; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 32px; }
.sidebar-toggle { cursor: pointer; user-select: none; }
.sidebar-brand small { display: block; color: rgba(255,255,255,0.65); }
.sidebar-nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar-nav a { text-decoration: none; color: rgba(255,255,255,0.76); padding: 12px 16px; border-radius: 14px; display: flex; align-items: center; gap: 12px; transition: transform .18s ease, background-color .18s ease, color .18s ease; }
.sidebar-nav a i { font-size: 1rem; width: 18px; text-align: center; color: rgba(255,255,255,0.85); }
.sidebar-nav a span { overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav a.active, .sidebar-nav a:hover { background: rgba(255,255,255,0.09); color: #fff; transform: translateX(2px); }
.app-main { flex: 1; min-width: 0; padding-bottom: 88px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 24px 28px 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-actions input { min-width: 280px; }
.search-shell { position: relative; }
.search-shell i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ec-muted); }
.search-shell input { padding-left: 40px; }
.user-chip { padding: 10px 14px; background: rgba(255,255,255,0.8); border-radius: 16px; border: 1px solid var(--ec-border); }
.user-chip small { display: block; color: var(--ec-muted); }
.app-content { padding: 24px 28px 28px; }
.page-grid { display: grid; gap: 20px; }
.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi-card { padding: 18px; position: relative; overflow: hidden; animation: riseIn .35s ease both; }
.kpi-card::after {
    content: '';
    position: absolute;
    right: -22px;
    top: -22px;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(18, 52, 77, 0.12), transparent 68%);
}
.kpi-card .label { color: var(--ec-muted); font-size: 0.9rem; }
.kpi-card .value { font-size: 1.6rem; font-weight: 700; margin-top: 8px; }
.panel-card, .table-card { padding: 20px; animation: riseIn .4s ease both; }
.table-card table { width: 100%; }
.status-badge { padding: 6px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.status-success { background: rgba(45, 123, 99, 0.12); color: var(--ec-success); }
.status-warning { background: rgba(185, 139, 47, 0.14); color: var(--ec-warning); }
.status-danger { background: rgba(161, 74, 69, 0.12); color: var(--ec-danger); }
.status-info { background: rgba(18, 52, 77, 0.1); color: var(--ec-primary); }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,0.96); border-top: 1px solid var(--ec-border); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); z-index: 1040; justify-content: space-around; }
.mobile-nav a { text-decoration: none; color: var(--ec-primary); font-size: 0.82rem; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mobile-nav a i { font-size: 1.1rem; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.quick-actions .btn { padding: 18px; border-radius: 18px; text-align: left; }
.quick-link { display: flex; align-items: center; gap: 12px; font-weight: 600; transition: transform .18s ease, box-shadow .18s ease; }
.quick-link i { font-size: 1.15rem; color: var(--ec-primary); }
.quick-link:hover { transform: translateY(-2px); box-shadow: 0 14px 24px rgba(18, 52, 77, 0.08); }
.form-step { border-bottom: 1px solid var(--ec-border); padding-bottom: 18px; margin-bottom: 18px; }
.timeline-list { list-style: none; padding: 0; margin: 0; }
.timeline-list li { border-left: 2px solid var(--ec-border); padding: 0 0 16px 16px; margin-left: 8px; position: relative; }
.timeline-list li::before { content: ''; width: 10px; height: 10px; background: var(--ec-primary); border-radius: 50%; position: absolute; left: -6px; top: 6px; }
.document-list { display: grid; gap: 10px; }
.document-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--ec-border); border-radius: 14px; background: rgba(255,255,255,0.72); }
.document-item small { display: block; color: var(--ec-muted); margin-top: 2px; }
.empty-state { color: var(--ec-muted); }
.clients-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; background: linear-gradient(135deg, rgba(18,52,77,.98), rgba(27,95,122,.88)); color: #fff; }
.clients-hero .text-muted { color: rgba(255,255,255,.72) !important; }
.clients-hero-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.eyebrow { display: inline-block; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.72); margin-bottom: 10px; }
.mini-stat { min-width: 92px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); }
.mini-stat strong { display: block; font-size: 1.15rem; color: #fff; }
.mini-stat span { display: block; font-size: .82rem; color: rgba(255,255,255,.72); }
.clients-table-card .table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ec-muted); border-bottom-width: 1px; }
.client-cell { display: flex; align-items: center; gap: 12px; }
.client-avatar { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, rgba(18,52,77,.14), rgba(27,95,122,.18)); color: var(--ec-primary); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.client-cell small { display: block; color: var(--ec-muted); margin-top: 3px; }
.classification-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    border: 1px solid transparent;
}
.classification-chip::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 4px rgba(255,255,255,.45);
}
.classification-good { background: rgba(45,123,99,.12); color: var(--ec-success); border-color: rgba(45,123,99,.2); }
.classification-regular { background: rgba(18,52,77,.1); color: var(--ec-primary); border-color: rgba(18,52,77,.14); }
.classification-risk { background: rgba(185,139,47,.14); color: var(--ec-warning); border-color: rgba(185,139,47,.2); }
.classification-high { background: rgba(161,74,69,.12); color: var(--ec-danger); border-color: rgba(161,74,69,.2); }
.expediente-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.expediente-avatar { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--ec-primary), var(--ec-secondary)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; }
.expediente-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.expediente-grid > div { padding: 14px; border-radius: 16px; background: rgba(244,247,251,.9); border: 1px solid var(--ec-border); }
.expediente-grid strong { display: block; margin-bottom: 6px; font-size: .82rem; color: var(--ec-muted); text-transform: uppercase; letter-spacing: .04em; }
.expediente-modal-dialog { max-height: calc(100vh - 2rem); }
.expediente-modal-body { max-height: calc(100vh - 8rem); overflow-y: auto; overscroll-behavior: contain; padding-right: 18px; }
.expediente-summary-shell, .expediente-docs-shell { border-radius: 22px; }
.modal-dialog-scrollable .modal-content { max-height: calc(100vh - 2rem); }
.modal-dialog-scrollable .modal-body { overflow-y: auto; }
body.sidebar-collapsed .sidebar { width: 96px; padding-inline: 12px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; }
body.sidebar-collapsed .sidebar-brand > div:last-child,
body.sidebar-collapsed .sidebar-nav a { white-space: nowrap; overflow: hidden; }
body.sidebar-collapsed .sidebar-brand > div:last-child { width: 0; opacity: 0; }
body.sidebar-collapsed .sidebar-nav a { position: relative; min-height: 46px; justify-content: center; padding-inline: 10px; }
body.sidebar-collapsed .sidebar-nav a.active,
body.sidebar-collapsed .sidebar-nav a:hover { background: rgba(255,255,255,0.14); }
body.sidebar-collapsed .sidebar-nav a span { display: none; }
body.sidebar-collapsed .sidebar-nav a i { width: auto; font-size: 1.15rem; }
body.sidebar-open-mobile { overflow: hidden; }
body.sidebar-open-mobile .sidebar {
    display: block;
    position: fixed;
    left: 0;
    z-index: 1050;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}
body.sidebar-open-mobile::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(9, 19, 30, 0.36);
    z-index: 1040;
}
@media (max-width: 991px) {
    .sidebar { display: none; }
    .topbar { padding: 16px 16px 0; flex-direction: column; align-items: stretch; }
    .topbar-actions { flex-wrap: wrap; }
    .topbar-actions input { min-width: 100%; }
    .app-content { padding: 16px; }
    .mobile-nav { display: flex; }
    body.sidebar-collapsed .sidebar { width: 280px; padding: 24px 18px; }
    body.sidebar-collapsed .sidebar-brand > div:last-child { width: auto; opacity: 1; }
    body.sidebar-collapsed .sidebar-nav a { min-height: auto; justify-content: flex-start; }
    body.sidebar-collapsed .sidebar-nav a span { display: inline; }
    body.sidebar-collapsed .sidebar-nav a i { width: 18px; font-size: 1rem; }
    .clients-hero { flex-direction: column; align-items: stretch; }
    .clients-hero-actions { justify-content: space-between; }
    .expediente-modal-body { max-height: calc(100vh - 7rem); padding-right: 12px; }
}
@keyframes riseIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
