/* ============================================================
   EMEUTRANS — agenda_layout.css
   CSS específico das agendas (recolhas, grupagem, entregas)
   Carregado DEPOIS do CSS global do index.php
   Selectores .tw garantem especificidade sobre thead th / tbody td
   ============================================================ */

/* ── VARIÁVEIS (redundância intencional — picker carrega sem index.php) ── */
:root {
    --bg:#0d0f14;--bg2:#13161e;--bg3:#1a1e28;
    --border:#252a3a;--border2:#32394f;
    --text:#eef0f5;--text2:#a8b0c8;--text3:#404868;
    --accent:#2563eb;--green:#22c55e;--gdim:#166534;
    --yellow:#eab308;--orange:#f97316;--white:#eef0f5;
    --grp:#7c3aed;--grp-bg:#0e0a1c;
    --dir:#0891b2;--dir-bg:#071620;
    --hd-bg:#1e40af;--hd-bg2:#1d3a9e;
    --hd-green:#4ade80;--hd-orange:#fb923c;
    --row-h:22px;
}

/* ── RESET CRÍTICO — anula padding do index.php nas agendas ── */
/* index.php tem: tbody td { padding:9px 12px } e thead th { padding:8px 12px } */
/* .tw ganha especificidade suficiente para sobrepor */

.tw > table thead th,
.tw thead th {
    padding: 0 3px !important;
    height: 22px !important;
    max-height: 22px !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: .6px !important;
    text-align: center !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    color: #ffffff !important;
    background: #07090e !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 2px solid var(--border2) !important;
}

.tw > table tbody td,
.tw tbody td {
    padding: 0 2px !important;
    height: 22px !important;
    max-height: 22px !important;
    font-size: 16px !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}

/* ── LINHA TOTAIS (tr.sum) — altura 18px ── */
.tw tr.sum td,
.tw tr.sum.grp-sum td,
.tw tr.sum.dir-sum td {
    padding: 0 2px !important;
    height: 22px !important;
    max-height: 22px !important;
}

/* ── CABEÇALHO DE BLOCO (tr.hd-grp / tr.hd-dir) — altura 20px ── */
.tw tr.hd-grp td,
.tw tr.hd-dir td {
    padding: 0 !important;
    height: 22px !important;
    max-height: 22px !important;
}

/* ── LINHA BRANCO ── */
.tw tr.blank td {
    height: 7px !important;
    padding: 0 !important;
}

/* ── SCROLL ── */
.tw {
    overflow-y: auto;
    overflow-x: hidden;
}
.tw::-webkit-scrollbar { width: 5px; }
.tw::-webkit-scrollbar-track { background: var(--bg); }
.tw::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── TABLE BASE ── */
.tw table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.tw thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

/* ── HOVER LINHAS ── */
.tw tbody tr:hover td { background: #181e2f !important; }
.tw tbody tr.rg:hover td { background: #150f28 !important; }
.tw tbody tr.rd:hover td { background: #0d2030 !important; }

/* ── CABEÇALHO BLOCO — cores ── */
.tw tr.hd-grp td { background: var(--hd-bg) !important; border-left: 4px solid #c084fc !important; border-bottom: 1px solid #1e3a8a !important; }
.tw tr.hd-dir td { background: var(--hd-bg) !important; border-left: 4px solid #67e8f9 !important; border-bottom: 1px solid #1e3a8a !important; }

/* ── LINHAS GRUPAGEM/DIRETA/SOLTA ── */
.tw tr.rg td { background: var(--grp-bg); }
.tw tr.rd td { background: var(--dir-bg); }
.tw tr.rsolto td { background: var(--bg); }

/* ── TOTAIS — cores ── */
.tw tr.sum td,
.tw tr.sum.grp-sum td,
.tw tr.sum.dir-sum td {
    background: var(--hd-bg2) !important;
    border-top: 2px solid #3b82f6 !important;
    border-bottom: 2px solid #1e3a8a !important;
}
.tw tr.sum.grp-sum td { border-left: 4px solid #c084fc !important; }
.tw tr.sum.dir-sum td { border-left: 4px solid #67e8f9 !important; }

/* ── CÉLULAS ESPECIAIS ── */
.tw td.drag { text-align: center; color: var(--text3); font-size: 11px; cursor: grab; background: #0a0c12; }
.tw td.drag:hover { color: var(--accent); }
.tw td.res-num { font-family: monospace; font-size: 16px !important; font-weight: 600; color: #93c5fd; cursor: pointer; }
.tw td.res-num:hover { color: #fff; text-decoration: underline; }
.tw td.mono { font-family: monospace; font-size: 16px !important; }
.tw td.r { text-align: right; padding-right: 4px !important; }
.tw td.c { text-align: center; }
.tw td.sv { font-family: monospace; font-size: 13px !important; font-weight: 700; color: #84cc16 !important; text-align: right; padding-right: 4px !important; }
.tw td.sv.eur { color: #84cc16 !important; font-size: 13px !important; }
.tw .sum-lbl { font-size: 13px !important; font-style: italic; color: #fb923c !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 5px; }

/* ── CABEÇALHO BLOCO INTERIOR ── */
.tw .hd-inner { display: flex; align-items: center; height: 100%; padding: 0 5px; gap: 0; overflow: visible; }
.tw .hd-tag { font-size: 13px !important; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; margin-right: 6px; flex-shrink: 0; white-space: nowrap; }
.tw .hd-tag.g { background: #f97316; color: #fff; }
.tw .hd-tag.d { background: #f97316; color: #fff; }
.tw .hd-tag.sel { background: #84cc16 !important; color: #0a1a00 !important; box-shadow: 0 0 8px #84cc16; }
.tw .hd-lbl { font-size: 13px !important; font-weight: 700 !important; text-transform: uppercase; letter-spacing: .5px; color: #ffd700 !important; }
.tw .hd-f { display: flex; align-items: center; gap: 3px; padding: 0 6px !important; border-right: 1px solid rgba(255,255,255,.15); height: 100%; flex-shrink: 0; white-space: nowrap; font-size: 13px !important; }
.tw .hd-v { font-family: monospace; font-size: 13px !important; font-weight: 700; color: #e0f2fe; }
.tw .hd-sel { background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.2); color: #e0f2fe; padding: 2px 8px; border-radius: 3px; font-size: 13px !important; font-family: inherit; cursor: pointer; outline: none; max-width: 120px; }
.tw .hd-inp { background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.2); color: #fff; padding: 2px 8px; border-radius: 3px; font-family: monospace; font-size: 13px !important; width: 150px; outline: none; }
.tw .hd-btn { height: 22px; padding: 0 8px; border-radius: 3px; border: 1px solid rgba(255,255,255,.2); background: transparent; color: rgba(255,255,255,.5); font-size: 11px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.tw .hd-btn.on { background: rgba(74,222,128,.2); border-color: #4ade80; color: #4ade80; }
.tw .hd-btn:hover { border-color: rgba(255,255,255,.5); color: #fff; }
.tw .hd-chv { margin-left: auto; color: rgba(255,255,255,.35); cursor: pointer; font-size: 12px; padding: 0 5px; flex-shrink: 0; transition: transform .2s; background: none; border: none; }
.tw .hd-chv.o { transform: rotate(90deg); }

/* ── ROTA ── */
.tw .hd-rota { display: flex; align-items: center; gap: 4px; padding: 0 8px; border-right: 1px solid rgba(255,255,255,.15); height: 100%; flex-shrink: 0; white-space: nowrap; }
.tw .hd-rota-name { font-family: monospace; font-size: 13px !important; font-weight: 700; color: #fde047; }
.tw .hd-rota-prog { font-size: 11px; color: rgba(255,255,255,.5); margin-left: 3px; }
.tw .hd-rota-bar { width: 55px; height: 5px; background: rgba(255,255,255,.1); border-radius: 3px; margin-left: 4px; overflow: hidden; flex-shrink: 0; }
.tw .hd-rota-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.tw .hd-rota-fill.warn { background: var(--hd-orange); }
.tw .hd-rota-fill.ok { background: #4ade80; box-shadow: 0 0 4px #4ade80; }

/* ── PISCOS ── */
.tw .pisco { display: inline-block; width: 10px !important; height: 10px !important; border-radius: 50%; vertical-align: middle; cursor: pointer; }
.tw .pisco.off { background: #1e2535; border: 1px solid #2a3050; }
.tw .pisco.sent { background: var(--orange); border: 1px solid var(--orange); box-shadow: 0 0 4px var(--orange); }
.tw .pisco.read { background: var(--green); border: 1px solid var(--green); box-shadow: 0 0 4px var(--green); }
.tw .pisco.warn { background: var(--yellow); border: 1px solid var(--yellow); }

/* ── MC (motorista cell) ── */
.tw .mc { display: flex; align-items: center; gap: 2px; }
.tw .mc .mt { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 13px !important; }
.tw .mc .me { width: 16px; height: 16px; border: none; background: transparent; color: var(--text3); cursor: pointer; font-size: 11px; flex-shrink: 0; border-radius: 2px; padding: 0; display: flex; align-items: center; justify-content: center; }
.tw .mc .me:hover { color: var(--accent); background: var(--bg3); }

/* ── BADGES ESTADO ── */
.tw .est { padding: 1px 5px; border-radius: 8px; font-size: 16px !important; font-weight: 600; white-space: nowrap; }
.tw .e-pend { background: #1c1a00; color: #fde047; border: 1px solid #713f12; }
.tw .e-rec  { background: #0c1a2e; color: #60a5fa; border: 1px solid #1e3a5f; }
.tw .e-grp  { background: #1a0d2e; color: #c4b5fd; border: 1px solid #4c1d95; }
.tw .e-tran { background: #0a1f0a; color: #86efac; border: 1px solid #14532d; }
.tw .e-fat  { background: #1c1700; color: #fbbf24; border: 1px solid #78350f; }
.tw .e-can  { background: #1a0000; color: #f87171; border: 1px solid #7f1d1d; }

/* ── PRIORIDADES ── */
.tw .pri { font-size: 16px !important; font-weight: 700; padding: 1px 4px; border-radius: 3px; font-family: monospace; }
.tw .p1 { background: #450a0a; color: #f87171; }
.tw .p2 { background: #451a03; color: #fb923c; }
.tw .p3 { background: #1c1a00; color: #fde047; }
.tw .p4 { background: #0a1a0a; color: #86efac; }

/* ── CHECKBOX ── */
.tw .chk-sel { width: 13px; height: 13px; accent-color: #84cc16; cursor: pointer; display: block; margin: 0 auto; }

/* ── BOTÃO ORDENAR ── */
.tw .ord-btn { width: 100%; height: 18px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.25); border-radius: 3px; color: #4ade80; font-size: 11px; font-weight: 700; cursor: pointer; font-family: monospace; display: flex; align-items: center; justify-content: center; }
.tw .ord-btn:hover { background: rgba(74,222,128,.2); border-color: #4ade80; }

/* ── MSG BADGE ── */
.tw .msgb { background: var(--accent); color: #fff; font-size: 10px !important; font-weight: 700; padding: 1px 3px; border-radius: 4px; font-family: monospace; cursor: pointer; }
.tw .msgb:hover { background: #3b82f6; }
.tw .msgb.lido { background: var(--text3); }

/* Remove browser default focus outline/border nos inputs */
input:focus, select:focus, textarea:focus {
    outline: none !important;
    box-shadow: none !important;
    border-color: #2e3850 !important;
}

/* ── TOOLBAR BOTÕES — fix v31 ── */
.toolbar .btn {
    height: 22px !important;
    font-size: 17px !important;
    padding: 0 8px !important;
}
.toolbar {
    height: 22px !important;
}

/* ── OVERRIDE btn-h do index.php — fix v31 ── */
body .toolbar .btn,
body .toolbar button.btn {
    height: 22px !important;
    font-size: 17px !important;
    padding: 0 8px !important;
    line-height: 22px !important;
}
body .toolbar {
    height: 22px !important;
    min-height: 22px !important;
    max-height: 22px !important;
}
