:root {
    --ink: #101828;
    --muted: #667085;
    --line: #e4e7ec;
    --surface: #ffffff;
    --canvas: #f5f7fb;
    --navy: #091426;
    --navy-2: #102642;
    --cyan: #00a8e8;
    --cyan-soft: #e6f7fd;
    --green: #087443;
    --green-soft: #eaf8f1;
    --amber: #9a6700;
    --amber-soft: #fff7db;
    --red: #b42318;
    --red-soft: #fef0ef;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px; }
a { color: inherit; }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 20; display: flex; flex-direction: column; padding: 24px 16px; color: #d9e4f0; background: linear-gradient(180deg, var(--navy), #07101e); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 30px; color: #fff; text-decoration: none; font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.brand img { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }
.brand span span, .login-brand span { color: var(--cyan); }
.brand small { display: block; margin-top: 2px; color: #7890aa; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px; color: #9fb1c5; text-decoration: none; font-weight: 600; transition: .15s ease; }
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar nav a.active { color: #fff; background: linear-gradient(90deg, rgba(0,168,232,.3), rgba(0,168,232,.11)); box-shadow: inset 3px 0 var(--cyan); }
.nav-icon { width: 19px; color: #83a0bb; text-align: center; font-size: 17px; }
.logout-form { margin-top: auto; }
.logout-form button { width: 100%; padding: 11px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; color: #a9bbce; background: transparent; }
.logout-form button:hover { color: #fff; background: rgba(255,255,255,.06); }

.main-area { width: calc(100% - 248px); margin-left: 248px; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(10px); }
.topbar h1 { margin: 0 0 3px; font-size: 20px; letter-spacing: -.02em; }
.topbar p { margin: 0; color: var(--muted); font-size: 12px; }
.admin-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.admin-user b { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--cyan), #0068a7); }
.menu-button { display: none; padding: 8px; border: 0; color: var(--ink); background: transparent; font-size: 22px; }
main { max-width: 1500px; margin: 0 auto; padding: 28px 30px 50px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(155px,1fr)); gap: 14px; margin-bottom: 22px; }
.metric { position: relative; overflow: hidden; min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric::after { content: ""; position: absolute; width: 74px; height: 74px; right: -30px; bottom: -34px; border-radius: 50%; background: var(--cyan-soft); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; overflow: hidden; margin: 14px 0 7px; font-size: clamp(22px,2vw,30px); letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; }
.metric small { font-size: 12px; }
.metric.accent { color: #fff; border-color: transparent; background: linear-gradient(135deg, #075f8b, #00a8e8); }
.metric.accent span, .metric.accent small { color: rgba(255,255,255,.78); }
.metric.accent::after { background: rgba(255,255,255,.12); }

.panel { margin-bottom: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-heading a, .row-link, .back-link { color: #087eb5; font-weight: 700; text-decoration: none; }
.panel-heading a:hover, .row-link:hover, .back-link:hover { text-decoration: underline; }
.count { padding: 5px 10px; border-radius: 20px; color: #087eb5; background: var(--cyan-soft); font-size: 12px; font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; color: var(--muted); background: #fafbfc; font-size: 11px; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid #eef0f3; vertical-align: middle; }
tbody tr:hover { background: #fbfdff; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.right { text-align: right; }
.strong { font-weight: 700; white-space: nowrap; }
.badge { display: inline-block; padding: 4px 9px; border-radius: 20px; font-size: 10px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.badge.success, .timeline-dot.success { color: var(--green); background: var(--green-soft); }
.badge.warning, .timeline-dot.warning { color: var(--amber); background: var(--amber-soft); }
.badge.danger, .timeline-dot.danger { color: var(--red); background: var(--red-soft); }
.badge.neutral, .timeline-dot.neutral { color: #475467; background: #f2f4f7; }
.empty { padding: 38px !important; color: var(--muted); text-align: center; }
.empty h2 { color: var(--ink); }

.filters { display: grid; grid-template-columns: minmax(180px,1.2fr) minmax(210px,1.3fr) 120px 140px 140px auto auto; gap: 12px; align-items: end; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
label { display: block; margin: 0 0 6px; color: #475467; font-size: 12px; font-weight: 700; }
input, select { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 9px; color: var(--ink); background: #fff; }
input:focus, select:focus { outline: 3px solid rgba(0,168,232,.13); border-color: var(--cyan); }
.button, button.primary { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 9px 15px; border: 0; border-radius: 9px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.primary { color: #fff; background: #087eb5; }
.primary:hover { background: #056b9a; }
.secondary { color: #344054; border: 1px solid #d0d5dd; background: #fff; }
.full { width: 100%; }
.summary-strip { display: grid; grid-template-columns: repeat(4,1fr); gap: 1px; margin-bottom: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.summary-strip div { padding: 14px 18px; background: #fff; }
.summary-strip span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.summary-strip strong { display: block; margin-top: 5px; font-size: 18px; }
.pagination { display: flex; align-items: center; gap: 6px; padding: 16px; border-top: 1px solid var(--line); }
.pagination a { min-width: 32px; padding: 7px; border-radius: 7px; color: var(--muted); text-align: center; text-decoration: none; }
.pagination a.active { color: #fff; background: #087eb5; }
.pagination span { margin-left: auto; color: var(--muted); font-size: 12px; }

.timeline { padding: 4px 20px 12px; }
.timeline article { display: grid; grid-template-columns: 14px 1fr auto; gap: 14px; padding: 16px 0; border-bottom: 1px solid #eef0f3; }
.timeline article:last-child { border: 0; }
.timeline-dot { width: 10px; height: 10px; margin-top: 6px; border: 3px solid currentColor; border-radius: 50%; }
.timeline h3 { display: inline; margin: 0 0 0 8px; font-size: 14px; }
.timeline p { margin: 5px 0 0; color: var(--muted); }
.timeline-meta { color: var(--muted); text-align: right; font-size: 12px; }
.timeline-meta strong { display: block; margin-top: 5px; color: var(--ink); }

.back-link { display: inline-block; margin-bottom: 14px; }
.detail-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding: 24px; border-radius: var(--radius); color: #fff; background: linear-gradient(120deg, var(--navy-2), #075f8b); box-shadow: var(--shadow); }
.detail-hero h2 { margin: 7px 0 3px; font-size: 25px; }
.detail-hero p { margin: 0; color: rgba(255,255,255,.72); }
.detail-hero > strong { font-size: 28px; white-space: nowrap; }
.detail-hero .button { color: var(--ink); }
.eyebrow { color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; padding: 20px; }
.data-grid.four { grid-template-columns: repeat(4,1fr); }
.data-grid span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.data-grid strong { display: block; overflow-wrap: anywhere; }
.money-grid strong { font-size: 17px; }
code { padding: 3px 6px; border-radius: 5px; color: #344054; background: #f2f4f7; }
pre { max-height: 390px; margin: 0 20px 20px; overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 10px; color: #344054; background: #f8fafc; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.panel > label { margin: 0 20px 7px; }
.terms-preview { max-height: 560px; }

.plan-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.plan-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.plan-card h2 { margin: 7px 0 12px; font-size: 21px; }
.plan-card > strong { font-size: 27px; }
.plan-card p, .plan-card small { color: var(--muted); }
.plan-card ul { margin: 20px 0; padding: 0; list-style: none; }
.plan-card li { padding: 7px 0; border-bottom: 1px solid #f0f2f5; }
.plan-card li.yes { color: var(--green); }
.plan-card li.no { color: #98a2b3; }
.notice { margin-bottom: 18px; padding: 12px 15px; border-radius: 10px; font-weight: 600; }
.notice.success { color: var(--green); background: var(--green-soft); }
.notice.danger { color: var(--red); background: var(--red-soft); }
.visitor-summary { grid-template-columns: repeat(4, 1fr); }
.visitor-table code { white-space: nowrap; }
.map-link { display: inline-flex; padding: 7px 10px; border-radius: 8px; color: #fff; background: #087eb5; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.map-link:hover { background: #056b9a; }
.map-unavailable { color: var(--muted); font-size: 12px; white-space: nowrap; }
.visitor-privacy-note { color: #475467; background: #eef7fb; }

.request-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 20px; }
.request-card { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.request-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.request-head h3 { margin: 8px 0 3px; font-size: 17px; }
.request-head p { margin: 0; color: var(--muted); font-size: 12px; }
.request-head > strong { color: #087eb5; font-size: 27px; text-align: right; }
.request-head > strong small { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.approval-form { display: grid; grid-template-columns: 1.4fr .8fr .8fr; gap: 12px; align-items: end; padding-top: 16px; }
.approval-form button { grid-column: 1 / -1; }
.reject-form { margin-top: 8px; }
.danger-button { width: 100%; min-height: 38px; padding: 8px 14px; border: 1px solid #f3c7c2; border-radius: 9px; color: var(--red); background: var(--red-soft); font-weight: 700; }
.danger-button:hover { color: #fff; background: var(--red); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, #103a5f 0, transparent 30%), radial-gradient(circle at 85% 80%, #075f8b 0, transparent 28%), #070f1c; }
.login-card { width: min(920px,100%); min-height: 520px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 22px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.38); }
.login-brand { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 40px; color: #fff; background: linear-gradient(145deg, rgba(9,20,38,.88), rgba(9,20,38,.98)), url('/img/vortexai/home.jpeg') center/cover; font-size: 34px; font-weight: 900; }
.login-brand::after { content: "Control y trazabilidad de Vortex/A"; max-width: 280px; color: #9eb3c8; font-size: 13px; font-weight: 500; letter-spacing: .03em; text-align: center; }
.login-brand img { width: 105px; height: 105px; object-fit: contain; padding: 9px; border-radius: 24px; background: #fff; }
.login-body { align-self: center; padding: 50px; }
.login-body h1 { margin: 8px 0; font-size: 27px; letter-spacing: -.04em; }
.login-body > p { margin: 0 0 25px; color: var(--muted); line-height: 1.6; }
.login-body label { margin-top: 13px; }
.login-body button { margin-top: 18px; }
.login-body > small { display: block; margin-top: 20px; color: #98a2b3; text-align: center; }

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(3,1fr); }
    .filters { grid-template-columns: repeat(3,1fr); }
    .data-grid.four { grid-template-columns: repeat(2,1fr); }
    .request-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
    .sidebar.open { transform: translateX(0); }
    .main-area { width: 100%; margin-left: 0; }
    .menu-button { display: block; }
    .topbar { padding: 0 18px; }
    main { padding: 20px 16px 40px; }
    .metric-grid, .plan-grid, .two-column { grid-template-columns: 1fr; }
    .filters { grid-template-columns: 1fr 1fr; }
    .summary-strip { grid-template-columns: 1fr 1fr; }
    .login-card { max-width: 460px; grid-template-columns: 1fr; }
    .login-brand { min-height: 190px; padding: 24px; }
    .login-brand img { width: 70px; height: 70px; }
    .login-brand::after { display: none; }
    .login-body { padding: 34px 28px; }
}

@media (max-width: 560px) {
    .metric-grid, .filters, .summary-strip, .data-grid, .data-grid.four { grid-template-columns: 1fr; }
    .admin-user span { display: none; }
    .detail-hero { align-items: flex-start; flex-direction: column; }
    .detail-hero > strong { font-size: 23px; }
    .timeline article { grid-template-columns: 12px 1fr; }
    .timeline-meta { grid-column: 2; text-align: left; }
    .approval-form { grid-template-columns: 1fr; }
}
