:root {
    --primary: #1d4ed8;
    --primary-dark: #0f172a;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #0891b2;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 18px;
    --shadow: 0 18px 40px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, #0f172a, #1e293b);
    color: white;
    padding: 22px;
    display: flex;
    flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; background: #facc15; color: #0f172a; display: grid; place-items: center; font-weight: 900; }
.brand strong { display:block; font-size: 19px; }
.brand span { color: #cbd5e1; font-size: 13px; }
.menu { margin-top: 24px; display: grid; gap: 9px; }
.menu a { padding: 13px 14px; border-radius: 14px; color: #e2e8f0; transition: .2s; }
.menu a:hover { background: rgba(255,255,255,.12); color: white; transform: translateX(3px); }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.15); padding-top: 18px; display:grid; gap:8px; color:#cbd5e1; }
.logout { color:#fecaca; font-weight:700; }
.main-content { padding: 28px; min-width: 0; }
.topbar { display:flex; justify-content:space-between; gap:20px; align-items:center; margin-bottom: 22px; }
.topbar h1 { margin: 0 0 4px; font-size: 28px; }
.topbar p { margin:0; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow:hidden; }
.card-body { padding: 24px; }
.card-title { font-size: 18px; margin: 0 0 12px; }
.metric { font-size: 42px; font-weight: 900; margin: 4px 0; }
.muted { color: var(--muted); }

.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; border:0; border-radius: 13px; padding: 11px 16px; cursor:pointer; font-weight: 800; transition:.2s; font-size: 14px; }
.btn:hover { transform: translateY(-1px); filter: brightness(.98); }
.btn-primary { background: var(--primary); color:white; }
.btn-dark { background: #0f172a; color:white; }
.btn-success { background: var(--success); color:white; }
.btn-warning { background: var(--warning); color:#111827; }
.btn-danger { background: var(--danger); color:white; }
.btn-info { background: var(--info); color:white; }
.btn-secondary { background: #e2e8f0; color:#0f172a; }
.btn-outline { border: 1px solid var(--border); background:white; color:#0f172a; }
.btn-lg { padding: 16px 22px; font-size: 17px; border-radius: 16px; }
.btn-xl { padding: 26px; font-size: 24px; width:100%; min-height: 150px; flex-direction: column; }
.actions { display:flex; gap:10px; flex-wrap:wrap; }

.alert { border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; font-weight: 700; }
.alert-success { background:#dcfce7; color:#166534; }
.alert-error, .alert-danger { background:#fee2e2; color:#991b1b; }
.alert-warning { background:#fef3c7; color:#92400e; }

.form-group { margin-bottom: 15px; }
label { display:block; font-weight: 800; margin-bottom: 8px; }
input, select, textarea {
    width:100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 13px; font: inherit; background:white;
}
textarea { min-height: 90px; resize: vertical; }
.form-hint { color: var(--muted); font-size: 13px; margin-top: 5px; }

.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse: collapse; background:white; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align:left; vertical-align:middle; }
th { color:#475569; font-size:13px; text-transform:uppercase; letter-spacing:.04em; background:#f8fafc; }
.badge { display:inline-block; padding:6px 10px; border-radius:999px; font-size:12px; font-weight:900; }
.badge-normal { background:#dbeafe; color:#1d4ed8; }
.badge-preferencial { background:#fee2e2; color:#b91c1c; }
.badge-pendiente { background:#fef3c7; color:#92400e; }
.badge-llamado { background:#dbeafe; color:#1d4ed8; }
.badge-atencion { background:#cffafe; color:#155e75; }
.badge-atendido { background:#dcfce7; color:#166534; }
.badge-no { background:#fee2e2; color:#991b1b; }

.current-turn { text-align:center; }
.current-turn .code { font-size: 88px; font-weight: 900; line-height:1; letter-spacing:-3px; color:var(--primary); }
.current-turn .label { font-size:20px; color:var(--muted); margin-top: 8px; }

.login-page { min-height:100vh; display:grid; place-items:center; padding:20px; background: radial-gradient(circle at top left, #dbeafe, transparent 30%), linear-gradient(135deg, #0f172a, #1d4ed8); }
.login-card { width:min(440px, 100%); background:white; border-radius:24px; padding:28px; box-shadow: 0 26px 70px rgba(0,0,0,.25); }
.login-logo { width: 68px; height:68px; display:grid; place-items:center; background:#facc15; border-radius:20px; font-weight:900; font-size:24px; margin-bottom:14px; }

.ticket-page { background:white; }
.ticket { width: 280px; margin: 0 auto; padding: 12px; font-family: Arial, Helvetica, sans-serif; text-align:center; }
.ticket-box { border:1px dashed #111; padding:14px; }
.ticket-title { font-size:14px; font-weight:900; text-transform:uppercase; }
.ticket-office { font-size:13px; margin-top:3px; }
.ticket-code { font-size:52px; line-height:1; font-weight:900; margin:16px 0; }
.ticket-type { font-weight:900; font-size:14px; }
.ticket-detail { font-size:12px; margin-top:8px; }
.ticket-msg { margin-top:12px; padding-top:10px; border-top:1px dashed #111; font-size:12px; }
.no-print { margin: 15px auto; width: 280px; display:flex; gap:8px; justify-content:center; }

.tv-body { margin:0; min-height:100vh; background:#020617; color:white; font-family: Arial, Helvetica, sans-serif; overflow:hidden; }
.tv { min-height:100vh; display:grid; grid-template-rows:auto 1fr auto; }
.tv-header { padding:24px 40px; background:#0f172a; display:flex; justify-content:space-between; align-items:center; border-bottom:4px solid #facc15; }
.tv-header h1 { margin:0; font-size:38px; text-transform:uppercase; }
.tv-header p { margin:4px 0 0; color:#cbd5e1; font-size:19px; }
.tv-clock { font-size:34px; font-weight:900; color:#facc15; }
.tv-main { display:grid; place-items:center; text-align:center; padding:30px; }
.tv-small { font-size:44px; color:#cbd5e1; }
.tv-code { font-size:170px; line-height:1; font-weight:900; color:#facc15; text-shadow:0 10px 50px rgba(250,204,21,.2); }
.tv-type { font-size:42px; margin-top:18px; }
.tv-module { display:inline-block; margin-top:24px; background:#2563eb; padding:18px 38px; border-radius:18px; font-size:36px; font-weight:900; }
.tv-footer { background:#0f172a; padding:20px 34px; }
.tv-footer h3 { margin:0 0 12px; font-size:24px; color:#cbd5e1; text-align:center; }
.tv-last { display:flex; gap:14px; justify-content:center; flex-wrap:wrap; }
.tv-last-item { background:#1e293b; border:1px solid #334155; padding:14px 28px; border-radius:16px; font-size:32px; font-weight:900; }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position:relative; height:auto; }
    .menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { flex-direction: column; align-items: stretch; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main-content { padding: 18px; }
    .current-turn .code { font-size: 62px; }
}

@media print {
    .no-print { display:none; }
    body { margin:0; }
}

/* Mejora visual v1.1: lenguaje público centrado en Ticket N.º */
.current-prefix {
    display: inline-block;
    margin-bottom: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.ticket-number-label {
    margin-top: 14px;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.ticket-box {
    border-radius: 10px;
}
.ticket-code {
    letter-spacing: -1px;
}
.tv-small {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 999px;
    background: rgba(250, 204, 21, .12);
    border: 1px solid rgba(250, 204, 21, .35);
    color: #fde68a;
    font-size: 42px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.tv-code {
    margin-top: 18px;
}


/* v1.2 mejora institucional con logo, login y pantalla TV */
.brand-logo {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    padding: 4px;
    box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.topbar-kicker {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #64748b;
    font-weight: 900;
    margin-bottom: 8px;
}
.login-card-wide { width:min(880px, 100%); }
.login-grid {
    display:grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 28px;
    align-items: center;
}
.login-side {
    padding: 10px;
}
.login-logo-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    background: #fff;
    padding: 8px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .14);
    margin-bottom: 18px;
}
.login-highlight {
    margin-top: 18px;
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    border: 1px solid #dbeafe;
    border-radius: 18px;
    padding: 16px;
    display:grid;
    gap:6px;
}
.login-highlight strong { color:#0f172a; }
.login-highlight span { color:#475569; font-size:14px; line-height:1.5; }
.ticket-logo {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 50%;
    margin: 0 auto 8px;
    display:block;
}
.ticket-box-pro {
    border: 1px dashed #0f172a;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff, #f8fafc);
}
.ticket-title { line-height: 1.35; }
.ticket-office { color:#334155; font-weight:700; }
.tv-pro {
    background:
      radial-gradient(circle at top center, rgba(250,204,21,.08), transparent 28%),
      linear-gradient(180deg, #03112f, #020617);
}
.tv-header-pro {
    padding: 22px 34px;
    border-bottom: 3px solid #facc15;
    background: rgba(15, 23, 42, .96);
    backdrop-filter: blur(4px);
}
.tv-head-left {
    display:flex;
    align-items:center;
    gap:18px;
}
.tv-logo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background:#fff;
    padding:6px;
    object-fit: cover;
    box-shadow: 0 12px 28px rgba(0,0,0,.22);
}
.tv-overline {
    display:inline-block;
    margin-bottom: 8px;
    color:#93c5fd;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.tv-head-right {
    text-align:right;
}
.tv-date {
    color:#cbd5e1;
    font-size: 18px;
    text-transform: capitalize;
    margin-bottom: 8px;
}
.tv-main-pro {
    padding: 36px 26px 28px;
}
.tv-now {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: .18em;
    color:#93c5fd;
    text-transform: uppercase;
    margin-bottom: 20px;
}
.tv-small {
    font-size: 30px;
    padding: 12px 28px;
}
.tv-code {
    margin-top: 24px;
    font-size: 184px;
    letter-spacing: -4px;
}
.tv-type {
    margin-top: 18px;
    font-size: 36px;
    color:#f8fafc;
}
.tv-module-wrap {
    margin-top: 28px;
    display: inline-flex;
    align-items:center;
    gap: 16px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    padding: 20px 30px;
    border-radius: 22px;
    box-shadow: 0 20px 40px rgba(37,99,235,.28);
}
.tv-module-icon {
    font-size: 34px;
    line-height: 1;
}
.tv-module-text {
    font-size: 34px;
    font-weight: 900;
}
.tv-footer-pro {
    display:grid;
    gap:14px;
    padding: 20px 34px 22px;
    background: rgba(15, 23, 42, .95);
}
.tv-last-item {
    min-width: 150px;
    text-align:center;
    background: linear-gradient(180deg, #1e293b, #0f172a);
    border: 1px solid #334155;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.tv-bottom-note {
    text-align:center;
    color:#cbd5e1;
    font-size: 16px;
}
.tv-pulse {
    animation: tvPulse .7s ease;
}
@keyframes tvPulse {
    0% { transform: scale(.92); opacity:.6; }
    60% { transform: scale(1.04); opacity:1; }
    100% { transform: scale(1); }
}
@media (max-width: 900px) {
    .login-grid { grid-template-columns: 1fr; }
    .tv-header { padding: 16px; align-items:flex-start; gap:14px; }
    .tv-head-left { align-items:flex-start; }
    .tv-logo { width: 66px; height: 66px; }
    .tv-header h1 { font-size: 28px; }
    .tv-header p { font-size: 15px; }
    .tv-date { font-size: 14px; }
    .tv-clock { font-size: 24px; }
    .tv-now { font-size: 18px; }
    .tv-small { font-size: 20px; }
    .tv-code { font-size: 92px; }
    .tv-type { font-size: 24px; }
    .tv-module-wrap { padding: 14px 18px; gap: 10px; }
    .tv-module-text { font-size: 20px; }
    .tv-last-item { min-width: 100px; font-size: 22px; }
}


/* v1.2.1 ajuste fino del logo institucional */
.brand {
    align-items: center;
}
.brand-logo {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 14px;
    object-fit: contain;
    background: rgba(255,255,255,.95);
    padding: 4px;
    box-shadow: 0 8px 20px rgba(0,0,0,.18);
}
.login-logo-img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 18px;
    background: #ffffff;
    padding: 6px;
    display: block;
    margin-bottom: 14px;
}
.ticket-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 3px;
    margin: 0 auto 6px;
    display: block;
}
.tv-head-left {
    gap: 14px;
}
.tv-logo {
    width: 74px;
    height: 74px;
    border-radius: 18px;
    object-fit: contain;
    background: rgba(255,255,255,.98);
    padding: 5px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.tv-header h1 {
    font-size: 34px;
    line-height: 1.05;
}
.tv-header p {
    font-size: 18px;
}
.tv-overline {
    margin-bottom: 6px;
    font-size: 12px;
}
@media (max-width: 900px) {
    .tv-logo {
        width: 56px;
        height: 56px;
        border-radius: 14px;
    }
    .brand-logo {
        width: 46px;
        height: 46px;
    }
    .login-logo-img {
        width: 82px;
        height: 82px;
    }
}


/* v1.2.2 bloqueo de tamaño de logo para evitar desbordes por caché */
img.brand-logo {
    width: 52px !important;
    height: 52px !important;
    max-width: 52px !important;
    max-height: 52px !important;
    object-fit: contain !important;
    flex: 0 0 52px !important;
}
img.tv-logo {
    width: 64px !important;
    height: 64px !important;
    max-width: 64px !important;
    max-height: 64px !important;
    object-fit: contain !important;
    flex: 0 0 64px !important;
}
img.login-logo-img {
    width: 90px !important;
    height: 90px !important;
    max-width: 90px !important;
    max-height: 90px !important;
    object-fit: contain !important;
}
img.ticket-logo {
    width: 42px !important;
    height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    object-fit: contain !important;
}


/* v1.3 mejoras de dashboard, atención y reportes */
.hero-panel {
    background:
      radial-gradient(circle at top right, rgba(37,99,235,.16), transparent 34%),
      linear-gradient(135deg, #ffffff, #f8fafc);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 24px;
    padding: 24px;
    display:flex;
    justify-content:space-between;
    gap:18px;
    align-items:center;
}
.hero-panel h2 {
    margin: 4px 0 6px;
    font-size: 30px;
}
.hero-panel p {
    margin: 0;
    color: var(--muted);
}
.hero-kicker {
    display:inline-flex;
    background:#dbeafe;
    color:#1d4ed8;
    border-radius:999px;
    padding:6px 12px;
    font-size:12px;
    font-weight:900;
    text-transform:uppercase;
    letter-spacing:.08em;
}
.hero-actions {
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    justify-content:flex-end;
}
.metric-card .card-body {
    position:relative;
    min-height: 138px;
}
.metric-card small {
    color: var(--muted);
    font-weight:700;
}
.metric-icon {
    width:42px;
    height:42px;
    display:grid;
    place-items:center;
    border-radius:14px;
    background:#eff6ff;
    margin-bottom:10px;
}
.metric-sm {
    font-size: 32px;
    letter-spacing:-1px;
}
.section-head {
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:14px;
    margin-bottom: 12px;
}
.section-head .card-title {
    margin-bottom: 4px;
}
.current-card {
    min-height: 430px;
}
.empty-state {
    display:grid;
    place-items:center;
    text-align:center;
    padding: 20px;
}
.empty-state.small {
    min-height: 130px;
}
.empty-icon {
    font-size: 46px;
    margin-bottom: 10px;
}
.ticket-meta {
    margin-top: 14px;
    display:flex;
    justify-content:center;
    gap:10px;
    flex-wrap:wrap;
}
.ticket-meta span {
    background:#f1f5f9;
    border:1px solid #e2e8f0;
    padding:8px 12px;
    border-radius:999px;
    color:#475569;
    font-weight:700;
}
.next-ticket-box {
    border-radius: 22px;
    background:
      radial-gradient(circle at top right, rgba(250,204,21,.18), transparent 35%),
      linear-gradient(135deg, #0f172a, #1e293b);
    color: #fff;
    padding: 22px;
    display:grid;
    gap:8px;
    text-align:center;
}
.next-ticket-box span {
    color:#fde68a;
    font-size:13px;
    letter-spacing:.12em;
    text-transform:uppercase;
    font-weight:900;
}
.next-ticket-box strong {
    font-size: 64px;
    line-height: 1;
    color:#facc15;
}
.next-ticket-box.compact strong {
    font-size: 46px;
}
.next-ticket-box small {
    color:#cbd5e1;
}
.quick-list {
    display:grid;
    gap:8px;
}
.quick-list a {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:12px 14px;
    border:1px solid var(--border);
    border-radius:14px;
    background:#fff;
    font-weight:800;
    transition:.2s;
}
.quick-list a:hover {
    background:#f8fafc;
    transform: translateX(3px);
}
.attention-layout {
    display:grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap:18px;
    align-items:start;
}
.attention-side {
    position: sticky;
    top: 18px;
}
.action-grid form {
    display:inline-flex;
}
.call-next-btn {
    width: min(520px, 100%);
}
.mini-stats {
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:10px;
}
.mini-stats div {
    border:1px solid var(--border);
    background:#f8fafc;
    border-radius:16px;
    padding:14px;
}
.mini-stats strong {
    display:block;
    font-size:30px;
    line-height:1;
}
.mini-stats span {
    color: var(--muted);
    font-size:13px;
    font-weight:700;
}
.order-badge {
    width:34px;
    height:34px;
    border-radius:50%;
    background:#e0f2fe;
    color:#075985;
    display:grid;
    place-items:center;
    font-weight:900;
}
.row-next {
    background:#fffbeb;
}
.ticket-create-card {
    position:relative;
}
.ticket-create-card .card-body {
    padding: 30px;
}
.ticket-create-card h2 {
    margin: 8px 0 4px;
    font-size: 28px;
}
.ticket-create-card .btn-xl {
    min-height: auto;
    margin-top: 8px;
}
.ticket-create-card.normal {
    border-top: 5px solid #1d4ed8;
}
.ticket-create-card.pref {
    border-top: 5px solid #dc2626;
}
.create-icon {
    width:64px;
    height:64px;
    display:grid;
    place-items:center;
    font-size:32px;
    border-radius:22px;
    background:#f1f5f9;
}
.last-tickets-grid {
    display:grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap:10px;
}
.last-ticket {
    border:1px solid var(--border);
    background:#fff;
    border-radius:16px;
    padding:14px;
    display:grid;
    gap:4px;
}
.last-ticket span {
    color: var(--muted);
    font-size:11px;
    letter-spacing:.08em;
    text-transform:uppercase;
    font-weight:900;
}
.last-ticket strong {
    font-size:28px;
}
.last-ticket small {
    color: var(--muted);
}
@media print {
    .sidebar, .topbar, .hero-panel, .actions, .btn, .no-print { display:none !important; }
    .app-shell { display:block !important; }
    .main-content { padding:0 !important; }
    .card { box-shadow:none !important; border:0 !important; }
}
@media (max-width: 1100px) {
    .attention-layout {
        grid-template-columns: 1fr;
    }
    .attention-side {
        position:relative;
        top:0;
    }
    .last-tickets-grid {
        grid-template-columns: repeat(3, minmax(130px, 1fr));
    }
}
@media (max-width: 700px) {
    .hero-panel {
        flex-direction:column;
        align-items:stretch;
    }
    .hero-actions {
        justify-content:stretch;
    }
    .hero-actions .btn {
        width:100%;
    }
    .section-head {
        flex-direction:column;
    }
    .last-tickets-grid {
        grid-template-columns: 1fr 1fr;
    }
    .next-ticket-box strong {
        font-size: 48px;
    }
}
