/* ======================================================
   HP CRM 2026 — Sky Blue Theme
   ====================================================== */
:root {
  --primary:       #0ea5e9;
  --primary-dark:  #0284c7;
  --primary-darker:#0369a1;
  --primary-light: #e0f2fe;
  --primary-bg:    #f0f9ff;
  --sidebar-w:     260px;
  --sidebar-bg:    #1e293b;
  --sidebar-text:  #94a3b8;
  --topbar-h:      64px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow:        0 4px 16px rgba(0,0,0,.1);
  --radius:        12px;
  --radius-sm:     8px;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --bg:            #f8fafc;
}

/* ── Base ─────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); margin: 0; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1000; overflow-y: auto;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; border-bottom: 1px solid #334155;
  text-decoration: none;
}
.sidebar-brand .brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); display: flex;
  align-items: center; justify-content: center;
  color: white; font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-brand .brand-logo {
  width: 42px; height: 42px; flex-shrink: 0;
  object-fit: contain;
}
.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-name { color: white; font-weight: 800; font-size: .95rem; display: block; }
.sidebar-brand .brand-sub  { color: var(--sidebar-text); font-size: .68rem; display: block; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid #334155;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.user-name  { color: white; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { color: var(--sidebar-text); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; list-style: none; margin: 0; padding: 10px 0; }
.nav-section-title {
  padding: 14px 20px 5px;
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: #4b5563;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 13px; margin: 2px 10px; color: var(--sidebar-text);
  text-decoration: none; font-size: .82rem;
  transition: all .16s; position: relative;
  border-radius: 9px;
}
.sidebar-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav .nav-link.active {
  color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--primary), #0284c7);
  box-shadow: 0 3px 10px rgba(14,165,233,.38);
}
.sidebar-nav .nav-link.active i { color: #fff; }
.sidebar-nav .nav-link i {
  width: 20px; text-align: center; font-size: .9rem;
  color: #94a3b8; transition: color .16s;
}
.sidebar-nav .nav-link:hover i { color: #fff; }

.sidebar-footer { padding: 10px 0; border-top: 1px solid #334155; }
.sidebar-footer .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--sidebar-text);
  text-decoration: none; font-size: .82rem; transition: all .18s;
}
.sidebar-footer .nav-link:hover { color: #f87171; }
.sidebar-footer .nav-link i { width: 18px; text-align: center; }

/* ── Main content ─────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin-left .3s; }

.top-navbar {
  height: var(--topbar-h); background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 14px;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  display: none; background: none; border: none;
  font-size: 1.15rem; color: var(--text-muted); cursor: pointer;
  padding: 6px 8px; border-radius: 8px; transition: all .2s;
}
.sidebar-toggle:hover { background: var(--primary-light); color: var(--primary); }
.navbar-title { flex: 1; font-weight: 700; font-size: 1rem; color: var(--text); }
.navbar-actions { display: flex; align-items: center; gap: 8px; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 999;
}

.alert-container { padding: 16px 24px 0; }

.page-content { padding: 20px 24px 40px; }

/* ── Bootstrap overrides ─────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,.18);
}
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.nav-tabs .nav-link { color: var(--text-muted); }
.nav-tabs .nav-link:hover { color: var(--primary); }
.pagination .page-link { color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Cards ────────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { background: white; border-bottom: 1px solid var(--border); padding: 14px 20px; font-weight: 700; font-size: .9rem; }

/* ── KPI Cards ────────────────────────────────────────── */
.kpi-card {
  border-radius: var(--radius); padding: 20px;
  background: white; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 14px; flex-shrink: 0;
}
.kpi-value  { font-size: 1.65rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.kpi-label  { font-size: .75rem; color: var(--text-muted); font-weight: 500; margin-top: 3px; }
.kpi-sub    { font-size: .72rem; color: var(--text-muted); margin-top: 8px; }
.kpi-target { font-size: .72rem; color: var(--text-muted); margin-top: 4px; }

.kpi-sky    .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-green  .kpi-icon { background: #dcfce7; color: #16a34a; }
.kpi-orange .kpi-icon { background: #fef3c7; color: #d97706; }
.kpi-purple .kpi-icon { background: #ede9fe; color: #7c3aed; }

/* ── Stage & Status Badges ───────────────────────────── */
.stage-badge, .status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
/* ── 5 giai đoạn mới ──────────────────────── */
.stage-not_approached    { background: #f1f5f9; color: #475569; border: 1.5px dashed #94a3b8; }
.stage-pre_feasibility   { background: #dbeafe; color: #1d4ed8; }
.stage-design_quote      { background: #fce7f3; color: #9d174d; }
.stage-under_construction{ background: #fee2e2; color: #b91c1c; }
.stage-completed         { background: #dcfce7; color: #15803d; }

/* ── Legacy (9 giai đoạn cũ — giữ cho history records) ─ */
.stage-approach    { background: #dbeafe; color: #1d4ed8; }
.stage-survey      { background: #cffafe; color: #0e7490; }
.stage-design      { background: #fef9c3; color: #92400e; }
.stage-quotation   { background: #fce7f3; color: #9d174d; }
.stage-negotiation { background: #fef3c7; color: #b45309; }
.stage-contract    { background: #dcfce7; color: #15803d; }
.stage-construction{ background: #fee2e2; color: #dc2626; }
.stage-completion  { background: #f1f5f9; color: #334155; }

.status-active    { background: #dbeafe; color: #1e40af; }
.status-won       { background: #dcfce7; color: #15803d; }
.status-lost      { background: #fee2e2; color: #dc2626; }
.status-on_hold   { background: #fef3c7; color: #b45309; }
.status-cancelled { background: #f1f5f9; color: #64748b; }

/* ── Stage Progress Bar ──────────────────────────────── */
.stage-progress {
  display: flex; align-items: flex-start;
  overflow-x: auto; padding-bottom: 4px;
  gap: 0;
}
.stage-step { flex: 1; min-width: 80px; text-align: center; position: relative; }
.stage-step::after {
  content: ''; position: absolute;
  top: 13px; left: calc(50% + 15px); right: calc(-50% + 15px);
  height: 2px; background: var(--border); z-index: 0;
}
.stage-step:last-child::after { display: none; }
.stage-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--border); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
  position: relative; z-index: 1;
  transition: all .3s;
}
.stage-step.done .stage-dot    { background: var(--primary); color: white; }
.stage-step.done::after        { background: var(--primary); }
.stage-step.current .stage-dot { background: var(--primary); color: white; box-shadow: 0 0 0 4px var(--primary-light); }
.stage-lbl {
  display: block; font-size: .62rem; margin-top: 6px;
  color: var(--text-muted); font-weight: 500; line-height: 1.3;
}
.stage-step.done .stage-lbl, .stage-step.current .stage-lbl { color: var(--primary); font-weight: 600; }

/* not_approached — dot dùng màu xám thay vì xanh */
.stage-step.current.stage-key-not_approached .stage-dot {
  background: #64748b; box-shadow: 0 0 0 4px #f1f5f9;
}
.stage-step.current.stage-key-not_approached .stage-lbl { color: #64748b; }

/* ── Tables ───────────────────────────────────────────── */
.table th { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 2px solid var(--border); padding: 10px 12px; }
.table td { padding: 12px; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--primary-bg); cursor: pointer; }
.table-hover tbody tr:hover td { border-color: transparent; }

/* ── Forms ────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .82rem; color: var(--text); margin-bottom: 5px; }
.form-section {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
}
.form-section-title {
  font-weight: 700; font-size: .85rem; color: var(--primary);
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
  display: flex; align-items: center; gap: 8px;
}
.required::after { content: ' *'; color: #ef4444; }

/* ── Timeline ─────────────────────────────────────────── */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: ''; position: absolute; left: 11px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot {
  position: absolute; left: -32px; top: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; z-index: 1;
}
.timeline-body {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.timeline-time { font-size: .7rem; color: var(--text-muted); }
.timeline-stage { font-weight: 600; font-size: .82rem; }
.timeline-note { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }

/* ── Legal Docs ───────────────────────────────────────── */
.legal-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.legal-row:last-child { border-bottom: none; }
.legal-icon { font-size: 1.15rem; width: 22px; text-align: center; }
.legal-status-completed { color: #16a34a; }
.legal-status-processing { color: #d97706; }
.legal-status-pending    { color: #94a3b8; }

/* ── Charts ───────────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap-tall { position: relative; height: 320px; }

/* ── Empty State ──────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 2.8rem; margin-bottom: 14px; opacity: .25; display: block; }
.empty-state h6 { color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: .85rem; }

/* ── Misc utilities ───────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.bg-primary-soft { background: var(--primary-light); }
.hover-up { transition: transform .18s, box-shadow .18s; }
.hover-up:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.badge-code { background: var(--primary-light); color: var(--primary-darker); font-family: monospace; font-size: .72rem; padding: 2px 7px; border-radius: 5px; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.progress { height: 8px; border-radius: 4px; }
.progress-bar { background: var(--primary); }

/* ── Login ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0369a1 0%, #0ea5e9 55%, #38bdf8 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: white; border-radius: 20px; padding: 44px 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .login-logo-img {
  height: 96px; width: auto; max-width: 100%;
  margin: 0 auto 14px; display: block; object-fit: contain;
}
.login-logo .logo-box {
  width: 70px; height: 70px; border-radius: 18px;
  background: var(--primary-light); margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; color: var(--primary);
}
.login-logo h5 { font-weight: 800; color: var(--text); margin: 0; }
.login-logo p  { color: var(--text-muted); font-size: .82rem; margin-top: 4px; }

/* ── Project Group tabs (5 loại tiến độ) ─────────────── */
.group-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.group-tab-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; border: 2px solid transparent;
  font-size: .81rem; font-weight: 600; text-decoration: none;
  transition: all .18s; white-space: nowrap; cursor: pointer;
}
.group-tab-btn:hover    { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.group-tab-btn.empty    { opacity: .5; }
.group-tab-btn.active   { box-shadow: 0 3px 12px rgba(0,0,0,.18); }
.group-tab-count {
  background: rgba(0,0,0,.12); border-radius: 10px;
  padding: 1px 7px; font-size: .7rem; font-weight: 700;
}
.group-tab-btn.active .group-tab-count { background: rgba(255,255,255,.3); }
.group-tab-all {
  color: var(--text); background: white; border-color: var(--border);
}
.group-tab-all:hover, .group-tab-all.active {
  color: var(--primary); background: var(--primary-bg); border-color: var(--primary);
}

/* ── Customer Autocomplete ────────────────────────────── */
.ac-wrapper { position: relative; }

.ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: white;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(14,165,233,.15);
  max-height: 280px; overflow-y: auto;
  z-index: 1050;
}
.ac-dropdown.show { display: block; }

.ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--primary-bg); }

.ac-item-flag { font-size: 1.1rem; flex-shrink: 0; }
.ac-item-name { font-weight: 600; font-size: .85rem; color: var(--text); }
.ac-item-meta { font-size: .72rem; color: var(--text-muted); margin-top: 1px; }

.ac-item-new {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  color: var(--primary); font-weight: 600; font-size: .84rem;
  background: var(--primary-bg);
  border-top: 1.5px dashed var(--primary-light);
  transition: background .12s;
}
.ac-item-new:hover { background: var(--primary-light); }

.ac-status {
  font-size: .78rem; margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 6px;
}
.ac-status.selected  { background: #dcfce7; color: #15803d; }
.ac-status.creating  { background: var(--primary-bg); color: var(--primary-darker); }

/* New customer extra fields */
.ac-new-fields {
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px; margin-top: 10px;
  background: var(--primary-bg);
  animation: slideDown .2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ac-new-fields .form-label { font-size: .77rem; }

/* ── Error pages ──────────────────────────────────────── */
.error-page { min-height: 80vh; display: flex; align-items: center; justify-content: center; }

/* ── Legal checklist ──────────────────────────────────── */
.legal-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-darker);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .72rem;
}
.legal-tick { width: 34px; }
.legal-row:last-child { border-bottom: none !important; }

/* ── Workflow stepper (tiến trình triển khai) ─────────── */
.wf-step {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); position: relative;
}
.wf-step:last-child { border-bottom: none; }
.wf-dot {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #e2e8f0; color: #64748b; font-weight: 700; font-size: .8rem;
}
.wf-step.wf-done .wf-dot    { background: #16a34a; color: white; }
.wf-step.wf-current .wf-dot { background: var(--primary); color: white; box-shadow: 0 0 0 4px var(--primary-light); }
.wf-step.wf-current { background: var(--primary-bg); }
.wf-body { flex: 1; }
.wf-name { font-weight: 600; font-size: .85rem; color: var(--text); }
.wf-step.wf-done .wf-name    { color: #15803d; }
.wf-step.wf-current .wf-name { color: var(--primary-darker); }
.wf-desc { font-size: .76rem; color: var(--text-muted); margin-top: 2px; }
.wf-roles { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.wf-role-tag {
  font-size: .65rem; font-weight: 700; padding: 1px 7px; border-radius: 5px;
  background: var(--primary-light); color: var(--primary-darker);
}

/* ── Sequence number badge (số thứ tự dự án) ──────────── */
.seq-badge {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 8px; margin-top: 2px;
  background: var(--primary-light); color: var(--primary-darker);
  font-weight: 800; font-size: .82rem;
}

/* ── Year filter tabs ─────────────────────────────────── */
.year-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.year-tab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  font-size: .82rem; font-weight: 600;
  color: var(--text-muted);
  background: white; border: 1.5px solid var(--border);
  text-decoration: none; transition: all .18s;
  white-space: nowrap;
}
.year-tab-btn:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-bg);
}
.year-tab-btn.active {
  background: var(--primary); color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(14,165,233,.35);
}
.year-tab-count {
  background: rgba(0,0,0,.1); color: inherit;
  border-radius: 10px; padding: 1px 7px;
  font-size: .7rem; font-weight: 700;
}
.year-tab-btn.active .year-tab-count {
  background: rgba(255,255,255,.25);
}
.year-tab-btn.empty {
  opacity: .55;
}
.year-tab-btn.empty:hover {
  opacity: 1;
}

/* ── Year pills (in table) ────────────────────────────── */
.year-pill {
  display: inline-block; padding: 2px 9px;
  border-radius: 6px; font-size: .72rem; font-weight: 700;
  text-decoration: none; transition: all .15s;
}
.year-pill-2026 { background: #dbeafe; color: #1d4ed8; }
.year-pill-2025 { background: #dcfce7; color: #15803d; }
.year-pill-2024 { background: #fef3c7; color: #b45309; }
.year-pill-2023, .year-pill-2022, .year-pill-2021 { background: #f1f5f9; color: #475569; }
.year-pill:hover { opacity: .8; transform: scale(1.05); }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .page-content { padding: 14px 16px 40px; }
  .top-navbar { padding: 0 14px; }
  .alert-container { padding: 12px 16px 0; }
  .kpi-value { font-size: 1.4rem; }
  .stage-lbl { display: none; }
  .login-card { padding: 32px 24px; }
}
@media (max-width: 480px) {
  .d-xs-none { display: none !important; }
}

/* ===== Tối ưu thao tác trên điện thoại ===== */
@media (max-width: 768px) {
  .btn { min-height: 38px; }
  .btn-sm { min-height: 32px; }
  .form-control, .form-select { font-size: 16px; }     /* iOS không tự zoom khi gõ */
  .form-control-sm, .form-select-sm { font-size: 15px; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table td, .table th { padding: .5rem .5rem; }
  .card-body { padding: 1rem; }
  .card-header { font-size: .92rem; }
  .navbar-title { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Tabs lọc cuộn ngang gọn gàng thay vì xuống dòng */
  .nav-pills, .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-pills::-webkit-scrollbar, .nav-tabs::-webkit-scrollbar { height: 0; }
  .nav-pills .nav-link, .nav-tabs .nav-link { white-space: nowrap; }
}
@media (max-width: 480px) {
  .page-content { padding: 12px 12px 40px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 1.25rem; }
  .kpi-icon { width: 38px; height: 38px; font-size: 1rem; }
}

/* ===== Thanh điều hướng dưới cho điện thoại ===== */
.mobile-bottom-nav { display: none; }
@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
    background: #fff; border-top: 1px solid var(--border);
    display: flex; z-index: 1030; box-shadow: 0 -2px 10px rgba(0,0,0,.07);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; color: #64748b; font-size: .64rem;
    text-decoration: none; font-weight: 600;
  }
  .mobile-bottom-nav a i { font-size: 1.15rem; }
  .mobile-bottom-nav a.active { color: var(--primary); }
  .mobile-bottom-nav a.active i { transform: translateY(-1px); }
  /* Chấm tròn báo mục đang chọn */
  .mobile-bottom-nav a.active::after {
    content: ''; position: absolute; top: 6px; width: 5px; height: 5px;
    border-radius: 50%; background: var(--primary);
  }
  .mobile-bottom-nav a { position: relative; }
  .mobile-bottom-nav a:active { background: var(--primary-light); }
  .page-content { padding-bottom: 78px !important; }

  /* Nút ➕ tròn nổi ở giữa thanh dưới (tạo nhanh) */
  .mobile-fab-wrap { position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%); z-index: 1031; }
  .mobile-fab {
    width: 56px; height: 56px; border-radius: 50%; border: 3px solid #fff;
    background: linear-gradient(135deg, var(--primary), #0284c7); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
    box-shadow: 0 5px 16px rgba(14,165,233,.5); padding: 0;
  }
  .mobile-fab:active { transform: scale(.94); }
}

/* ===== Tối ưu chạm trên điện thoại (Nhóm 4) ===== */
/* Ẩn thanh điều hướng dưới khi đang mở hộp thoại (tránh che nút) */
body.modal-open .mobile-bottom-nav { display: none !important; }

@media (max-width: 768px) {
  /* Nút biểu tượng trong bảng/timeline: đủ to để chạm chính xác */
  .table .btn, .timeline .btn, .ia-item .btn { min-height: 36px; min-width: 36px; }
  .btn.py-0 { padding-top: .3rem !important; padding-bottom: .3rem !important; }
}
