/* ==== Tải hoá đơn điện tử — giao diện ==== */
:root {
  --blue: #1f4e79;
  --blue-dark: #163a5c;
  --blue-light: #eaf1f8;
  --green: #1e7e46;
  --red: #b42318;
  --border: #d6dde6;
  --text: #1c2733;
  --muted: #5b6b7c;
  --bg: #f2f5f9;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}

/* ---- Top bar ---- */
.topbar {
  background: linear-gradient(90deg, var(--blue-dark), var(--blue));
  color: #fff; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 8px; background: #fff; color: var(--blue);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.title { font-size: 17px; font-weight: 700; }
.subtitle { font-size: 12px; opacity: .8; }
.userbox { display: flex; align-items: center; gap: 12px; }
.mst-badge { background: rgba(255,255,255,.15); padding: 6px 12px; border-radius: 20px; font-size: 13px; }

/* ---- Buttons / inputs ---- */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 14px;
  transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; border-color: rgba(120,140,160,.5); }
.topbar .btn.ghost { color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 14px; }
input[type=text], input[type=password], input[type=date], select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid #9cc0e4; border-color: var(--blue); }
label { display: block; margin: 12px 0 5px; font-weight: 600; font-size: 13px; color: var(--muted); }

/* ---- Cards ---- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin: 16px auto; max-width: 1200px;
  box-shadow: 0 1px 3px rgba(20,40,70,.06);
}

/* ---- Login ---- */
.login-wrap { display: flex; justify-content: center; padding: 48px 16px; }
.login-card { width: 420px; }
.login-card h2 { margin: 0 0 6px; font-size: 20px; color: var(--blue-dark); }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.captcha-row { display: flex; gap: 8px; align-items: stretch; }
.captcha-box {
  min-width: 150px; height: 46px; border: 1px solid var(--border); border-radius: 7px;
  background: #fbfcfe; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.captcha-box svg { height: 44px; }
.captcha-row input { flex: 1; }
.captcha-row .btn { padding: 0 12px; font-size: 18px; }
.auto-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600;
  color: var(--text); cursor: pointer; margin: 14px 0 2px; }
.auto-toggle input { width: auto; }
.auto-hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.auto-hint.warn { color: #9a6a00; }
.error {
  background: #fdeceb; color: var(--red); border: 1px solid #f4c7c3;
  padding: 9px 12px; border-radius: 7px; margin-top: 12px; font-size: 13px;
  white-space: pre-wrap;
}

/* ---- Filter ---- */
.filter-grid { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr 1fr 1.4fr auto; gap: 14px; align-items: end; }
.filter-grid .field label { margin-top: 0; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button {
  flex: 1; border: 0; background: #fff; padding: 9px 10px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.seg button.active { background: var(--blue); color: #fff; font-weight: 600; }
@media (max-width: 980px) { .filter-grid { grid-template-columns: 1fr 1fr; } }

/* ---- Result ---- */
.result-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.summary { font-size: 14px; color: var(--muted); }
.summary b { color: var(--text); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chk { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 9px; }
table { border-collapse: collapse; width: 100%; min-width: 980px; }
thead th {
  background: var(--blue-light); color: var(--blue-dark); text-align: left;
  padding: 9px 10px; font-size: 12.5px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid #eef2f6; vertical-align: top; }
tbody tr:hover { background: #f7fafd; }
th.num, td.num { text-align: right; white-space: nowrap; }
.w-chk { width: 34px; } .w-stt { width: 44px; } .w-act { width: 168px; }
.party-name { font-weight: 600; }
.party-mst { color: var(--muted); font-size: 12px; }
.status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef2f6; }
.status.s1 { background: #e2f2e8; color: var(--green); }
.status.s6 { background: #fdeceb; color: var(--red); }
.status.s2, .status.s3 { background: #fff4e0; color: #9a6a00; }
.availability { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.availability.yes { background: #e2f2e8; color: var(--green); }
.availability.no { background: #fdeceb; color: var(--red); }
.row-actions { display: flex; gap: 5px; }
.row-actions .btn { padding: 4px 8px; font-size: 12.5px; }

.pager { display: flex; gap: 6px; justify-content: center; padding: 14px 0 2px; flex-wrap: wrap; }
.pager button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 5px 11px; cursor: pointer;
}
.pager button.cur { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(15,25,40,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal-box {
  background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden;
}
.preview-box { width: min(880px, 96vw); height: min(94vh, 1100px); }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--blue-light); color: var(--blue-dark); font-weight: 700;
}
.preview-note { background: #fff8e6; color: #8a6100; font-size: 12.5px; padding: 6px 14px; }
#previewFrame { flex: 1; border: 0; width: 100%; background: #fff; }

.job-box { width: min(560px, 94vw); }
.job-body { padding: 18px; }
.progress { height: 14px; background: #e8edf3; border-radius: 8px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--blue); transition: width .3s; }
.job-text { margin-top: 10px; color: var(--muted); font-size: 13px; }
.job-errors {
  margin-top: 10px; max-height: 160px; overflow: auto; background: #fdeceb; color: var(--red);
  border-radius: 7px; padding: 8px 12px; font-size: 12.5px;
}
.job-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #23303e; color: #fff; padding: 11px 18px; border-radius: 9px;
  font-size: 13.5px; z-index: 99; max-width: 88vw; white-space: pre-wrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.toast.err { background: var(--red); }
