/* ========================================================
   HỎI BÁO CÁO AI - MOBILE-FIRST STYLESHEET
   Accurate 1:1 match to reference UI + Ultra-smooth interactions
   ======================================================== */

:root {
  --bg-primary: #f8fafc;
  --bg-white: #ffffff;
  --bg-hero-top: #ede9fe;
  --bg-hero-mid: #f5f3ff;
  --bg-hero-bot: #f8fafc;
  
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --color-blue: #3b82f6;
  --color-blue-dark: #2563eb;
  --color-green: #10b981;
  --color-purple: #8b5cf6;
  --color-amber: #f59e0b;
  --color-coral: #f43f5e;

  --border-subtle: #f1f5f9;
  --border-light: #e2e8f0;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.03), 0 1px 2px rgba(15, 23, 42, 0.02);
  --shadow-float: 0 10px 25px -5px rgba(15, 23, 42, 0.08);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  background-color: #f8fafc;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  touch-action: pan-x pan-y;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body.mobile-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* ========================================================
   EMBEDDED MOBILE APP SHELL (FULL SCREEN, NO ZOOM)
   ======================================================== */
.device-viewport-wrapper {
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  max-width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: #f8fafc !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

.desktop-device-bar,
.phone-notch,
.mobile-status-bar,
.mobile-home-indicator {
  display: none !important;
}

.mobile-phone-frame {
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  max-width: 100% !important;
  max-height: none !important;
  background: #ffffff !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* Dynamic Island Notch */
.phone-notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 28px;
  background: #000000;
  border-radius: 20px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12px;
}

.notch-sensor {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111827;
  border: 1px solid #1f2937;
}

/* ========================================================
   TOP STATUS BAR
   ======================================================== */
.mobile-status-bar {
  height: 44px;
  padding: 10px 24px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 80;
  background: transparent;
}

.status-time {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
}

.signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 11px;
}

.signal-bars .bar {
  width: 3px;
  background-color: var(--text-primary);
  border-radius: 1px;
}

.signal-bars .bar-1 { height: 3px; }
.signal-bars .bar-2 { height: 5px; }
.signal-bars .bar-3 { height: 8px; }
.signal-bars .bar-4 { height: 11px; }

.status-wifi {
  font-size: 13px;
  margin-left: 2px;
}

.battery-icon {
  width: 22px;
  height: 11px;
  border: 1.5px solid var(--text-primary);
  border-radius: 3.5px;
  padding: 1px;
  position: relative;
  display: flex;
  align-items: center;
  margin-left: 2px;
}

.battery-icon::after {
  content: '';
  position: absolute;
  right: -3.5px;
  top: 2.5px;
  width: 2px;
  height: 4px;
  background-color: var(--text-primary);
  border-radius: 0 1px 1px 0;
}

.battery-level {
  width: 75%;
  height: 100%;
  background-color: var(--text-primary);
  border-radius: 1.5px;
}

/* ========================================================
   TOP APP HEADER
   ======================================================== */
.mobile-app-header {
  display: none !important;
  height: 52px;
  padding: 0 18px;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  z-index: 70;
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: #475569;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  background: #ffffff;
  color: var(--text-primary);
  transform: scale(1.05);
}

.header-icon-btn:active {
  transform: scale(0.95);
}

#btnHeaderSettings {
  visibility: hidden !important;
  pointer-events: none !important;
}

.header-page-title {
  font-size: 17.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* ========================================================
   VIEW SCREENS
   ======================================================== */
.mobile-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#screenHome {
  background: url('/main.png') no-repeat center top / cover;
}

#screenChat {
  background: url('/chat.jpg') no-repeat center center / cover;
}

.mobile-screen.active {
  display: flex;
  animation: fadeInScreen 0.25s ease-out;
}

@keyframes fadeInScreen {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 80px;
}

.screen-scrollable::-webkit-scrollbar,
.chat-thread-container::-webkit-scrollbar {
  display: none;
}

/* ========================================================
   VIEW 1: HERO MASCOT & GREETING
   ======================================================== */
.hero-mascot-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 20px 14px 20px;
  background: transparent;
  position: relative;
}

.mascot-img-wrap {
  width: 190px;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mascot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 24px;
  filter: drop-shadow(0 14px 28px rgba(99, 102, 241, 0.16));
  animation: floatMascot 4.5s ease-in-out infinite;
}

@keyframes floatMascot {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(-1deg);
  }
}

.hero-text-wrap {
  margin-top: 10px;
}

.hero-greeting-title {
  font-size: 19.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.hero-greeting-sub {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========================================================
   4 QUICK ACTION / KPI CARDS (2x2 GRID)
   ======================================================== */
.quick-cards-section {
  padding: 12px 18px 0 18px;
}

.quick-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-action-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  padding: 13px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.quick-action-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  border-color: #cbd5e1;
}

.quick-action-card:active {
  transform: scale(0.97);
}

.quick-card-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.bg-mint { background: #ecfdf5; }
.bg-blue-soft { background: #eff6ff; }
.bg-pink-soft { background: #fdf2f8; }
.bg-amber-soft { background: #fffbeb; }
.bg-purple-soft { background: #f5f3ff; }
.bg-slate-soft { background: #f1f5f9; }

.icon-green { color: #10b981; }
.icon-blue { color: #3b82f6; }
.icon-coral { color: #f43f5e; }
.icon-amber { color: #f59e0b; }

.quick-card-text {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

.quick-card-arrow {
  color: #cbd5e1;
  font-size: 11.5px;
  display: flex;
  align-items: center;
}

/* ========================================================
   RECENT CONVERSATIONS ("Trò chuyện gần đây")
   ======================================================== */
.recent-convos-section {
  margin-top: 22px;
  padding: 0 18px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.btn-see-all {
  background: transparent;
  border: none;
  color: var(--color-blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-see-all:hover {
  background: #eff6ff;
  color: var(--color-blue-dark);
}

.recent-convos-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recent-convo-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.recent-convo-card:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
  border-color: #cbd5e1;
}

.recent-convo-card:active {
  transform: scale(0.98);
}

.recent-convo-icon {
  color: var(--color-purple);
  font-size: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.recent-convo-content {
  flex: 1;
}

.recent-convo-text {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
}

.recent-convo-time {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-light);
  margin-top: 4px;
}

/* ========================================================
   VIEW 2: CHAT CONVERSATION THREAD
   ======================================================== */
.chat-thread-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 80px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.message-bubble {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: fadeInBubble 0.25s ease-out;
}

@keyframes fadeInBubble {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  max-width: 85%;
}

.msg-user-content {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
  word-break: break-word;
}

.msg-ai {
  align-self: flex-start;
  width: 100%;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 0 !important;
}

.ai-header-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ai-avatar-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dc2626;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
  border: none;
}

.ai-avatar-badge svg {
  display: block;
}

.ai-name-label {
  font-size: 16px;
  font-weight: 700;
  color: #dc2626;
  letter-spacing: -0.2px;
}

.ai-sub-label {
  display: none;
}

.ai-greeting-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-sec-badge {
  font-size: 13.5px;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  margin: 10px 0 6px;
}

.ai-sec-overview {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

.ai-sec-risk {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fef3c7;
}

.ai-sec-action {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #d1fae5;
}

.ai-bullet-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 5px 0;
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
}

.ai-bullet-point {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6366f1;
  margin-top: 8px;
  flex-shrink: 0;
}

.ai-section-break {
  height: 8px;
}

.chat-sugg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat-pill {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chat-pill:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--color-blue-dark);
}

.chat-pill.highlight {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 600;
}

/* Typing state */
.typing-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 0;
}

.typing-circle {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-purple);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-circle:nth-child(2) { animation-delay: 0.2s; }
.typing-circle:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ========================================================
   AI RESPONSE MOBILE REPORT CARD (MODERN FINTECH STYLE)
   ======================================================== */
.m-ai-report-card {
  margin-top: 10px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 1. Header Card */
.m-report-card-head {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.03);
}

.m-report-head-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.m-report-head-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

.m-report-main-title {
  font-size: 15px;
  font-weight: 750;
  color: #0f172a;
  line-height: 1.25;
  letter-spacing: -0.2px;
}

.m-report-sub-info {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 3px;
  font-weight: 500;
}

.m-report-badges-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.m-badge-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3.5px 10px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 5px;
}

.m-badge-pill.period {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.m-badge-pill.live {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.m-live-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulseDot 1.8s infinite;
}

/* 2. 4 KPI Tiles Grid - Modern Fintech Mobile */
.m-report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.m-kpi-card-tile {
  background: #ffffff;
  border-radius: 18px;
  padding: 13px 12px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 124px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.m-kpi-card-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -3px rgba(15, 23, 42, 0.08);
}

.m-kpi-card-tile.card-emerald {
  background: linear-gradient(165deg, #f0fdf4 0%, #ffffff 58%);
  border-color: #dcfce7;
}

.m-kpi-card-tile.card-blue {
  background: linear-gradient(165deg, #eff6ff 0%, #ffffff 58%);
  border-color: #dbeafe;
}

.m-kpi-card-tile.card-purple {
  background: linear-gradient(165deg, #faf5ff 0%, #ffffff 58%);
  border-color: #f3e8ff;
}

.m-kpi-card-tile.card-amber {
  background: linear-gradient(165deg, #fffbeb 0%, #ffffff 58%);
  border-color: #fef3c7;
}

.m-kpi-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.m-kpi-tile-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.m-kpi-tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.m-kpi-tile-icon svg {
  display: block;
  width: 17px;
  height: 17px;
}

.card-emerald .m-kpi-tile-icon { background: #dcfce7; color: #059669; }
.card-blue .m-kpi-tile-icon { background: #dbeafe; color: #2563eb; }
.card-purple .m-kpi-tile-icon { background: #ede9fe; color: #7c3aed; }
.card-amber .m-kpi-tile-icon { background: #fef3c7; color: #d97706; }

.m-kpi-tile-value {
  font-size: 21px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.4px;
  line-height: 1.15;
  margin: 6px 0 5px 0;
}

.m-kpi-tile-value small {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin-left: 2px;
}

.m-kpi-tile-sub {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.m-kpi-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2.5px 7px;
  border-radius: 12px;
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  line-height: 1;
}

.m-kpi-badge.positive { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.m-kpi-badge.blue { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.m-kpi-badge.neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.m-kpi-badge.amber { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

.m-kpi-num-note {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 3. Section Containers (Chi nhánh, Cơ cấu, Staff) */
.m-report-section {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.m-report-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}

.m-section-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
}

/* Chi nhánh cards */
.m-branch-stat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-branch-stat-item {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #f1f5f9;
}

.m-branch-stat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.m-branch-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.m-branch-name i {
  color: #3b82f6;
  font-size: 12px;
}

.m-branch-orders-pill {
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.m-branch-bar-line {
  margin-bottom: 6px;
}

.m-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 3px;
}

.m-bar-meta strong {
  color: #0f172a;
  font-weight: 700;
}

.m-bar-track {
  height: 7px;
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.m-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.m-bar-fill.fill-green { background: linear-gradient(90deg, #10b981 0%, #059669 100%); }
.m-bar-fill.fill-blue { background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%); }
.m-bar-fill.fill-purple { background: linear-gradient(90deg, #8b5cf6 0%, #6d28d9 100%); }

/* Cơ cấu phục vụ */
.m-types-stat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-type-stat-row {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #f1f5f9;
}

.m-type-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.m-type-amount {
  color: #7c3aed;
  font-weight: 700;
}

.m-type-amount small {
  color: #94a3b8;
  font-weight: 500;
}

.m-type-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

/* Top Nhân viên */
.m-staff-ranks-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m-staff-rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px 12px;
  border: 1px solid #f1f5f9;
}

.m-staff-medal {
  font-size: 18px;
  line-height: 1;
}

.m-staff-info {
  flex: 1;
}

.m-staff-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}

.m-staff-orders {
  font-size: 11px;
  color: #64748b;
}

.m-staff-rev {
  font-size: 13.5px;
  font-weight: 800;
  color: #d97706;
  background: #fffbeb;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid #fef3c7;
}

/* Đơn hàng gần nhất */
.m-orders-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m-order-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
}

.m-order-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
  display: block;
}

.m-order-time {
  font-size: 10.5px;
  color: #94a3b8;
  display: block;
  margin-top: 1px;
}

.m-order-price {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  display: block;
  text-align: right;
}

.m-order-status {
  font-size: 10px;
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  display: block;
  text-align: right;
  margin-top: 1px;
}

/* AI Insights Box */
.m-report-insight-box {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border: 1px solid #e9d5ff;
  border-radius: 16px;
  padding: 12px 14px;
}

.m-insight-box-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #7e22ce;
  margin-bottom: 8px;
}

.m-insight-bullets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m-insight-bullet {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #581c87;
}

.m-insight-bullet i {
  font-size: 12px;
  color: #9333ea;
  margin-top: 2px;
}

/* ========================================================
   VIEW 3: MOBILE FULL BI DASHBOARD
   ======================================================== */
.mobile-filter-bar {
  padding: 12px 16px 4px 16px;
  position: relative;
  z-index: 50;
}

.filter-chip-group {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* Modern Custom Combobox Component */
.custom-combobox {
  position: relative;
  flex: 1;
  min-width: 0;
  user-select: none;
}

.combobox-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1.5px solid rgba(226, 232, 240, 0.9);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.combobox-trigger:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.custom-combobox.open .combobox-trigger {
  border-color: #4f46e5;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.combobox-lead {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.combobox-icon {
  font-size: 13px;
  flex-shrink: 0;
  transition: color 0.2s;
}

#comboBranch .combobox-icon {
  color: #0284c7;
}

#comboPeriod .combobox-icon {
  color: #6366f1;
}

.combobox-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.combobox-chevron {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 6px;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
}

.custom-combobox.open .combobox-chevron {
  transform: rotate(180deg);
  color: #4f46e5;
}

.combobox-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 175px;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 14px;
  box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.14), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  padding: 6px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s;
  pointer-events: none;
}

.custom-combobox.open .combobox-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.combobox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.combobox-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.combobox-item.active {
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
  font-weight: 600;
}

.combobox-item-check {
  font-size: 11px;
  color: #4f46e5;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.combobox-item.active .combobox-item-check {
  opacity: 1;
}

.mobile-filter-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid rgba(226, 232, 240, 0.9);
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.mobile-filter-btn:hover {
  background: #f8fafc;
  border-color: #4f46e5;
  color: #4f46e5;
}

.mobile-filter-btn.spinning i {
  animation: filterBtnSpin 0.6s linear infinite;
}

@keyframes filterBtnSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.mobile-dash-title-box {
  padding: 12px 16px 4px 16px;
}

.mobile-dash-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.mobile-dash-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mobile-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px 16px;
}

.m-kpi-card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  box-shadow: var(--shadow-card);
}

.m-kpi-card.card-blue { border-top: 3px solid var(--color-blue); }
.m-kpi-card.card-green { border-top: 3px solid var(--color-green); }
.m-kpi-card.card-purple { border-top: 3px solid var(--color-purple); }
.m-kpi-card.card-amber { border-top: 3px solid var(--color-amber); }
.m-kpi-card.card-rose { border-top: 3px solid #e11d48; }
.m-kpi-card.card-indigo { border-top: 3px solid #6366f1; }

.m-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.m-kpi-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 4px;
}

.m-kpi-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 10.5px;
}

.m-kpi-pill {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 4px;
}

.m-kpi-pill.neutral {
  background: #f1f5f9;
  color: #475569;
}

.m-kpi-note {
  color: var(--text-muted);
}

.mobile-charts-stack {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-chart-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
}

.m-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.m-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.m-chart-badge {
  background: #f1f5f9;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.m-chart-box {
  height: 180px;
  position: relative;
}

.m-table-wrap {
  overflow-x: auto;
}

.m-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.m-data-table th {
  text-align: left;
  padding: 8px 6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
}

.m-data-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.order-code-badge {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* ========================================================
   BOTTOM DOCKED INPUT & ACTION BAR (EXACT SCREENSHOT)
   ======================================================== */
.mobile-bottom-dock {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(241, 245, 249, 0.85);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.05);
  z-index: 85;
  display: flex;
  flex-direction: column;
}

.dock-input-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 2px 16px;
}

.dock-btn-menu {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dock-btn-menu:hover {
  background: #ede9fe;
  transform: scale(1.05);
}

.dock-btn-menu:active {
  transform: scale(0.95);
}

.dock-btn-back {
  width: 30px;
  height: 30px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 6px !important;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  margin-right: -2px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dock-btn-back:hover {
  color: #0f172a;
}

.dock-btn-back:active {
  transform: scale(0.9);
  color: #0f172a;
}

.dock-input-capsule {
  flex: 1;
  height: 44px;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  padding: 0 16px;
  transition: all 0.2s;
}

.dock-input-capsule:focus-within {
  border-color: #93c5fd;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dock-text-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15.5px;
  color: var(--text-primary);
  font-weight: 500;
}

.dock-text-input::placeholder {
  color: var(--text-light);
}

.dock-btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dock-btn-send:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.45);
}

.dock-btn-send:active {
  transform: scale(0.94);
}

.mobile-home-indicator {
  width: 134px;
  height: 5px;
  background: #000000;
  border-radius: var(--radius-pill);
  margin: 6px auto 6px auto;
  flex-shrink: 0;
}

/* ========================================================
   BOTTOM SHEET DRAWER (MODALS ON MOBILE)
   ======================================================== */
.sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  animation: fadeInBackdrop 0.2s ease-out;
}

.sheet-backdrop.open {
  display: flex;
}

@keyframes fadeInBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-drawer {
  width: 100%;
  background: #ffffff;
  border-radius: 28px 28px 0 0;
  padding: 12px 18px 28px 18px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  animation: slideUpSheet 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4.5px;
  background: #cbd5e1;
  border-radius: var(--radius-pill);
  margin: 0 auto 12px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-header h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-close-btn {
  background: #f1f5f9;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.sheet-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.sheet-menu-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.sheet-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sheet-item-text {
  flex: 1;
}

.sheet-item-text strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-primary);
}

.sheet-item-text span {
  font-size: 11.5px;
  color: var(--text-muted);
}

.sheet-menu-item .arrow-icon {
  color: #cbd5e1;
  font-size: 12px;
}

.recent-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.recent-sheet-item:hover {
  background: #f5f3ff;
  border-color: #ddd6fe;
}

.recent-sheet-icon {
  color: var(--color-purple);
  font-size: 16px;
  flex-shrink: 0;
}

.recent-sheet-meta {
  flex: 1;
}

.recent-sheet-query {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.recent-sheet-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ========================================================
   SETTINGS MODAL
   ======================================================== */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeInBackdrop 0.2s ease-out;
}

.modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 360px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: scaleModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleModal {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.modal-title h3 {
  font-size: 15px;
  font-weight: 700;
}

.btn-modal-close {
  background: #f1f5f9;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-field input, .form-field select {
  height: 38px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}

.form-field input:focus, .form-field select:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.form-field small {
  font-size: 10.5px;
  color: var(--text-muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-foot {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.btn-save-settings {
  background: var(--color-blue);
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save-settings:hover {
  background: var(--color-blue-dark);
}

/* ========================================================
   TOAST NOTIFICATION
   ======================================================== */
.toast-holder {
  position: absolute;
  top: 55px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: 90%;
  max-width: 320px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideToast 0.25s ease-out;
}

@keyframes slideToast {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

/* ========================================================
   EMBEDDED MOBILE APP OPTIMIZATION (NO ZOOM / NATIVE SHELL)
   ======================================================== */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile full-bleed app shell */
.device-viewport-wrapper {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: #f8fafc !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.desktop-device-bar,
.phone-notch,
.mobile-status-bar,
.mobile-home-indicator {
  display: none !important;
}

.mobile-phone-frame {
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  max-width: 100% !important;
  max-height: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  background: #ffffff !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  overflow: hidden !important;
}

.mobile-app-header {
  height: calc(56px + var(--sat));
  padding: var(--sat) 16px 0 16px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid #e7ebf5;
  box-shadow: 0 1px 6px rgba(24, 41, 71, 0.04);
}

.header-page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.mobile-screen {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.mobile-screen.active {
  display: flex;
}

.screen-scrollable {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 0 0 24px;
}

/* Chat container for mobile app */
.chat-thread-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 12px 24px;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.msg-ai {
  padding: 4px 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.msg-user {
  max-width: 88%;
}

.msg-user-content {
  font-size: 16px;
  padding: 11px 16px;
}

.ai-greeting-text {
  font-size: 15.5px;
  line-height: 1.6;
}

/* Bottom dock attached firmly to bottom with safe-area */
.mobile-bottom-dock {
  width: 100%;
  padding: 8px 12px max(10px, var(--sab)) 12px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #e8edf6;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
  bottom: 0;
  z-index: 40;
}

.dock-input-form {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dock-input-capsule {
  flex: 1;
  height: 44px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 0 16px;
  display: flex;
  align-items: center;
}

/* Input font size 16px prevents iOS Safari/WKWebView auto-zoom on focus */
.dock-text-input {
  font-size: 16px !important;
  user-select: text !important;
  -webkit-user-select: text !important;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

/* Copy text allowed in messages */
.msg-user-content,
.ai-greeting-text,
.message-bubble,
.aid-block {
  user-select: text;
  -webkit-user-select: text;
}

/* Touch manipulation prevents double tap zoom */
button,
input,
select,
.combobox-trigger,
.combobox-item,
.chat-pill,
.sheet-menu-item,
.nav-tab-item,
.kpi-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Animation utilities */
.ai-response-enter { animation: ai-message-enter .35s cubic-bezier(.2,.75,.2,1) both; }
.ai-typed-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-type-cursor { display: inline-block; height: 1em; width: 2px; background: #6366f1; vertical-align: -.18em; margin-left: 3px; animation: ai-cursor-blink .8s steps(2,end) infinite; }
@keyframes ai-message-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ai-cursor-blink { 0%, 45% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media(prefers-reduced-motion:reduce) { .ai-response-enter,.ai-type-cursor { animation:none!important; } }
