:root {
    --brand: #0b3d5c;
    --brand-700: #082e45;
    --brand-100: #e6eef5;
    --accent: #0f9b8e;
    --accent-soft: #e2f5f2;
    --ink: #12212f;
    --muted: #63717f;
    --line: #e3e8ee;
    --bg: #f4f7fa;
    --radius: 14px;
}

* { -webkit-tap-highlight-color: transparent; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Navbar ---------- */
.app-navbar {
    background: linear-gradient(100deg, var(--brand-700), var(--brand) 60%, var(--brand-700));
    padding-block: .65rem;
    box-shadow: 0 2px 10px rgba(11, 61, 92, .18);
}

.app-navbar .navbar-brand {
    color: #fff;
    line-height: 1.1;
    font-size: .95rem;
    letter-spacing: .2px;
}

.app-navbar .navbar-brand small {
    color: #a9c6da;
    font-size: .72rem;
    font-weight: 400;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    font-weight: 800;
    color: var(--brand);
    background: linear-gradient(150deg, #ffffff, #cfe6f2);
    box-shadow: inset 0 -2px 6px rgba(11, 61, 92, .18);
}

.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.5rem; }

.nav-link-app {
    color: #cfe0ec;
    text-decoration: none;
    font-size: .9rem;
    padding: .35rem .6rem;
    border-radius: 9px;
    transition: background .15s ease, color .15s ease;
}

.nav-link-app:hover, .nav-link-app.active { color: #fff; background: rgba(255, 255, 255, .12); }
.nav-link-app i { margin-right: .25rem; }

.user-chip {
    color: #fff;
    font-size: .85rem;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.user-chip .role {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: rgba(255, 255, 255, .14);
    padding: .18rem .45rem;
    border-radius: 6px;
    color: #d7e8f3;
}

/* ---------- Conteúdo ---------- */
.app-main {
    padding-top: 1.5rem;
    padding-bottom: 6rem;
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head p { color: var(--muted); margin: .2rem 0 0; font-size: .9rem; }

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    height: 100%;
    box-shadow: 0 1px 2px rgba(18, 33, 47, .04);
}

.stat-card .stat-label {
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: .35rem;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--brand-100);
    color: var(--brand);
    font-size: 1.15rem;
}

.stat-card .stat-icon.accent { background: var(--accent-soft); color: var(--accent); }

.card-app {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(18, 33, 47, .04);
}

.card-app .card-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    padding: .9rem 1.1rem;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-app .card-body { padding: 1.1rem; }

.table-app { margin: 0; font-size: .9rem; }
.table-app thead th {
    background: #f8fafc;
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table-app td { vertical-align: middle; border-color: #eef2f6; }

.badge-role {
    font-size: .7rem;
    font-weight: 600;
    padding: .28rem .5rem;
    border-radius: 6px;
    background: var(--brand-100);
    color: var(--brand);
}
.badge-role.is-admin { background: #e8f0ff; color: #2456b3; }
.badge-role.is-atendente { background: var(--accent-soft); color: #0b7a6f; }
.badge-role.is-super { background: #fdf0e3; color: #a86a12; }

/* ---------- Barra fixa mobile ---------- */
.bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(18, 33, 47, .07);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-bar-form { flex: 1 1 0; display: flex; margin: 0; }

.bottom-bar-item {
    flex: 1 1 0;
    border: 0;
    background: none;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #7b8794;
    font-size: .7rem;
    text-decoration: none;
}

.bottom-bar-item i { font-size: 1.25rem; }
.bottom-bar-item.active { color: var(--brand); font-weight: 600; }
.bottom-bar-item.active i { color: var(--brand); }

/* ---------- Login ---------- */
.auth-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(1200px 600px at 15% 0%, #12496d 0%, transparent 55%),
        radial-gradient(900px 500px at 100% 100%, #0d6b62 0%, transparent 50%),
        #081f2e;
}

.auth-wrapper {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    padding: 2rem 1.6rem 1.6rem;
    box-shadow: 0 24px 60px rgba(4, 23, 35, .45);
}

.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.25rem; font-weight: 700; margin: .8rem 0 .15rem; }
.auth-brand p { color: var(--muted); font-size: .85rem; margin: 0; }

.auth-card .form-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.auth-card .form-control { border-color: var(--line); }
.auth-card .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(11, 61, 92, .12);
}
.auth-card .btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    font-weight: 600;
}
.auth-card .btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }

.auth-foot {
    text-align: center;
    color: var(--muted);
    font-size: .75rem;
    margin: 1.2rem 0 0;
}

@media (min-width: 992px) {
    .app-main { padding-bottom: 2.5rem; }
}

@media (max-width: 575.98px) {
    .app-main { padding-top: 1rem; }
    .stat-card { padding: .9rem 1rem; }
    .stat-card .stat-value { font-size: 1.6rem; }
}

/* ---------- Listas, badges e formulários ---------- */
.list-item { padding: .95rem 1.1rem; border-bottom: 1px solid #eef2f6; }
.list-item:last-child { border-bottom: 0; }

.badge-soft {
    font-size: .7rem;
    font-weight: 600;
    padding: .25rem .5rem;
    border-radius: 6px;
    background: #f1f5f9;
    color: var(--muted);
}
.badge-soft.text-success { background: #e7f6ec; }
.badge-soft.text-danger { background: #fdeceb; }

.form-label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(11, 61, 92, .12);
}
.modal-content { border: 0; border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--line); }

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}

.filters-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters-bar .form-select { width: auto; min-width: 150px; }

/* ---------- Público: totem e confirmação ---------- */
.public-body { background: var(--bg); }

.public-head {
    background: linear-gradient(100deg, var(--brand-700), var(--brand) 60%, var(--brand-700));
    color: #fff;
    padding: .9rem 0;
    box-shadow: 0 2px 10px rgba(11, 61, 92, .18);
}

.public-main { padding: 1.5rem 0 3rem; max-width: 960px; }

.option-card {
    display: block;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: .85rem 1rem;
    margin-bottom: .6rem;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card:has(input:checked) {
    border-color: var(--brand);
    background: #f7fbfd;
    box-shadow: 0 0 0 3px rgba(11, 61, 92, .1);
}
.option-body { display: flex; align-items: center; gap: .5rem; }

.ticket-card {
    background: #fff;
    border-radius: 20px;
    padding: 2rem 1.4rem;
    box-shadow: 0 16px 44px rgba(18, 33, 47, .14);
    max-width: 540px;
    margin: 0 auto;
}

.ticket-label {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .74rem;
    font-weight: 700;
    color: var(--muted);
}

.ticket-code {
    font-size: clamp(3rem, 17vw, 6rem);
    font-weight: 800;
    letter-spacing: .05em;
    line-height: 1;
    color: var(--brand);
    margin: .5rem 0 .9rem;
}

.ticket-meta { color: var(--muted); }
.ticket-position { margin-top: 1rem; font-weight: 700; }

@media print {
    .public-head, .btn { display: none !important; }
    .public-main { padding-top: 0; }
    .ticket-card { box-shadow: none; }
}

/* ---------- Painel do atendente ---------- */
.queue-switch { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .35rem; }

.queue-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
}

.queue-pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.queue-pill.active .color-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }

.current-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: 0 6px 20px rgba(18, 33, 47, .06);
}

.current-code {
    font-size: clamp(2.6rem, 12vw, 4.2rem);
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1.05;
    color: var(--brand);
    margin: .4rem 0 .2rem;
}

/* ---------- Painel de TV ---------- */
body.tv-body {
    background: #07131d;
    color: #eaf2f8;
    margin: 0;
    overflow: hidden;
}

.tv-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: clamp(.6rem, 1.4vh, 1.2rem);
    padding: clamp(.8rem, 2vh, 1.8rem);
}

.tv-head { display: flex; justify-content: space-between; align-items: center; }
.tv-brand { display: flex; align-items: center; gap: .8rem; }
.tv-brand strong { display: block; font-size: clamp(1.1rem, 2.2vw, 2rem); }
.tv-brand small { color: #7fa3bb; font-size: clamp(.7rem, 1vw, .95rem); }
.tv-clock {
    font-size: clamp(1.6rem, 3vw, 3rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #9fc4d8;
}

.tv-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1.6fr .9fr;
    gap: clamp(.6rem, 1.2vw, 1.2rem);
    min-height: 0;
}

.tv-calls { display: flex; flex-direction: column; gap: .55rem; min-height: 0; }

.tv-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    background: #0e2230;
    border: 1px solid #16344a;
    border-radius: 16px;
    padding: .6rem 1.1rem;
}

.tv-row.is-new {
    background: linear-gradient(90deg, #0f4c5a, #0e2230 70%);
    border-color: #1b7f8f;
    box-shadow: 0 0 0 1px rgba(28, 160, 175, .35);
}

.tv-code {
    font-size: clamp(2rem, 5vw, 4.4rem);
    font-weight: 800;
    letter-spacing: .03em;
    line-height: 1;
}

.tv-info .tv-queue {
    color: #8fb2c7;
    font-size: clamp(.72rem, 1.05vw, 1rem);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.tv-name { font-size: clamp(.95rem, 1.5vw, 1.4rem); font-weight: 600; }

.tv-desk { text-align: right; }
.tv-desk small {
    display: block;
    color: #7fa3bb;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.tv-desk strong { font-size: clamp(1.4rem, 2.8vw, 2.6rem); }

.tv-side { display: flex; min-height: 0; }

.tv-banner {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    background: #0e2230;
    border: 1px solid #16344a;
    border-radius: 16px;
    overflow: hidden;
    text-align: center;
    padding: 1.2rem;
}

.tv-banner img { max-width: 100%; max-height: 55%; object-fit: contain; border-radius: 10px; }
.tv-banner h2 { font-size: clamp(1.05rem, 1.8vw, 1.8rem); margin: 0; }
.tv-banner p { margin: 0; color: #9fc4d8; font-size: clamp(.82rem, 1.05vw, 1.05rem); }
.tv-banner-empty { opacity: .75; }

.tv-foot {
    display: flex;
    justify-content: space-between;
    color: #7fa3bb;
    font-size: clamp(.72rem, .95vw, .9rem);
}

.tv-empty { display: grid; place-items: center; height: 100%; color: #7fa3bb; font-size: 1.4rem; }

.tv-sound {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(4, 15, 23, .9);
    color: #cfe3ef;
}

@media (max-width: 900px) {
    .tv-grid { grid-template-columns: 1fr; }
    .tv-side { display: none; }
}
