/* #### Dashbosrd.css */

/* ================= GLOBAL ================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  margin: 0;
  background: #f6f9fc;
  color: #111827;
  min-width: 320px;
  overflow-x: hidden;
}

html {
  box-sizing: border-box;
  font-size: 16px;
}

/* ================= HEADER ================= */
header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 68px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid #e5e7eb;
  z-index: 1000;
}

header img {
  height: 30px;
}

header .title {
  display: flex;
  flex-direction: column;
}

header h1 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

header p {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

/* ================= LOGIN HEADER (LOGO LEFT, TITLE RIGHT) ================= */
.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
}

.login-header .title {
  margin-left: auto;
  text-align: right;
}

/* ================= USER INFO SECTION ================= */
.user-info-section {
  position: fixed;
  top: 16px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 10001;
}

.user-info-section .user-name {
  font-size: 13px;
  color: #111827;
  font-weight: 500;
}

.user-info-section .divider {
  width: 1px;
  height: 20px;
  background: #d1d5db;
}

.user-info-section .logout-btn {
  padding: 4px 11px;
  background: transparent;
  color: #2563eb;
  text-decoration: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid #2563eb;
  display: inline-block;
}

.user-info-section .logout-btn:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

/* ================= LOGOUT VISIBILITY CONTROL ================= */
@media (min-width: 769px) {
  .mobile-logout {
    display: none;
  }
}

/* ================= SIDEBAR TOGGLE BUTTON ================= */
.sidebar-toggle-btn {
  position: fixed;
  left: 14px;
  top: 76px;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border: 1px solid #6b7280;
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: all 0.3s ease;
  color: #374151;
  font-size: 12px;
  padding: 0;
}

.sidebar-toggle-btn svg {
  width: 12px;
  height: 12px;
}

.sidebar-toggle-btn:hover {
  background: #f9fafb;
  border-color: #4b5563;
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.16);
  transform: scale(1.02);
}

.sidebar-toggle-btn.open {
  left: calc(280px - 38px);
  transform: none;
  width: 22px;
  height: 22px;
  font-size: 12px;
  border: 1px solid #6b7280;
}

/* ================= SIDEBAR ================= */
.sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  width: 280px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  transition: transform 0.3s ease, left 0.3s ease, visibility 0.3s ease;
  transform: translateX(0);
  visibility: visible;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  visibility: hidden;
}

/* Tablet + mobile should start collapsed and overlay when opened */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    visibility: hidden;

  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    z-index: 1002;
  }

  #chat {
    margin-left: 0;
    width: 100%;
    padding: 0 16px;
    max-width: 100%;
  }

  footer {
    left: 0;
    width: 100%;
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Desktop layout: sidebar is persistently visible unless collapsed */
@media (min-width: 1025px) {
  .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    visibility: hidden;
  }

  #chat {
    margin-left: 280px;
    width: calc(100% - 280px);
    max-width: calc(100% - 280px);
  }
}

.sidebar-header h3 {
  margin: 0 0 16px 0;
  font-size: 12px;
  font-weight: 700;
  color: #111827;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-category {
  margin-bottom: 24px;
}

.sidebar-category h4 {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin-bottom: 8px;
}

.question-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: #f3f4f6;
  border: 1px solid transparent;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  margin-bottom: 18px;
}

.question-btn:hover {
  background: #e5e7eb;
  color: #111827;
  border-color: #d1d5db;
}

/* ================= CHAT AREA ================= */
#chat {
  max-width: 1100px;
  width: 100%;
  margin: 80px auto 140px;
  padding: 0 16px;
  min-height: calc(100vh - 220px);
  overflow-y: auto;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

#chat.sidebar-collapsed {
  margin-left: auto;
  width: 100%;
  margin-right: auto;
}

/* Desktop layout (sidebar as persistent panel) */
@media (min-width: 1025px) {
  #chat {
    margin-left: 280px;
    width: calc(100% - 280px);
    max-width: calc(100% - 280px);
    padding: 0 40px;
  }
}


/* ================= MESSAGES ================= */
.message {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.user {
  background: #2563eb;
  color: #ffffff;
  margin-left: auto;
  max-width: 70%;
}

.ai {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  max-width: 90%;
}

/* ================= KPI ================= */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.kpi {
  background: #f9fafb;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
}

.kpi h3 {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.kpi p {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 700;
}

/* ================= CHARTS ================= */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.chart-box {
  height: 260px;
  background: #ffffff;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #e5e7eb;
}

/* ================= INPUT BAR ================= */
footer {
  position: fixed;
  bottom: 0;
  right: 0;
  width: calc(100% - 280px);
  background: #ffffff;
  display: flex;
  justify-content: center;
  padding: 10px 18px;
  border-top: 1px solid #e5e7eb;
  z-index: 95;
  transition: all 0.3s ease;
}

footer.sidebar-collapsed {
  width: 100%;
  left: 0;
}

.input-bar {
  width: 100%;
  max-width: 1100px;
  display: flex;
  gap: 10px;
}

textarea {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  min-height: 38px;
  max-height: 140px;
  resize: none;
  padding: 9px 14px;
  font-size: 14px;
  border-radius: 14px;
  border: 1px solid #d1d5db;
  outline: none;
  overflow-x: hidden;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9ca3af transparent;
}

textarea::-webkit-scrollbar {
  width: 6px;
}

textarea::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

textarea::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
}

textarea:focus {
  border-color: #2563eb;
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
  transition: background 0.18s ease, transform 0.12s ease,
    box-shadow 0.18s ease;
}

.send-button:hover {
  background: #1e4ed8;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.32);
}

.send-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.send-button:disabled {
  background: #93c5fd;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  opacity: 0.75;
}

.send-button span.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ================= LOADER ================= */
.loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.loader-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid #d1d5db;
  border-top-color: #2563eb;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ================= AI STRUCTURED TEXT (PROFESSIONAL MARKDOWN STYLING) ================= */

.ai-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  line-height: 1.7;
}

/* Section Headings (Summary, Key Details, Analytics & Insights) */
.ai-section-heading {
  margin: 20px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #2563eb;
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  letter-spacing: -0.01em;
}

.ai-section-heading:first-child {
  margin-top: 0;
}

/* Period Headings (January 2025, December 2024, etc.) */
.ai-period-heading {
  margin: 16px 0 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  background: #f3f4f6;
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid #2563eb;
}

/* Bullet Point Items */
.ai-bullet-item {
  display: flex;
  gap: 10px;
  margin: 2px 0;
  /* Reduced from 6px to 2px - tighter spacing */
  padding-left: 4px;
}

.ai-bullet {
  color: #2563eb;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-bullet-content {
  flex: 1;
  line-height: 1.6;
}

/* Metrics within bullet points (Label: Value) */
.ai-metric-label {
  font-weight: 600;
  color: #374151;
}

.ai-metric-value {
  color: #111827;
  font-weight: 500;
  margin-left: 4px;
}

/* Location Names (Edinburgh, London, etc.) */
.ai-location {
  color: #1f2937;
  font-weight: 600;
}

/* Regular Paragraphs */
.ai-paragraph {
  margin: 4px 0;
  /* Reduced from 8px to 4px - tighter within sections */
  line-height: 1.7;
  color: #374151;
}

.ai-paragraph strong {
  font-weight: 600;
  color: #111827;
}

/* Legacy support for old structure */
.ai-heading {
  margin-top: 18px;
  padding-top: 6px;
  border-top: 1px solid #e5e7eb;
  font-size: 15px;
  font-weight: 600;
  color: #1f4fd8;
}

.ai-row {
  display: flex;
  gap: 6px;
  padding-left: 10px;
  line-height: 1.6;
}

.ai-label {
  font-weight: 600;
  color: #111827;
}

.ai-value {
  color: #111827;
}

.ai-heading+.ai-paragraph {
  margin-top: 6px;
}

/* ================= SCROLL BUTTON ================= */
.scroll-btn {
  position: fixed;
  bottom: 90px;
  right: 30px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  color: #2563eb;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.scroll-btn.show {
  opacity: 1;
  pointer-events: auto !important;
}

.scroll-btn:hover {
  background: #f9fafb;
  transform: translateY(-2px);
}

/* ================= LOGIN CONTAINER ================= */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 100px);
  padding: 40px 20px;
}

.login-box {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-title {
  text-align: center;
  margin-bottom: 30px;
}

.login-title h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #111827;
}

.login-title p {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
  color: #9ca3af;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.submit-btn:active {
  transform: translateY(0);
}

.error-message {
  background: #fee2e2;
  color: #dc2626;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  border-left: 4px solid #dc2626;
}

.footer-text {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  margin-top: 20px;
}

/* ================= LOGIN PAGE RESPONSIVE ================= */
@media (max-width: 480px) {
  .login-box {
    padding: 30px 20px;
  }

  .login-title h2 {
    font-size: 24px;
  }
}

/* ===================================================================================== */
/* ============ RESPONSIVE DESIGN - EXACT WIREFRAME MOBILE LAYOUT ===================== */
/* ===================================================================================== */

/* ================= SIDEBAR OVERLAY (MOBILE) ================= */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .sidebar-overlay {
    display: block;
  }
}

/* Tablet Landscape and Below (≤1024px) */
@media (max-width: 1024px) {
  #chat {
    margin-left: 0;
    width: 100%;
    padding: 0 16px;
    min-height: calc(100vh - 220px);
  }

  footer {
    left: 0;
    width: 100%;
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: -280px;
    width: 280px;
    transform: translateX(-100%);
    visibility: hidden;
    z-index: 1000;
  }

  .sidebar.open {
    transform: translateX(0);
    left: 0;
    visibility: visible;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    visibility: hidden;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .kpi-row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}


@media (min-width: 1025px) {
  .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    visibility: hidden;
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
  }
}

/* Ensure chart containers never overflow on small/mobile screens */
.chart-box {
  min-width: 0;
  width: 100%;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}


/* ===================================================================================== */
/* ========== MOBILE LAYOUT - MATCHING WIREFRAME (<768px) =============================== */
/* ===================================================================================== */
@media (max-width: 767px) {
  body {
    --mobile-header-height: 76px;
    --mobile-sidebar-width: 132px;
    --mobile-footer-height: 70px;
  }

  /* ========== HEADER - 2x2 GRID LAYOUT (MATCHING WIREFRAME) ========== */
  header {
    height: var(--mobile-header-height);
    padding: 8px 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 4px 8px;
    align-items: center;
    align-content: center;
  }

  /* Logo - Top Left */
  header img {
    height: 24px;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  /* Username - Top Right */
  .user-info-section {
    position: static;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    background: transparent;
    border: none;
  }

  .user-info-section .user-name {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
  }

  .user-info-section .divider {
    display: none;
  }

  .user-info-section .logout-btn {
    display: none;
    /* Logout button will be in bottom left */
  }

  /* Title "AI Assistance" - Bottom Left */
  header .title {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    text-align: left;
  }

  header h1 {
    font-size: 13px;
    font-weight: 600;
  }

  header p {
    display: none;
  }

  /* ========== LOGOUT BUTTON - BOTTOM RIGHT (MATCHING WIREFRAME) ========== */
  header::after {
    content: '';
    grid-column: 2;
    grid-row: 2;
  }

  /* Create logout button container in header */
  .mobile-logout {
    display: none;
  }

  @supports (display: grid) {
    .mobile-logout {
      display: block;
      grid-column: 2;
      grid-row: 2;
      justify-self: end;
    }

    .mobile-logout .logout-btn {
      padding: 3px 10px;
      background: transparent;
      color: #2563eb;
      text-decoration: none;
      border-radius: 6px;
      font-size: 10px;
      font-weight: 600;
      border: 1px solid #3b82f6;
      display: inline-block;
    }
  }

  /* Keep login header in one horizontal row on mobile */
  .login-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    height: 60px;
    padding: 0 14px;
  }

  .login-header img {
    height: 24px;
    grid-column: auto;
    grid-row: auto;
  }

  .login-header .title {
    grid-column: auto;
    grid-row: auto;
    justify-self: auto;
    margin-left: auto;
    text-align: right;
  }

  .login-header h1 {
    font-size: 13px;
    font-weight: 700;
  }

  .sidebar-overlay,
  .sidebar-overlay.active {
    display: none !important;
  }

  /* ========== SIDEBAR - COLLAPSIBLE PANEL (MATCHING WIREFRAME) ========== */
  .sidebar {
    top: var(--mobile-header-height);
    bottom: 0;
    width: var(--mobile-sidebar-width);
    max-width: none;
    z-index: 1000;
    box-shadow: none;
    border-right: 1px solid #d1d5db;
    padding: 12px 8px 18px;
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar .sidebar-title {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .sidebar .sidebar-category h5 {
    margin: 0 0 8px;
    font-size: 11px;
    color: #6b7280;
  }

  .sidebar .question-btn {
    font-size: 11px;
    padding: 6px 8px;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    visibility: hidden;
  }

  /* ========== SIDEBAR TOGGLE - TOP LEFT OF CHAT (MATCHING WIREFRAME) ========== */
  .sidebar-toggle-btn {
    position: fixed;
    top: calc(var(--mobile-header-height) + 12px);
    left: 8px;
    width: 20px;
    height: 20px;
    margin-top: 0;
    transform: none;
    z-index: 1002;
  }

  .sidebar-toggle-btn.open {
    left: calc(var(--mobile-sidebar-width) - 32px);
    transform: none;
    width: 20px;
    height: 20px;
  }

  .sidebar-toggle-btn svg {
    width: 11px;
    height: 11px;
  }

  /* ========== CHAT AREA - SPLIT WHEN SIDEBAR OPEN ========== */
  #chat {
    margin-top: calc(var(--mobile-header-height) + 12px);
    margin-bottom: calc(var(--mobile-footer-height) + 12px);
    margin-left: var(--mobile-sidebar-width);
    margin-right: 0;
    padding: 0 14px 0 12px;
    width: calc(100% - var(--mobile-sidebar-width));
    max-width: 100%;
    min-height: auto;
  }

  #chat.sidebar-collapsed {
    margin-left: 0;
    padding-left: 56px;
    width: 100%;
  }

  /* ========== MESSAGES ========== */
  .message {
    font-size: 13px;
    padding: 10px 12px;
  }

  .user {
    max-width: 85%;
  }

  .ai {
    max-width: 95%;
  }

  /* ========== KPIs - 2 COLUMNS ========== */
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .kpi {
    padding: 12px 8px;
  }

  .kpi h3 {
    font-size: 11px;
  }

  .kpi p {
    font-size: 16px;
  }

  /* ========== CHARTS - SINGLE COLUMN ========== */
  .chart-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-box {
    height: 240px;
    padding: 10px;
  }

  /* ========== FOOTER - SPLIT WHEN SIDEBAR OPEN ========== */
  footer {
    left: var(--mobile-sidebar-width);
    width: calc(100% - var(--mobile-sidebar-width));
    min-height: var(--mobile-footer-height);
    padding: 8px 14px;
  }

  footer.sidebar-collapsed {
    left: 0;
    width: 100%;
  }

  .input-bar {
    gap: 8px;
  }

  textarea {
    font-size: 13px;
    padding: 8px 12px;
    min-height: 36px;
  }

  .send-button {
    padding: 0 16px;
    font-size: 13px;
  }

  /* ========== SCROLL BUTTON ========== */
  .scroll-btn {
    bottom: 80px;
    right: 16px;
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* ========== MOBILE PHONES (<768px) ========== */
@media (max-width: 767px) {
  body {
    --mobile-header-height: 70px;
    --mobile-sidebar-width: 116px;
    --mobile-footer-height: 66px;
  }

  header {
    padding: 7px 10px;
    gap: 3px 6px;
  }

  header img {
    height: 20px;
  }

  .user-info-section .user-name {
    font-size: 12px;
  }

  header h1 {
    font-size: 12px;
  }

  .login-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    height: 54px;
    padding: 0 10px;
  }

  .login-header img {
    height: 20px;
  }

  .login-header h1 {
    font-size: 12px;
  }

  .sidebar {
    width: var(--mobile-sidebar-width);
  }

  .sidebar-toggle-btn {
    width: 18px;
    height: 18px;
  }

  .sidebar-toggle-btn.open {
    left: calc(var(--mobile-sidebar-width) - 30px);
  }

  .sidebar-toggle-btn svg {
    width: 10px;
    height: 10px;
  }

  #chat {
    margin-top: calc(var(--mobile-header-height) + 10px);
    margin-bottom: calc(var(--mobile-footer-height) + 10px);
    padding: 0 10px 0 8px;
  }

  #chat.sidebar-collapsed {
    padding-left: 50px;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .kpi {
    padding: 10px 6px;
  }

  .kpi h3 {
    font-size: 10px;
  }

  .kpi p {
    font-size: 14px;
  }

  .chart-box {
    height: 220px;
    padding: 8px;
  }

  .ai-heading {
    font-size: 13px;
  }

  .ai-row {
    font-size: 11px;
    padding-left: 6px;
  }

  footer {
    left: var(--mobile-sidebar-width);
    width: calc(100% - var(--mobile-sidebar-width));
    padding: 7px 10px;
  }

  footer.sidebar-collapsed {
    left: 0;
    width: 100%;
  }

  textarea {
    font-size: 12px;
    padding: 7px 10px;
  }

  .send-button {
    padding: 0 14px;
    font-size: 12px;
  }

  .send-button span.icon {
    font-size: 14px;
  }

  .scroll-btn {
    bottom: 70px;
    right: 12px;
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

/* ========== EXTRA SMALL PHONES (≤360px) ========== */
@media (max-width: 360px) {
  body {
    --mobile-sidebar-width: 100px;
  }

  .sidebar {
    width: var(--mobile-sidebar-width);
  }

  .sidebar-toggle-btn.open {
    left: calc(var(--mobile-sidebar-width) - 30px);
  }

  .kpi-row {
    grid-template-columns: 1fr;
  }

  header h1 {
    font-size: 11px;
  }

  .user-info-section .user-name {
    font-size: 11px;
  }
}

/* ========== LANDSCAPE MOBILE ========== */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    --mobile-header-height: 74px;
    --mobile-footer-height: 60px;
  }

  header {
    padding: 8px 12px;
  }

  .login-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    height: 52px;
    padding: 0 10px;
  }

  .sidebar-toggle-btn {
    top: calc(var(--mobile-header-height) + 12px);
  }

  #chat {
    margin-top: calc(var(--mobile-header-height) + 10px);
  }

  footer {
    padding: 6px 12px;
  }

}

/* ===================================================================================== */
/* ================= TABLET LAYOUT NORMALIZATION (768px-1024px) ======================== */
/* ===================================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  body {
    --tablet-header-height: 84px;
    --tablet-sidebar-width: clamp(220px, 30vw, 280px);
    --tablet-footer-height: 84px;
  }

  header {
    height: var(--tablet-header-height);
    padding: 12px 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 6px 16px;
    align-items: center;
  }

  header img {
    grid-column: 1;
    grid-row: 1;
    height: 28px;
  }

  header .title {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
  }

  header h1 {
    font-size: 18px;
    line-height: 1.2;
  }

  .user-info-section {
    position: static;
    grid-column: 2;
    grid-row: 1 / span 2;
    justify-self: end;
    max-width: min(42vw, 320px);
    gap: 10px;
  }

  .user-info-section .user-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-logout {
    display: none;
  }

  .sidebar-overlay,
  .sidebar-overlay.active {
    display: none !important;
  }

  .sidebar {
    top: var(--tablet-header-height);
    left: 0;
    width: var(--tablet-sidebar-width);
    padding: 20px 16px 24px;
    transform: translateX(0);
    visibility: visible;
    z-index: 1000;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    visibility: hidden;
  }

  .sidebar-title {
    font-size: 24px;
    margin-bottom: 20px;
  }

  .sidebar .sidebar-category h5 {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.35;
    color: #111827;
  }

  .sidebar .question-btn {
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 12px;
  }

  .sidebar-toggle-btn {
    top: calc(var(--tablet-header-height) + 14px);
    left: 16px;
    width: 28px;
    height: 28px;
    z-index: 1003;
  }

  .sidebar-toggle-btn svg {
    width: 14px;
    height: 14px;
  }

  .sidebar-toggle-btn.open {
    left: calc(var(--tablet-sidebar-width) - 14px);
    width: 28px;
    height: 28px;
  }

  #chat {
    margin-top: calc(var(--tablet-header-height) + 20px);
    margin-bottom: calc(var(--tablet-footer-height) + 18px);
    margin-left: var(--tablet-sidebar-width);
    width: calc(100% - var(--tablet-sidebar-width));
    max-width: calc(100% - var(--tablet-sidebar-width));
    padding: 0 24px 0 18px;
    min-height: auto;
  }

  #chat.sidebar-collapsed {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    padding-left: 64px;
    padding-right: 24px;
  }

  .message {
    font-size: 15px;
  }

  .user {
    max-width: min(72%, 640px);
  }

  .ai {
    max-width: min(92%, 760px);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  footer {
    left: var(--tablet-sidebar-width);
    width: calc(100% - var(--tablet-sidebar-width));
    min-height: var(--tablet-footer-height);
    padding: 12px 20px;
  }

  footer.sidebar-collapsed {
    left: 0;
    width: 100%;
  }

  .input-bar {
    max-width: 100%;
    gap: 12px;
  }

  textarea {
    min-height: 46px;
    font-size: 15px;
    padding: 11px 14px;
  }

  .send-button {
    min-width: 120px;
    font-size: 15px;
  }
}






