/* =========================================================
   Avado CRM — Mobile-first CSS (giống PWA gốc)
   Max-width ~480px, màu chủ đạo #10c9a5
   ========================================================= */

:root {
  --primary: #10c9a5;
  --primary-dark: #0ea88a;
  --primary-light: #e8f7f0;
  --bg: #F2F4F7;
  --card: #ffffff;
  --text: #1a1d26;
  --muted: #8a94a6;
  --border: #e8ecf0;
  --danger: #e53935;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.dark-mode {
  --bg: #12141a;
  --card: #1c1f28;
  --text: #f0f2f5;
  --muted: #9aa3b2;
  --border: #2a2e3a;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
}

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

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body.tcb-body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);
  -webkit-font-smoothing: antialiased;
}

/* Sidebar ẩn trên mobile */
.tcb-sidebar {
  display: none;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* ---------- Login ---------- */
.tcb-login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: linear-gradient(160deg, #E8F7F0 0%, #ffffff 50%, #f5f0ff 100%);
}
.dark-mode .tcb-login-page {
  background: linear-gradient(160deg, #0d2a22 0%, #12141a 50%, #1a1525 100%);
}

.tcb-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
}

.tcb-login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.tcb-logo-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10c9a5, #0ea88a);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 16px rgba(16,201,165,.35);
}
.tcb-login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.tcb-login-sub {
  color: var(--muted);
  font-size: .9rem;
  margin-top: 4px;
}

.tcb-field {
  margin-bottom: 16px;
}
.tcb-field label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.tcb-field input[type="text"],
.tcb-field input[type="password"],
.tcb-field input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.tcb-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,201,165,.15);
}

.tcb-field-check {
  margin-bottom: 20px;
}
.tcb-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--muted);
}
.tcb-checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.tcb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.tcb-btn-primary {
  background: var(--primary);
  color: #fff;
}
.tcb-btn-primary:hover { background: var(--primary-dark); }
.tcb-btn-primary:active { transform: scale(.98); }
.tcb-btn-block { width: 100%; }

.tcb-alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.tcb-alert-error {
  background: #ffebee;
  color: var(--danger);
  border: 1px solid #ffcdd2;
}
.dark-mode .tcb-alert-error {
  background: #3d1f1f;
  border-color: #5c2b2b;
}

.tcb-login-footer {
  margin-top: 24px;
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- Shell & Hero ---------- */
.tcb-shell {
  min-height: 100%;
}

.tcb-hero {
  background: linear-gradient(135deg, #d4f5ec 0%, #e8e0ff 50%, #ffe8d4 100%);
  padding: 16px 20px 28px;
  border-radius: 0 0 24px 24px;
  position: relative;
}
.dark-mode .tcb-hero {
  background: linear-gradient(135deg, #0d2a22 0%, #1a1530 50%, #2a1f15 100%);
}

.tcb-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tcb-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(16,201,165,.3);
}
.tcb-hero-actions {
  display: flex;
  gap: 8px;
}
.tcb-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.7);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.dark-mode .tcb-icon-btn {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.tcb-hero-greeting h1 {
  font-size: 1.35rem;
  font-weight: 700;
}
.tcb-muted { color: var(--muted); font-size: .9rem; }

/* ---------- Main content ---------- */
.tcb-main {
  padding: 16px 16px 24px;
  margin-top: -12px;
}

.tcb-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.tcb-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.tcb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.tcb-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 500;
  font-size: .9rem;
  cursor: pointer;
}
.tcb-tab.is-active {
  background: var(--primary);
  color: #fff;
}

.tcb-empty-state {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}

.tcb-card-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: .85rem;
}
.tcb-card-footer a { color: var(--primary); font-weight: 500; }

/* Tray icons */
.tcb-tray-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.tcb-tray-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
}
.tcb-tray-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
}
.tcb-tray-label {
  font-size: .7rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

/* ---------- Bottom Navigation ---------- */
.tcb-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.04);
}
.tcb-bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--nav-height);
  padding: 0 4px;
}
.tcb-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: .65rem;
  padding: 6px 0;
  transition: color .15s;
}
.tcb-nav-item.is-active {
  color: var(--primary);
}
.tcb-nav-item.is-center .tcb-nav-icon {
  /* Home nổi nhẹ */
}
.tcb-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tcb-nav-label {
  font-weight: 500;
}

/* ---------- Utilities ---------- */
.tcb-text-center { text-align: center; }
.tcb-mt-1 { margin-top: 8px; }
.tcb-mt-2 { margin-top: 16px; }

/* Toast (dùng bởi app.js) */
.tcb-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1d26;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  max-width: 90%;
  pointer-events: none;
}
.tcb-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.dark-mode .tcb-toast {
  background: #f0f2f5;
  color: #1a1d26;
}

/* Loading overlay */
.tcb-loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.tcb-loading.is-show {
  opacity: 1;
  pointer-events: auto;
}
.dark-mode .tcb-loading { background: rgba(0,0,0,.5); }
.tcb-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Bước 2 — Dashboard extras (không đụng core layout/nav)
   ========================================================= */

/* Search giả trên hero */
.tcb-search-fake {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,.75);
  border-radius: 999px;
  color: var(--muted);
  font-size: .85rem;
  text-decoration: none;
  backdrop-filter: blur(8px);
  min-width: 0;
}
.tcb-search-fake span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dark-mode .tcb-search-fake {
  background: rgba(255,255,255,.1);
  color: #b0b8c4;
}

/* Badge unread */
.tcb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--card);
}
.tcb-tray-icon { position: relative; }
.tcb-bell { position: relative; }
.tcb-badge-bell {
  top: 2px;
  right: 2px;
  border-color: transparent;
}

/* Channel icon backgrounds */
.tcb-tray-fb { background: #e7f0ff; }
.tcb-tray-zalo { background: #e6f4ff; color: #0068ff; font-weight: 700; }
.tcb-tray-wa { background: #e7f8ef; }
.tcb-tray-tt { background: #f5f5f5; }
.tcb-tray-map { background: #e8f7f0; }
.tcb-tray-letter { font-size: 1rem; font-weight: 700; }

.dark-mode .tcb-tray-tt { background: #2a2e3a; }
.dark-mode .tcb-tray-tt svg { fill: #eee; }

/* Reminder list items */
.tcb-reminder-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tcb-rem-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.tcb-rem-item:last-child { border-bottom: none; }
.tcb-rem-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tcb-rem-body { flex: 1; min-width: 0; }
.tcb-rem-title {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tcb-rem-meta {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tcb-days-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: #e8f7f0;
  color: #0ea88a;
}
.tcb-days-warn { background: #fff4e5; color: #e67e22; }
.tcb-days-urgent { background: #ffebee; color: #e53935; }

/* Promo card */
.tcb-promo-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f3e8ff 0%, #e8f0fe 50%, #fce8f0 100%);
}
.dark-mode .tcb-promo-card {
  background: linear-gradient(135deg, #2a1f3d 0%, #1a2540 50%, #3a1f2a 100%);
}
.tcb-promo-body { flex: 1; }
.tcb-promo-body h3 {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.tcb-promo-body p {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.tcb-promo-art {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dark-mode .tcb-promo-art { background: rgba(255,255,255,.08); }

.tcb-btn-dark {
  background: #1a1d26;
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: .8rem;
  font-weight: 600;
  display: inline-flex;
  text-decoration: none;
}
.dark-mode .tcb-btn-dark {
  background: #f0f2f5;
  color: #1a1d26;
}
.tcb-btn-sm { padding: 8px 16px; font-size: .8rem; }

/* Today progress */
.tcb-today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tcb-today-pct {
  font-weight: 700;
  color: var(--primary);
  font-size: .95rem;
}
.tcb-progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.tcb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10c9a5, #0ea88a);
  border-radius: 999px;
  transition: width .4s ease;
}
.tcb-today-meta {
  margin-top: 8px;
  font-size: .8rem;
}

.tcb-loading-inline {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

/* Hero top flex khi có search */
.tcb-hero-top {
  align-items: center;
}

/* =========================================================
   Bước 3 — CRM Khách hàng (không đụng core layout/nav)
   ========================================================= */

.tcb-page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.tcb-page-title {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}
.tcb-btn-add {
  background: var(--primary) !important;
  color: #fff !important;
}
.tcb-page-toolbar {
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tcb-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.tcb-search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: .9rem;
  min-width: 0;
}
.tcb-switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
}
.tcb-switch {
  width: 40px;
  height: 22px;
  appearance: none;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.tcb-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.tcb-switch:checked { background: var(--primary); }
.tcb-switch:checked::after { transform: translateX(18px); }

.tcb-main-list {
  padding-top: 8px;
}

/* List cards */
.tcb-list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}
.tcb-list-card-static { cursor: default; }
.tcb-list-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}
.tcb-list-body { flex: 1; min-width: 0; }
.tcb-list-title {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tcb-list-sub {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 2px;
}
.tcb-list-meta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 2px;
}
.tcb-list-chevron {
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 300;
}

.tcb-load-more {
  text-align: center;
  padding: 8px 16px 24px;
}
.tcb-btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 500;
  cursor: pointer;
}

/* Detail */
.tcb-avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
}
.tcb-detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.tcb-detail-head h2 {
  font-size: 1.15rem;
  margin: 0 0 2px;
}
.tcb-dl {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.tcb-dl > div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  font-size: .9rem;
}
.tcb-dl dt {
  color: var(--muted);
  font-weight: 500;
}
.tcb-dl dd { margin: 0; word-break: break-word; }

.tcb-section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tcb-link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  padding: 4px 8px;
}

.tcb-phone-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tcb-phone-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.tcb-phone-item:last-child { border-bottom: none; }
.tcb-phone-item a { color: var(--text); font-weight: 500; }
.tcb-tag {
  font-size: .65rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* Timeline */
.tcb-timeline {
  position: relative;
  padding-left: 20px;
}
.tcb-timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.tcb-timeline-dot {
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.tcb-timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.tcb-timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .85rem;
  margin-bottom: 4px;
}
.tcb-timeline-body p {
  font-size: .9rem;
  line-height: 1.45;
  margin: 0 0 4px;
}
.tcb-timeline-user { font-size: .75rem; }

/* FAB */
.tcb-fab {
  position: fixed;
  right: max(16px, calc(50% - 240px + 16px));
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(16,201,165,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
}
.tcb-fab:active { transform: scale(.95); }

/* Modal bottom sheet */
.tcb-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.tcb-modal[hidden] { display: none !important; }
.tcb-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
}
.tcb-modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(16px + var(--safe-bottom));
  animation: sheetUp .25s ease;
}
.tcb-modal-sheet-sm { padding-bottom: calc(8px + var(--safe-bottom)); }
@keyframes sheetUp {
  from { transform: translateY(40px); opacity: .5; }
  to { transform: translateY(0); opacity: 1; }
}
.tcb-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}
.tcb-modal-head h2 {
  font-size: 1.05rem;
  margin: 0;
}
.tcb-modal-body {
  padding: 8px 16px 16px;
}
.tcb-modal-body select,
.tcb-modal-body textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
}
.tcb-modal-body select:focus,
.tcb-modal-body textarea:focus {
  border-color: var(--primary);
}

.tcb-menu-item {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.tcb-menu-item:last-child { border-bottom: none; }
.tcb-menu-danger { color: var(--danger); }

/* =========================================================
   Bước 4 — Doanh số & Bán hàng
   ========================================================= */

.tcb-form-sale .tcb-field { margin-bottom: 14px; }

.tcb-selected-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--primary-light);
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--primary-dark);
}
.tcb-chip-x {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

.tcb-suggest {
  margin-top: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.tcb-suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: .9rem;
}
.tcb-suggest-item:last-child { border-bottom: none; }
.tcb-suggest-item:active { background: var(--bg); }
.tcb-suggest-empty {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

.tcb-proof-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.tcb-proof-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.tcb-proof-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tcb-proof-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

.tcb-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tcb-input-sm {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: .85rem;
  outline: none;
  flex: 1;
  min-width: 0;
}
.tcb-input-sm:focus { border-color: var(--primary); }

.tcb-sum-bar {
  padding: 10px 12px;
  background: var(--primary-light);
  border-radius: 10px;
  font-size: .9rem;
  color: var(--primary-dark);
}
.dark-mode .tcb-sum-bar {
  background: rgba(16,201,165,.15);
  color: var(--primary);
}

.tcb-status-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
}
.tcb-badge-ok { background: #e8f7f0; color: #0ea88a; }
.tcb-badge-fail { background: #ffebee; color: #e53935; }
.tcb-badge-pending { background: #fff4e5; color: #e67e22; }
.dark-mode .tcb-badge-ok { background: rgba(16,201,165,.2); }
.dark-mode .tcb-badge-fail { background: rgba(229,57,53,.2); }

.tcb-btn-sm {
  padding: 8px 12px;
  font-size: .8rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* =========================================================
   Bước 5 — Inbox + Chat
   ========================================================= */

.tcb-channel-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tcb-ch-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  border: none;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
}
.tcb-ch-tab.is-active {
  background: var(--primary);
  color: #fff;
}

.tcb-filter-chips {
  display: flex;
  gap: 8px;
}
.tcb-chip {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
}
.tcb-chip.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.tcb-kpi-pill {
  font-size: .75rem;
  font-weight: 700;
  background: #e53935;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
}

.tcb-conv-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.tcb-conv-card.is-unread .tcb-list-title { font-weight: 700; }
.tcb-conv-top, .tcb-conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tcb-conv-time {
  font-size: .72rem;
  color: var(--muted);
  flex-shrink: 0;
}
.tcb-unread-dot {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat shell — full height, no bottom nav */
.tcb-chat-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 0 !important;
  background: var(--bg);
}
.tcb-chat-header { flex-shrink: 0; }
.tcb-chat-title-wrap { flex: 1; min-width: 0; }
.tcb-chat-title-wrap .tcb-page-title {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tcb-chat-sub { font-size: .75rem; display: block; }

.tcb-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tcb-bubble {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}
.tcb-bubble.is-in { align-self: flex-start; }
.tcb-bubble.is-out { align-self: flex-end; }
.tcb-bubble-inner {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: .95rem;
  line-height: 1.4;
  word-break: break-word;
}
.tcb-bubble.is-in .tcb-bubble-inner {
  background: var(--card);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.tcb-bubble.is-out .tcb-bubble-inner {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tcb-bubble-img {
  max-width: 220px;
  border-radius: 12px;
  display: block;
  margin-bottom: 4px;
}
.tcb-bubble-meta {
  font-size: .65rem;
  color: var(--muted);
  margin-top: 2px;
  padding: 0 4px;
}
.tcb-bubble.is-out .tcb-bubble-meta { text-align: right; }
.tcb-msg-fail { color: #e53935; font-weight: 700; }

.tcb-composer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
}
.tcb-composer-input-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 20px;
  padding: 8px 14px;
}
.tcb-composer-input-wrap textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  color: var(--text);
  font-size: .95rem;
  max-height: 120px;
  line-height: 1.4;
}
.tcb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.tcb-send-btn:active { transform: scale(.95); }

/* Customer side panel */
.tcb-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  justify-content: flex-end;
}
.tcb-panel[hidden] { display: none !important; }
.tcb-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
}
.tcb-panel-sheet {
  position: relative;
  width: min(360px, 88vw);
  height: 100%;
  background: var(--card);
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: panelIn .25s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
@keyframes panelIn {
  from { transform: translateX(40px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}
.tcb-panel-body { padding: 8px 16px 24px; }

/* =========================================================
   Bước 7 — Công việc & KPI
   ========================================================= */

.tcb-kpi-big {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}
.tcb-progress-bar-lg { height: 12px; margin: 12px 0 10px; }
.tcb-progress-gradient {
  background: linear-gradient(90deg, #ff6b6b, #f5a623, #4fc3f7, #10c9a5);
}
.tcb-kpi-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.tcb-leg {
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
}
.tcb-leg-r { background: #e53935; }
.tcb-leg-o { background: #f5a623; }
.tcb-leg-b { background: #42a5f5; }
.tcb-leg-g { background: #10c9a5; }

.tcb-status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.tcb-quick-prog {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.tcb-list-card.is-unread {
  background: linear-gradient(90deg, rgba(16,201,165,.08), var(--card));
}

/* =========================================================
   Bước 8 — Chấm công + Bản đồ
   ========================================================= */

.tcb-att-card { text-align: center; padding: 24px 16px; }
.tcb-att-status {
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.tcb-att-status.is-in { color: var(--primary); }
.tcb-att-status.is-out { color: #e67e22; }
.tcb-att-time {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.tcb-att-info {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 16px 0;
  font-size: .9rem;
}
.tcb-att-gps { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.tcb-att-fence { font-size: .85rem; font-weight: 600; margin-bottom: 16px; }
.tcb-att-fence.is-in { color: var(--primary); }
.tcb-att-fence.is-out { color: #e53935; }
.tcb-att-actions { max-width: 280px; margin: 0 auto; }

.tcb-map-shell {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom)) !important;
}
.tcb-map {
  height: calc(100vh - 120px - var(--nav-height) - env(safe-area-inset-bottom, 0px));
  min-height: 320px;
  width: 100%;
  z-index: 1;
}
.tcb-map-settings {
  margin: 12px 16px 24px;
}

/* =========================================================
   Bước 9 — Thông báo
   ========================================================= */

.tcb-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.tcb-notif-item.is-unread {
  background: linear-gradient(90deg, rgba(16,201,165,.1), var(--card));
}
.tcb-notif-item.is-unread .tcb-list-title { font-weight: 700; }
.tcb-notif-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* =========================================================
   Bước 10 — Monitor + Account
   ========================================================= */

.tcb-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tcb-stat {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}
.tcb-stat-val {
  font-weight: 800;
  font-size: .95rem;
  color: var(--text);
}
.tcb-stat-lbl {
  font-size: .7rem;
  color: var(--muted);
  margin-top: 4px;
}
.tcb-monitor-ch {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.tcb-monitor-ch:last-child { border-bottom: none; }
.tcb-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 24px;
}
.tcb-account-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.tcb-menu-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: .95rem;
  text-decoration: none;
  cursor: pointer;
}
.tcb-menu-row:last-child { border-bottom: none; }

/* =========================================================
   DESKTOP LAYOUT (≥ 900px) — Sidebar trái + nội dung rộng
   ========================================================= */

@media (min-width: 900px) {
  :root {
    --sidebar-width: 260px;
    --nav-height: 0px;
  }

  body.tcb-body {
    max-width: none;
    margin: 0;
    padding-bottom: 0;
    padding-left: var(--sidebar-width);
    display: block;
    min-height: 100vh;
  }

  /* Ẩn bottom nav trên desktop */
  .tcb-bottom-nav {
    display: none !important;
  }

  /* Sidebar cố định bên trái */
  .tcb-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #1a1d26;
    color: #c8cdd6;
    z-index: 200;
    border-right: 1px solid #2a2e3a;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .dark-mode .tcb-sidebar {
    background: #0f1117;
    border-right-color: #1e222d;
  }

  .tcb-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid #2a2e3a;
    flex-shrink: 0;
  }

  .tcb-sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #10c9a5, #0ea88a);
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(16,201,165,.3);
  }

  .tcb-sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
  }
  .tcb-sidebar-brand-text strong {
    color: #fff;
    font-size: 1rem;
  }
  .tcb-sidebar-brand-text span {
    font-size: .75rem;
    color: #8a94a6;
  }

  .tcb-sidebar-nav {
    flex: 1;
    padding: 12px 10px 20px;
    overflow-y: auto;
  }

  .tcb-sidebar-group {
    margin-bottom: 18px;
  }

  .tcb-sidebar-group-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    padding: 6px 12px 8px;
  }

  .tcb-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #c8cdd6;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
    position: relative;
  }

  .tcb-sidebar-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
  }

  .tcb-sidebar-item.is-active {
    background: rgba(16,201,165,.15);
    color: #10c9a5;
  }

  .tcb-sidebar-item.is-active .tcb-sidebar-icon svg {
    stroke: #10c9a5;
  }

  .tcb-sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    flex-shrink: 0;
  }

  .tcb-sidebar-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tcb-sidebar-badge {
    background: #e53935;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
  }

  .tcb-sidebar-footer {
    padding: 10px;
    border-top: 1px solid #2a2e3a;
    flex-shrink: 0;
  }

  .tcb-sidebar-dark-toggle {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
  }

  /* Nội dung chính full width desktop */
  .tcb-shell {
    min-height: 100vh;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 16px 20px 32px;
    box-sizing: border-box;
  }

  /* Bảng CRM / sản phẩm / doanh số tận dụng chiều ngang */
  .tcb-shell .tcb-card {
    max-width: none;
  }
  .crm-toolbar,
  .crm-filters,
  .crm-actions {
    width: 100%;
  }
  .crm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .crm-table-wrap,
  .tcb-card:has(.crm-table),
  .tcb-card:has(.prod-table),
  .tcb-card:has(.rev-table) {
    width: 100%;
    max-width: none;
    overflow-x: auto;
  }
  .crm-table,
  .prod-table,
  .rev-table {
    width: 100%;
    min-width: 1100px;
  }
  .tcb-page-header {
    max-width: none;
  }

  /* Page header desktop */
  .tcb-page-header {
    padding: 20px 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .tcb-page-title {
    font-size: 1.5rem;
    font-weight: 700;
  }

  /* Toolbar & filters rộng hơn */
  .tcb-page-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 0;
  }

  .tcb-search-box {
    flex: 1;
    min-width: 220px;
    max-width: 360px;
  }

  /* Main content */
  .tcb-main {
    padding: 0;
  }

  .tcb-main-list {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
  }

  /* Hero trên desktop gọn hơn */
  .tcb-hero {
    border-radius: 0 0 16px 16px;
    margin: 0 -24px 20px;
    padding: 20px 24px 24px;
  }

  /* Cards rộng */
  .tcb-card {
    border-radius: 12px;
  }

  /* Toast vị trí desktop */
  .tcb-toast {
    bottom: 32px;
    left: calc(50% + var(--sidebar-width) / 2);
  }

  /* Modal desktop: không full sheet */
  .tcb-modal-sheet {
    max-width: 480px;
    border-radius: 16px;
    max-height: 90vh;
  }

  /* Table-like list items rộng hơn */
  .tcb-list-item {
    padding: 14px 20px;
  }

  /* Empty / loading */
  .tcb-empty-state {
    padding: 48px 24px;
  }

  /* Login page vẫn centered */
  .tcb-login-page {
    padding-left: 0;
  }
  body.tcb-body .tcb-login-page {
    margin-left: calc(-1 * var(--sidebar-width));
  }
}

/* Desktop lớn hơn (≥ 1200px) */
@media (min-width: 1200px) {
  :root {
    --sidebar-width: 280px;
  }

  .tcb-shell {
    padding: 0 32px 48px;
  }

  .tcb-page-title {
    font-size: 1.65rem;
  }
}

/* Scrollbar sidebar đẹp */
.tcb-sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.tcb-sidebar-nav::-webkit-scrollbar-thumb {
  background: #3a3f4b;
  border-radius: 3px;
}
.tcb-sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}


/* ===== Slide 2-panel sidebar (như functions.php WP) ===== */
@media (min-width: 900px) {
  .tcb-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .tcb-slide-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #1a1d26; /* nền đặc, không lộ menu dưới */
  }
  .dark-mode .tcb-slide-wrap {
    background: #0f1117;
  }
  .tcb-slide-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 0 8px 16px;
    background: #1a1d26; /* panel đặc, che hoàn toàn panel kia */
    transition: transform 0.38s cubic-bezier(0.25, 0.8, 0.25, 1);
  }
  .dark-mode .tcb-slide-panel {
    background: #0f1117;
  }
  .tcb-slide-p1 {
    transform: translateX(0);
    z-index: 2;
  }
  .tcb-slide-p1.is-out {
    transform: translateX(-100%); /* đẩy hẳn ra, không còn thấy mờ */
    pointer-events: none;
    visibility: hidden;
  }
  .tcb-slide-p2 {
    transform: translateX(100%);
    z-index: 10;
  }
  .tcb-slide-p2.is-active {
    transform: translateX(0);
  }
  .tcb-slide-back {
    margin-bottom: 6px !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,0.06) !important;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
  }
  .tcb-slide-back:hover {
    background: rgba(255,255,255,0.12) !important;
  }
  .tcb-sidebar-chevron {
    margin-left: auto;
    opacity: 0.45;
    display: flex;
    align-items: center;
  }
  .tcb-sidebar-item.has-panel {
    cursor: pointer;
  }
  .tcb-sidebar-item {
    position: relative;
  }
}

/* Mobile: ẩn slide sidebar (dùng bottom nav) */
@media (max-width: 899px) {
  .tcb-slide-wrap { display: none; }
}
