/* Màn Chăm sóc khách (đợt 8): tab, ô nhóm, thẻ khách, khung "Đã nói chuyện", tab Tìm (phiếu lọc, bộ lọc), hộp thoại.
   Chỉ dùng biến màu chung (app.css) nên tự theo sáng / tối. Hàng chip cuộn ngang bên trong, trang không cuộn ngang. */

.cs-page { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.cs-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.cs-tab { padding: 9px 14px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--ink-2); text-decoration: none; white-space: nowrap; font-weight: 600; border: 1px solid transparent; border-bottom: 0; }
.cs-tab:hover { background: var(--surface-2); }
.cs-tab.is-active { background: var(--surface); color: var(--ink); border-color: var(--line); margin-bottom: -1px; }

.cs-summary p { margin: 0; }
.cs-summary .chips { flex-wrap: nowrap; }

.cs-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cs-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); font: inherit; min-width: 0; }
.cs-tile:hover { border-color: var(--line-strong); }
.cs-tile.is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.cs-tile.is-done .cs-tile-num { color: var(--good); }
.cs-tile-num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.cs-tile-label { font-weight: 600; font-size: 13px; }
.cs-tile-hint { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.cs-tile-sm .cs-tile-num { font-size: 18px; }

.cs-quicklists { align-items: center; }
.cs-quicklists .chip { text-decoration: none; }

.cs-group { display: flex; flex-direction: column; gap: 8px; }
.cs-group-head { font-size: 12px; letter-spacing: 0.06em; color: var(--ink-2); margin: 6px 0 0; display: flex; align-items: center; gap: 6px; }
.cs-list { display: flex; flex-direction: column; gap: 10px; }
.cs-more { display: flex; justify-content: center; }
.cs-count { margin: 4px 0 0; }

.cs-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; min-width: 0; }
.cs-card.is-late { border-left: 3px solid var(--danger); }
.cs-card.is-stopped { opacity: 0.85; }
.cs-logged { background: var(--good-bg); color: var(--good); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.cs-head { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.cs-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.cs-order { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 0; }
.cs-order .ellipsis { max-width: 320px; }
.cs-warn { color: var(--bad); font-weight: 600; }
.ellipsis-inline { overflow-wrap: anywhere; }
.cs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }

.cs-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cs-talk { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.cs-talk textarea { width: 100%; min-height: 70px; resize: vertical; font: inherit; }
.cs-later { align-items: center; }
.cs-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-history { border-top: 1px dashed var(--line); padding-top: 8px; max-height: 360px; overflow-y: auto; }
.cs-orders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.cs-now { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.cs-find { display: flex; flex-direction: column; gap: 10px; }
.cs-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; background: var(--info-bg); border-radius: var(--radius-sm); }
.cs-presets, .cs-saved { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cs-chip-row { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; scrollbar-width: thin; }
.cs-chip-row .chip { white-space: nowrap; flex: 0 0 auto; }
.cs-script { margin: 0; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.cs-saved-chip { display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.cs-saved-x { width: 26px; height: 26px; font-size: 12px; }
.cs-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.cs-controls .search { flex: 1 1 200px; min-width: 0; }
.cs-select { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cs-select select { max-width: 100%; }
.cs-filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.cs-filter-label { flex: 0 0 auto; }
.cs-range { display: inline-flex; align-items: center; gap: 4px; }
.cs-range input { width: 64px; }
.cs-detail { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.cs-selects { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

.cs-result-form .cs-reasons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cs-result-form .cs-reasons[hidden], .cs-noanswer[hidden] { display: none; }
.cs-effect { margin: 0; padding: 6px 10px; background: var(--warn-bg); border-radius: var(--radius-sm); }
.cs-template { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.cs-template textarea { width: 100%; min-height: 96px; resize: vertical; font: inherit; }

@media (max-width: 640px) {
  .cs-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-quick > span { grid-column: 1 / -1; }
  .cs-order .ellipsis { max-width: 100%; }
  .cs-controls > * { flex: 1 1 100%; }
  .cs-summary .chips { flex-wrap: wrap; }
}
