/* ==========================================================================
   Gestão de Efetivo — folha de estilo única
   Paleta e componentes conforme "Wireframes - Gestao de Efetivo" (seção 6).
   ========================================================================== */

:root {
  --bg:            #FFFFFF;
  --brand:         #993C1D;  /* título / marca            */
  --accent:        #D85A30;  /* ação principal / destaque */
  --accent-press:  #BC4A25;
  --green:         #3B6D11;  /* status positivo           */
  --green-2:       #639922;
  --muted:         #6B6A63;  /* texto secundário          */
  --border:        #E5E3DB;  /* bordas / divisores        */
  --card:          #FAFAF7;  /* fundo de card neutro      */
  --nav-off:       #9A9891;

  --pill-o-bg:     #FAECE7;
  --pill-o-fg:     #712B13;
  --pill-g-bg:     #EAF3DE;
  --pill-g-fg:     #27500A;

  --danger:        #B3261E;
  --danger-bg:     #FCEEED;

  --radius:        13px;
  --radius-sm:     9px;
  --tap:           44px;     /* alvo mínimo de toque */

  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --nav-h:         62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #EFEEE9;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: #1F1E1B;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }

/* --- casco do app: coluna mobile centralizada também no desktop ---------- */

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

@media (min-width: 481px) {
  body { padding: 0; }
  #app { min-height: 100vh; }
}

/* ---------------------------------------------------------------- topbar */

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.topbar-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
}
.topbar-btn:active { background: var(--card); }
.topbar-btn.is-syncing svg { animation: spin 0.9s linear infinite; }
.topbar-btn[data-state="pending"] { color: var(--accent); }
.topbar-btn[data-state="off"]     { color: var(--nav-off); }

@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--pill-o-bg);
  color: var(--pill-o-fg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------ view */

#view {
  flex: 1;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 24px);
}

.section-label {
  margin: 20px 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-label:first-child { margin-top: 0; }

.hint {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.empty {
  padding: 26px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ----------------------------------------------------------------- cards */

.card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.card + .card { margin-top: 10px; }
.card--neutral { background: var(--card); }

/* --------------------------------------------------------- seletor torre */

.tower-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(46%, 1fr);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.tower-grid::-webkit-scrollbar { display: none; }

.tower {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
}
.tower.is-active {
  border: 2px solid var(--accent);
  background: var(--bg);
  padding: 9px;
}

.tower-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--nav-off);
  margin-bottom: 8px;
}
.tower.is-active .tower-name { color: var(--brand); }

.floors {
  display: flex;
  flex-direction: column-reverse; /* térreo embaixo, como o prédio */
  gap: 3px;
  max-height: 190px;
  overflow-y: auto;
}
.floors::-webkit-scrollbar { width: 0; }

.floor {
  display: grid;
  place-items: center;
  height: 17px;
  border-radius: 3px;
  background: #EDECE6;
  color: transparent;
  font-size: 10px;
  font-weight: 700;
  transition: background 0.12s;
}
.tower.is-active .floor { background: #F7EDE9; }
.tower.is-active .floor.has-work { background: #F0DED6; }
.tower.is-active .floor.is-selected {
  background: var(--accent);
  color: #fff;
}

.tower-foot {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.tower.is-active .tower-foot { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------- card atividade  */

.activity + .activity { margin-top: 10px; }

.activity-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.activity-name {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: #1F1E1B;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status--andamento { color: var(--green-2); }
.status--pausado   { color: #B07A12; }
.status--concluido { color: var(--muted); }

/* ------------------------------------------------------------- drop zone */

.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 78px;
  margin-top: 12px;
  padding: 12px;
  border: 1.5px dashed #D9D6CB;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
}
.dropzone.is-over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--pill-o-bg);
  color: var(--pill-o-fg);
}
.dropzone-arrow { font-size: 16px; line-height: 1; }

.alloc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.alloc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 10px;
  border-radius: 999px;
  background: var(--pill-g-bg);
  color: var(--pill-g-fg);
  font-size: 12px;
  font-weight: 700;
}
.alloc-x {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(39, 80, 10, 0.12);
  color: var(--pill-g-fg);
  font-size: 13px;
  line-height: 1;
}
.alloc-x:active { background: rgba(39, 80, 10, 0.25); }

/* ---------------------------------------------------------- chips efetivo */

.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 6px;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 84px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  text-align: center;
  /* pan-x deixa o dedo rolar a lista de lado; o gesto vertical fica para o
     arraste até a área de drop, que é sempre acima dos chips. */
  touch-action: pan-x;
  user-select: none;
  transition: transform 0.1s, box-shadow 0.1s;
}
.chip svg { color: var(--brand); }
.chip-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.chip-count { font-size: 11px; font-weight: 700; color: var(--accent); }

.chip.is-empty { opacity: 0.45; }
.chip.is-empty .chip-count { color: var(--muted); }
.chip.is-dragging { opacity: 0.35; }
.chip:not(.is-empty):active { transform: scale(0.96); }

.chip-ghost {
  position: fixed;
  z-index: 999;
  width: 84px;
  padding: 10px 6px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.04);
  text-align: center;
}

/* -------------------------------------------------------------- contador */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.row + .row { margin-top: 8px; }
.row-icon { display: grid; place-items: center; color: var(--brand); flex: 0 0 auto; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 700; }
.row-sub { font-size: 12px; color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 4px; }
.step-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}
.step-btn--minus { border: 1px solid var(--border); color: var(--muted); background: var(--bg); }
.step-btn--plus  { background: var(--accent); color: #fff; }
.step-btn--plus:active { background: var(--accent-press); }
.step-btn:disabled { opacity: 0.4; }
.step-val {
  min-width: 26px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- total */

.total {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
}
.total-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.total-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi {
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 14px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.kpi-value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-label { font-size: 11px; color: var(--muted); text-align: center; }

/* --------------------------------------------------------------- botões  */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:active { background: var(--accent-press); }
.btn--primary:disabled { background: #E4C8BC; }
.btn--ghost { border: 1px solid var(--border); background: var(--bg); color: #1F1E1B; }
.btn--ghost:active { background: var(--card); }
.btn--danger { border: 1px solid #E8CDCB; background: var(--danger-bg); color: var(--danger); }
.btn--dashed {
  border: 1px dashed var(--border);
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  min-height: 40px;
}
/* tracejado, porém em laranja: para ações que o usuário precisa encontrar */
.btn--destaque {
  border-color: var(--accent);
  background: var(--pill-o-bg);
  color: var(--pill-o-fg);
  font-weight: 700;
}
.btn--icon { width: 44px; flex: 0 0 44px; padding: 0; }
.btn--sm {
  width: auto;
  min-height: 32px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--bg);
}
.btn-row { display: flex; gap: 8px; }

.sticky-action {
  position: sticky;
  bottom: 0;
  margin: 16px -16px 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 22%);
}

/* ---------------------------------------------------------------- pills  */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pill--orange { background: var(--pill-o-bg); color: var(--pill-o-fg); }
.pill--green  { background: var(--pill-g-bg); color: var(--pill-g-fg); }
.pill--grey   { background: #F0EFEA; color: var(--muted); }

/* ---------------------------------------------------------------- busca  */

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted);
}
.search input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: none;
  background: none;
  outline: none;
  font-size: 14px;
  color: #1F1E1B;
}

.field { margin-bottom: 12px; }
.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  font-size: 15px;
}
.input:focus { border-color: var(--accent); }
select.input { appearance: none; background-image: none; }

/* -------------------------------------------------------- lista serviços */

.svc {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  text-align: left;
}
.svc + .svc { margin-top: 8px; }
.svc--off { background: var(--card); }
.svc-body { flex: 1; min-width: 0; }
.svc-name { font-size: 14px; font-weight: 700; }
.svc-meta { font-size: 12px; color: var(--muted); }
.svc-chev { color: #C7C4BA; flex: 0 0 auto; }

.group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 18px 0 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-title::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.group-title--on::before { background: var(--green-2); }

/* ------------------------------------------------------------- relatório */

.rep-tower {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.rep-block {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.rep-block + .rep-block { margin-top: 8px; }
.rep-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.rep-floor { font-size: 13px; font-weight: 700; }
.rep-svc { font-size: 12px; font-weight: 600; color: var(--accent); text-align: right; }
.rep-pills { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------------ nav  */

#tabbar {
  position: fixed;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  max-width: 480px;
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.tab {
  position: relative;      /* âncora do .tab-badge */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  color: var(--nav-off);
  font-size: 10px;
  font-weight: 500;
}
.tab.is-active { color: var(--accent); font-weight: 700; }
.tab-badge {
  position: absolute;
  transform: translate(14px, -12px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

/* ---------------------------------------------------------------- modal  */

#modal-root:empty { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(31, 30, 27, 0.42);
  animation: fade 0.15s ease-out;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--bg);
  animation: rise 0.2s ease-out;
}
.modal-title { margin: 0 0 4px; font-size: 17px; font-weight: 700; color: var(--brand); }
.modal-sub { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); } }

.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.opt {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
}
.opt.is-on { border-color: var(--accent); background: var(--pill-o-bg); color: var(--pill-o-fg); }

/* ---------------------------------------------------------------- toast  */

#toast-root {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: 50%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: calc(100% - 32px);
  max-width: 448px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  background: #2B2A26;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  animation: rise 0.16s ease-out;
}
.toast--warn { background: var(--danger); }

/* ------------------------------------------------------------ impressão  */

#print-area { display: none; }

@media print {
  @page { margin: 14mm; }

  body { background: #fff; }
  #app, #modal-root, #toast-root { display: none !important; }

  #print-area {
    display: block;
    font-size: 11pt;
    color: #000;
  }
  .p-head { border-bottom: 2px solid var(--brand); padding-bottom: 8pt; margin-bottom: 14pt; }
  .p-title { font-size: 20pt; font-weight: 700; color: var(--brand); margin: 0; }
  .p-sub { font-size: 10pt; color: #444; margin: 3pt 0 0; }
  .p-kpis { display: flex; gap: 10pt; margin-bottom: 14pt; }
  .p-kpi { flex: 1; border: 1px solid #999; border-radius: 4pt; padding: 8pt; text-align: center; }
  .p-kpi b { display: block; font-size: 17pt; }
  .p-kpi span { font-size: 9pt; color: #444; }
  .p-destaque {
    font-size: 11pt;
    padding: 6pt 8pt;
    background: #FAECE7;
    border-left: 3pt solid var(--accent);
    margin: 0 0 12pt;
  }
  .p-foot { margin-top: 18pt; font-size: 8.5pt; color: #666; border-top: 1px solid #ccc; padding-top: 6pt; }
  .p-table { width: 100%; border-collapse: collapse; margin-top: 6pt; font-size: 10.5pt; }
  .p-table th, .p-table td {
    border: 1px solid #bbb;
    padding: 5pt 7pt;
    text-align: left;
    vertical-align: top;
  }
  .p-table th { background: #f0efea; }
  .p-table tr { page-break-inside: avoid; }
  .p-table small { color: #666; }
}
