:root {
    --sidebar: #1c2738;
    --sidebar-hover: #2a3a54;
    --sidebar-active: #3b82c4;
    --bg: #f4f6f9;
    --card-radius: .75rem;
    --ink: #1f2937;
    --muted: #6b7280;
    --accent: #2563a8;
    --sidebar-w: 250px;
    --sidebar-w-collapsed: 70px;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .93rem; }
.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; letter-spacing: -.01em; }
a { color: var(--accent); }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar); color: #cbd5e1; position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column; transition: width .2s ease, transform .2s ease; overflow: hidden; }
.sidebar .brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem; color: #fff; text-decoration: none; font-weight: 600; font-size: 1rem; line-height: 1.25; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand-text { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.brand-mark { width: 36px; height: 36px; border-radius: .6rem; background: var(--sidebar-active); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.sidebar .nav { padding: .75rem .6rem; gap: .15rem; }
.sidebar .nav-link { display: flex; align-items: center; gap: .85rem; color: #cbd5e1; padding: .62rem .8rem; border-radius: .55rem; white-space: nowrap; }
.sidebar .nav-link i { font-size: 1.15rem; width: 1.4rem; text-align: center; flex: none; }
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-foot { margin-top: auto; padding: .9rem 1.2rem; font-size: .75rem; color: #7b8aa3; }
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; transition: margin .2s ease; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .brand-text, body.sidebar-collapsed .sidebar .nav-link span, body.sidebar-collapsed .sidebar-foot { display: none; }
body.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding-inline: 0; }
.sidebar-backdrop { display: none; }

.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: #fff; border-bottom: 1px solid #e5e9f0; }
.btn-icon { border: 0; background: transparent; padding: .2rem .5rem; color: var(--ink); }
.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search .form-control { padding-left: 2.4rem; background: #f1f4f8; border-color: transparent; border-radius: 2rem; }
.global-search .form-control:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(37,99,168,.15); }
.user-btn { display: flex; align-items: center; gap: .6rem; border: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sidebar); color: #fff; display: grid; place-items: center; font-weight: 600; }

.content { padding: 1.5rem 1.5rem 2rem; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.45rem; font-weight: 600; margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.app-footer { padding: .9rem 1.5rem; font-size: .78rem; color: var(--muted); text-align: center; }

/* Tarjetas */
.card { border: 0; border-radius: var(--card-radius); box-shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid #eef1f5; font-weight: 600; padding: .9rem 1.15rem; }
.kpi { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.kpi-icon { width: 48px; height: 48px; border-radius: .8rem; display: grid; place-items: center; font-size: 1.4rem; flex: none; }
.kpi-value { font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: .82rem; }
.kpi-blue .kpi-icon { background: #e3effa; color: #2563a8; }
.kpi-green .kpi-icon { background: #e0f4e8; color: #1e8449; }
.kpi-violet .kpi-icon { background: #ebe7f8; color: #5b4bb5; }
.kpi-amber .kpi-icon { background: #fdf0d5; color: #b7791f; }
.chart-box { position: relative; height: 270px; }

/* Tablas */
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table thead th { font-weight: 600; font-size: .8rem; color: #475467; background: #f8fafc; border-bottom: 1px solid #e5e9f0; white-space: nowrap; }
.table-hover tbody tr:hover { background: #f8fbff; }
.thumb { object-fit: cover; border-radius: .5rem; border: 1px solid #e5e9f0; background: #fff; }
.thumb-empty { display: inline-grid; place-items: center; color: #9aa7b8; background: #f1f4f8; border-radius: .5rem; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { border-radius: .5rem; }
.dt-buttons .btn { font-size: .8rem; }
.row-actions { white-space: nowrap; }
.row-actions .btn { padding: .2rem .5rem; }
.badge { font-weight: 500; }
.avail-pill { min-width: 2.2rem; }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* Formularios */
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .25rem; }
.form-control, .form-select { border-radius: .5rem; }
.nav-tabs .nav-link { color: var(--muted); font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--accent); font-weight: 600; }
.img-preview { width: 100%; max-width: 260px; aspect-ratio: 4/3; object-fit: cover; border-radius: .75rem; border: 1px dashed #c7d0dc; background: #f1f4f8; }
.req::after { content: " *"; color: #dc3545; }
.hint { font-size: .75rem; color: var(--muted); }
dl.detail dt { font-weight: 500; color: var(--muted); font-size: .8rem; }
dl.detail dd { margin-bottom: .6rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(155deg, #162033 0%, #22385a 100%); color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 38px 38px; mask-image: radial-gradient(circle at 30% 70%, #000 10%, transparent 70%); -webkit-mask-image: radial-gradient(circle at 30% 70%, #000 10%, transparent 70%); }
.login-art > * { position: relative; }
.login-art h2 { font-weight: 600; max-width: 18ch; line-height: 1.2; }
.login-art ul { list-style: none; padding: 0; margin: 0; color: #a9b8cf; }
.login-art li { padding: .25rem 0; }
.login-art li i { color: #7fb4e8; margin-right: .6rem; }
.login-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.login-form .inner { width: 100%; max-width: 380px; }

/* Acta de entrega */
.acta { background: #fff; max-width: 900px; margin: 1.5rem auto; padding: 2.5rem; border-radius: .5rem; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.acta h1 { font-size: 1.4rem; }
.sign-box { height: 110px; border: 1px solid #333; border-radius: .25rem; }

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
    .app-main, body.sidebar-collapsed .app-main { margin-left: 0; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035; }
    body.sidebar-collapsed .sidebar .brand-text, body.sidebar-collapsed .sidebar .nav-link span { display: inline; }
    body.sidebar-collapsed .sidebar .nav-link { justify-content: flex-start; padding-inline: .8rem; }
    .content { padding: 1rem; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-art { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Impresión */
@media print {
    .sidebar, .topbar, .app-footer, .no-print, .page-actions, .btn, .alert { display: none !important; }
    .app-main { margin: 0 !important; }
    body { background: #fff; }
    .content { padding: 0; }
    .card { box-shadow: none; }
    .acta { box-shadow: none; margin: 0; max-width: none; padding: 0; }
}
