:root {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: #172033;
  background: #f4f7f8;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --primary-soft: #eaf7f4;
  --blue: #2563eb;
  --amber: #d97706;
  --rose: #b42318;
  --line: #dde5e8;
  --muted: #667085;
  --panel: #ffffff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: #f4f7f8; }
button, input, select { font: inherit; }
a { color: inherit; }

/* ====== CÁC THÀNH PHẦN DÙNG CHUNG / TRANG ADMIN ====== */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  padding: 20px 28px; background: #fff; border-bottom: 1px solid #dfe4ea;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0 0 4px; font-size: 22px; }
.topbar p { margin: 0; color: #667085; }
.topbar-actions, .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.container { width: min(1500px, 96%); margin: 24px auto; }
.panel {
  background: #fff; border: 1px solid #e3e7ed; border-radius: 12px;
  padding: 18px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(16,24,40,.04);
}
.panel h2 { margin-top: 0; font-size: 19px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stats-grid.small { grid-template-columns: repeat(3, 1fr); }
.stat { background: #fff; border: 1px solid #e3e7ed; border-radius: 12px; padding: 16px; }
.stat span { display: block; color: #667085; font-size: 14px; margin-bottom: 8px; }
.stat strong { font-size: 28px; }
.filters { display: grid; grid-template-columns: 2fr 1.2fr 1fr auto; gap: 12px; align-items: end; }
.import-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; margin-bottom: 14px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
input, select {
  width: 100%; border: 1px solid #cfd6df; border-radius: 8px;
  padding: 10px 12px; background: #fff; color: #172033;
}
input:focus, select:focus {
  outline: none; border-color: #54a8a0; box-shadow: 0 0 0 3px rgba(15,118,110,.11);
}
.btn {
  border: 1px solid #cfd6df; background: #fff; color: #172033; border-radius: 8px;
  padding: 10px 14px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 600; transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,24,40,.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: #155eef; color: #fff; border-color: #155eef; }
.btn.success { background: #067647; color: #fff; border-color: #067647; }
.btn.danger { background: #b42318; color: #fff; border-color: #b42318; }
.btn.small { padding: 6px 9px; font-size: 13px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 330px); }
.preview-wrap { max-height: 460px; }
table { width: 100%; border-collapse: collapse; min-width: 1050px; }
th, td { padding: 10px 9px; border-bottom: 1px solid #eaecf0; text-align: left; vertical-align: top; }
th { background: #f8fafc; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.name-cell { font-weight: 650; }
.num { text-align: right; }
.source { color: #667085; font-size: 12px; }
.inactive-row { opacity: .55; background: #fafafa; }
.muted { color: #667085; }
.message { min-height: 22px; color: #344054; }
.message.error { color: #b42318; }
.empty { text-align: center; color: #667085; padding: 28px; }
.hidden { display: none !important; }
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg,#eef4ff,#f8fafc);
}
.login-card {
  width: min(430px,100%); background: #fff; padding: 28px; border: 1px solid #e3e7ed;
  border-radius: 14px; box-shadow: 0 14px 40px rgba(16,24,40,.08);
}
.login-card h1 { margin-top: 0; font-size: 22px; }
.stack { display: grid; gap: 14px; }

/* ====== TRANG CHỦ MỚI ====== */
.home-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 5% 0%, rgba(15,118,110,.08), transparent 26%),
    radial-gradient(circle at 92% 2%, rgba(37,99,235,.06), transparent 24%),
    #f5f8f8;
}

.home-header {
  background: linear-gradient(115deg, #0b5f59 0%, #0f766e 55%, #14867d 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.16);
}
.home-header-inner {
  width: min(1500px, 96%);
  margin: 0 auto;
  min-height: 138px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 22px 0;
}
.brand-block { display: flex; align-items: center; gap: 20px; min-width: 0; }
.brand-mark {
  width: 72px; height: 72px; border-radius: 22px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 10px 24px rgba(0,0,0,.12);
}
.brand-mark span { font-size: 25px; font-weight: 800; letter-spacing: .06em; }
.brand-kicker {
  font-size: 13px; font-weight: 800; letter-spacing: .12em; opacity: .88; margin-bottom: 6px;
}
.brand-copy h1 {
  margin: 0; font-size: clamp(26px, 2.5vw, 38px); line-height: 1.12;
  letter-spacing: .01em; font-weight: 800;
}
.brand-copy p { margin: 8px 0 0; font-size: 14px; color: rgba(255,255,255,.82); }
.home-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.home-actions .btn { min-height: 42px; }
.admin-btn { background: #fff; border-color: #fff; color: #0b5f59; }

.module-nav {
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 14px rgba(16,24,40,.04);
  position: sticky;
  top: 0;
  z-index: 12;
}
.module-nav-inner {
  width: min(1500px, 96%); margin: 0 auto; display: flex; align-items: stretch;
  gap: 4px; overflow-x: auto; scrollbar-width: thin;
}
.module-tab {
  position: relative; flex: 0 0 auto; min-height: 58px; border: 0; border-bottom: 3px solid transparent;
  padding: 0 18px; display: inline-flex; align-items: center; gap: 9px;
  background: transparent; text-decoration: none; color: #53606f; font-size: 13px;
  font-weight: 800; letter-spacing: .025em; white-space: nowrap;
}
.module-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); background: #f4fbf9; }
.module-tab.active .tab-dot { background: var(--primary); box-shadow: 0 0 0 4px rgba(15,118,110,.11); }
.module-tab.upcoming { color: #98a2b3; cursor: default; }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: #aab3be; }
.soon-badge {
  padding: 3px 7px; border-radius: 999px; background: #f2f4f7; color: #7c8795;
  font-size: 10px; font-weight: 700; letter-spacing: 0;
}

.home-container { margin-top: 28px; }
.section-heading {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 2px 18px;
}
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.section-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.section-description { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.live-status {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  padding: 8px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  color: #475467; font-size: 12px; font-weight: 700;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 4px rgba(22,163,74,.10); }

.home-stats { gap: 16px; margin-bottom: 20px; }
.home-stats .stat {
  min-height: 128px; padding: 20px; border: 1px solid #dfe7e9; border-radius: 16px;
  display: flex; align-items: center; gap: 16px; box-shadow: 0 7px 20px rgba(16,24,40,.045);
  overflow: hidden; position: relative;
}
.home-stats .stat::after {
  content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%;
  right: -32px; bottom: -40px; background: currentColor; opacity: .045;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  flex: 0 0 auto; font-size: 17px; font-weight: 900;
}
.stat-content { min-width: 0; }
.home-stats .stat span { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: #667085; }
.home-stats .stat strong { display: block; font-size: 30px; line-height: 1.05; letter-spacing: -.03em; }
.home-stats .stat small { display: block; margin-top: 5px; color: #98a2b3; font-size: 11px; }
.stat-households { color: #0f766e; }
.stat-households .stat-icon { background: #eaf7f4; color: #0f766e; }
.stat-population { color: #2563eb; }
.stat-population .stat-icon { background: #eef4ff; color: #2563eb; }
.stat-villages { color: #d97706; }
.stat-villages .stat-icon { background: #fff7e8; color: #b65e04; }
.stat-flooded { color: #b42318; }
.stat-flooded .stat-icon { background: #fff0ee; color: #b42318; }

.home-filters {
  grid-template-columns: 1.1fr 2fr 1.15fr 1.05fr auto;
  gap: 14px; align-items: end; padding: 20px; border-radius: 16px;
  box-shadow: 0 7px 20px rgba(16,24,40,.04);
}
.filter-title { align-self: center; padding-right: 8px; }
.filter-title strong { display: block; font-size: 14px; }
.filter-title span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.45; }
.home-filters label { font-size: 12px; color: #344054; }
.home-filters input, .home-filters select { height: 43px; border-radius: 10px; }
.clear-btn { height: 43px; color: #475467; }

.data-panel { padding: 0; border-radius: 16px; overflow: hidden; box-shadow: 0 7px 22px rgba(16,24,40,.045); }
.panel-heading-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 20px 14px; border-bottom: 1px solid #e8edef;
}

.panel-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.excel-btn {
  background: #087443;
  border-color: #087443;
  color: #fff;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 10px;
}
.excel-btn:hover { background: #06653a; border-color: #06653a; }
.excel-icon {
  width: 22px; height: 22px; border-radius: 5px; display: inline-grid; place-items: center;
  margin-right: 7px; background: rgba(255,255,255,.16); font-size: 12px; font-weight: 900;
}

.panel-heading-row h3 { margin: 0; font-size: 16px; }
.panel-heading-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.home-table-wrap { max-height: calc(100vh - 405px); min-height: 250px; }
.home-table-wrap table { min-width: 1120px; }
.home-table-wrap th {
  top: 0; padding: 12px 11px; background: #f7faf9; color: #344054;
  font-size: 12px; text-transform: none; border-bottom: 1px solid #dfe7e9;
}
.home-table-wrap td { padding: 11px; font-size: 13px; }
.home-table-wrap tbody tr:hover { background: #f9fcfb; }

.home-footer {
  width: min(1500px, 96%); margin: 28px auto 20px; padding: 14px 0;
  color: #98a2b3; text-align: center; font-size: 11px; letter-spacing: .06em;
}

@media (max-width: 1120px) {
  .home-header-inner { align-items: flex-start; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .home-filters { grid-template-columns: 1fr 1fr; }
  .filter-title { grid-column: 1 / -1; }
  .clear-btn { width: 100%; }
}

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats-grid, .stats-grid.small { grid-template-columns: repeat(2, 1fr); }
  .filters, .import-grid { grid-template-columns: 1fr; }
  .home-header-inner { min-height: auto; align-items: stretch; flex-direction: column; }
  .home-actions { justify-content: flex-start; }
  .brand-mark { width: 60px; height: 60px; border-radius: 18px; }
  .brand-copy p { max-width: 680px; }
}

@media (max-width: 640px) {
  .home-header-inner, .module-nav-inner, .home-footer { width: 92%; }
  .container { width: 92%; }
  .brand-block { align-items: flex-start; gap: 13px; }
  .brand-mark { width: 50px; height: 50px; border-radius: 15px; }
  .brand-mark span { font-size: 19px; }
  .brand-kicker { font-size: 10px; }
  .brand-copy h1 { font-size: 23px; }
  .brand-copy p { font-size: 12px; }
  .home-actions .btn { flex: 1 1 auto; }
  .module-tab { min-height: 52px; padding: 0 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .home-stats { grid-template-columns: 1fr; }
  .home-stats .stat { min-height: 108px; }
  .home-filters { grid-template-columns: 1fr; }
  .filter-title { grid-column: auto; }
  .stats-grid, .stats-grid.small { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .panel-heading-row { align-items: flex-start; flex-direction: column; }
  .panel-actions, .excel-btn { width: 100%; }
}
