:root {
    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-light: #ccfbf1;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f4f7f9;
    --sidebar: #0b1f2a;
    --sidebar-soft: #12313f;
    --danger: #b91c1c;
    --success: #15803d;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 258px; background: var(--sidebar); color: #cbd5e1; position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column; z-index: 1040; transition: transform .2s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-brand .mark { width: 38px; height: 38px; border-radius: 11px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.sidebar-brand strong { color: #fff; display: block; font-size: 15px; line-height: 1.1; }
.sidebar-brand span { font-size: 11px; color: #94a3b8; }
.sidebar-nav { overflow-y: auto; padding: 12px 10px 20px; flex: 1; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: #64748b; padding: 14px 12px 6px; }
.sidebar .nav-link { color: #cbd5e1; border-radius: 9px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sidebar .nav-link:hover { background: var(--sidebar-soft); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar .nav-link .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11px; color: #64748b; }

.main { flex: 1; margin-left: 258px; min-width: 0; }
.topbar { height: 62px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 22px; gap: 14px; position: sticky; top: 0; z-index: 1020; }
.topbar .page-title { font-weight: 700; font-size: 16px; margin: 0; }
.topbar .spacer { flex: 1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-light); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; }
.content { padding: 22px; max-width: 1500px; margin: 0 auto; }

.card { border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 10px rgba(15,23,42,.03); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; padding: 13px 16px; border-radius: 14px 14px 0 0 !important; }
.card-body { padding: 16px; }

.stat { display: flex; gap: 13px; align-items: flex-start; }
.stat .icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--brand-light); color: var(--brand-dark); flex: none; }
.stat .icon.red { background: #fee2e2; color: #b91c1c; }
.stat .icon.green { background: #dcfce7; color: #15803d; }
.stat .icon.amber { background: #fef3c7; color: #92400e; }
.stat .value { font-size: 23px; font-weight: 800; line-height: 1.1; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

.table { --bs-table-bg: transparent; font-size: 13px; margin-bottom: 0; }
.table > thead th { background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #475569; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table > :not(caption) > * > * { padding: .6rem .65rem; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f0fdfa; }

.badge-state { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; }
.badge-soft { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f1f5f9; color: #475569; }
.badge-soft.red { background: #fee2e2; color: #b91c1c; }
.badge-soft.green { background: #dcfce7; color: #166534; }
.badge-soft.amber { background: #fef3c7; color: #92400e; }
.badge-soft.blue { background: #dbeafe; color: #1d4ed8; }
.flag-alto, .flag-critico_alto { color: #b91c1c; font-weight: 700; }
.flag-bajo, .flag-critico_bajo { color: #b45309; font-weight: 700; }
.flag-normal { color: #15803d; }

.btn { border-radius: 9px; font-size: 13px; font-weight: 600; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-sm { font-size: 12px; padding: .28rem .55rem; }
.form-label { font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 4px; }
.form-control, .form-select { border-radius: 9px; border-color: #cbd5e1; font-size: 13px; padding: .48rem .7rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.form-text { font-size: 11px; }

.alert { border-radius: 10px; font-size: 13px; padding: .7rem .9rem; border: 1px solid transparent; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 800; margin: 0 0 3px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 150px; }

.nav-tabs .nav-link { font-size: 13px; font-weight: 600; color: #475569; border: 0; border-bottom: 2px solid transparent; border-radius: 0; }
.nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty-state .big { font-size: 34px; opacity: .35; }

.critical-pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(185,28,28,.35); } 50% { box-shadow: 0 0 0 8px rgba(185,28,28,0); } }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035; }

.signature-box { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 12px; text-align: center; min-height: 90px; display: grid; place-items: center; }
.signature-box img { max-height: 70px; max-width: 190px; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .main { margin-left: 0; }
    .content { padding: 14px; }
    .topbar { padding: 0 14px; }
}

@media print {
    .sidebar, .topbar, .no-print, .sidebar-backdrop { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; max-width: none !important; }
    body { background: #fff !important; }
    .card { border: 0 !important; box-shadow: none !important; }
    a { color: inherit !important; text-decoration: none !important; }
}
