:root{
  --bg:#0b1220;
  --card:#111b33;
  --text:#e8eefc;
  --muted:#a9b5d1;
  --accent:#4f8cff;
  --accent2:#34d399;
  --danger:#fb7185;
  --border: rgba(255,255,255,0.12);
}
*{ box-sizing:border-box; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: Arial, Helvetica, sans-serif;
}
a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }
.container{
  max-width: 100%;
  margin: 16px auto;
  padding: 0 16px;
}
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.row{ display:flex; gap:12px; flex-wrap:wrap; }
.col{ flex:1; min-width: 240px; }
.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 14px;
}
.title{
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}
.muted{ color: var(--muted); font-size: 14px; }
label{ display:block; font-size: 14px; color: var(--muted); margin-bottom:6px; }
input, select, button{
  width:100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  outline: none;
  margin-bottom: 10px; 
}

/* Fix: option trong select đôi khi bị render nền trắng/chữ trắng trên theme tối */
select option{
  background: var(--card);
  color: var(--text);
}

select option:checked{
  background: rgba(79,140,255,0.35);
  color: var(--text);
}
button{
  cursor:pointer;
  background: var(--accent);
  border-color: rgba(79,140,255,0.7);
}
button.secondary{
  background: var(--accent);
  border-color: var(--border);
}
.alert{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 12px;
}
.alert.ok{ border-color: rgba(52,211,153,0.55); }
.alert.err{ border-color: rgba(251,113,133,0.55); }
table{
  width:100%;
  border-collapse: collapse;
}
th, td{
  text-align:left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
th{ color: var(--muted); font-weight: 600; }

.chart-scroll{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}
.chart-scroll canvas{
  min-width: 560px; /* giữ nhãn ngày/legend không bị dồn trên mobile */
  max-width: none;
  display:block;
}

.table-scroll-x{
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-scroll-x table{
  width: 100%;
}

.admin-logout{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  width:100%;
}
.admin-logout-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
}

.ai-analysis-panel{
  background: linear-gradient(180deg, rgba(14,20,34,0.95) 0%, rgba(10,14,24,0.95) 100%);
  color: var(--muted) !important;
  font-size: 14px;
  line-height: 1.5;
}

.ai-analysis-panel,
.ai-analysis-panel p,
.ai-analysis-panel li,
.ai-analysis-panel span,
.ai-analysis-panel div,
.ai-analysis-panel strong,
.ai-analysis-panel b,
.ai-analysis-panel em{
  color: var(--muted) !important;
  font-size: 14px;
  line-height: 1.5;
}

.ai-analysis-panel h1,
.ai-analysis-panel h2,
.ai-analysis-panel h3,
.ai-analysis-panel h4,
.ai-analysis-panel h5,
.ai-analysis-panel h6{
  color: var(--muted) !important;
  line-height: 1.5;
}

/* Ép toàn bộ descendants trong khối AI dùng màu muted, tránh bị đè bởi var(--text). */
.ai-analysis-panel *{
  color: var(--muted) !important;
}

.ai-analysis-panel hr{
  border-bottom-color: rgba(169,181,209,0.25);
}
hr {
  border: none;
  border-bottom: 2px solid var(--border);
  margin: 16px 0;
  height: 0;
  width: 100%;
}

@media (max-width: 640px) {
  .container{
    padding: 0 6px;
    margin: 6px auto;
  }
  .card{
    padding: 14px;
  }
  .header{
    flex-direction: column;
    align-items: flex-start;
    gap: 0px;
  }
  .row{
    gap: 10px;
  }
  .col{
    min-width: 100%;
  }
  .title{
    font-size: 16px;
    margin-bottom: 10px;
  }
  .muted{
    font-size: 13px;
  }
  label{
    font-size: 13px;
  }
  th, td{
    font-size: 12px;
    padding: 9px 8px;
  }
  input, select, button{
    padding: 10px 10px;
    border-radius: 10px;
    margin-bottom: 10px;
  }

  /* Mobile: ưu tiên fit màn hình, không bắt buộc cuộn ngang */
  .chart-scroll{
    overflow-x: hidden;
    padding-bottom: 0;
  }
  .chart-scroll canvas{
    min-width: 0;
    width: 100% !important;
    max-width: 100%;
  }

  /* Bảng dữ liệu/đánh giá: chữ 1 hàng + scroll ngang xem cột */
  .table-scroll-x{
    overflow-x: auto;
  }

  .table-scroll-x table{
    min-width: 680px;
  }

  .table-scroll-x th,
  .table-scroll-x td{
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    padding: 8px 6px;
  }

  /* Cố định cột đầu (Ngày) để kéo ngang vẫn dễ theo dõi */
  .table-scroll-x th:first-child,
  .table-scroll-x td:first-child{
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 2;
    border-right: 1px solid rgba(255,255,255,0.10);
  }
  .table-scroll-x th:first-child{
    z-index: 3;
  }

  /* Mobile: căn nút đăng xuất vào giữa để gọn */
  .admin-logout{
    justify-content:center;
    margin-bottom: 6px;
  }
  .muted{
    font-size: 12px;
    text-align: left;
  }
  .hide-mobile{
    display: none;
  }
}


