:root {
  --primary: #1d4ed8;
  --primary-600: #2563eb;
  --primary-50: #eff6ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f5f7fb;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Be Vietnam Pro', Inter, Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

/* ---------- Card ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { font-size: 15px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 20px; }

/* ---------- Form ---------- */
.label { display: block; font-size: 13px; font-weight: 500; color: #334155; margin-bottom: 6px; }
.label.req::after { content: ' *'; color: #dc2626; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 9px 12px; font-size: 14px; line-height: 1.4;
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.input::placeholder { color: #94a3b8; }
.input:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input[readonly], .input:disabled { background: #f1f5f9; color: #475569; }
.input.is-invalid { border-color: #dc2626; background: #fef2f2; }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.input { resize: vertical; }
.input-sm { padding: 7px 10px; font-size: 13px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.choice {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  cursor: pointer; background: #fff; transition: all .15s;
}
.choice:hover { border-color: #93c5fd; }
.choice input { margin-top: 2px; accent-color: var(--primary); width: 16px; height: 16px; flex-shrink: 0; }
.choice.on { border-color: var(--primary-600); background: var(--primary-50); box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.choice-group.is-invalid .choice { border-color: #fca5a5; }

.tag-opt { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; border: 1px solid #cbd5e1; font-size: 12px; cursor: pointer; background: #fff; user-select: none; transition: all .12s; }
.tag-opt:hover { border-color: #93c5fd; }
.tag-opt.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 9px; padding: 9px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; font-family: inherit; line-height: 1.3;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
html .btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
html .btn-outline { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-outline:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }
.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover { background: #f1f5f9; }
html .btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
html .btn-danger-soft { background: #fef2f2; color: #dc2626; }
.btn-danger-soft:hover { background: #fee2e2; }
html .btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
html .btn-demo { background: #fffbeb; border: 1px dashed #f59e0b; color: #b45309; }
.btn-demo:hover { background: #fef3c7; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { padding: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pending { background: #fef3c7; color: #92400e; }
.st-received { background: #dbeafe; color: #1e40af; }
.st-processing { background: #ede9fe; color: #5b21b6; }
.st-done { background: #d1fae5; color: #065f46; }
.st-supplement { background: #ffedd5; color: #9a3412; }
.st-accepted { background: #e0f2fe; color: #075985; }
.st-testing { background: #fae8ff; color: #86198f; }
.st-reviewing { background: #e0e7ff; color: #3730a3; }
.st-rejected { background: #fee2e2; color: #991b1b; }
.flow-red { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }
.flow-green { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; font-weight: 600; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-step { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #f1f5f9; color: #475569; font-weight: 500; }

/* ---------- Sidebar ---------- */
.sidebar { width: 264px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #475569; font-weight: 500; transition: background .15s, color .15s; }
.nav-link svg { width: 18px; height: 18px; color: #94a3b8; }
.nav-link:hover { background: #f1f5f9; color: var(--ink); }
.nav-link.active { background: var(--primary-50); color: var(--primary); }
.nav-link.active svg { color: var(--primary); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; background: #fef3c7; color: #92400e; padding: 1px 7px; border-radius: 999px; }

/* ---------- Table ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: #64748b; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl-wrap { overflow-x: auto; }

/* ---------- Accordion (form gửi hồ sơ) ---------- */
.acc { scroll-margin-top: 84px; }
.acc-h { display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer; user-select: none; }
.acc-num { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: #eff6ff; color: var(--primary); flex-shrink: 0; }
.acc.valid .acc-num { background: #d1fae5; color: #047857; }
.acc.invalid .acc-num { background: #fee2e2; color: #b91c1c; }
.acc-chev { transition: transform .2s; color: #94a3b8; }
.acc.open .acc-chev { transform: rotate(180deg); }
.acc-b { display: none; border-top: 1px solid var(--line); padding: 20px; }
.acc.open .acc-b { display: block; }
.acc.open { box-shadow: 0 4px 16px rgba(15, 23, 42, .06); }
.sub-h { font-size: 13px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.sub-h::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fafbfd; }

/* ---------- Stepper trạng thái ---------- */
.stepper { display: flex; align-items: flex-start; }
.stepper .st { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; font-size: 12px; color: #94a3b8; }
.stepper .st::before { content: ''; position: absolute; top: 15px; left: -50%; right: 50%; height: 2px; background: #e2e8f0; z-index: 0; }
.stepper .st:first-child::before { display: none; }
.stepper .st.done::before, .stepper .st.cur::before { background: var(--primary-600); }
.stepper .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid #e2e8f0; position: relative; z-index: 1; margin-bottom: 6px; }
.stepper .ic svg { width: 15px; height: 15px; }
.stepper .st.done .ic { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.stepper .st.cur .ic { border-color: var(--primary-600); color: var(--primary-600); box-shadow: 0 0 0 4px rgba(37, 99, 235, .15); }
.stepper .st.done, .stepper .st.cur { color: var(--ink); font-weight: 600; }
.stepper .st.fail .ic { background: #dc2626; border-color: #dc2626; color: #fff; }
.stepper .st.fail { color: #b91c1c; font-weight: 600; }
.stepper-7 .st { font-size: 11.5px; }
@media (max-width: 640px) { .stepper .st { font-size: 10.5px; } .stepper .ic { width: 26px; height: 26px; } .stepper .st::before { top: 12px; } }
.tl-i.cust::before { border-color: #f59e0b; }

/* ---------- Panel thao tác theo bước ---------- */
.action-card { border: 1.5px solid #bfdbfe; box-shadow: 0 6px 24px rgba(29, 78, 216, .08); }
.action-card > .card-h { background: linear-gradient(90deg, #eff6ff, #fff); border-radius: 14px 14px 0 0; }
.ck-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.ck-row:hover { border-color: #93c5fd; }
.ck-row input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.ck-row.on { border-color: #86efac; background: #f0fdf4; }
.callout { border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.callout svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.callout.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.callout.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.callout.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.callout.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---------- Biểu mẫu in (A4) ---------- */
.modal.doc-modal { max-width: 880px; }
.doc-scroll { max-height: 75vh; overflow-y: auto; background: #e2e8f0; padding: 16px; border-radius: 0 0 16px 16px; }
.doc { background: #fff; color: #000; font-family: 'Times New Roman', Times, serif; font-size: 14.5px; line-height: 1.45; padding: 36px 44px; max-width: 794px; margin: 0 auto; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.doc .doc-head { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; font-size: 13px; }
.doc .b { font-weight: 700; } .doc .i { font-style: italic; } .doc .u { text-decoration: underline; }
.doc .c { text-align: center; } .doc .r { text-align: right; white-space: nowrap; }
.doc h1 { text-align: center; font-size: 19px; font-weight: 700; margin: 22px 0 2px; text-transform: uppercase; }
.doc .doc-sub { text-align: center; font-style: italic; margin-bottom: 14px; }
.doc h2 { font-size: 15px; font-weight: 700; margin: 14px 0 4px; }
.doc p { margin: 6px 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.doc th, .doc td { border: 1px solid #444; padding: 4px 6px; font-size: 13.5px; vertical-align: top; }
.doc th { background: #f1f5f9; font-weight: 700; }
.doc table.kvt td:first-child { width: 34%; color: #333; }
.doc .note { border: 1px dashed #b45309; background: #fffbeb; padding: 6px 10px; }
.doc .doc-sign { display: grid; gap: 12px; text-align: center; margin-top: 26px; font-size: 13.5px; }
.doc .doc-sig { height: 70px; display: grid; place-items: center; }
.doc .doc-stamp { border: 2px solid #b91c1c; color: #b91c1c; border-radius: 6px; padding: 2px 10px; font-weight: 700; transform: rotate(-6deg); font-family: Arial, sans-serif; font-size: 12px; }
@media (max-width: 640px) { .doc { padding: 18px 14px; font-size: 13px; } .doc-scroll { padding: 6px; } .doc .doc-head { grid-template-columns: 1fr; } }

/* ---------- Timeline ---------- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: #e2e8f0; }
.tl-i { position: relative; padding-bottom: 16px; }
.tl-i:last-child { padding-bottom: 0; }
.tl-i::before { content: ''; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--primary-600); }

/* ---------- Detail key/value ---------- */
.kv { display: grid; grid-template-columns: minmax(100px, 150px) 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }

/* ---------- Toast / Modal ---------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: #0f172a; color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(15, 23, 42, .25); animation: tin .2s ease; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.ok svg { color: #34d399; } .toast.err svg { color: #f87171; } .toast.info svg { color: #93c5fd; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fin .15s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 25px 60px rgba(15, 23, 42, .3); animation: tin .2s ease; }
.modal.lg { max-width: 760px; }
@keyframes fin { from { opacity: 0; } to { opacity: 1; } }
.drawer-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 80; animation: fin .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--bg); z-index: 81; display: flex; flex-direction: column; box-shadow: -20px 0 50px rgba(15, 23, 42, .2); animation: din .22s ease; }
@keyframes din { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.stat { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); }

.auth-bg { background: radial-gradient(1200px 500px at 0% 0%, #dbeafe 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #e0e7ff 0%, transparent 55%), #f8fafc; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 12px; color: #cbd5e1; }

[data-lucide] { display: inline-block; }

@media print {
  .no-print, aside, header, #toasts { display: none !important; }
  body.print-doc > *:not(.modal-bg) { display: none !important; }
  body.print-doc .modal-bg { position: static; background: none; padding: 0; display: block; overflow: visible; }
  body.print-doc .modal { box-shadow: none; max-width: none; border-radius: 0; }
  body.print-doc .doc-scroll { max-height: none; overflow: visible; background: #fff; padding: 0; }
  body.print-doc .doc { box-shadow: none; padding: 0; max-width: none; }
  body { background: #fff; }
  .lg\:pl-64 { padding-left: 0 !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

.no-sb { scrollbar-width: none; }
.no-sb::-webkit-scrollbar { display: none; }
