:root {
    color-scheme: dark;
    --bg: #07111f;
    --panel: rgba(9, 24, 42, 0.88);
    --panel-2: rgba(13, 32, 54, 0.92);
    --border: rgba(125, 211, 252, 0.17);
    --text: #e7f3ff;
    --muted: #8fa8bd;
    --cyan: #38bdf8;
    --green: #22c55e;
    --yellow: #facc15;
    --orange: #fb923c;
    --red: #ef4444;
    --purple: #c084fc;
}

* { box-sizing: border-box; }
body.admin-body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #102a45 0, var(--bg) 45%, #030812 100%); color: var(--text); font-family: Inter, "Segoe UI", Arial, sans-serif; }
a { color: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 18px 28px; background: rgba(4, 12, 23, .92); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px); }
.topbar h1 { margin: 3px 0 0; font-size: clamp(1.35rem, 3vw, 2rem); }
.eyebrow { color: var(--cyan); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.topbar-actions form { margin: 0; }
.admin-name { color: var(--muted); }

.admin-shell { width: min(1500px, calc(100% - 28px)); margin: 24px auto 50px; }
.admin-shell.two-column { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, .75fr); gap: 22px; align-items: start; }
.full-span { grid-column: 1 / -1; }
.left-column { display: grid; gap: 22px; }
.right-column { position: sticky; top: 104px; }

.panel, .ticket-card, .stat-card, .auth-card { background: linear-gradient(180deg, rgba(16, 39, 64, .93), rgba(7, 20, 36, .92)); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, .24); }
.panel { padding: 20px; }
.panel h2 { margin: 0 0 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { text-decoration: none; padding: 16px; min-height: 104px; display: flex; flex-direction: column; justify-content: space-between; transition: .18s ease; }
.stat-card:hover { transform: translateY(-2px); border-color: rgba(56, 189, 248, .45); }
.stat-card span { color: var(--muted); font-size: .88rem; }
.stat-card strong { font-size: 2rem; }
.stat-card.new strong { color: var(--cyan); }
.stat-card.assigned strong { color: var(--purple); }
.stat-card.process strong { color: #60a5fa; }
.stat-card.waiting strong { color: var(--yellow); }
.stat-card.solved strong { color: var(--green); }

.filter-panel { margin-bottom: 18px; }
.filters { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(150px, 1fr)) auto auto; gap: 10px; }
input, select, textarea { width: 100%; border: 1px solid rgba(148, 163, 184, .22); background: rgba(3, 11, 22, .72); color: var(--text); border-radius: 11px; padding: 11px 12px; outline: none; font: inherit; }
input:focus, select:focus, textarea:focus { border-color: rgba(56, 189, 248, .68); box-shadow: 0 0 0 3px rgba(56, 189, 248, .10); }
textarea { min-height: 105px; resize: vertical; }
label { display: block; margin: 15px 0 7px; color: #cce4f7; font-size: .9rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 14px; border-radius: 10px; border: 1px solid transparent; text-decoration: none; cursor: pointer; font: inherit; font-weight: 700; }
.btn.primary { background: linear-gradient(135deg, #0ea5e9, #2563eb); color: #fff; }
.btn.ghost { background: rgba(148, 163, 184, .08); border-color: rgba(148, 163, 184, .18); color: #dcecff; }
.btn.whatsapp { background: rgba(34, 197, 94, .16); color: #8df0ad; border-color: rgba(34, 197, 94, .3); }
.btn.danger-outline { background: transparent; color: #fca5a5; border-color: rgba(239, 68, 68, .38); }
.btn.full { width: 100%; margin-top: 18px; }

.results-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 2px 12px; color: var(--muted); }
.results-head h2 { color: var(--text); margin: 0; }
.ticket-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.ticket-card { padding: 18px; }
.ticket-card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.ticket-card h3 { margin: 18px 0 12px; }
.ticket-code { color: var(--cyan); font-weight: 800; text-decoration: none; letter-spacing: .02em; }
.service-label { color: var(--muted); font-size: .86rem; margin-top: 5px; }
.pill-stack { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill, .priority-pill, .visibility-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.status-new { background: rgba(56, 189, 248, .16); color: #7dd3fc; }
.status-assigned { background: rgba(192, 132, 252, .16); color: #d8b4fe; }
.status-progress { background: rgba(96, 165, 250, .16); color: #93c5fd; }
.status-waiting { background: rgba(250, 204, 21, .14); color: #fde047; }
.status-solved { background: rgba(34, 197, 94, .15); color: #86efac; }
.status-closed { background: rgba(148, 163, 184, .15); color: #cbd5e1; }
.priority-low { background: rgba(148, 163, 184, .11); color: #cbd5e1; }
.priority-normal { background: rgba(56, 189, 248, .11); color: #7dd3fc; }
.priority-high { background: rgba(251, 146, 60, .14); color: #fdba74; }
.priority-urgent { background: rgba(239, 68, 68, .17); color: #fca5a5; }

.ticket-data { display: grid; gap: 9px; margin: 0; }
.ticket-data div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.ticket-data dt { color: var(--muted); font-size: .82rem; }
.ticket-data dd { margin: 0; }
.card-actions { display: flex; gap: 8px; margin-top: 17px; }

.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-grid > div { background: rgba(3, 11, 22, .45); border: 1px solid rgba(148, 163, 184, .10); border-radius: 12px; padding: 13px; }
.detail-grid .wide { grid-column: 1 / -1; }
.detail-grid small { display: block; color: var(--muted); margin-bottom: 5px; }
.detail-grid p { margin: 0; line-height: 1.55; }
.attachments { margin-top: 18px; }
.attachments h3 { margin-bottom: 9px; }
.attachment-link { display: inline-flex; margin: 4px 8px 4px 0; padding: 8px 10px; border-radius: 9px; background: rgba(56, 189, 248, .08); color: #a5ddf7; text-decoration: none; }

.timeline { display: grid; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 18px 1fr; gap: 11px; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: #64748b; box-shadow: 0 0 0 5px rgba(100, 116, 139, .10); }
.timeline-item.public .timeline-dot { background: var(--cyan); box-shadow: 0 0 0 5px rgba(56, 189, 248, .10); }
.timeline-head { display: flex; justify-content: space-between; gap: 10px; }
.timeline-head span, .timeline-item small { color: var(--muted); font-size: .8rem; }
.timeline-item p { margin: 7px 0; line-height: 1.5; }
.visibility-badge { background: rgba(148, 163, 184, .10); color: #9fb3c7; padding: 3px 7px; }
.timeline-item.public .visibility-badge { background: rgba(56, 189, 248, .10); color: #7dd3fc; }

.update-form h2 { margin-bottom: 8px; }
.alert { padding: 12px 14px; border-radius: 11px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.success { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .25); color: #9af0b5; }
.alert.error { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .25); color: #fecaca; }
.empty-state { text-align: center; color: var(--muted); }
.back-link { color: #91c9e7; text-decoration: none; display: inline-block; margin-top: 16px; }
.back-link.inline { margin: 0 0 4px; }

.auth-body { display: grid; place-items: center; padding: 20px; }
.auth-shell { width: min(440px, 100%); }
.auth-card { padding: 28px; }
.auth-card h1 { margin: 6px 0 8px; }
.auth-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(135deg, #0ea5e9, #2563eb); font-weight: 900; }
.auth-card .btn { width: 100%; margin-top: 18px; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .ticket-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-shell.two-column { grid-template-columns: 1fr; }
    .right-column { position: static; }
}

@media (max-width: 720px) {
    .topbar { position: static; padding: 15px; align-items: flex-start; flex-direction: column; }
    .topbar-actions { justify-content: flex-start; }
    .admin-shell { width: min(100% - 18px, 1500px); margin-top: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .ticket-grid, .filters, .detail-grid { grid-template-columns: 1fr; }
    .detail-grid .wide { grid-column: auto; }
    .ticket-data div { grid-template-columns: 78px 1fr; }
    .card-actions { flex-wrap: wrap; }
    .timeline-head { flex-direction: column; }
}

/* PASO 2.2 - Recuperación de contraseña */
.forgot-link { display: block; margin-top: 16px; text-align: center; color: #7dd3fc; text-decoration: none; font-weight: 700; }
.forgot-link:hover { text-decoration: underline; }
.auth-action { width: 100%; margin-top: 8px; }
.alert.warning { background: rgba(250, 204, 21, .10); border-color: rgba(250, 204, 21, .28); color: #fde68a; }
.alert.warning a { color: #ffffff; }
.account-shell { width: min(820px, calc(100% - 28px)); display: grid; gap: 18px; }
.account-card p.muted-copy { color: var(--muted); line-height: 1.5; }
.account-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.account-meta > div { background: rgba(3, 11, 22, .45); border: 1px solid rgba(148, 163, 184, .10); border-radius: 12px; padding: 13px; }
.account-meta small { display: block; color: var(--muted); margin-bottom: 5px; }
.account-meta strong { word-break: break-word; }
@media (max-width: 720px) {
    .account-shell { width: min(100% - 18px, 820px); }
    .account-meta { grid-template-columns: 1fr; }
}

/* PASO 2.3 - Dos administradores y gestión de cuentas */
.setup-body { align-items: start; }
.setup-shell { width: min(1040px, calc(100% - 28px)); margin: 28px auto; }
.setup-card { width: 100%; }
.setup-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.admin-create-card { min-width: 0; margin: 0; padding: 18px; border: 1px solid rgba(125, 211, 252, .17); border-radius: 15px; background: rgba(3, 11, 22, .36); }
.admin-create-card legend { padding: 0 8px; color: #7dd3fc; font-weight: 800; }
.setup-warning { margin-top: 18px; }
.admin-users-shell { width: min(1100px, calc(100% - 28px)); display: grid; gap: 18px; }
.admin-users-list { display: grid; gap: 10px; }
.admin-user-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px; border: 1px solid rgba(148, 163, 184, .12); border-radius: 13px; background: rgba(3, 11, 22, .38); }
.admin-user-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.admin-user-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 8px; color: var(--muted); font-size: .86rem; }
.admin-user-meta strong { color: var(--text); }
.admin-create-panel .muted-copy, .section-title-row .muted-copy { color: var(--muted); margin: 4px 0 0; line-height: 1.5; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.admin-create-panel .btn.primary { margin-top: 18px; }
@media (max-width: 760px) {
    .setup-shell, .admin-users-shell { width: min(100% - 18px, 1100px); }
    .setup-admin-grid, .admin-form-grid { grid-template-columns: 1fr; }
    .admin-user-row { align-items: flex-start; flex-direction: column; }
}
