/* ============================================================
   TCB DriveR v2 — main.css
   Tema: verde TCB, mobile-first, dark mode automático
   ============================================================ */

:root {
  /* ===== AppTheme — LIGHT (default) ===== */
  /* Fundos */
  --bg:           #eef2ef;
  --bg-2:         #e3e9e4;
  --card:         #ffffff;
  --card-2:       #f6f8f6;
  /* Alias: muito código usa var(--card-bg); segue SEMPRE o --card do tema atual.
     Sem isto, caía para branco (default) e no tema escuro dava texto claro em
     fundo branco = invisível. Definir aqui arranja todos os usos de uma vez. */
  --card-bg:      var(--card);
  --surface:      var(--card-2);
  /* Marca */
  --primary:      #1f5c2d;
  --primary-light:#2e7d32;
  --primary-faint:#e4f1e5;
  --accent:       #2e7d32;
  /* Texto */
  --text:         #1f2937;
  --text-2:       #374151;
  --muted:        #6b7280;
  /* Estados */
  --success:      #15803d;
  --success-bg:   #e6f4ea;
  --warning:      #b45309;
  --warning-bg:   #fef3e2;
  --error:        #dc2626;
  --error-bg:     #fdecec;
  --info:         #1d4ed8;
  --info-bg:      #e7eefe;
  /* Estrutura */
  --border:       #dfe5df;
  --separator:    #e5e9e5;
  --on-primary:   #ffffff;
  /* Navegação */
  --nav-bg:       rgba(20,40,20,.94);
  --nav-text:     #ffffff;
  --bnav-bg:      #ffffff;
  --bnav-text:    #6b7280;
  --bnav-active:  #1f5c2d;
  /* Sombra / forma */
  --shadow:       0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:    0 12px 28px rgba(0,0,0,.10);
  --radius:       20px;
  --radius-sm:    12px;
  --radius-lg:    24px;
  /* Espaçamento */
  --space-xs:     .35rem;
  --space-sm:     .65rem;
  --space-md:     1rem;
  --space-lg:     1.5rem;
  /* Tipografia */
  --fs-xs:        .72rem;
  --fs-sm:        .85rem;
  --fs-md:        1rem;
  --fs-lg:        1.2rem;
  /* Dimensões */
  --btn-h:        44px;
  --bnav-h:       62px;
  --header-h:     54px;
}

/* ===== AppTheme — DARK ===== */
[data-theme="dark"] {
  --bg:           #0f1720;
  --bg-2:         #0b1117;
  --card:         #17212b;
  --card-2:       #1d2732;
  --primary:      #2e7d32;
  --primary-light:#4ade80;
  --primary-faint:#1a2e1a;
  --accent:       #4ade80;
  --text:         #e5e7eb;
  --text-2:       #cbd2da;
  --muted:        #8d99a6;
  --success:      #4ade80;
  --success-bg:   #16321f;
  --warning:      #fbbf24;
  --warning-bg:   #3a2a10;
  --error:        #f87171;
  --error-bg:     #3a1717;
  --info:         #60a5fa;
  --info-bg:      #16243a;
  --border:       #293342;
  --separator:    #232d3a;
  --on-primary:   #ffffff;
  --nav-bg:       rgba(10,18,24,.94);
  --nav-text:     #e5e7eb;
  --bnav-bg:      #17212b;
  --bnav-text:    #8d99a6;
  --bnav-active:  #4ade80;
  --shadow:       0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.45);
  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow-lg:    0 12px 28px rgba(0,0,0,.55);
}


/* ===== AppTheme — TCB DRIVER (verde de marca, claro) ===== */
[data-theme="tcb"] {
  --bg:           #e8f1e8;
  --bg-2:         #dceadc;
  --card:         #ffffff;
  --card-2:       #f1f7f1;
  --primary:      #143214;
  --primary-light:#1f5c2d;
  --primary-faint:#d8ead8;
  --accent:       #1f5c2d;
  --text:         #16241a;
  --text-2:       #2f4636;
  --muted:        #5c7060;
  --border:       #cadccc;
  --separator:    #d4e3d6;
  --nav-bg:       rgba(15,40,15,.96);
  --nav-text:     #ffffff;
  --bnav-bg:      #ffffff;
  --bnav-text:    #5c7060;
  --bnav-active:  #143214;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: var(--text);
  min-height: 100vh;
}

/* ===== PAGE TRANSITION ===== */
#app-content {
  opacity: 1;
  transition: opacity .18s ease;
}
#app-content.fading { opacity: 0; }

/* ===== HEADER ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(20,40,20,.94);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.header-inner {
  max-width: 1400px; margin: auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem; gap: 1rem;
}
.logo {
  color: white; font-size: 1.15rem; font-weight: 800;
  letter-spacing: -.3px; text-decoration: none;
  display: flex; align-items: center; gap: .5rem;
}
.logo-badge {
  background: #2e7d32; color: white;
  font-size: .55rem; font-weight: 800;
  padding: .2rem .5rem; border-radius: 999px;
  letter-spacing: .5px; text-transform: uppercase;
}
.nav { display: flex; gap: .5rem; }
.nav a {
  color: white; text-decoration: none;
  padding: .5rem .9rem; border-radius: 999px;
  transition: .18s; font-size: .85rem; font-weight: 600;
}
.nav a:hover  { background: rgba(255,255,255,.1); }
.nav a.active { background: #2e7d32; }

/* ===== CLOCK ===== */
.clock {
  color: rgba(255,255,255,.75); font-size: .82rem;
  font-weight: 700; letter-spacing: .5px; white-space: nowrap;
}
@media(max-width:480px) { .clock { font-size: .72rem; } }

/* ===== BANNER UPDATE ===== */
#update-banner {
  background: #1f5c2d; color: #fff;
  text-align: center; padding: .6rem 1rem;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  position: sticky; top: 0; z-index: 200;
  animation: pulse-update 2s infinite;
}
#update-banner:hover { background: #174d25; }
@keyframes pulse-update {
  0%,100% { opacity: 1; } 50% { opacity: .85; }
}

/* ===== ALERTA BAR ===== */
#alert-bar {
  display: none; align-items: center; gap: .6rem;
  background: #fef3c7; border-bottom: 2px solid #f59e0b;
  padding: .5rem 1.5rem;
  font-size: .78rem; font-weight: 700; color: #78350f;
  position: sticky; top: var(--header-h); z-index: 99;
}
#alert-bar svg {
  width: 15px; height: 15px; fill: none; stroke: #d97706;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.alert-label {
  font-size: .62rem; font-weight: 800; letter-spacing: .5px;
  text-transform: uppercase; color: #b45309;
  background: #fde68a; border-radius: 999px; padding: .15rem .55rem; flex-shrink: 0;
}
.alert-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== BOTTOM NAV ===== */
.bottom-nav { display: none; }

@media(max-width:768px) {
  body { padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(16,32,16,.97); backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,.1); z-index: 200;
  }
  .header .nav { display: none !important; }
  .header-inner { padding: .6rem 1rem; }
  #alert-bar { top: 46px; padding: .45rem 1rem; font-size: .75rem; }
}

.bn-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .2rem; color: rgba(255,255,255,.45);
  text-decoration: none; font-size: .58rem;
  font-weight: 700; letter-spacing: .2px;
  transition: color .2s; padding: .4rem 0;
}
.bn-item.active, .bn-item:hover { color: #4ade80; }
.bn-item svg {
  width: 22px; height: 22px; stroke-width: 2;
  fill: none; stroke: currentColor;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Menu "Mais" popup */
.bn-mais-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 199; animation: fadeIn .2s ease;
}
.bn-mais-panel {
  position: fixed; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px));
  left: .5rem; right: .5rem; z-index: 201;
  background: rgba(16,32,16,.97); backdrop-filter: blur(20px);
  border-radius: .8rem .8rem 0 0; padding: .5rem;
  box-shadow: 0 -4px 20px rgba(0,0,0,.4);
  animation: slideUp .25s ease;
}
.bn-mais-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem .8rem; border-radius: .5rem;
  color: rgba(255,255,255,.7); text-decoration: none;
  font-size: .82rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.bn-mais-link:hover, .bn-mais-link:active { background: rgba(255,255,255,.08); color: #4ade80; }
.bn-mais-link svg {
  width: 20px; height: 20px; stroke-width: 2;
  fill: none; stroke: currentColor;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== CONTAINER ===== */
.container { max-width: 1400px; margin: auto; padding: 1.2rem 1.5rem; }
@media(max-width:768px) { .container { padding: 1rem; } }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius); padding: 1.4rem 1.5rem;
  color: white; margin-bottom: 1.2rem;
  display: flex; justify-content: space-between;
  align-items: flex-end; flex-wrap: wrap; gap: 1rem;
}
.hero-left h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.5px; margin-bottom: .3rem; }
.hero-left p  { font-size: .9rem; opacity: .85; font-weight: 500; }
.hero-date    { text-align: right; font-size: .8rem; opacity: .8; font-weight: 600; line-height: 1.7; }
.hero-date strong { display: block; font-size: 1.1rem; font-weight: 800; opacity: 1; }
@media(max-width:480px) { .hero { padding: 1.2rem; } .hero-left h1 { font-size: 1.3rem; } }
.btn-nova-nota { padding:.55rem 1.1rem; border-radius:.75rem; border:2px solid rgba(255,255,255,.7); background:rgba(255,255,255,.15); color:#fff; font-size:.88rem; font-weight:700; cursor:pointer; white-space:nowrap; }
.btn-nova-nota:hover { background:rgba(255,255,255,.28); }

/* ===== CARDS ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  margin-bottom: 1.2rem; overflow: hidden;
}
.card-header {
  background: var(--primary-faint); padding: .9rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-header-left  { display: flex; align-items: center; gap: .6rem; }
.card-header-left svg { width: 18px; height: 18px; stroke: var(--primary); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.card-title  { font-size: .9rem; font-weight: 800; color: var(--primary); }
.card-sub    { font-size: .75rem; color: var(--muted); font-weight: 600; }
.card-body   { padding: 1rem 1.2rem; }
.card-action {
  font-size: .75rem; color: var(--primary); font-weight: 700;
  cursor: pointer; text-decoration: underline;
  background: none; border: none; padding: 0;
}

/* ===== MEU TURNO ===== */
.mt-setup   { display: flex; flex-direction: column; gap: .8rem; }
.mt-setup p { font-size: .875rem; color: var(--muted); }
.mt-setup-row { display: flex; gap: .6rem; }
.mt-input {
  flex: 1; border: 1px solid var(--border); border-radius: 12px;
  padding: .65rem .9rem; font-size: .9rem; font-family: inherit;
  outline: none; transition: .18s; background: var(--card); color: var(--text);
}
.mt-input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(46,125,50,.12); }
.btn {
  background: var(--primary); color: white; border: none;
  border-radius: 12px; padding: .65rem 1.2rem;
  font-size: .85rem; font-weight: 700; cursor: pointer;
  transition: .2s; white-space: nowrap; font-family: inherit;
}
.btn:hover    { background: var(--primary-light); }
.btn:focus    { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-outline  { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-faint); }
.mt-error { font-size: .8rem; color: #dc2626; font-weight: 600; }
.mt-loading { text-align: center; padding: 1rem; color: var(--muted); font-size: .85rem; }

/* ===== TURNO 3 DIAS ===== */
.turnos-3dias {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem;
  padding-bottom: .3rem;
}
.dia-col { display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center; }
.dia-label { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.dia-data  { font-size: .7rem; color: var(--muted); }
.turno-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 54px; padding: .4rem .6rem; border-radius: 10px;
  font-size: .9rem; font-weight: 800; letter-spacing: -.3px;
  cursor: pointer; transition: .15s;
}
.turno-badge:hover   { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.turno-badge.manha   { background: #dbeafe; color: #1e40af; }
.turno-badge.inter   { background: #fef3c7; color: #92400e; }
.turno-badge.noite   { background: #ede9fe; color: #5b21b6; }
.turno-badge.sobra   { background: #fce7f3; color: #9d174d; }
.turno-badge.folga   { background: #f3f4f6; color: #9ca3af; font-style: italic; font-size: .8rem; cursor: default; }
.turno-badge.reserva  { background: #fce7f3; color: #9d174d; }
.turno-badge.ausencia { background: #ccfbf1; color: #0f766e; font-weight: 700; cursor: default; border: 1px solid #5eead4; }
.turno-badge.hoje-col { transform: scale(1.1); box-shadow: 0 4px 14px rgba(46,125,50,.2); }
.dia-col.hoje .dia-label { color: var(--primary); }
.dia-tipo-badge {
  font-size: .62rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: 999px; letter-spacing: .03em;
}
.dia-tipo-fer { background: #fee2e2; color: #b91c1c; }
.dia-tipo-sab { background: #dcfce7; color: #166534; }

/* ===== TURNO DETALHE ===== */
.turno-detail-wrap {
  overflow: hidden; max-height: 0;
  transition: max-height .38s cubic-bezier(.4,0,.2,1), margin .38s ease, opacity .25s ease;
  opacity: 0; margin-bottom: 0;
}
.turno-detail-wrap.open { max-height: 1200px; opacity: 1; margin-bottom: 1.2rem; }
/* Quando posicionado via JS (fixed abaixo do marker) */
.turno-detail-wrap[style*="position:fixed"] {
  max-height: none; margin-bottom: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  border-radius: var(--radius);
  animation: fadeInDown .18s ease;
}
.turno-detail-wrap[style*="position:fixed"].open { max-height: none; }

/* Detalhe inline (abre entre cards na grelha) */
.turno-inline-detail {
  grid-column: 1 / -1;
  animation: fadeInDown .22s ease;
  margin: .2rem 0 .4rem;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.turno-card-active { outline: 2px solid var(--primary); outline-offset: 2px; }
.turno-detail-inner { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.turno-detail-header { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem .6rem; border-bottom: 1px solid var(--border); }
.turno-detail-header h3 { color: var(--primary); font-size: .95rem; font-weight: 800; }
.close-detail { background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 0; }

/* Períodos dentro do detalhe */
.periodo { border-top: 1px solid #edf0ed; padding-top: .6rem; margin-top: .6rem; }
.periodo-title { font-weight: 800; margin-bottom: .4rem; font-size: .85rem; color: var(--primary); }
.periodo-flow { display: grid; grid-template-columns: 1fr .85fr .85fr .85fr 1fr; align-items: center; gap: .1rem; padding: .5rem 0; font-size: .82rem; line-height: 1.3; }
.pf-local-e { text-align: left; word-break: break-word; font-weight: 600; }
.pf-hora-e  { text-align: center; color: var(--muted); font-size: .78rem; }
.pf-servico { text-align: center; font-weight: 800; color: var(--primary); font-size: .85rem; }
.pf-hora-s  { text-align: center; color: var(--muted); font-size: .78rem; }
.pf-local-s { text-align: right; word-break: break-word; font-weight: 600; }
.rend-periodo { margin: .4rem 0; padding: .2rem 0; font-size: .75rem; display: flex; justify-content: center; align-items: center; gap: .3rem; color: #5a6e5a; }
.pausa { border-top: 1px solid #edf0ed; padding-top: .6rem; margin-top: .6rem; text-align: center; font-size: .85rem; color: #5a6e5a; }
.card-stats { margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed #d0dbd0; display: flex; justify-content: flex-end; font-size: .75rem; font-weight: 600; color: #2c3e2f; }
.card-stats span { background: #f0f4f0; padding: .2rem .6rem; border-radius: 20px; }

/* ===== NOVO DETALHE DE TURNO ===== */
.detalhe-periodos { display: flex; flex-direction: column; gap: 0; }
.detalhe-periodo {
  background: var(--bg); border-radius: 12px; padding: .85rem 1rem;
  margin-bottom: .5rem; border: 1px solid var(--border);
}
.dp-label {
  font-size: .68rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .6px; color: var(--primary); margin-bottom: .55rem;
}
.dp-local {
  font-size: .78rem; font-weight: 700; color: var(--muted);
  margin-bottom: .25rem;
}
.dp-servico {
  display: flex; align-items: center; gap: .45rem;
  margin-bottom: .35rem;
}
.dp-icon { font-size: 1rem; line-height: 1; }
.dp-srv-code { font-size: .95rem; font-weight: 800; color: var(--text); }
.dp-horas {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.05rem; font-weight: 800; color: var(--primary);
  margin-bottom: .25rem;
}
.dp-seta { color: var(--muted); font-weight: 400; font-size: .9rem; }
.dp-pausa {
  text-align: center; font-size: .8rem; color: var(--muted);
  padding: .4rem 0; font-weight: 600;
}
.dp-total {
  display: flex; align-items: center; gap: .75rem;
  background: var(--primary-faint); border: 1px solid var(--border);
  border-radius: 12px; padding: .85rem 1rem; margin-top: .5rem;
}
.dp-total-icon { font-size: 1.3rem; }
.dp-total-label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.dp-total-val { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.dp-notas {
  margin-top: .5rem; font-size: .78rem; color: var(--muted);
  padding: .5rem .75rem; background: var(--bg); border-radius: 8px;
  border: 1px solid var(--border);
}
/* ===== DARK MODE (componentes) ===== */
[data-theme="dark"] .detalhe-periodo {background: #1a2430; }
[data-theme="dark"] .dp-total {background: #162b16; }


/* ===== QUICK ACCESS ===== */
.section-title { font-size: 1rem; font-weight: 800; color: var(--text); margin-bottom: .9rem; opacity: .65; }
.quick-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.2rem;
}
@media(min-width:600px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } }
.quick-card {
  background: var(--card); border-radius: var(--radius); padding: 1.3rem 1rem;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center;
  gap: .7rem; text-align: center;
  transition: transform .2s, box-shadow .2s; cursor: pointer;
}
.quick-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0,0,0,.1); }
.quick-card:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.qc-icon { width: 48px; height: 48px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.qc-icon svg { width: 24px; height: 24px; stroke-width: 2; fill: none; stroke: white; stroke-linecap: round; stroke-linejoin: round; }
.qc-label { font-size: .85rem; font-weight: 800; color: var(--text); }
.qc-desc  { font-size: .72rem; color: var(--muted); line-height: 1.35; }
.qc-escala    .qc-icon { background: linear-gradient(135deg,#1f5c2d,#2e7d32); }
.qc-servico   .qc-icon { background: linear-gradient(135deg,#b45309,#d97706); }
.qc-turnos    .qc-icon { background: linear-gradient(135deg,#1d4ed8,#2563eb); }
.qc-contactos .qc-icon { background: linear-gradient(135deg,#6d28d9,#7c3aed); }
.qc-mapa      .qc-icon { background: linear-gradient(135deg,#0369a1,#0284c7); }
.qc-admin      .qc-icon { background: linear-gradient(135deg,#991b1b,#dc2626); }

/* ===== INFO CARD ===== */
.info-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; margin-bottom: 1.2rem;
  display: flex; align-items: center; gap: 1rem;
}
.info-card svg { width: 20px; height: 20px; min-width: 20px; stroke: var(--primary); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.info-card a   { color: var(--primary); font-weight: 700; text-decoration: none; }
.info-card a:hover { text-decoration: underline; }
.info-card p   { font-size: .85rem; color: var(--muted); line-height: 1.5; }

/* ===== ESCALA ===== */
/* ── Controlos ── */
.escala-controls {
  display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.escala-controls select, .escala-controls input {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .5rem .8rem; font-size: .85rem; font-family: inherit;
  background: var(--card); color: var(--text); outline: none;
}
.escala-controls select:focus, .escala-controls input:focus { border-color: var(--primary); }

/* ── Tabela ── */
.escala-table-wrap {
  overflow: auto; /* scroll horizontal + vertical DENTRO da caixa */
  /* Altura limitada → a caixa rola por dentro e a barra de dias (thead) + a coluna
     do agente ficam mesmo FIXAS ao rolar (sticky). Sem isto, os dias saíam do ecrã. */
  max-height: 100vh;
  max-height: calc(100dvh - 200px);
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}
table.escala-table {
  border-collapse: collapse;
  font-size: .82rem;
  table-layout: auto;
  min-width: 100%;
}
table.escala-table th {
  background: var(--primary); color: white;
  padding: .5rem .55rem; text-align: center;
  font-weight: 700; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
  box-shadow: 0 2px 5px rgba(0,0,0,.14); /* barra de dias fixa "descolada" ao rolar */
}
table.escala-table th:first-child {
  text-align: left;
  position: sticky; left: 0; z-index: 2;
}
table.escala-table td {
  padding: .4rem .55rem; border-bottom: 1px solid var(--border);
  text-align: center; white-space: nowrap;
}
table.escala-table td:first-child {
  text-align: left; font-weight: 600;
  position: sticky; left: 0; z-index: 1;
  background: var(--card);
  box-shadow: 2px 0 4px rgba(0,0,0,.06);
}
table.escala-table tr:hover td { background: var(--primary-faint); }
table.escala-table tr:hover td:first-child { background: var(--primary-faint); }
table.escala-table td .tb {
  display: inline-block; padding: .15rem .4rem;
  border-radius: 6px; font-weight: 800; font-size: .78rem;
  min-width: 2rem; text-align: center;
}
table.escala-table td .tb.manha  { background: #dbeafe; color: #1e40af; }
table.escala-table td .tb.inter  { background: #fef3c7; color: #92400e; }
table.escala-table td .tb.noite  { background: #ede9fe; color: #5b21b6; }
table.escala-table td .tb.sobra  { background: #fce7f3; color: #9d174d; }
table.escala-table td .tb.folga   { background: #f3f4f6; color: #9ca3af; font-style: italic; }
table.escala-table td .tb.reserva { background: #fce7f3; color: #9d174d; }
table.escala-table td .tb.ausencia { background: #ccfbf1; color: #0f766e; font-weight: 700; cursor: pointer; border: 1px solid #5eead4; }

/* ── Popup partilhado de detalhe de turno (clicável em qualquer lado) ── */
.turno-clicavel { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.turno-clicavel:hover { transform: scale(1.08); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.turno-popup-overlay {
  position: fixed; inset: 0; z-index: 11000;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 640px) { .turno-popup-overlay { align-items: center; padding: 1rem; } }
.turno-popup {
  background: var(--card-bg,#fff); color: var(--text,#111);
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; box-shadow: 0 -6px 30px rgba(0,0,0,.4);
  padding: 1rem 1.1rem 1.3rem;
}
@media (min-width: 640px) { .turno-popup { border-radius: 16px; } }
.turno-popup-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.turno-popup-sub { font-size: .72rem; font-weight: 600; color: var(--muted); }
.turno-popup-tit { font-size: 1.05rem; font-weight: 800; margin: .1rem 0 0; }
.turno-popup-close {
  border: none; background: var(--card-2,#f1f5f9); color: var(--text,#111);
  width: 34px; height: 34px; border-radius: 50%; font-size: 1.3rem; line-height: 1; cursor: pointer; flex-shrink: 0;
}

/* ── Popup de tomada de conhecimento (bloqueante) ── */
.popup-ack-overlay {
  position: fixed; inset: 0; z-index: 12000;
  background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.popup-ack {
  background: var(--card-bg,#fff); color: var(--text,#111);
  border-radius: 14px; max-width: 420px; width: 100%;
  padding: 1.2rem 1.25rem 1.1rem; box-shadow: 0 12px 40px rgba(0,0,0,.4);
  max-height: 88vh; overflow-y: auto;
}
.popup-ack-titulo { font-size: 1.1rem; font-weight: 800; margin-bottom: .5rem; }
.popup-ack-msg { font-size: .9rem; line-height: 1.5; color: var(--text,#111); }
.popup-ack-check {
  display: flex; align-items: center; gap: .5rem; margin: 1rem 0 .8rem;
  font-size: .85rem; font-weight: 600; cursor: pointer;
}
.popup-ack-check input { width: 18px; height: 18px; }
.popup-ack-ok {
  width: 100%; padding: .7rem; border: none; border-radius: 10px;
  font-size: .95rem; font-weight: 800; cursor: pointer;
  background: #166534; color: #fff;
}
.popup-ack-ok:disabled { background: #9ca3af; cursor: not-allowed; }

/* Banner de nível crítico na Home */
.nivel-critico-banner {
  background: #dc2626; color: #fff; border-radius: 12px;
  padding: .7rem .9rem; margin-bottom: 1rem; font-size: .85rem; line-height: 1.4;
  box-shadow: 0 2px 10px rgba(220,38,38,.35);
}
.nivel-critico-banner strong { display: block; font-size: .95rem; margin-bottom: .15rem; }

/* Dia em decurso (hoje) — acento dourado, sobrepõe-se às cores do tipo de dia */
table.escala-table th.col-hoje {
  box-shadow: inset 0 -4px 0 #f59e0b, 0 2px 5px rgba(0,0,0,.14);
}
table.escala-table td.col-hoje {
  box-shadow: inset 3px 0 0 #f59e0b, inset -3px 0 0 #f59e0b;
}
table.escala-table tr:last-child td.col-hoje { box-shadow: inset 3px 0 0 #f59e0b, inset -3px 0 0 #f59e0b, inset 0 -3px 0 #f59e0b; }
.th-hoje-tag {
  display: inline-block; margin-top: 2px;
  font-size: .58rem; font-weight: 800; letter-spacing: .3px;
  color: #451a03; background: #f59e0b; border-radius: 999px; padding: 0 .35rem;
}

/* Colunas por tipo de dia */
table.escala-table th.col-dom,
table.escala-table th.col-fer  { background: #b91c1c; }
table.escala-table th.col-sab  { background: #166534; }
table.escala-table td.col-dom  { background: #fff1f2; }
table.escala-table td.col-fer  { background: #fff1f2; }
table.escala-table td.col-sab  { background: #f0fdf4; }
table.escala-table tr:hover td.col-dom,
table.escala-table tr:hover td.col-fer { background: #fecdd3; }
table.escala-table tr:hover td.col-sab { background: #bbf7d0; }

/* ── Semana / nav ── */
.week-nav { display: flex; align-items: center; gap: .5rem; }
.week-nav button {
  background: var(--primary-faint); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .7rem;
  cursor: pointer; font-weight: 700; color: var(--primary);
}
.week-nav button:hover { background: var(--primary); color: white; }
.week-label {
  font-size: .88rem; font-weight: 800; color: var(--primary);
  text-align: center;
}

/* ── Tabs escala ── */
.escala-tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.escala-tab {
  background: none; border: 1px solid var(--border);
  border-radius: 999px; padding: .35rem .85rem;
  font-size: .78rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  color: var(--muted); transition: .18s;
}
.escala-tab:hover  { border-color: var(--primary); color: var(--primary); }
.escala-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Agente ── */
.escala-agente { font-weight: 800; color: var(--primary); }

/* ── Dots de fonte/confiança ── */
.contrib-dot {
  display: inline-block; width: .55rem; height: .55rem;
  border-radius: 50%; margin-right: .35rem; vertical-align: middle; flex-shrink: 0;
}
.contrib-dot-admin { background: #2563eb; }   /* azul — escala oficial admin/mod */
.contrib-dot--1    { background: #6b7280; }   /* cinzento — sem dados */
.contrib-dot-0     { background: #dc2626; }   /* vermelho */
.contrib-dot-1     { background: #ea580c; }   /* laranja */
.contrib-dot-2     { background: #ca8a04; }   /* amarelo */
.contrib-dot-3     { background: #16a34a; }   /* verde */

/* ── Mobile ── */
@media(max-width:600px) {
  .escala-controls { gap: .4rem; }
  #escalaSearch    { flex: 1; min-width: 0; max-width: none !important; }
  .week-label      { font-size: .78rem; }
  table.escala-table          { font-size: .75rem; }
  table.escala-table th,
  table.escala-table td       { padding: .35rem .35rem; }
  table.escala-table td .tb   { font-size: .72rem; padding: .12rem .3rem; min-width: 1.8rem; }
}

/* Turno clicável */
.escala-turno-btn { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.escala-turno-btn:hover { transform: scale(1.12); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.escala-turno-open { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Detalhe inline dentro da tabela */
.escala-detalhe-wrap { background: var(--bg); border-radius: 12px; padding: .75rem; }
.escala-detalhe-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; font-size: .85rem; font-weight: 700; color: var(--primary); }

/* Serviços Extraordinários */
.sobras-day { margin-bottom: 1.5rem; }
.sobras-day-header { font-size: .88rem; font-weight: 800; color: var(--primary); padding: .5rem 0 .4rem; border-bottom: 2px solid var(--primary); margin-bottom: .5rem; display: flex; align-items: center; gap: .5rem; }
.sobras-day-date { font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--bg); padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--border); }
table.sobras-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
table.sobras-table th { background: #f0f5f0; color: var(--primary); font-weight: 700; padding: .35rem .5rem; text-align: left; border-bottom: 1px solid var(--border); }
table.sobras-table td { padding: .3rem .5rem; border-bottom: 1px solid #f0f4f0; }
table.sobras-table tr:hover td { background: #f8fbf8; }
.sobras-hora   { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.sobras-nome   { color: var(--text); }
.sobras-agente { font-weight: 800; color: var(--primary); text-align: left; white-space: nowrap; width: 3.5rem; }

/* ===== TURNOS LIST ===== */
.turnos-filter { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-chip {
  padding: .35rem .85rem; border-radius: 999px;
  border: 2px solid var(--border); background: var(--card);
  font-size: .78rem; font-weight: 700; cursor: pointer; transition: .18s;
  color: var(--muted);
}
.filter-chip.active { border-color: var(--primary); background: var(--primary); color: white; }
.turnos-search { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: .6rem 1rem; font-size: .9rem; font-family: inherit; background: var(--card); color: var(--text); outline: none; margin-bottom: 1rem; }
.turnos-search:focus { border-color: var(--primary); }
.turnos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.turno-card {
  background: var(--card); border-radius: 14px; border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: .85rem 1rem; cursor: pointer;
  transition: transform .18s, box-shadow .18s;
}
.turno-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.turno-card-id  { font-size: 1.1rem; font-weight: 800; color: #089018; margin-bottom: .45rem; }

/* Card grelha — períodos (grid 5 colunas: P# | serviço | entrada | → | saída) */
.tc-periodos { display: flex; flex-direction: column; gap: .45rem; }
.tc-p-block  {
  display: grid;
  /* Colunas flexíveis (min-content garante que horas/serviço nunca cortam;
     1fr deixa os textos longos ocupar o espaço e quebrar em vez de transbordar). */
  grid-template-columns: 1.1rem minmax(min-content, 1.2fr) minmax(min-content, 1fr) .6rem minmax(min-content, 1fr);
  column-gap: .3rem;
  row-gap: .15rem;
  align-items: baseline;
  min-width: 0;
}
.tc-p-num  { font-size: .62rem; font-weight: 800; color: var(--muted); }
.tc-srv    { font-size: .76rem; font-weight: 700; color: #089018; min-width: 0; overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.tc-ent,
.tc-sai    { font-size: .76rem; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-hsep   { font-size: .7rem; color: var(--muted); text-align: center; }
/* Linha 2: locais — espacer ocupa colunas 1+2, locais ficam nas colunas 3 e 5 */
.tc-spacer { grid-column: 1 / 3; }
.tc-mid    { } /* col 4 — alinha com → */
.tc-le,
.tc-ls     { font-size: .68rem; color: #B86800; font-weight: 600; min-width: 0; overflow-wrap: normal; word-break: keep-all; hyphens: none; }

/* ===== DETALHE INLINE — turno ===== */
.td-card { /* sem card próprio — já está dentro de turno-detail-inner */ }

/* Período — grelha: linha 1 chapa | hora-ent autocarro hora-sai | duração.
   linha 2: local-ent e local-sai por baixo da hora respetiva; chips (parque/rendição) nos cantos.
   Os wrappers de entrada/saída e do serviço desaparecem do layout (display:contents)
   e os seus filhos passam a ser células diretas desta grelha. */
.td-period {
  display: grid;
  /* 4 colunas: chapa | hora/local-ent | ícone+duração | hora/local-sai.
     (Removida a 5ª coluna vazia de 3.6rem que apertava os locais.)
     col1 cresce com a chapa; col3 = auto para o pill da duração caber;
     os 1fr deixam locais e chips quebrar em vez de cortar. */
  grid-template-columns: minmax(4.5rem, auto) minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  row-gap: .6rem; column-gap: .7rem;
  padding: 1.2rem 1.3rem 1.05rem;
}

.td-row, .td-srv { display: contents; }

/* Chapa clicável no detalhe do turno → abre o cartão resumido da chapa. */
.td-chapa-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.td-chapa-link:hover { filter: brightness(1.15); }

/* Linha 1 — chapa | hora-ent · autocarro · hora-sai | duração
   Colunas 1/3/5 com largura fixa (em vez de auto) para que chapa, ícone
   e duração fiquem sempre na mesma posição entre períodos diferentes. */
.td-srv-label        { grid-row: 1; grid-column: 1; justify-self: start; font-size: 1.2rem; font-weight: 800; color: #089018; line-height: 1.15; min-width: 0; white-space: normal; overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.td-row-ent .td-time  { grid-row: 1; grid-column: 2; justify-self: center; }
.td-icon              { grid-row: 1; grid-column: 3; justify-self: center; font-size: 1rem; line-height: 1; }
.td-row-sai .td-time  { grid-row: 1; grid-column: 4; justify-self: center; }
.td-dur               { grid-row: 2; grid-column: 3; justify-self: center; display: inline-block; font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: .9rem; padding: .2rem .55rem; white-space: nowrap; }
.td-time { font-size: 1.2rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }

/* Linha 2 — locais por baixo das horas; chips nos cantos (esq=entrada, dir=saída) */
.td-row-ent .td-local { grid-row: 2; grid-column: 2; justify-self: center; }
.td-row-sai .td-local { grid-row: 2; grid-column: 4; justify-self: center; }
.td-row-ent .td-chips { grid-row: 3; grid-column: 2; justify-self: center; }
.td-row-sai .td-chips { grid-row: 3; grid-column: 4; justify-self: center; }
.td-local {
  font-size: .7rem; font-weight: 600; color: #B86800;
  min-width: 0; white-space: normal; overflow-wrap: normal; word-break: keep-all; hyphens: none; text-align: center;
}
.td-chips { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; }

/* Chips: notas e rendições */
.td-chip       { display: inline-block; font-size: .72rem; font-weight: 600; border-radius: .9rem; padding: .2rem .55rem; white-space: nowrap; }
.td-chip-nota    { background: #fef3c7; color: #92400e; }
/* Rendições podem trazer T.id + Ag. + nome — quebrar SÓ entre palavras
   (o chip cresce em altura). NUNCA partir uma palavra/nome a meio
   ("Fernand o"): overflow-wrap:normal + word-break:keep-all + hyphens:none. */
.td-chip-rende,
.td-chip-rendido { white-space: normal; overflow-wrap: normal; word-break: keep-all; hyphens: none; max-width: 100%; }
.td-chip-rende   { background: #dcfce7; color: #15803d; }   /* verde    — turno que rende (chega) */
.td-chip-rendido { background: #fee2e2; color: #b91c1c; }   /* vermelho — turno rendido (sai) */
.td-rend-ent, .td-rend-sai { grid-row: 4; justify-self: center; text-align: center; line-height: 1.25; margin-top: .15rem; }
.td-rend-ent { grid-column: 2; }
.td-rend-sai { grid-column: 4; }


.td-divider { height: 1px; background: var(--border); margin: 0 1rem; }
.td-pausa {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  text-align: center; font-size: .72rem; font-weight: 700; color: #92400e;
  padding: .4rem .9rem; margin: 0 1rem; background: #fef3c7; border-radius: .6rem;
}
.td-notas {
  padding: .5rem 1rem; font-size: .78rem; color: var(--muted);
  border-top: 1px solid var(--border); text-align: center;
}
.td-total {
  padding: .6rem 1rem; border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--muted);
  display: flex; justify-content: center; align-items: center; gap: .35rem;
  background: var(--bg);
}
.td-total strong { color: var(--text); font-size: 1rem; font-weight: 800; }
.td-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: .82rem; }

/* ===== CONTACTOS ===== */
.contactos-list { display: flex; flex-direction: column; gap: .8rem; }
.contacto-card {
  background: var(--card); border-radius: 14px; border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: .9rem 1.1rem;
  display: flex; align-items: center; gap: 1rem;
}
.contacto-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 1rem; flex-shrink: 0;
}
.contacto-info { flex: 1; min-width: 0; }
.contacto-nome   { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contacto-cargo  { font-size: .75rem; color: var(--muted); }
.contacto-tel    { font-size: .82rem; color: var(--primary); font-weight: 600; text-decoration: none; }
.contacto-tel:hover { text-decoration: underline; }
.btn-whatsapp {
  display: inline-flex; align-items: center; gap: .35rem;
  background: #25D366; color: #fff; font-weight: 700; font-size: .82rem;
  padding: .35rem .75rem; border-radius: 999px; text-decoration: none;
  transition: background .15s, transform .1s;
  line-height: 1;
}
.btn-whatsapp:hover { background: #1ebe5a; transform: scale(1.04); }
.contacto-chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; }
.chip-emergencia { background: #fde8e8; color: #b91c1c; }
.chip-supervisor { background: var(--primary-faint); color: var(--primary); }
.btn-copy-tel {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem;
  background: none;
  border: none;
  border-radius: .35rem;
  cursor: pointer;
  color: var(--muted, #6b7280);
  transition: color .15s, background .15s;
  flex-shrink: 0;
  padding: 0;
}
.btn-copy-tel:hover  { color: var(--primary, #1f5c2d); background: var(--primary-faint, #f0fdf4); }
.btn-copy-tel:active { transform: scale(.9); }
.btn-copy-tel.copied { color: #16a34a; }

/* ===== MAPA ===== */
#page-mapa { display: flex; flex-direction: column; height: calc(100vh - var(--header-h)); }
#mapid { flex: 1; }
.map-controls {
  position: absolute; top: calc(var(--header-h) + 8px); right: 8px; z-index: 450;
  display: flex; flex-direction: column; gap: 6px;
}
.map-btn {
  background: white; border: 1px solid var(--border); border-radius: 10px;
  padding: .5rem .8rem; font-size: .75rem; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow); color: var(--text);
  display: flex; align-items: center; gap: .35rem;
}
.map-btn:hover { background: var(--primary-faint); }
.map-btn svg   { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-status {
  position: absolute; bottom: calc(var(--bnav-h) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 450; background: white; border: 1px solid var(--border);
  border-radius: 999px; padding: .3rem .9rem; font-size: .75rem;
  font-weight: 700; color: var(--muted); box-shadow: var(--shadow);
  pointer-events: none;
}
@media(min-width:769px) { .map-status { bottom: 8px; } }

/* ===== SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: sk-pulse 1.5s infinite;
  border-radius: 8px; height: 1.2rem;
}
@keyframes sk-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== DARK MODE ===== */
/* ===== DARK MODE (componentes) ===== */
[data-theme="dark"] .mt-input, [data-theme="dark"] .turnos-search, [data-theme="dark"] .escala-controls select, [data-theme="dark"] .escala-controls input {background: #1d2732; color: #e5e7eb; border-color: #293342; }
[data-theme="dark"] .turno-badge.folga {background: #1d2732; color: #6b7280; }
[data-theme="dark"] .card-stats span {background: #2a3a2a; color: #e0e0e0; }
[data-theme="dark"] .filter-chip {background: #1d2732; color: #8d99a6; }
[data-theme="dark"] .map-btn, [data-theme="dark"] .map-status {background: #17212b; color: #e5e7eb; border-color: #293342; }
[data-theme="dark"] .week-nav button {background: #1a2e1a; color: #4ade80; }
[data-theme="dark"] .skeleton {background: linear-gradient(90deg,#2a3a3a 25%,#3a4a4a 50%,#2a3a3a 75%); }
[data-theme="dark"] table.escala-table td.tb-folga {background: #1d2732; }
[data-theme="dark"] table.escala-table td.col-dom, [data-theme="dark"] table.escala-table td.col-fer {background: #2a1a1a; }
[data-theme="dark"] table.escala-table td.col-sab {background: #0f2a1a; }
[data-theme="dark"] table.escala-table tr:hover td.col-dom, [data-theme="dark"] table.escala-table tr:hover td.col-fer {background: #3d1515; }
[data-theme="dark"] table.escala-table tr:hover td.col-sab {background: #0f3a1f; }
[data-theme="dark"] .es-linha-grupo {border-color: #293342; }
[data-theme="dark"] .es-grupo {border-color: #293342; background: #17212b; }
[data-theme="dark"] .es-chapa-header {background: #1d2732; border-color: #293342; }
[data-theme="dark"] .es-row {border-color: #293342; }
[data-theme="dark"] .es-dup {background: rgba(220,38,38,.18); }
[data-theme="dark"] .es-dup-row {background: rgba(220,38,38,.12); }


/* ─── Em Serviço Agora ───────────────────────────────────── */
.em-servico-lista {
  display: flex;
  flex-direction: column;
  gap: 1rem; /* mais espaçamento entre chapas — quadros bem separados */
}

/* Cada chapa (15-1, 15-2, …) é um quadro independente e destacado. */
.es-chapa-card {
  box-shadow: 0 2px 10px rgba(0,0,0,.10);
  border-width: 1.5px;
}

/* Nível 1: agrupamento por linha */
.es-linha-grupo {
  border: 1.5px solid rgba(0,0,0,.08);
  border-radius: .75rem;
  overflow: hidden;
}
.es-linha-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem;
}
.es-linha-badge {
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .3px;
}
.es-linha-count {
  font-size: .68rem;
  font-weight: 600;
}

/* Nível 2: chapas dentro de cada linha */
.es-grupo {
  border-top: 1px solid rgba(0,0,0,.06);
  background: rgba(255,255,255,.02);
}
.es-chapa-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap; /* se a chapa for longa, as horas passam para baixo em vez de comprimir */
  padding: .35rem .75rem;
  background: rgba(0,0,0,.04);
  border-bottom: 1px solid rgba(0,0,0,.05);
}
.es-chapa-label {
  font-size: .74rem;
  font-weight: 700;
  color: var(--text, #111);
  min-width: 0;
  overflow-wrap: break-word;
}
.es-chapa-horas {
  font-size: .66rem;
  font-weight: 600;
  color: var(--muted, #6b7280);
  white-space: nowrap;
}
.es-row {
  display: flex;
  align-items: flex-start; /* topo — quando o nome/detalhe quebra em 2 linhas, o badge fica alinhado ao início */
  gap: .65rem;
  padding: .5rem .7rem;
  border-bottom: 1px solid rgba(0,0,0,.04);
}
.es-row:last-child { border-bottom: none; }
.es-dup { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.35) !important; }
.es-dup-row { background: rgba(220,38,38,.08); }
.es-dup-row .es-nome,
.es-dup-row .es-detalhe { color: #dc2626 !important; }
.es-info { flex: 1; min-width: 0; }
.es-nome {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text, #111);
  /* Nunca truncar/partir o nome: quebra só entre palavras, cartão cresce em altura. */
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
}
.es-detalhe {
  font-size: .66rem;
  color: var(--muted, #6b7280);
  margin-top: .1rem;
  line-height: 1.35;
  /* Detalhe (agente · serviço · horas) pode ocupar várias linhas em vez de comprimir. */
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

/* ===== LOGIN OVERLAY ===== */
#login-overlay, #chpass-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(10,18,10,.92); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .25s;
}
#login-overlay.visible, #chpass-overlay.visible { opacity: 1; }

.login-box {
  background: var(--card, #fff); border-radius: 1.25rem;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  padding: 2rem 1.75rem; width: 100%; max-width: 360px; margin: 1rem;
}

.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo-text {
  display: block; font-size: 1.5rem; font-weight: 800;
  color: var(--primary, #1f5c2d); letter-spacing: -.5px;
}
.login-logo-badge {
  display: inline-block; margin-top: .25rem; font-size: .72rem;
  background: var(--primary-faint, #e8f5e9); color: var(--primary, #1f5c2d);
  padding: .2rem .6rem; border-radius: 99px; font-weight: 600;
}

.login-field { margin-bottom: 1rem; }
.login-field label {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--muted, #6b7280); margin-bottom: .3rem;
}
.login-field input {
  width: 100%; padding: .65rem .85rem; border-radius: .6rem;
  border: 1.5px solid var(--border, #e5e7eb);
  background: var(--bg, #f8fafc); color: var(--text, #111);
  font-size: .95rem; box-sizing: border-box; outline: none;
  transition: border-color .15s;
}
.login-field input:focus { border-color: var(--primary, #1f5c2d); }

.login-pass-wrap { position: relative; }
.login-pass-wrap input { padding-right: 2.8rem; }
.login-pass-toggle {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: .2rem;
  color: var(--muted, #6b7280); display: flex; align-items: center;
}
.login-pass-toggle svg { width: 18px; height: 18px; }

/* ===== NÍVEL / PONTOS ===== */
.nivel-badge {
  font-size: .72rem; font-weight: 700; padding: .22rem .65rem;
  border-radius: 99px; white-space: nowrap; letter-spacing: .01em;
}
.nivel-visitante   { background: #374151; color: #e5e7eb; }
.nivel-motorista   { background: #1e40af; color: #dbeafe; }
.nivel-colaborador { background: #92400e; color: #fef3c7; }
.nivel-prime       { background: #065f46; color: #d1fae5; }
.nivel-moderador   { background: #4c1d95; color: #ede9fe; }
.nivel-admin       { background: #7f1d1d; color: #fee2e2; }

.ud-nivel {
  font-size: .75rem; font-weight: 700; margin-top: .2rem;
  color: var(--primary);
}

/* ===== CONTRIBUIR PAGE ===== */
.contrib-locked {
  font-size: .85rem; color: var(--muted); padding: .5rem 0;
}

/* Grid compacto de turnos */
.turnos-grid-compact {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: .3rem; margin: .5rem 0;
}
.tgc-cell {
  display: flex; flex-direction: column; align-items: center;
  gap: .15rem;
}
.tgc-dia {
  font-size: .65rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.tgc-turno {
  font-size: .8rem; font-weight: 600; background: var(--primary-faint);
  color: var(--primary); padding: .2rem .4rem; border-radius: .4rem;
  min-width: 2rem; text-align: center;
}
.tgc-empty { background: var(--border); color: var(--muted); font-weight: 400; }

/* ===== TABELAS DE CHAPAS (catálogo) — legibilidade fixa em qualquer tema =====
   Fundo BRANCO + texto PRETO sempre, independentemente do tema (claro/escuro/tcb/
   futuros). As células de ESTADO (início/fim de serviço, etc.) guardam a sua cor
   em variáveis por-célula (--cell-bg / --cell-fg) que esta regra !important lê:
   assim nenhum tema sobrepõe, mas as exceções de estado mantêm-se. Remove também
   qualquer herança de opacity/filter/mix-blend-mode. */
.cat-tabela th,
.cat-tabela td {
  background: var(--cell-bg, #ffffff) !important;
  color: var(--cell-fg, #000000) !important;
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Audit cards */
.audit-card {
  border: 1.5px solid var(--border); border-radius: .75rem;
  padding: .85rem; margin-bottom: .75rem;
}
.audit-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .5rem; font-size: .9rem;
}
.audit-semana { font-size: .75rem; color: var(--muted); }
.audit-actions {
  display: flex; gap: .5rem; margin-top: .75rem;
}
.audit-done {
  font-size: .85rem; color: var(--muted); padding: .5rem 0;
  font-style: italic;
}

/* Formulário de escala */
.escala-form-dias { display: flex; flex-direction: column; gap: .4rem; }
.escala-form-row {
  display: grid; grid-template-columns: 3rem 1fr; align-items: center; gap: .5rem;
}
.escala-form-dia {
  font-size: .8rem; font-weight: 700; color: var(--muted); text-align: right;
}
.escala-form-inp { width: 100%; }

/* Botões de auditoria */
.btn-confirm {
  flex: 1; padding: .55rem .75rem; border-radius: .55rem; border: none;
  background: var(--primary); color: white; font-weight: 600; font-size: .85rem;
  cursor: pointer; transition: opacity .15s;
}
.btn-confirm:hover { opacity: .85; }
.btn-confirm:disabled { opacity: .5; cursor: default; }
.btn-flag {
  flex: 1; padding: .55rem .75rem; border-radius: .55rem; border: none;
  background: #fef3c7; color: #92400e; font-weight: 600; font-size: .85rem;
  cursor: pointer; transition: opacity .15s;
}
.btn-flag:hover { opacity: .85; }

/* Modal de sinalização */
.contrib-modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 1rem;
}
.contrib-modal {
  background: var(--card); border-radius: 1.25rem 1.25rem 1rem 1rem;
  padding: 1.5rem; width: 100%; max-width: 480px;
  box-shadow: 0 -8px 32px rgba(0,0,0,.18);
  max-height: 85vh; overflow-y: auto;
}
.contrib-modal-title { font-size: 1rem; font-weight: 800; margin-bottom: .5rem; }

.sinalizar-dia-row {
  display: grid; grid-template-columns: auto 2.5rem 1fr; align-items: center;
  gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border);
}
.sinalizar-check { display: flex; align-items: center; gap: .4rem; font-size: .85rem; cursor: pointer; }
.sinalizar-atual { font-size: .8rem; color: var(--muted); text-align: center; }
.sinalizar-correto {
  font-size: .85rem; padding: .3rem .5rem; border-radius: .4rem;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text); width: 100%; outline: none;
}
.sinalizar-correto:not([disabled]):focus { border-color: var(--primary); }
.sinalizar-correto[disabled] { opacity: .35; }

/* var --success */
:root { --success: #16a34a; }

.login-error {
  font-size: .8rem; color: #dc2626;
  background: #fef2f2; border-radius: .45rem;
  padding: .5rem .75rem; margin-bottom: .75rem;
}
.login-success {
  font-size: .8rem; color: #166534;
  background: #f0fdf4; border-radius: .45rem;
  padding: .5rem .75rem; margin-bottom: .75rem;
}

.login-btn {
  width: 100%; padding: .7rem; border-radius: .65rem;
  background: var(--primary, #1f5c2d); color: #fff;
  font-size: .95rem; font-weight: 700; border: none;
  cursor: pointer; margin-top: .25rem; transition: opacity .15s;
}
.login-btn:hover { opacity: .88; }
.login-btn:disabled { opacity: .55; cursor: not-allowed; }
.login-btn-cancel {
  background: transparent; color: var(--muted, #6b7280);
  border: 1.5px solid var(--border, #e5e7eb); margin-top: .5rem;
}

.login-hint {
  margin-top: 1.25rem; text-align: center; font-size: .75rem;
  color: var(--muted, #9ca3af); line-height: 1.6;
}
.login-hint code {
  background: var(--primary-faint, #e8f5e9); color: var(--primary, #1f5c2d);
  padding: .1rem .35rem; border-radius: .3rem; font-size: .75rem;
}

/* ===== ONBOARDING OVERLAY ===== */
#onboarding-overlay {
  position: fixed; inset: 0; z-index: 10001;
  background: linear-gradient(160deg, #0a180a 0%, #0f2e14 60%, #0d2010 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.5rem 1rem;
  opacity: 0; transition: opacity .35s;
}
#onboarding-overlay.visible { opacity: 1; }

/* Logo topo */
.ob-header {
  display: flex; flex-direction: column; align-items: center;
  gap: .3rem; margin-bottom: 1.75rem;
}
.ob-header-logo {
  font-size: 1.1rem; font-weight: 800; color: rgba(255,255,255,.9);
  letter-spacing: -.3px;
}
.ob-header-badge {
  font-size: .6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: rgba(255,255,255,.4);
}

.ob-wrap {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; gap: 1.25rem;
}

/* Cards */
.ob-cards {
  width: 100%; overflow: hidden; border-radius: 1.35rem;
  box-shadow: 0 32px 80px rgba(0,0,0,.55);
}
.ob-track {
  display: flex; transition: transform .38s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.ob-card {
  min-width: 100%; background: #fff;
  border-radius: 1.35rem; padding: 2.25rem 1.75rem 2rem;
  box-sizing: border-box;
}

/* Card info (1-4 e 7) */
.ob-icon {
  font-size: 2.5rem; text-align: center; margin-bottom: .9rem;
  line-height: 1;
}
.ob-title {
  font-size: 1.25rem; font-weight: 800; color: var(--primary, #1f5c2d);
  text-align: center; margin-bottom: .8rem; letter-spacing: -.3px;
  line-height: 1.25;
}
.ob-text {
  font-size: .9rem; color: #4b5563; line-height: 1.7;
  text-align: center;
}
.ob-sig {
  margin-top: 1.5rem; text-align: center;
  font-size: .85rem; font-weight: 700; color: var(--primary, #1f5c2d);
  opacity: .75;
}

/* Pontos de navegação */
.ob-dots {
  display: flex; gap: .4rem; align-items: center;
}
.ob-dot {
  height: 6px; width: 6px; border-radius: 99px;
  background: rgba(255,255,255,.25); transition: all .25s ease;
}
.ob-dot.active {
  background: #fff; width: 22px;
}

/* Botão avançar */
.ob-btn {
  width: 100%; padding: .8rem; border-radius: .85rem;
  background: #1f5c2d; color: #fff;
  font-size: .95rem; font-weight: 700; border: none;
  cursor: pointer; font-family: inherit;
  transition: background .18s, transform .12s, opacity .15s;
  box-shadow: 0 4px 16px rgba(31,92,45,.4);
}
.ob-btn:hover  { background: #2e7d32; }
.ob-btn:active { transform: scale(.98); }
.ob-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Link "já tenho conta" */
.ob-login-link {
  color: rgba(255,255,255,.4); font-size: .78rem;
  background: none; border: none; cursor: pointer;
  font-family: inherit; padding: .25rem .5rem;
  transition: color .15s;
}
.ob-login-link:hover { color: rgba(255,255,255,.75); }

/* Primeiro acesso link no login */
.login-register-link {
  display: block; text-align: center; margin-top: 1rem;
  font-size: .8rem; color: var(--primary, #1f5c2d);
  cursor: pointer; background: none; border: none;
  font-family: inherit; font-weight: 600;
  opacity: .75; transition: opacity .15s;
}
.login-register-link:hover { opacity: 1; }

/* ===== USER MENU ===== */
.user-menu-btn {
  display: flex; align-items: center; gap: .4rem;
  background: rgba(255,255,255,.12); border: none; border-radius: 99px;
  color: #fff; padding: .3rem .65rem .3rem .4rem;
  cursor: pointer; font-size: .78rem; font-weight: 600;
  transition: background .15s; white-space: nowrap;
}
.user-menu-btn:hover { background: rgba(255,255,255,.2); }
.user-menu-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.user-menu-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }

#userDropdown {
  position: fixed; z-index: 9999;
  background: var(--card, #fff); border-radius: .85rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  border: 1px solid var(--border, #e5e7eb);
  min-width: 190px; overflow: hidden;
}
.ud-info {
  padding: .75rem 1rem .6rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.ud-nome { font-size: .85rem; font-weight: 700; color: var(--text, #111); }
.ud-agente { font-size: .72rem; color: var(--muted, #6b7280); margin-top: .1rem; }
.ud-item {
  display: block; width: 100%; text-align: left;
  padding: .6rem 1rem; background: none; border: none;
  font-size: .83rem; color: var(--text, #111); cursor: pointer;
  transition: background .1s;
}
.ud-item:hover { background: var(--primary-faint, #e8f5e9); }
.ud-logout { color: #dc2626; }
.ud-logout:hover { background: #fef2f2; }

/* ── Escala — contribuições com código de cores ─────────── */
/* Fundo subtil na linha + indicador no agente */
tr.contrib-level-0 { background: rgba(220,38,38,.07); }   /* vermelho  */
tr.contrib-level-1 { background: rgba(234,88,12,.07); }   /* laranja   */
tr.contrib-level-2 { background: rgba(202,138,4,.07); }   /* amarelo   */
tr.contrib-level-3 { background: rgba(22,163,74,.07); }   /* verde     */

.contrib-dot {
  display: inline-block;
  width: .5rem; height: .5rem;
  border-radius: 50%;
  margin-right: .3rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.contrib-dot-0 { background: #dc2626; }
.contrib-dot-1 { background: #ea580c; }
.contrib-dot-2 { background: #ca8a04; }
.contrib-dot-3 { background: #16a34a; }

.contrib-by {
  display: block;
  font-size: .62rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: .01em;
  line-height: 1.3;
}

/* ── Contribuir — banner + tabs + SE ─────────────────────── */
.contribuir-banner-box {
  background: var(--primary-faint, #e8f5e9);
  border: 1.5px solid var(--primary-light, #a5d6a7);
  border-radius: .7rem;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.contrib-banner-semana {
  font-size: .85rem;
  margin-bottom: .4rem;
}
.contrib-banner-docs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.contrib-doc-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--card-bg, #fff);
  border: 1.5px solid var(--primary-light, #a5d6a7);
  border-radius: .4rem;
  padding: .25rem .6rem;
  text-decoration: none;
  transition: background .15s;
}
.contrib-doc-link:hover {
  background: var(--primary-light, #a5d6a7);
  color: var(--text);
}
.contrib-tab {
  font-size: .82rem;
  padding: .4rem .9rem;
  border-radius: .4rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
}

/* ─── Botão Settings (header) ───────────────────────────────── */
.btn-settings {
  background: none; border: none; cursor: pointer;
  font-size: 1.15rem; padding: .25rem .4rem; border-radius: .5rem;
  color: var(--muted); transition: color .15s, background .15s;
  line-height: 1;
}
.btn-settings:hover { color: var(--primary); background: var(--hover); }

/* ─── Settings page ─────────────────────────────────────────── */
.settings-wrap  { max-width: 520px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.settings-page  { display: flex; flex-direction: column; gap: 1.25rem; }
.settings-card  {
  background: var(--card); border: 1px solid var(--border);
  border-radius: .85rem; padding: 1.25rem 1.25rem 1rem;
}
.settings-card-mod { border-color: #fbbf24; }
.settings-card-title { font-weight: 700; font-size: .95rem; margin-bottom: .85rem; }
.settings-field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.settings-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.settings-input {
  padding: .55rem .75rem; border: 1px solid var(--border); border-radius: .6rem;
  background: var(--bg); color: var(--text); font-size: .9rem;
  transition: border-color .15s;
}
.settings-input:focus { outline: none; border-color: var(--primary); }
.settings-row-info { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; font-size: .85rem; }
.settings-value.muted { color: var(--muted); font-size: .85rem; }
.settings-sep { border: none; border-top: 1px solid var(--border); margin: .5rem 0 .85rem; }
.settings-btn {
  width: 100%; padding: .6rem; border: none; border-radius: .65rem;
  background: var(--primary); color: #fff; font-size: .9rem; font-weight: 700;
  cursor: pointer; transition: opacity .15s;
}
.settings-btn:hover  { opacity: .88; }
.settings-btn:disabled { opacity: .5; cursor: not-allowed; }
.settings-btn-mod { background: #d97706; }
.settings-msg { font-size: .82rem; margin-bottom: .5rem; }

/* ── Footer ──────────────────────────────────────── */
.app-footer {
  display: block;
  width: 100%;
  text-align: center;
  padding: 1.5rem 1rem 5rem;
  border-top: 1px solid var(--border, #e5e7eb);
  margin-top: 2rem;
  box-sizing: border-box;
}
.app-footer-emoji {
  display: block;
  font-size: 1.4rem;
  margin: 0 0 .4rem;
  opacity: .7;
  text-align: center;
}
.app-footer-text {
  display: block;
  font-size: .73rem;
  color: var(--muted, #6b7280);
  line-height: 1.8;
  margin: 0;
  text-align: center;
}


/* Número do agente clicável → card telefónico (escala/500) */
.escala-agente, .sobras-agente { cursor: pointer; }
.escala-agente:hover, .sobras-agente:hover { text-decoration: underline; }

/* ===== ACORDEON ACESSO RÁPIDO ===== */
.accordion-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; cursor: pointer; padding: 0; text-align: left; }
.accordion-chevron { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; opacity: .55; transition: transform .2s; }
.accordion-toggle.open .accordion-chevron { transform: rotate(180deg); }
.qc-catalogo   .qc-icon { background: linear-gradient(135deg,#9a3412,#ea580c); }
.qc-contribuir .qc-icon { background: linear-gradient(135deg,#0f766e,#14b8a6); }

/* ===== BARRA DE AVISOS OPERACIONAIS (ticker) ===== */
:root {
  --avisos-bg:     #F1F3F5;
  --avisos-text:   #1F2933;
  --avisos-novo:   #000000;
  --avisos-sep:    #4B5563;
  --avisos-border: #d4d9de;
  --avisos-urgent: #b91c1c;
}

  [data-theme="dark"] {
    --avisos-bg:     #20262D;
    --avisos-text:   #E6E6E6;
    --avisos-novo:   #FFFFFF;
    --avisos-sep:    #A0A0A0;
    --avisos-border: #2c333b;
    --avisos-urgent: #f87171;
  }


#avisos-bar {
  position: sticky; top: var(--header-h); z-index: 99;
  display: none; align-items: center;
  background: var(--avisos-bg);
  border-bottom: 1px solid var(--avisos-border);
  height: 30px; overflow: hidden; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#avisos-bar.show { display: flex; }
#avisos-bar .av-pin {
  flex-shrink: 0; display: flex; align-items: center; gap: .3rem;
  height: 100%; padding: 0 .6rem;
  font-size: .58rem; font-weight: 800; letter-spacing: .4px;
  text-transform: uppercase; color: var(--avisos-novo);
  background: rgba(0,0,0,.06); border-right: 1px solid var(--avisos-border);
}
[data-theme="dark"] #avisos-bar .av-pin {background: rgba(255,255,255,.05); }

#avisos-bar .av-pin svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#avisos-bar .av-viewport { flex: 1; overflow: hidden; height: 100%; position: relative; }
#avisos-bar .av-track {
  position: absolute; top: 0; left: 0; height: 100%;
  display: flex; align-items: center; white-space: nowrap;
  will-change: transform; animation: avisos-scroll linear infinite;
}
#avisos-bar:hover .av-track, #avisos-bar:active .av-track { animation-play-state: paused; }
#avisos-bar .av-item { font-size: .76rem; font-weight: 600; color: var(--avisos-text); padding: 0 .15rem; }
#avisos-bar .av-item.av-novo { font-weight: 800; color: var(--avisos-novo); text-transform: uppercase; }
#avisos-bar .av-item.av-urgente .av-tag { color: var(--avisos-urgent); }
#avisos-bar .av-tag { font-weight: 800; }
#avisos-bar .av-sep { color: var(--avisos-sep); padding: 0 .9rem; font-weight: 700; }
@keyframes avisos-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (max-width: 720px) { #avisos-bar { top: 46px; height: 28px; } #avisos-bar .av-item { font-size: .72rem; } }
/* ===== APARÊNCIA / SELETOR DE TEMA ===== */
.theme-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .6rem;
}
@media(min-width:520px){ .theme-grid { grid-template-columns: repeat(4,1fr); } }
.theme-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem;
  padding: .8rem .9rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card-2);
  color: var(--text); cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
  min-height: var(--btn-h);
}
.theme-opt:active { transform: scale(.98); }
.theme-opt.active {
  border-color: var(--primary); background: var(--primary-faint);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.theme-opt-label { font-size: var(--fs-sm); font-weight: 800; }
.theme-opt-desc  { font-size: var(--fs-xs); color: var(--muted); }

/* ============================================================
   REDESIGN PÁGINA INICIAL (v2 home) — mobile-first
   ============================================================ */

/* Hero compacto */
.hero-compact {
  padding: .7rem 1.1rem; min-height: 60px; align-items: center;
  margin-bottom: 1rem; flex-direction: column; gap: .15rem; align-items: flex-start;
}
.hero-compact #heroGreet { font-size: 1rem; font-weight: 800; color: #fff; opacity: 1; margin: 0; }
.hero-compact .hero-date { text-align: left; font-size: .78rem; font-weight: 600; opacity: .9; }
.hero-compact .hero-date strong { display: inline; font-size: .78rem; }

/* Títulos de secção planos */
.section-title-plain { display: flex; padding: 0; background: none; border: none; cursor: default; }
.section-title-plain span { font-size: 1rem; font-weight: 800; color: var(--text); opacity: .8; }

/* ===== BLOCO HOJE (destaque) ===== */
.turnos-3dias { display: block; padding: 0; }
.turno-hoje {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 1.1rem 1rem 1.2rem;
  background: var(--primary-faint);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  margin-bottom: .8rem;
}
.th-label {
  font-size: .72rem; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--primary);
}
.th-badge-wrap { line-height: 1; }
.th-date { font-size: .9rem; font-weight: 700; color: var(--text-2); text-align: center; }

/* Badge gigante do HOJE */
.turno-badge.big {
  min-width: 96px; padding: .9rem 1.4rem; border-radius: 18px;
  font-size: 2.6rem; line-height: 1; letter-spacing: -1px;
}
/* Badge pequeno (ontem/amanhã) */
.turno-badge.mini { min-width: 46px; padding: .3rem .55rem; font-size: 1rem; border-radius: 9px; }
/* Badge ainda mais pequeno (dias já passados desta semana) */
.turno-badge.micro { min-width: 38px; padding: .22rem .45rem; font-size: .82rem; border-radius: 8px; }

/* Semana dobrada à volta de hoje: dias passados (por cima) + seguintes (por baixo).
   SEMPRE 1 linha: não quebra; se não couber, desliza na horizontal (centrado quando cabe). */
.wk-row {
  display: flex; flex-wrap: nowrap; gap: .35rem;
  justify-content: safe center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.wk-row::-webkit-scrollbar { display: none; }
.wk-past   { margin-bottom: .6rem; }
.wk-future { margin-top: .6rem; }
.wk-day {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .4rem .45rem; min-width: 3.1rem;
}
.wk-day.wk-micro { min-width: 2.7rem; padding: .3rem .35rem; opacity: .9; }
/* Separador entre o resto desta semana e a próxima semana (fila de baixo) */
.wk-sep { flex: 0 0 auto; align-self: stretch; width: 2px; margin: .25rem .15rem; border-radius: 2px; background: var(--border); }
.wk-day[data-hoje] { border-color: var(--primary); }
.wk-day-lbl  { font-size: .6rem; font-weight: 800; color: var(--muted); text-align: center; line-height: 1.15; }
.wk-day-date { display: block; font-size: .55rem; font-weight: 600; opacity: .75; }

/* Linha ontem / amanhã */
.turno-around { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.ta-col {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: .7rem .5rem; background: var(--card-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ta-label { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.ta-data { font-size: .66rem; color: var(--muted); }

/* ===== GRELHA PRINCIPAL / SECUNDÁRIA ===== */
.quick-grid-main { grid-template-columns: 1fr 1fr; }
.quick-grid-sec  { grid-template-columns: 1fr 1fr; margin-top: .3rem; }
.quick-grid-sec .quick-card { padding: 1rem .8rem; }
.quick-grid-sec .qc-icon { width: 40px; height: 40px; }
.quick-grid-sec .qc-icon svg { width: 20px; height: 20px; }
@media(min-width:700px){
  .quick-grid-main { grid-template-columns: repeat(4,1fr); }
  .quick-grid-sec  { grid-template-columns: repeat(4,1fr); }
}

/* Feedback ao toque (mobile) */
.quick-card:active { transform: scale(.97); }
.turno-badge:focus-visible,
.quick-card:focus-visible,
.links-uteis:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ===== LINKS ÚTEIS ===== */
.links-uteis {
  display: flex; align-items: center; gap: .85rem;
  margin: 1.2rem 0; padding: .9rem 1.1rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s;
}
.links-uteis:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.links-uteis:active { transform: scale(.99); }
.lu-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-faint);
}
.lu-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lu-text { display: flex; flex-direction: column; flex: 1; }
.lu-text strong { font-size: .92rem; font-weight: 800; }
.lu-text small { font-size: .74rem; color: var(--muted); }
.lu-arrow { font-size: 1.4rem; color: var(--muted); font-weight: 400; }

/* ===== BARRA DE AVISOS — afinação ===== */
#avisos-bar { height: 36px; }
#avisos-bar .av-viewport { padding-left: .9rem; }
@media (max-width: 720px) { #avisos-bar { height: 34px; } #avisos-bar .av-viewport { padding-left: .7rem; } }

/* ===== TEMA ALTO CONTRASTE ===== */
[data-theme="contraste"] {
  --bg:#000000; --bg-2:#000000; --card:#000000; --card-2:#0a0a0a;
  --primary:#ffe600; --primary-light:#ffe600; --primary-faint:#1a1a00; --accent:#ffe600;
  --text:#ffffff; --text-2:#ffffff; --muted:#dcdcdc;
  --success:#00ff66; --warning:#ffb300; --error:#ff5252; --info:#4db8ff;
  --border:#ffffff; --separator:#ffffff; --on-primary:#000000;
  --nav-bg:#000000; --nav-text:#ffffff; --bnav-bg:#000000; --bnav-text:#ffffff; --bnav-active:#ffe600;
  --shadow:none; --shadow-sm:none; --shadow-lg:none;
}
[data-theme="contraste"] .quick-card,
[data-theme="contraste"] .links-uteis,
[data-theme="contraste"] .turno-hoje,
[data-theme="contraste"] .ta-col { border-width: 2px; }
