:root {
    --bg-global: #051e3e; --bg-header: #03162f; --bg-nav: #0a2b5e; --bg-container: #0d3c75;
    --card-blue: #3498db; --card-teal: #1abc9c; --card-pink: #e91e63; 
    --card-orange: #f39c12; --card-indigo: #8e44ad; --card-success: #2ecc71;
    --text-white: #ffffff; --text-dim: #cfd8dc;
}
* { box-sizing: border-box; }
body { 
    margin: 0; padding: 0; 
    background: var(--bg-global); color: var(--text-white); 
    font-family: 'Segoe UI', Tahoma, sans-serif; 
    overflow: hidden; height: 100vh; width: 100vw;
    display: flex; flex-direction: column; 
}

/* HEADER */
.header-container { background-color: var(--bg-header); height: 50px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); flex-shrink: 0; z-index: 100; }
.app-title { font-size: clamp(16px, 1.8vw, 22px); font-weight: 800; letter-spacing: 1px; text-transform: uppercase; position: absolute; left: 50%; transform: translateX(-50%); }
.header-right { display: flex; align-items: center; gap: 15px; font-size: 14px; color: var(--text-dim); }
.btn-gear { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; cursor: pointer; font-size: 28px; padding: 5px 15px; border-radius: 8px; transition: 0.2s; }
.btn-gear:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); }

/* NAV */
.nav-bar { background: var(--bg-nav); display: flex; justify-content: center; padding: 0; margin-bottom: 5px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); flex-shrink: 0; }
.nav-btn { background: transparent; border: none; color: rgba(255,255,255,0.6); padding: 10px 20px; font-size: clamp(11px, 1.2vw, 14px); cursor: pointer; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 3px solid transparent; transition: all 0.3s; }
.nav-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-btn.active { color: #fff; background: rgba(255,255,255,0.1); border-bottom-color: var(--card-blue); }

/* METRICS */
.metrics-wrapper { flex-shrink: 0; margin-bottom: 10px; padding: 0 10px; }
.metrics-row { display: none; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.metrics-row.active { display: grid; } 
.kpi-card { padding: 5px; border-radius: 10px; text-align: center; height: 10vh; min-height: 70px; display: flex; flex-direction: column; justify-content: center; align-items: center; box-shadow: 0 4px 10px rgba(0,0,0,0.1); background: var(--bg-container); }
.kpi-card.c-orange { background-color: var(--card-orange); } .kpi-card.c-blue { background-color: var(--card-blue); }
.kpi-card.c-teal { background-color: var(--card-teal); } .kpi-card.c-pink { background-color: var(--card-pink); }
.kpi-card.c-indigo { background-color: var(--card-indigo); } .kpi-card.c-success { background-color: var(--card-success); }
.kpi-label { font-size: clamp(9px, 0.8vw, 11px); color: rgba(255,255,255,0.9); text-transform: uppercase; font-weight: 600; margin-bottom: 2px; }
.kpi-value { font-size: clamp(20px, 3vw, 36px); font-weight: 800; line-height: 1; text-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.kpi-sub { font-size: clamp(8px, 0.6vw, 10px); margin-top: 2px; opacity: 0.8; }

/* CONTENT */
.main-wrapper { padding: 0 10px; flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.content-area { flex-grow: 1; position: relative; overflow: hidden; margin-bottom: 5px; display: flex; flex-direction: column; min-height: 0; }
.tab-pane { display: none; height: 100%; width: 100%; animation: fadeIn 0.4s ease-in-out; flex-grow: 1; min-height: 0; }
.tab-pane.active { display: block; }
.split-view { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; height: 100%; min-height: 0; }
.list-panel { background: var(--bg-container); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; border: none; box-shadow: 0 4px 15px rgba(0,0,0,0.15); height: 100%; }
.panel-header { padding: 8px 15px; background: rgba(0,0,0,0.1); font-size: clamp(12px, 1.4vw, 15px); font-weight: 700; text-transform: uppercase; color: var(--text-white); display: flex; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.05); flex-shrink: 0; }
.scroller-container { overflow-y: auto; flex-grow: 1; position: relative; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; min-height: 0; display: flex; flex-direction: column; }
.scroller-content { padding: 0 15px; }
.ticket-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); align-items: center; }
.t-subject { font-size: clamp(12px, 1.1vw, 15px); font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.t-meta { font-size: clamp(10px, 0.9vw, 12px); color: rgba(255,255,255,0.6); margin-top: 2px; }
.t-time { font-size: clamp(11px, 1vw, 13px); font-weight: 700; color: var(--card-blue); white-space: nowrap; margin-left: 10px; }
.badge { padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: bold; margin-left: 6px;}
.b-urgent { background: var(--card-pink); color: #fff; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* QUALITY TAB */
.quality-container { height: 100%; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; background: var(--bg-container); border-radius: 12px; border: 2px solid var(--card-orange); text-align: center; position: relative; overflow: hidden; padding: 10px; }
.q-stars { font-size: clamp(30px, 5vw, 60px); animation: pulse 2s infinite; line-height: 1; }
.q-comment-box { background: rgba(255,255,255,0.05); padding: 15px; border-radius: 12px; width: 95%; font-size: clamp(16px, 2.2vh, 26px); font-style: italic; line-height: 1.3; font-family: 'Georgia', serif; max-height: 45%; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.q-info-block { display: flex; flex-direction: column; gap: 2px; }
.q-agent-name { font-size: clamp(20px, 3vw, 36px); font-weight: 800; color: var(--card-orange); line-height: 1.1; }
.q-client-block { margin-top: 5px; }
.q-org { font-size: clamp(16px, 2vw, 26px); font-weight: 800; color: white; line-height: 1.1; }
.q-meta { font-size: 12px; color:#888; margin-top: 5px; }

/* RANKING FIX */
.agent-list { display: flex; flex-direction: column; align-items: stretch; justify-content: space-evenly; height: 100%; padding: 10px 20px; overflow: hidden; } 
.agent-card { background: rgba(255,255,255,0.05); padding: 5px 15px; border-radius: 50px; display: grid; grid-template-columns: 30px 40px 1fr auto; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,0.1); flex: 1; max-height: 18%; min-height: 0; }
.rank-1 { background: var(--card-blue); border: 2px solid #fff; box-shadow: 0 0 10px rgba(52, 152, 219, 0.5); transform: scale(1.01); }
.a-pos { font-size: 20px; font-weight: 800; text-align: center; }
.a-avatar { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; background: #333; }
.a-info { display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.a-name { font-size: clamp(13px, 1.4vw, 18px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-badge { font-size: 9px; opacity: 0.8; text-transform: uppercase; }
.a-score-box { font-size: 22px; font-weight: 800; color: #fff; padding-right: 5px; }
.chart-container { position: relative; height: 100%; width: 100%; padding: 10px; display: flex; justify-content: center; align-items: center; }
.footer { background-color: var(--bg-nav); height: 25px; display: flex; justify-content: center; align-items: center; font-size: 11px; font-weight: bold; color: rgba(255,255,255,0.4); letter-spacing: 2px; text-transform: uppercase; flex-shrink: 0; }

/* CONFIGURAÇÕES - TV MODE (BIG BUTTONS) */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 2000; display: flex; justify-content: center; align-items: center; }

/* Modal maior para TV */
.modal-box { 
    background: var(--bg-container); 
    padding: 30px; 
    width: 80%; /* Mais largo */
    max-width: 900px;
    border-radius: 20px; 
    border: 2px solid rgba(255,255,255,0.2); 
    display: flex; 
    flex-direction: column; 
    max-height: 95vh;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

.input-group { margin-bottom: 20px; flex-grow: 1; min-height: 0; display: flex; flex-direction: column; }
label { display: block; font-size: 18px; color: var(--card-blue); font-weight: bold; margin-bottom: 8px; text-transform: uppercase; }

/* Área de Grupos com botões de scroll grandes */
.group-control-wrapper { display: flex; gap: 20px; flex-grow: 1; min-height: 0; border: 1px solid rgba(255,255,255,0.1); padding: 10px; border-radius: 10px; background: rgba(0,0,0,0.2); }
.group-scroll { flex-grow: 1; overflow-y: hidden; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; align-content: start; }

.chk-item { font-size: 20px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 8px; display: flex; align-items: center; gap: 15px; }
.chk-item input { width: 30px; height: 30px; }

.scroll-buttons { display: flex; flex-direction: column; gap: 10px; justify-content: center; width: 80px; }
.btn-scroll { background: var(--card-blue); border: none; color: white; border-radius: 10px; flex-grow: 1; cursor: pointer; font-size: 40px; display: flex; align-items: center; justify-content: center; transition: 0.1s; }
.btn-scroll:active { background: white; color: var(--card-blue); transform: scale(0.95); }

/* CONTROLES DE NÚMERO (STEPPERS) */
.stepper-container { display: flex; gap: 20px; justify-content: space-between; margin-bottom: 20px; }
.stepper-box { flex: 1; background: rgba(0,0,0,0.3); padding: 15px; border-radius: 12px; }
.stepper-ctrl { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
.btn-step { width: 60px; height: 60px; font-size: 30px; font-weight: bold; border-radius: 12px; border: none; cursor: pointer; background: var(--bg-nav); color: white; border: 2px solid rgba(255,255,255,0.1); }
.btn-step:active { background: var(--card-orange); }
.val-display { font-size: 32px; font-weight: 800; width: 100px; text-align: center; }

/* Botões de Ação Gigantes */
.action-row { display: flex; gap: 20px; margin-top: 10px; }
.btn-action { flex: 1; padding: 20px; font-size: 20px; font-weight: bold; border-radius: 12px; border: none; cursor: pointer; text-transform: uppercase; }
.btn-save { background: var(--card-success); color: white; }
.btn-test { background: var(--card-indigo); color: white; }
.btn-reload { background: var(--bg-nav); color: white; border: 1px solid rgba(255,255,255,0.2); }

@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fall { to { transform: translateY(100vh) rotate(720deg); } }
.hidden { display: none; }
.confetti { position: absolute; width: 10px; height: 10px; top: -10px; }