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

* { box-sizing: border-box; }
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5ea;
  --text: #171a24;
  --muted: #6b7078;
  --primary: #2c4373;
  --primary-dark: #1f325a;
  --primary-soft: #eef1f8;
  --danger: #b3413a;
  --danger-bg: #fbebe9;
  --success: #1f7a52;
  --success-bg: #e8f5ee;
  --warn: #9a6a1a;
  --warn-bg: #fbf1de;
  --sidebar-bg: #12172a;
  --sidebar-text: #9aa1b8;
  --sidebar-text-active: #ffffff;
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; animation: screenIn .35s ease; }

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

/* ---------- Auth screens ---------- */
.center-box {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, #eef1f7 0%, var(--bg) 60%);
}
.center-box h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.center-box .subtitle { color: var(--muted); font-size: 13px; margin-top: -12px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 34px 32px;
  box-shadow: 0 1px 2px rgba(15,18,30,0.04), 0 12px 32px rgba(15,18,30,0.08);
  width: 380px;
  border: 1px solid var(--border);
  animation: fadeIn .4s ease;
  transition: box-shadow .2s, transform .2s;
}
.card h2 { margin: 0 0 20px; font-size: 17px; font-weight: 700; }
.field-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; display: block; }
.card input {
  width: 100%;
  padding: 11px 13px;
  margin: 0 0 18px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  background: #fbfbfc;
  color: var(--text);
}
.card input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.card input::placeholder { color: #a8adb8; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, transform .05s;
  letter-spacing: -0.005em;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(44,67,115,.25); }
.btn:active { transform: scale(.97); box-shadow: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.secondary:hover { background: #e2e7f3; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.danger:hover { background: #f6d9d6; }
.btn.small { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.error { color: var(--danger); font-size: 13px; margin: -12px 0 14px; min-height: 16px; }

/* ---------- App shell (sidebar) ---------- */
.app-shell { display: flex; width: 100%; min-height: 100vh; }
.sidebar {
  width: 236px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  flex-shrink: 0;
}
.sidebar .brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 26px; display: flex; align-items: center; gap: 9px; letter-spacing: -0.01em; }
.sidebar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: #5b7cd6; box-shadow: 0 0 0 4px rgba(91,124,214,.22); }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px; margin-bottom: 2px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--sidebar-text);
  transition: background .15s, color .15s, transform .1s;
}
.nav-item .ic { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; opacity: .85; transition: opacity .15s, transform .15s; }
.nav-item .ic svg { width: 16px; height: 16px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; transform: translateX(2px); }
.nav-item:hover .ic { transform: scale(1.08); }
.nav-item.active { background: rgba(91,124,214,.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(91,124,214,.3); }
.nav-item.active .ic { opacity: 1; }
.nav-item:active { transform: scale(.97); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .who { font-size: 11.5px; color: var(--sidebar-text); padding: 6px 12px 10px; }

.main-area { flex: 1; min-width: 0; overflow-y: auto; }
.page-header {
  padding: 24px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.page-header h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.page-header p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.content { padding: 28px 32px; max-width: 1280px; }

/* Header trang tài xế: nền sáng như các trang khác, chỉ nhấn nhẹ bằng avatar -
   để khối "Số tiền cần thanh toán" bên dưới là điểm nhấn neon duy nhất, tránh
   2 khối tối màu giống nhau đứng cạnh nhau gây rối mắt. */
.driver-header-info { display: flex; align-items: center; gap: 14px; }
.driver-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #5b7cd6, var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
  box-shadow: 0 0 0 4px var(--primary-soft);
  animation: avatarPop .4s cubic-bezier(.2,.9,.3,1.3);
}

@keyframes avatarPop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  animation: fadeIn .35s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(15,18,30,.08); border-color: #d3d8e6; }
.stat-card .label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 23px; font-weight: 700; margin-top: 8px; letter-spacing: -0.01em; transition: color .18s; }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.success { color: var(--success); }

/* ---------- Tables ---------- */
.admin-page { animation: fadeIn .3s ease; }
.table-wrap { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; animation: fadeIn .3s ease; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #fafafc; font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
code { background: #f1f2f5; padding: 2px 7px; border-radius: 5px; font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); }

.tag { padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; letter-spacing: .01em; transition: box-shadow .15s; }
.tag.truthu { background: var(--danger-bg); color: var(--danger); box-shadow: 0 0 0 rgba(179,65,58,0); }
.tag.hoanvi { background: var(--success-bg); color: var(--success); box-shadow: 0 0 0 rgba(31,122,82,0); }
.tag.dadu { background: #eef0f4; color: var(--muted); }
tr:hover .tag.truthu, .driver-card:hover .tag.truthu { box-shadow: 0 0 10px rgba(179,65,58,.25); }
tr:hover .tag.hoanvi, .driver-card:hover .tag.hoanvi { box-shadow: 0 0 10px rgba(31,122,82,.25); }
.badge { padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 600; background: #eef0f4; color: var(--muted); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.periods-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.period-chip {
  padding: 7px 15px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.period-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 14px rgba(44,67,115,.3); }
.period-chip:hover:not(.active) { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="text"], .toolbar input:not([type]) {
  padding: 9px 13px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 13px; min-width: 260px; background: #fff; font-family: var(--font);
}
.toolbar input:focus { outline: none; border-color: var(--primary); }
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-group select {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 13px; background: #fff; font-family: var(--font); color: var(--text); cursor: pointer;
}
.filter-group select:focus { outline: none; border-color: var(--primary); }
.period-chip .chip-actions { display: inline-flex; gap: 6px; margin-left: 8px; opacity: 0; transition: opacity .1s; }
.period-chip:hover .chip-actions { opacity: 1; }
.period-chip.active .chip-actions { opacity: 1; }
.period-chip .chip-actions button { border: none; background: transparent; cursor: pointer; color: inherit; font-size: 12px; padding: 0; line-height: 1; opacity: .75; }
.period-chip .chip-actions button:hover { opacity: 1; }
.period-chip { display: inline-flex; align-items: center; }

/* ---------- Driver cards ---------- */
.driver-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 14px;
  transition: transform .18s ease, box-shadow .18s ease;
  animation: fadeIn .35s ease;
}
.driver-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15,18,30,.07); }
.driver-card .period-title { font-size: 14.5px; font-weight: 700; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.driver-card .row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.driver-card .row:last-child { border-bottom: none; }
.driver-card .label { color: var(--muted); }
.driver-card .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.driver-card .value.neg { color: var(--danger); }
.driver-card .value.pos { color: var(--success); }

/* Thẻ theo kỳ kiểu mới: chia nhóm + hộp kết quả nổi bật */
.driver-card { border-top: 3px solid var(--border); }
.driver-card.card-truthu { border-top-color: var(--danger); }
.driver-card.card-hoanvi { border-top-color: var(--success); }
.driver-card.card-neutral { border-top-color: var(--border); }

.dc-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 16px 0 8px;
}
.dc-section-label:first-of-type { margin-top: 0; }
.dc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.dc-item {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px;
}
.dc-item .dc-k { color: var(--muted); }
.dc-item .dc-v { font-weight: 600; font-variant-numeric: tabular-nums; }

.dc-result {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 18px; padding: 16px 20px; border-radius: 12px;
  transition: box-shadow .2s;
}
.dc-result.neg { background: var(--danger-bg); }
.dc-result.pos { background: var(--success-bg); }
.dc-result.unknown { background: #eef0f4; }
.dc-result-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.dc-result-value { font-size: 22px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dc-result.neg .dc-result-label, .dc-result.neg .dc-result-value { color: var(--danger); }
.dc-result.pos .dc-result-label, .dc-result.pos .dc-result-value { color: var(--success); }
.dc-result.unknown .dc-result-label, .dc-result.unknown .dc-result-value { color: var(--muted); }
.driver-card:hover .dc-result.neg { box-shadow: 0 0 0 1px rgba(179,65,58,.15), 0 0 18px rgba(179,65,58,.15); }
.driver-card:hover .dc-result.pos { box-shadow: 0 0 0 1px rgba(31,122,82,.15), 0 0 18px rgba(31,122,82,.15); }

.dc-result-extra { display: flex; gap: 20px; }
.dc-result-extra > div { display: flex; flex-direction: column; }
.dc-result-extra span { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; }
.dc-result-extra strong { font-size: 14.5px; margin-top: 3px; color: var(--text); }

@media (max-width: 780px) {
  .dc-grid { grid-template-columns: 1fr; }
  .dc-result { flex-direction: column; align-items: flex-start; }
}

.hint { color: #9298a3; font-size: 12px; margin-top: 6px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 13px; }

.empty-state { text-align: center; padding: 64px 20px; color: var(--muted); font-size: 13.5px; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--sidebar-bg); color: #fff; padding: 12px 18px; border-radius: 9px;
  font-size: 13px; opacity: 0; transition: opacity .25s ease, transform .25s cubic-bezier(.2,.9,.3,1.2); transform: translateY(10px) scale(.96);
  box-shadow: 0 10px 24px rgba(0,0,0,.25); max-width: 320px;
  border-left: 3px solid #5b7cd6;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(12,14,24,.5);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.active { display: flex; animation: fadeIn .18s ease; }
.modal { background: #fff; border-radius: var(--radius); padding: 28px; width: 400px; max-height: 82vh; overflow-y: auto; animation: modalIn .22s cubic-bezier(.2,.9,.3,1.2); }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { margin: 0 0 18px; font-size: 16px; font-weight: 700; }
.modal-close-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Responsive: điện thoại ---------- */
@media (max-width: 780px) {
  .card { width: 100%; max-width: 360px; padding: 26px 22px; }

  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 4px;
  }
  .sidebar .brand { padding: 4px 10px 4px 4px; flex-shrink: 0; }
  .nav-item { margin-bottom: 0; flex-shrink: 0; white-space: nowrap; }
  .sidebar-footer { margin-top: 0; padding-top: 0; border-top: none; border-left: 1px solid rgba(255,255,255,.08); padding-left: 8px; flex-shrink: 0; }
  .sidebar-footer .who { display: none; }

  .page-header { padding: 16px 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .content { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 18px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type="text"], .toolbar input:not([type]) { min-width: 0; width: 100%; }

  .table-wrap { overflow-x: auto; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }

  .driver-card { padding: 18px 20px; }
  .modal { width: 92vw !important; padding: 22px; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Kéo-thả file Excel vào trang */
body.drag-over::after {
  content: 'Thả file Excel vào đây để import';
  position: fixed;
  inset: 0;
  background: rgba(44, 67, 115, 0.92);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  pointer-events: none;
  border: 4px dashed #fff;
}

/* Thẻ tổng số tiền cần thanh toán + QR (trang tài xế) - hiệu ứng neon để thu hút chú ý */
.payment-summary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0b1230 0%, #131b3f 55%, #0b1230 100%);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 18px;
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(56, 225, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(56,225,255,.08), 0 0 24px rgba(56,225,255,.25), 0 0 60px rgba(56,225,255,.08);
  animation: neonPulse 2.8s ease-in-out infinite;
}
.payment-summary::before {
  content: '';
  position: absolute;
  inset: -60% -20%;
  background: radial-gradient(circle, rgba(56,225,255,.18) 0%, transparent 65%);
  animation: neonSweep 6s linear infinite;
  pointer-events: none;
}
.payment-summary > * { position: relative; z-index: 1; }
.payment-summary-label { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #7fe8ff; }
.payment-summary-amount {
  font-size: 30px; font-weight: 800; margin-top: 4px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 8px rgba(56,225,255,.85), 0 0 22px rgba(56,225,255,.5), 0 0 40px rgba(56,225,255,.25);
}
.payment-summary .btn.secondary {
  background: rgba(56,225,255,.12);
  color: #baf6ff;
  border: 1px solid rgba(56,225,255,.55);
  box-shadow: 0 0 12px rgba(56,225,255,.25);
  transition: background .15s, box-shadow .2s, transform .05s;
}
.payment-summary .btn.secondary:hover { background: rgba(56,225,255,.22); box-shadow: 0 0 18px rgba(56,225,255,.45); }
.payment-summary .btn.secondary:active { transform: scale(.97); }

@keyframes neonPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(56,225,255,.08), 0 0 24px rgba(56,225,255,.25), 0 0 60px rgba(56,225,255,.08); }
  50% { box-shadow: 0 0 0 1px rgba(56,225,255,.16), 0 0 34px rgba(56,225,255,.4), 0 0 80px rgba(56,225,255,.16); }
}
@keyframes neonSweep {
  0% { transform: translateX(-30%) rotate(0deg); }
  100% { transform: translateX(30%) rotate(360deg); }
}

.qr-box {
  width: 100%;
  margin-top: 4px;
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--text);
  animation: qrReveal .25s ease-out;
  box-shadow: 0 0 0 1px rgba(56,225,255,.4), 0 0 24px rgba(56,225,255,.3);
}
.qr-box img { max-width: 240px; width: 100%; border-radius: 8px; }
.qr-box .hint { color: var(--muted); margin-top: 10px; margin-bottom: 0; }
.qr-box code { font-size: 14px; font-weight: 700; color: var(--primary); }
.qr-countdown { margin: 10px 0 0; font-weight: 700; color: var(--primary); }
.qr-countdown.expired { color: var(--danger); }

/* Khung thương hiệu VNPAY-QR bắt buộc theo yêu cầu VNPay - QR động được đặt CHÍNH XÁC vào
   vùng trống của khung (toạ độ % đo tay trên file gốc VNPay gửi, xem web/assets/vnpay-qr-frame.png). */
.vnpay-qr-frame {
  position: relative;
  width: 260px;
  max-width: 100%;
  aspect-ratio: 400 / 432;
  margin: 0 auto;
  background-image: url('./assets/vnpay-qr-frame.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.vnpay-qr-frame img {
  position: absolute;
  left: 14%;
  top: 18.06%;
  width: 72%;
  height: 66.67%;
  border-radius: 4px;
}

@keyframes qrReveal {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 780px) {
  .payment-summary { flex-direction: column; align-items: stretch; text-align: center; }
}
