* { margin:0; padding:0; box-sizing:border-box; }

:root {
  --brand: #F5A58E; 
  --brand-light: #fff2ef;
  --brand-dark: #e08b74;
  
  --saida: #f59e0b;
  --limpeza: #F5A58E;
  --concluido: #06b6d4;
  --finalizado: #10b981;
  
  --text-primary: #1e293b; 
  --text-secondary: #475569; 
  --text-muted: #94a3b8;
  
  --border: #f1f5f9; 
  --border-mid: #cbd5e1;
  --bg-app: #f8fafc; 
  --bg-card: #ffffff;
  
  --radius: 14px; 
  --radius-sm: 8px;
}

html, body { 
  height: 100%; 
  overflow: hidden; 
  background: var(--bg-app); 
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; 
  font-size: 15px; 
  color: var(--text-primary); 
  -webkit-font-smoothing: antialiased; 
}

#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Header ── */
#header {
  flex-shrink: 0; background: var(--bg-card); border-bottom: 1px solid #e2e8f0;
  z-index: 20; display: flex; align-items: flex-end; padding: 12px 16px; gap: 16px; width: 100%;
}
#filters-area { display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; }
#date-carousel-area { flex: 1; min-width: 0; overflow: hidden; }

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }

.fsel { position: relative; cursor: pointer; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); background: var(--bg-card); user-select: none; min-width: 120px; height: 32px; display: flex; align-items: center; transition: all 0.2s ease; }
.fsel:hover { border-color: var(--brand); }
.fsel.open { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.fsel.fsel-active { border-color: var(--brand); background: var(--brand-light); }
.fsel.fsel-active .fsel-val { color: var(--brand-dark); font-weight: 700; }
.fsel-face { display: flex; align-items: center; gap: 4px; padding: 0 10px; width: 100%; }
.fsel-val { flex: 1; font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsel-arrow { font-size: 0.55rem; color: var(--text-muted); margin-left: 4px; }
.fsel-clear { width: 16px; height: 16px; border-radius: 50%; background: var(--border-mid); color: white; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; margin-left: 4px; transition: background 0.2s; }
.fsel-clear:hover { background: #ef4444; }

.fsel-dropdown { position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; background: var(--bg-card); border: 1px solid var(--border-mid); border-radius: var(--radius-sm); z-index: 9999; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); overflow: hidden; }
.fsel-list { max-height: 220px; overflow-y: auto; overflow-x: hidden; }
.fsel-item { padding: 8px 12px; cursor: pointer; font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; transition: background 0.15s; }
.fsel-item:hover { background: var(--bg-app); }
.fsel-item.selected { background: var(--brand-light); font-weight: 700; color: var(--brand-dark); }
.fsel-search { width: 100%; padding: 8px 10px; border: none; border-bottom: 1px solid #e2e8f0; font-size: 0.85rem; outline: none; }

.prop-btn { height: 32px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-mid); background: var(--bg-card); font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; transition: all 0.2s ease; }
.prop-btn:hover { background: var(--bg-app); border-color: var(--brand); color: var(--brand-dark); }
.prop-btn.active { background: var(--brand); color: #ffffff; border-color: var(--brand); }

/* ── Carrossel de Datas ── */
.date-carousel { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 2px; scrollbar-width: none; cursor: grab; align-items: center; }
.date-carousel::-webkit-scrollbar { display: none; }
.date-item { height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 20px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; user-select: none; flex-shrink: 0; transition: all 0.2s ease; }
.date-item:hover { background: var(--brand-light); }
.date-item.active { border: 1px solid var(--brand); background: var(--bg-card); box-shadow: 0 2px 4px rgba(245,165,142,0.15); }

.date-item .dow { color: var(--text-primary); font-size: 0.85rem; font-weight: normal; }
.date-item.active .dow { color: var(--brand-dark); font-weight: 700; }
.date-item .day { color: var(--text-secondary); font-size: 0.85rem; font-weight: normal; }
.date-item.active .day { color: var(--brand-dark); font-weight: 700; }
.date-item .count-badge { background: #e2e8f0; color: var(--text-primary); font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 12px; transition: background 0.2s; }
.date-item.active .count-badge { background: var(--brand); color: white; }

/* ── Indicador de polling ── */
#sync-indicator { position: fixed; top: 12px; right: 16px; z-index: 100; pointer-events: none; }
#sync-dot { display: block; width: 6px; height: 6px; border-radius: 50%; background: transparent; transition: background 0.3s; }

/* ── Kanban Board Unificado ── */
#content-scroll { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 12px 16px; background: var(--bg-app); }
#content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.kanban-board { display: flex; gap: 20px; flex: 1; overflow-x: auto; overflow-y: hidden; width: 100%; align-items: stretch; scrollbar-width: thin; scrollbar-color: var(--border-mid) transparent; }

.kanban-col {
  flex: 1; min-width: 290px;
  background: transparent;
  border: none;
  display: flex; flex-direction: column;
  max-height: 100%; margin: 0;
  position: relative;
  z-index: 1;
}
.kanban-col:hover { z-index: 10; }

.kanban-col-header {
  padding: 6px 4px 12px 4px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text-primary);
  border-bottom: 4px solid var(--border-mid);
  flex-shrink: 0;
  margin-bottom: 12px;
}

.kanban-col-header.sh-saida { border-bottom-color: var(--saida); }
.kanban-col-header.sh-limpeza { border-bottom-color: var(--limpeza); }
.kanban-col-header.sh-concluido { border-bottom-color: var(--concluido); }
.kanban-col-header.sh-finalizado { border-bottom-color: var(--finalizado); }

.kanban-col-title { font-weight: 700; font-size: 0.88rem; text-transform: uppercase; letter-spacing: 0.5px; }
.kanban-col-count { font-size: 0.75rem; background: #e2e8f0; padding: 2px 8px; border-radius: 12px; font-weight: 700; color: var(--text-secondary); }

.kanban-col-scroll-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
  padding: 16px 4px 24px 4px; 
  display: flex; flex-direction: column; gap: 10px; 
}
.kanban-col-scroll-wrapper::-webkit-scrollbar { width: 4px; }
.kanban-col-scroll-wrapper::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }

/* ── Cartões (Compactos) ── */
.k-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px 12px; 
  border: 1px solid #e2e8f0;
  display: flex; flex-direction: column;
  position: relative; 
  overflow: visible; 
  flex-shrink: 0; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s ease;
  z-index: 1;
}
.k-card.no-obs { min-height: auto; }
.k-card.is-saving { opacity: 0.5; pointer-events: none; }
.k-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
  border-color: var(--brand);
  z-index: 100;
}

/* ── Cabeçalho dos Cartões ── */
.k-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2px; }
.k-title-wrap { display: flex; flex-direction: column; gap: 0; flex: 1; padding-right: 8px; }
.k-apto { font-weight: 700; font-size: 0.98rem; color: var(--text-primary); letter-spacing: -0.3px; }
.k-hospede { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; line-height: 1.2; }
.k-hora { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); text-align: right; white-space: nowrap; }

/* ── Linha Central (Tags e Botões) ── */
.k-middle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  min-height: 26px; 
}
.k-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 0; flex: 1; }

.tag-badge { 
  font-size: 0.68rem; font-style: normal; font-weight: 600;
  padding: 3px 8px; border-radius: 20px; letter-spacing: 0.2px;
}
.tag-badge-self { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.tag-badge-early { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.tag-badge-late { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.tag-badge-ultima { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; font-weight: 700; }

.k-card-content { display: flex; flex-direction: column; }

/* ── Controles e Botões (Compactos) ── */
.k-controls-container { display: flex; justify-content: flex-end; align-items: center; flex-shrink: 0; }
.k-controls { display: flex; align-items: center; gap: 6px; }

.icon-toggle-label { position: relative; cursor: pointer; display: inline-flex; }
.icon-toggle-label input { display: none; }
.icon-btn { 
  width: 26px; height: 26px; 
  border-radius: var(--radius-sm); 
  border: 1px solid #cbd5e1; 
  display: flex; justify-content: center; align-items: center; 
  background: var(--bg-card); color: var(--text-secondary); 
  transition: all 0.2s ease; 
}
.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.icon-toggle-label:hover .icon-btn { border-color: var(--brand); color: var(--brand-dark); transform: scale(1.05); }
.icon-toggle-label input:checked + .icon-btn { background: var(--brand); border-color: var(--brand); color: white; }

/* ── Tooltips ── */
.icon-tooltip { 
  position: absolute; 
  bottom: calc(100% + 6px); 
  right: -6px; 
  left: auto;
  transform: scale(0); 
  transform-origin: bottom right; 
  padding: 6px 10px; border-radius: 6px; 
  background: #ffffff; color: var(--text-primary); 
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  font-size: 0.7rem; font-weight: 600; pointer-events: none; 
  white-space: nowrap; 
  z-index: 99999; 
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.icon-tooltip::after {
  content: ''; position: absolute; top: 100%; 
  right: 16px; 
  left: auto; transform: none;
  border-width: 5px; border-style: solid; 
  border-color: #ffffff transparent transparent transparent;
}
.icon-tooltip::before {
  content: ''; position: absolute; top: calc(100% + 1px); 
  right: 15px; 
  left: auto; transform: none;
  border-width: 6px; border-style: solid; 
  border-color: #e2e8f0 transparent transparent transparent;
  z-index: -1;
}
.icon-toggle-label:hover .icon-tooltip { transform: scale(1); }

/* ── Área de Observações (Compacta) ── */
.k-obs {
  font-size: 0.8rem; color: var(--text-secondary);
  border: 1px solid #e2e8f0; border-radius: var(--radius-sm);
  padding: 6px 8px; background: #f8fafc;
  font-family: inherit; width: 100%; resize: none; min-height: 30px;
  box-sizing: border-box; line-height: 1.3;
  transition: border-color 0.2s ease, background 0.2s ease, min-height 0.2s ease;
}
.k-obs:focus { outline: none; border-color: var(--brand); background: var(--bg-card); min-height: 52px; }

/* ── Utilitários ── */
.vazio { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.8rem; }
.loading { font-size: 0.85rem; color: var(--text-secondary); text-align: center; padding: 30px 0; }
/* ── Undo bar ── */
.undo-bar {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: white;
}
.undo-bar-progress {
  height: 3px;
  background: var(--gray-bg);
}
.undo-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}
.undo-bar-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  gap: 8px;
}
.undo-bar-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.undo-countdown {
  font-weight: 700;
  color: var(--text-secondary);
}
.undo-btn {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.undo-btn:hover {
  background: var(--accent-soft);
}