:root {
  --navy: #0f294d;
  --primary: #1d4ed8;
  --indigo: #4338ca;
  --emerald: #047857;
  --rose: #be123c;
  --sky: #0284c7;
  --bg: #eef3f9;
  --card: #ffffff;
  --border: #dbe3ee;
  --border-dark: #94a3b8;
  --text: #0f172a;
  --muted: #475569;
  --shadow: 0 4px 18px rgba(15, 41, 77, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

.hidden { display: none !important; }
.center { text-align: center !important; }

/* ================= MÀN HÌNH ĐĂNG NHẬP ================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0b2447 0%, #1d4ed8 55%, #0284c7 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 18px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(11, 36, 71, 0.42);
}

.login-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 15px;
  background: linear-gradient(135deg, #be123c, #e11d48);
  color: #fff;
  font-weight: 900;
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(190, 18, 60, 0.35);
}

.login-card h1 { font-size: 18px; font-weight: 800; color: var(--navy); }
.login-sub { font-size: 13.5px; color: var(--muted); margin: 4px 0 22px; }

.login-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.form-group label { display: block; font-weight: 700; font-size: 13.5px; color: var(--navy); margin-bottom: 6px; }

.login-input {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 13px;
  border: 1.5px solid var(--border-dark);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
  transition: all 0.15s;
}
.login-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16);
}

.pwd-wrap { position: relative; }
.pwd-wrap .login-input { padding-right: 42px; }
.pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.remember-row input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.login-error {
  background: #ffe4e6;
  color: #9f1239;
  border: 1px solid #fda4af;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

/* ================= HEADER & BUTTONS ================= */
.app-header {
  background: linear-gradient(120deg, #0b2447 0%, #1d4ed8 68%, #0284c7 100%);
  color: #fff;
  padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(11, 36, 71, 0.3);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  background: #be123c;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 9px;
}
.brand h1 { font-size: 16.5px; font-weight: 800; }
.brand p { font-size: 12px; opacity: 0.92; margin-top: 1px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; padding: 11px; font-size: 14.5px; }
.btn-primary { background: linear-gradient(135deg, #1d4ed8, #2563eb); color: #fff; box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-emerald:hover { background: #065f46; }
.btn-sky { background: #0369a1; color: #fff; border: 1px solid rgba(255,255,255,0.45); }
.btn-sky:hover { background: #075985; }
.btn-danger-outline { background: rgba(190, 18, 60, 0.25); color: #fff; border: 1.5px solid rgba(255,255,255,0.7); }
.btn-danger-outline:hover { background: #be123c; }
.btn-soft { background: #eff6ff; color: var(--primary); border: 1.5px solid #93c5fd; }
.btn-soft:hover { background: #dbeafe; }
.btn-ghost { background: #e2e8f0; color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 9px; font-size: 12px; }

/* ================= MAIN LAYOUT ================= */
.container { max-width: 1560px; margin: 14px auto 36px; padding: 0 16px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 15px;
  box-shadow: var(--shadow);
}
.kpi-card.accent-indigo { border-top-color: var(--indigo); }
.kpi-card.accent-emerald { border-top-color: var(--emerald); }
.kpi-card.accent-rose { border-top-color: var(--rose); }

.kpi-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kpi-head span { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.kpi-head strong { font-size: 23px; font-weight: 900; color: var(--navy); }
.kpi-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.kpi-tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: #e2e8f0; color: #0f172a; }
.kpi-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 6px; }

.mini-bar { height: 7px; background: #e2e8f0; border-radius: 10px; overflow: hidden; margin-top: 7px; }
.mini-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--emerald)); transition: width 0.3s; }

/* CHARTS */
.charts-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 14px; font-weight: 800; color: var(--navy); margin-bottom: 8px; }
.chart-box { position: relative; height: 195px; }

/* TABS KHUNG NỔI + BỘ LỌC */
.nav-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tab-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  padding: 10px 16px;
  border: 2px solid var(--border-dark);
  background: #fff;
  color: var(--navy);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 3px 8px rgba(15, 41, 77, 0.08);
  transition: all 0.15s;
}
.tab-btn:hover { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.tab-btn.active {
  background: linear-gradient(135deg, #0f294d, #1d4ed8);
  color: #fff;
  border-color: #0f294d;
  box-shadow: 0 5px 14px rgba(29, 78, 216, 0.35);
}
.tab-count { font-size: 11.5px; font-weight: 800; padding: 2px 8px; border-radius: 12px; }
.tab-count.ok { background: #bbf7d0; color: #064e3b; }
.tab-count.err { background: #fecdd3; color: #9f1239; }

.filter-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-controls select, .filter-controls input {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border: 1.5px solid var(--border-dark);
  border-radius: 8px;
  background: #fff;
}

/* BẢNG DỮ LIỆU */
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 15.5px; font-weight: 800; color: var(--navy); }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.table-wrap {
  max-height: 540px;
  overflow: auto;
  border: 1.5px solid var(--border-dark);
  border-radius: 9px;
}
table { width: 100%; border-collapse: collapse; font-size: 13.2px; background: #fff; }
thead th {
  position: sticky;
  top: 0;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  padding: 9px 9px;
  text-align: left;
  border-right: 1px solid rgba(255,255,255,0.16);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
  z-index: 3;
}
#tblSubmitted thead tr:nth-child(2) th { top: 36px; z-index: 2; padding: 6px 8px; font-size: 12px; }
th.grp-blue { background: #1d4ed8; }
th.sub-blue { background: #2563eb; }
th.grp-green { background: #047857; }
th.sub-green { background: #059669; }
th.grp-rose { background: #9f1239; }
th.sub-rose { background: #be123c; }

tbody td {
  padding: 8px 9px;
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #e2e8f0;
  vertical-align: middle;
}
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: #dbeafe; }
th.num, td.num { text-align: right; white-space: nowrap; }

tfoot tr.total-row td {
  position: sticky;
  bottom: 0;
  background: #dbeafe;
  color: var(--navy);
  font-weight: 800;
  padding: 10px 9px;
  border-top: 2px solid var(--primary);
  z-index: 2;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-ok { background: #bbf7d0; color: #064e3b; }
.badge-err { background: #fecdd3; color: #9f1239; }
.badge-warn { background: #fde68a; color: #78350f; }
.badge-info { background: #bae6fd; color: #075985; }

/* MODAL & TOAST */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 120; padding: 16px;
}
.modal-box {
  background: #fff; width: 100%; max-width: 780px; max-height: 88vh;
  display: flex; flex-direction: column;
  border-radius: 14px; padding: 20px; border: 2px solid var(--navy);
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 10px; border-bottom: 1.5px solid var(--border); margin-bottom: 12px;
}
.modal-head h3 { color: var(--navy); font-size: 16.5px; font-weight: 800; }
.detail-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.detail-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.detail-box strong { color: var(--navy); display: block; margin-bottom: 4px; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--navy); color: #fff; padding: 11px 18px;
  border-radius: 10px; font-weight: 700; font-size: 13.5px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35); z-index: 100;
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
