/* =============================================================================
   SGD Municipal — Estilos personalizados
   Paleta institucional sobria con acento ámbar para elementos importantes.
   ============================================================================= */

:root {
    --color-primary:        #1f3b5c;        /* azul institucional */
    --color-primary-dark:   #142844;
    --color-primary-light:  #2c507a;
    --color-accent:         #c89b3c;        /* ámbar/dorado para acentos */
    --color-accent-dark:    #a37f29;
    --color-bg:             #f5f6f8;
    --color-surface:        #ffffff;
    --color-border:         #e3e6eb;
    --color-text:           #1d2330;
    --color-text-muted:     #6b7280;

    --sidebar-width:        260px;
    --topbar-height:        62px;

    --shadow-sm:            0 1px 2px rgba(20, 40, 68, 0.06);
    --shadow-md:            0 4px 12px rgba(20, 40, 68, 0.08);
    --radius-sm:            6px;
    --radius-md:            10px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', -apple-system, system-ui, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* =============================================================================
   ESTRUCTURA: Sidebar + Main
   ============================================================================= */
.app-shell {
    min-height: 100vh;
    display: flex;
}

/* ---- Sidebar ---- */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary);
    color: #d6dde7;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    transition: transform 0.25s ease;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #fff;
}
.app-sidebar__brand i { font-size: 1.6rem; color: var(--color-accent); }
.brand-logo {
    width: 68px;
    height: 68px;
    border-radius: 12px;
    object-fit: contain;
    background: #ffffff;
    padding: 6px;
    border: 2px solid rgba(255,255,255,.95);
    box-shadow: 0 10px 24px rgba(5, 44, 74, .28), 0 0 0 5px rgba(255,255,255,.16);
}
.brand-title { font-weight: 600; line-height: 1.1; }
.brand-sub   { font-size: 11px; opacity: 0.7; letter-spacing: 0.5px; text-transform: uppercase; }

.app-sidebar__nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}
.nav-group { margin-bottom: 18px; }
.nav-group__title {
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 6px 12px;
}
.app-sidebar .nav-link {
    color: #c9d1dc;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s, color 0.15s;
    font-size: 13.5px;
}
.app-sidebar .nav-link i { width: 18px; text-align: center; font-size: 1rem; }
.app-sidebar .nav-link:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}
.app-sidebar .nav-link.active {
    background: var(--color-primary-light);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.app-sidebar__footer {
    padding: 10px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}
.app-sidebar__footer .text-muted { color: rgba(255,255,255,0.45) !important; }

/* ---- Main ---- */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}
.app-topbar__title {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
}
.app-topbar__right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    background: transparent;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
}
.btn-icon:hover { background: var(--color-bg); }

/* User pill */
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--color-border);
    border-radius: 30px;
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.user-pill:hover { border-color: var(--color-primary-light); box-shadow: var(--shadow-sm); }
.user-pill::after { margin-left: 4px; }

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.user-avatar--photo {
    object-fit: cover;
}
.user-avatar--lg {
    width: 56px;
    height: 56px;
    font-size: 22px;
    flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.user-info__name { font-size: 13px; font-weight: 600; color: var(--color-text); }
.user-info__role { font-size: 11px; color: var(--color-text-muted); }

/* Contenido */
.app-content {
    padding: 24px;
    flex: 1;
}

/* =============================================================================
   COMPONENTES
   ============================================================================= */

/* Cards y tarjetas */
.card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    padding: 14px 18px;
}

/* Stat cards en dashboard */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card__icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-card__icon.bg-primary-soft { background: rgba(31, 59, 92, 0.10); color: var(--color-primary); }
.stat-card__icon.bg-accent-soft  { background: rgba(200, 155, 60, 0.15); color: var(--color-accent-dark); }
.stat-card__icon.bg-success-soft { background: rgba(25, 135, 84, 0.12); color: #198754; }
.stat-card__icon.bg-info-soft    { background: rgba(13, 110, 253, 0.12); color: #0d6efd; }
.stat-card__icon.bg-danger-soft  { background: rgba(217, 45, 32, 0.12); color: #d92d20; }

.stat-card__value { font-size: 24px; font-weight: 700; line-height: 1; color: var(--color-text); }
.stat-card__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); margin-top: 4px; }

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}
.page-header__sub { color: var(--color-text-muted); font-size: 13px; margin-top: 2px; }

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.import-columns {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.import-columns code {
    display: block;
    padding: 10px 12px;
    border: 1px solid #d6e4ee;
    border-radius: 6px;
    background: #f8fbfe;
    color: #1f3b5c;
    font-size: 13px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.import-result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    background: #f8fbfe;
}

.import-result-search {
    position: relative;
    flex: 1 1 520px;
    max-width: 720px;
}

.import-result-search i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #667085;
    z-index: 1;
}

.import-result-search .form-control {
    padding-left: 44px !important;
}

.folio-preview {
    background: #eef7fc !important;
    border-color: #9dcced !important;
    color: #124d78 !important;
    font-family: Consolas, "Courier New", monospace;
    font-weight: 800;
}

/* Botones primarios institucionales */
.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* Tablas */
.table { font-size: 13.5px; }
.table thead th {
    background: #fafbfc;
    border-bottom: 2px solid var(--color-border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    font-weight: 600;
}
.table td { vertical-align: middle; }

/* Badges */
.badge { font-weight: 500; padding: 4px 8px; }

/* Inputs y forms */
.form-label { font-weight: 500; font-size: 13px; }
.form-control:focus, .form-select:focus {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 0.2rem rgba(31, 59, 92, 0.12);
}

/* =============================================================================
   LOGIN
   ============================================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(200,155,60,0.07) 0, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(31,59,92,0.10) 0, transparent 40%),
        var(--color-bg);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 28px rgba(20, 40, 68, 0.12);
    overflow: hidden;
}
.login-card__header {
    background: var(--color-primary);
    color: #fff;
    padding: 28px 30px 22px;
    text-align: center;
}
.login-card__header i {
    font-size: 2.2rem;
    color: var(--color-accent);
    margin-bottom: 8px;
    display: block;
}
.login-logo {
    width: 86px;
    height: 86px;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255,255,255,.94);
    padding: 6px;
    margin: 0 auto 14px;
    display: block;
    box-shadow: 0 8px 22px rgba(8, 74, 122, .18);
}
.login-card__title { font-size: 18px; font-weight: 600; margin: 0; }
.login-card__sub   { font-size: 12px; opacity: 0.7; letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }
.login-card__body  { padding: 28px 30px 30px; }

/* =============================================================================
   ESTADOS DE OFICIO (badges)
   ============================================================================= */
.badge-borrador  { background: #fef3c7; color: #92400e; }
.badge-revision  { background: #dbeafe; color: #1e40af; }
.badge-firmado   { background: #d1fae5; color: #065f46; }
.badge-enviado   { background: #ede9fe; color: #5b21b6; }
.badge-archivado { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* =============================================================================
   BARRA DE FILTROS
   ============================================================================= */
.filters-bar {
    background: #fafbfc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 991px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0; }
}

/* =============================================================================
   Tema profesional azul institucional
   ============================================================================= */
:root {
    --color-primary: #1f6fa8;
    --color-primary-dark: #16466f;
    --color-primary-light: #3498d2;
    --color-accent: #f3b331;
    --color-accent-dark: #c68b13;
    --color-bg: #f3f7fb;
    --color-border: #d8e5ef;
    --shadow-sm: 0 2px 7px rgba(20, 70, 111, 0.08);
    --shadow-md: 0 8px 24px rgba(20, 70, 111, 0.12);
}

body {
    background: linear-gradient(180deg, #f7fbff 0, #eef4fa 100%);
}

.app-sidebar {
    background: linear-gradient(180deg, #319bd8 0%, #2b8dcc 38%, #1b5f93 100%);
    color: #eaf6ff;
    box-shadow: 4px 0 14px rgba(18, 72, 116, 0.28);
}

.app-sidebar__brand {
    min-height: 102px;
    padding: 24px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.16);
}

.app-sidebar__brand i {
    font-size: 2rem;
    color: var(--color-accent);
    filter: drop-shadow(0 2px 2px rgba(0,0,0,.18));
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
}

.brand-sub {
    opacity: .86;
    font-weight: 600;
}

.nav-group__title {
    color: rgba(255,255,255,0.68);
    font-size: 12px;
}

.app-sidebar .nav-link {
    color: #f3fbff;
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 15px;
}

.app-sidebar .nav-link i {
    font-size: 1.1rem;
}

.app-sidebar .nav-link:hover {
    background: rgba(255,255,255,0.15);
}

.app-sidebar .nav-link.active {
    background: rgba(19, 83, 132, 0.68);
    box-shadow: inset 4px 0 0 var(--color-accent), 0 7px 18px rgba(12, 56, 92, .18);
}

.app-topbar {
    height: 72px;
    background: linear-gradient(90deg, #ffffff 0%, #ffffff 20%, #e3f5fc 20%, #e3f5fc 100%);
    border-bottom: 1px solid #cfe3ef;
    box-shadow: 0 3px 10px rgba(22, 70, 111, .10);
    position: sticky;
}

.app-topbar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #3498d2 0%, #35a8df 65%, #79d5f1 100%);
}

.app-topbar__title {
    font-size: 20px;
    font-weight: 800;
}

.app-content {
    padding: 28px 30px;
}

.page-header h1 {
    font-size: 25px;
    font-weight: 800;
    color: #172033;
}

.page-header__sub {
    color: #5c6d7d;
}

.card {
    border-color: #d8e5ef;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-header {
    background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
    border-bottom-color: #d8e5ef;
    color: #16466f;
    font-weight: 800;
}

.form-label {
    color: #0f172a;
    font-size: 14px;
    font-weight: 800;
}

.form-control,
.form-select {
    min-height: 46px;
    border-color: #d5e0e8;
    border-radius: 6px;
    font-size: 16px;
}

textarea.form-control {
    min-height: 112px;
}

.form-control:focus,
.form-select:focus {
    border-color: #3498d2;
    box-shadow: 0 0 0 .2rem rgba(52,152,210,.16);
}

.btn-primary {
    background: #1d659c;
    border-color: #1d659c;
    box-shadow: 0 3px 9px rgba(29, 101, 156, .20);
    font-weight: 700;
}

.btn-primary:hover,
.btn-primary:focus {
    background: #16466f;
    border-color: #16466f;
}

.btn-outline-primary {
    color: #1d659c;
    border-color: #79b6dc;
}

.btn-outline-primary:hover {
    background: #1d659c;
    border-color: #1d659c;
}

.filters-bar {
    background: #fff;
    border-color: #d8e5ef;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.table thead th {
    background: #f2f8fc;
    color: #536272;
}

.alert {
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
}

.alert-danger {
    color: #8a1010;
    background: #ffe1e4;
    border-color: #ffb5bd;
}

.user-avatar {
    background: #3498d2;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}

.login-card__header {
    background: linear-gradient(135deg, #319bd8, #16466f);
}

/* Tema azul vivo, forzado sobre Bootstrap y reglas previas */
body .app-sidebar {
    background: linear-gradient(180deg, #36a3dc 0%, #2f98d4 34%, #2382bd 62%, #176499 100%) !important;
}

body .app-sidebar__brand {
    background: rgba(13, 85, 137, 0.18) !important;
}

body .app-sidebar .nav-link.active {
    background: rgba(20, 101, 158, 0.78) !important;
    border-left: 4px solid #f3b331 !important;
    box-shadow: 0 8px 18px rgba(8, 74, 122, .24) !important;
}

body .app-sidebar .nav-link:hover {
    background: rgba(255,255,255,.18) !important;
}

body .app-topbar {
    background: linear-gradient(90deg, #35a1da 0%, #35a1da 100%) !important;
    border-bottom: 1px solid #247caf !important;
    color: #fff !important;
    box-shadow: 0 3px 12px rgba(23, 100, 153, .28) !important;
}

body .app-topbar::before {
    height: 0 !important;
}

body .app-topbar__title {
    color: #fff !important;
}

body .user-pill {
    background: rgba(255,255,255,.96) !important;
    border-color: rgba(255,255,255,.9) !important;
}

body .app-content {
    background: #f4f7fb !important;
}

body .page-header {
    background: transparent !important;
}

body .filters-bar,
body .card {
    border: 1px solid #d6e4ee !important;
    box-shadow: 0 6px 18px rgba(28, 92, 141, .09) !important;
}

body .btn-primary {
    background: #1d659c !important;
    border-color: #1d659c !important;
}

body .btn-primary:hover,
body .btn-primary:focus {
    background: #144d79 !important;
    border-color: #144d79 !important;
}

/* Refinamiento visual de sistema administrativo */
body {
    color: #101828 !important;
}

body .app-sidebar {
    width: 320px !important;
}

body .app-main {
    margin-left: 320px !important;
}

body .app-sidebar__brand {
    min-height: 146px !important;
    padding: 34px 22px !important;
    gap: 16px !important;
}

body .brand-logo {
    width: 82px !important;
    height: 82px !important;
}

body .brand-title {
    font-size: 23px !important;
    letter-spacing: -0.4px !important;
}

body .brand-sub,
body .nav-group__title {
    letter-spacing: .6px !important;
}

body .app-sidebar__nav {
    padding: 18px 12px !important;
}

body .app-sidebar .nav-link {
    min-height: 54px !important;
    padding: 14px 18px !important;
    font-size: 17px !important;
    gap: 13px !important;
}

body .app-sidebar .nav-link i {
    font-size: 1.25rem !important;
}

body .app-content {
    padding: 36px 38px !important;
    min-height: calc(100vh - 72px) !important;
}

body .page-header {
    margin-bottom: 28px !important;
}

body .page-header h1 {
    font-size: 30px !important;
    letter-spacing: -0.7px !important;
}

body .card {
    max-width: none;
    background: #fff !important;
    border-radius: 9px !important;
}

body .card::before {
    content: "";
    display: block;
    height: 4px;
    background: linear-gradient(90deg, #35a1da 0%, #f3b331 100%);
}

body .card .card-body {
    padding: 30px !important;
}

body .filters-bar {
    padding: 16px 20px !important;
}

body .filters-bar .row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body .filters-bar .row > [class*="col-"],
body .filters-bar .row > .col-auto {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

body .filters-bar .row > [class*="col-"] {
    flex: 1 1 220px;
    width: auto;
    max-width: none;
}

body .filters-bar .row > .col-auto {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
}

body .filters-bar .form-control,
body .filters-bar .form-select {
    min-height: 48px !important;
    height: 48px !important;
    font-size: 15px !important;
    line-height: 1.25 !important;
    padding-top: 9px !important;
    padding-bottom: 9px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body .filters-bar .form-select {
    padding-right: 2.5rem !important;
}

body .filters-bar .btn {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px !important;
    padding: 0 !important;
}

body .form-label {
    margin-bottom: 9px !important;
}

body .form-control,
body .form-select {
    min-height: 58px !important;
    padding: 12px 16px !important;
    border-radius: 7px !important;
    font-size: 18px !important;
}

body textarea.form-control {
    min-height: 150px !important;
}

body .btn {
    border-radius: 7px !important;
    min-height: 46px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
}

body .btn-primary {
    padding-left: 18px !important;
    padding-right: 18px !important;
}

body .table {
    background: #fff !important;
}

body .table thead th {
    height: 48px !important;
    font-size: 13px !important;
    color: #667085 !important;
}

body .table tbody td {
    height: 56px !important;
}

.pagination-shell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-top: 1px solid #d6e4ee;
    background: #fff;
}

.pagination-summary {
    color: #667085;
    font-size: 13px;
    font-weight: 700;
}

.pagination .page-link {
    min-width: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-color: #c9d9e6;
    color: #1c5d91;
    font-weight: 800;
}

.pagination .page-item.active .page-link {
    background: #1f75ad;
    border-color: #1f75ad;
}

@media (max-width: 991px) {
    body .app-sidebar {
        width: 320px !important;
    }

    body .app-main {
        margin-left: 0 !important;
    }
}

/* Visor interno de documentos */
.document-viewer-shell {
    min-height: calc(100vh - 150px);
    background: #0f1720;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 14px 34px rgba(15, 23, 32, .22);
}

.document-viewer-shell.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
}

.document-viewer-shell.is-fullscreen .document-viewer-toolbar {
    min-height: 72px;
}

.document-viewer-shell.is-fullscreen .document-viewer-grid {
    min-height: calc(100vh - 72px);
    height: calc(100vh - 72px);
    grid-template-columns: 280px minmax(0, 1fr);
}

.document-viewer-shell.is-fullscreen .viewer-frame,
.document-viewer-shell.is-fullscreen .viewer-frame iframe,
.document-viewer-shell.is-fullscreen .document-image-preview {
    min-height: calc(100vh - 72px);
    height: calc(100vh - 72px);
}

body.viewer-fullscreen-active {
    overflow: hidden;
}

.document-viewer-toolbar {
    min-height: 88px;
    background: linear-gradient(90deg, #1c5d91 0%, #1f75ad 58%, #35a1da 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 22px;
}

.document-viewer-toolbar h1 {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.4px;
}

.viewer-eyebrow {
    color: rgba(255,255,255,.72);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .9px;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.viewer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    color: rgba(255,255,255,.86);
    font-size: 13px;
}

.viewer-meta span,
.viewer-actions {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.viewer-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.document-viewer-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: calc(100vh - 238px);
}

.viewer-side {
    background: #ffffff;
    padding: 24px;
    border-right: 1px solid #d6e4ee;
}

.viewer-side__label {
    color: #1c5d91;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .8px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.viewer-side p {
    color: #344054;
    line-height: 1.5;
    margin-bottom: 22px;
}

.viewer-side dl {
    margin: 0;
}

.viewer-side dt {
    color: #667085;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.viewer-side dd {
    color: #101828;
    margin: 4px 0 16px;
    overflow-wrap: anywhere;
}

.viewer-frame {
    background: #1b1f24;
    min-height: 680px;
    display: flex;
}

.viewer-frame iframe {
    width: 100%;
    min-height: 680px;
    border: 0;
    background: #111;
}

.document-image-preview {
    width: 100%;
    min-height: 680px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background:
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,.05) 25%, transparent 25%),
        #1b1f24;
    background-size: 24px 24px;
}

.document-image-preview img {
    max-width: 100%;
    max-height: calc(100vh - 280px);
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(0,0,0,.32);
}

.document-format-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid #cfe0ed;
    border-radius: 999px;
    background: #f6fbff;
    color: #1c5d91;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .35px;
}

.document-file-panel {
    align-self: stretch;
}

.document-file-panel input[type="file"] {
    font-size: 14px !important;
}

.document-file-panel input[type="file"]::file-selector-button {
    min-height: 44px;
    max-width: 58%;
    padding-inline: 12px;
    white-space: nowrap;
}

.current-file-box {
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
    overflow-wrap: anywhere;
}

.access-panel {
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    background: #fbfdff;
    padding: 18px;
}

.access-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.access-panel__actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

.access-grid--compact {
    grid-template-columns: 1fr;
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.access-option {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    background: #fff;
    color: #1d2939;
    font-weight: 700;
}

.access-option input {
    width: 18px;
    height: 18px;
    accent-color: #1f75ad;
}

.viewer-empty {
    margin: auto;
    width: min(520px, calc(100% - 40px));
    background: #fff;
    border-radius: 10px;
    padding: 34px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0,0,0,.28);
}

.viewer-empty i {
    color: #d92d20;
    font-size: 48px;
}

.viewer-empty h2 {
    font-size: 24px;
    font-weight: 800;
    margin: 12px 0 8px;
}

.viewer-empty p {
    color: #667085;
    margin-bottom: 22px;
}

.empty-attachment {
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background: #f8fafc;
}

.empty-attachment i {
    color: #94a3b8;
    font-size: 36px;
}

.empty-attachment h3 {
    color: #1d2939;
    font-size: 18px;
    font-weight: 800;
    margin: 10px 0 4px;
}

.empty-attachment p {
    color: #667085;
    margin: 0;
}

.profile-summary-card {
    text-align: center;
}

.profile-avatar {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #35a1da, #1c5d91);
    color: #fff;
    font-size: 32px;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(23, 100, 153, .22);
}

.profile-summary-card h2 {
    font-size: 22px;
    font-weight: 900;
    margin: 0 0 4px;
}

.department-picker {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    background: #fff;
}

.department-picker__head,
.department-picker__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px 88px;
    align-items: center;
    column-gap: 12px;
}

.department-picker__head {
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: 42px;
    padding: 0 16px;
    background: #eef7fc;
    border-bottom: 1px solid #d6e4ee;
    color: #476177;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.department-picker__head span:nth-child(2),
.department-picker__head span:nth-child(3) {
    text-align: center;
}

.department-picker__row {
    min-height: 54px;
    padding: 0 16px;
    border-bottom: 1px solid #edf2f7;
}

.department-picker__row:last-child {
    border-bottom: 0;
}

.department-picker__row.is-selected {
    background: #f4fbff;
}

.department-picker__name {
    color: #1d2939;
    font-weight: 600;
    margin: 0;
    overflow-wrap: anywhere;
}

.department-picker__check {
    display: flex;
    justify-content: center;
    margin: 0;
}

.department-picker .form-check-input {
    width: 20px;
    height: 20px;
    margin: 0;
}

.department-picker .titular-check:disabled {
    opacity: .28;
    cursor: not-allowed;
}

.form-card--wide {
    width: min(100%, 1420px);
}

.wide-entry-form {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 22px;
    align-items: start;
}

.wide-entry-form .form-field,
.wide-entry-form .form-actions {
    min-width: 0;
}

.wide-entry-form .span-3 { grid-column: span 3; }
.wide-entry-form .span-2 { grid-column: span 2; }
.wide-entry-form .span-4 { grid-column: span 4; }
.wide-entry-form .span-6 { grid-column: span 6; }
.wide-entry-form .span-8 { grid-column: span 8; }
.wide-entry-form .span-12 { grid-column: 1 / -1; }
.wide-entry-form .offset-8 { grid-column: 9 / span 4; }

.form-side-panel {
    background: #f8fbfe;
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    padding: 18px;
}

.wide-entry-form .form-select {
    padding-right: 3rem !important;
    text-overflow: ellipsis;
}

.form-side-panel .form-label:not(:first-child) {
    margin-top: 18px;
}

.wide-entry-form textarea.form-control {
    min-height: 210px !important;
}

.wide-entry-form .form-actions {
    display: flex;
    justify-content: flex-end;
}

.user-create-form > .user-form-grid {
    grid-column: span 8;
    margin: 0 !important;
}

.user-create-form > .mb-3 {
    grid-column: span 4;
    margin: 0 !important;
}

.user-create-form > .mb-4 {
    grid-column: span 8;
    margin: 0 !important;
}

.user-create-form__actions {
    grid-column: span 4;
    align-self: end;
}

.user-role-panel {
    display: flex;
    align-items: center;
    min-height: 58px;
}

.user-photo-field {
    background: #f8fbfe;
    border: 1px solid #d6e4ee;
    border-radius: 8px;
    padding: 18px;
}

.user-photo-preview,
.user-table-photo {
    border-radius: 50%;
    object-fit: cover;
    background: #eef7fc;
    border: 2px solid #d6e4ee;
}

.user-photo-preview {
    width: 64px;
    height: 64px;
}

.user-table-photo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.user-table-photo--initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #1f6fa8;
    border-color: #b9d7ea;
    font-size: 13px;
    font-weight: 800;
}

@media (max-width: 1199px) {
    .wide-entry-form .span-3,
    .wide-entry-form .span-2,
    .wide-entry-form .span-4,
    .wide-entry-form .span-6,
    .wide-entry-form .span-8,
    .wide-entry-form .offset-8 {
        grid-column: 1 / -1;
    }

    .user-create-form > .user-form-grid,
    .user-create-form > .mb-3,
    .user-create-form > .mb-4,
    .user-create-form__actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1100px) {
    .document-viewer-grid {
        grid-template-columns: 1fr;
    }

    .viewer-side {
        border-right: 0;
        border-bottom: 1px solid #d6e4ee;
    }

    .document-viewer-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Responsive base para toda la aplicacion */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1025;
    background: rgba(15, 23, 42, .44);
    opacity: 0;
    transition: opacity .2s ease;
}

.sidebar-backdrop.is-visible {
    opacity: 1;
}

body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 1199px) {
    body .app-sidebar {
        width: 300px !important;
    }

    body .app-main {
        margin-left: 300px !important;
    }

    body .app-content {
        padding: 28px 24px !important;
    }
}

@media (max-width: 991px) {
    body .app-sidebar {
        width: min(86vw, 320px) !important;
        transform: translateX(-105%) !important;
        z-index: 1035;
    }

    body .app-sidebar.is-open {
        transform: translateX(0) !important;
    }

    body .app-main {
        margin-left: 0 !important;
        min-width: 0;
    }

    body .app-topbar {
        height: 66px !important;
        padding: 0 14px !important;
    }

    body .app-topbar__title {
        font-size: 20px !important;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body .app-content {
        padding: 24px 18px !important;
    }

    body .page-header {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    body .page-header .btn {
        width: 100%;
    }

    body .page-actions {
        width: 100%;
    }

    body .page-actions .btn {
        flex: 1 1 180px;
    }

    .import-columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .import-result-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .import-result-search {
        flex-basis: auto;
        max-width: none;
    }

    body .filters-bar .row {
        row-gap: 10px !important;
    }

    body .filters-bar [class*="col-"],
    body .filters-bar .col-auto {
        width: 100%;
        flex: 0 0 100%;
    }

    body .filters-bar .btn {
        width: calc(50% - 4px);
    }

    body .filters-bar .btn + .btn,
    body .filters-bar .btn + a {
        margin-left: 8px !important;
    }

    body .card .card-body {
        padding: 22px !important;
    }

    .document-viewer-shell {
        border-radius: 0;
        margin: -24px -18px;
        min-height: calc(100vh - 66px);
    }

    .document-viewer-toolbar {
        min-height: auto;
        padding: 16px;
    }

    .viewer-actions {
        width: 100%;
    }

    .viewer-actions .btn {
        flex: 1 1 auto;
    }

    .viewer-frame,
    .viewer-frame iframe {
        min-height: 620px;
    }
}

@media (max-width: 767px) {
    body {
        font-size: 14px;
    }

    body .app-sidebar__brand {
        min-height: 118px !important;
        padding: 24px 20px !important;
    }

    body .brand-logo {
        width: 68px !important;
        height: 68px !important;
    }

    body .app-sidebar .nav-link {
        min-height: 50px !important;
        font-size: 16px !important;
    }

    body .app-content {
        padding: 18px 12px !important;
    }

    body .page-header h1 {
        font-size: 26px !important;
    }

    body .form-control,
    body .form-select {
        min-height: 50px !important;
        font-size: 16px !important;
    }

    body textarea.form-control {
        min-height: 140px !important;
    }

    .form-card--wide {
        width: 100%;
    }

    .wide-entry-form {
        gap: 16px;
    }

    .wide-entry-form textarea.form-control {
        min-height: 170px !important;
    }

    .form-side-panel {
        padding: 16px;
    }

    .department-picker__head {
        display: none;
    }

    .department-picker__row {
        grid-template-columns: minmax(0, 1fr) 68px 68px;
        min-height: 62px;
        padding: 8px 12px;
    }

    .department-picker__row::before,
    .department-picker__row::after {
        color: #667085;
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        text-align: center;
    }

    .department-picker__row::before {
        content: "Asignar";
        grid-column: 2;
        grid-row: 1;
    }

    .department-picker__row::after {
        content: "Titular";
        grid-column: 3;
        grid-row: 1;
    }

    .department-picker__name {
        grid-row: 1 / span 2;
    }

    .department-picker__check {
        grid-row: 2;
    }

    .table-responsive {
        overflow: visible;
    }

    .table-responsive .table {
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    .table-responsive .table thead {
        display: none;
    }

    .table-responsive .table tbody,
    .table-responsive .table tr,
    .table-responsive .table td {
        display: block;
        width: 100%;
    }

    .table-responsive .table tr {
        background: #fff;
        border: 1px solid #d6e4ee;
        border-radius: 8px;
        box-shadow: 0 3px 10px rgba(20, 70, 111, .08);
        overflow: hidden;
    }

    .table-responsive .table tbody td {
        min-height: 0 !important;
        height: auto !important;
        padding: 10px 14px !important;
        border-bottom: 1px solid #edf2f7;
        text-align: left !important;
    }

    .table-responsive .table tbody td:last-child {
        border-bottom: 0;
        display: flex;
        gap: 8px;
        justify-content: flex-start;
    }

    .table-responsive .table tbody td::before {
        content: attr(data-label);
        display: block;
        color: #667085;
        font-size: 11px;
        font-weight: 900;
        letter-spacing: .45px;
        margin-bottom: 3px;
        text-transform: uppercase;
    }

    .table-responsive .table tbody td:not([data-label])::before {
        content: none;
    }
}

@media (max-width: 575px) {
    body .app-topbar {
        height: 60px !important;
    }

    body .user-pill {
        padding: 4px !important;
    }

    body .app-content {
        padding: 14px 10px !important;
    }

    body .card {
        border-radius: 8px !important;
    }

    body .card .card-body {
        padding: 18px !important;
    }

    body .btn {
        width: 100%;
    }

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

    .import-result-toolbar {
        padding: 12px;
    }

    .document-viewer-shell {
        margin: -14px -10px;
    }

    .viewer-meta {
        display: grid;
        grid-template-columns: 1fr;
    }

    .viewer-actions .btn {
        flex-basis: 100%;
    }
}
