/* KYC Elevate Flow - giao diện fintech/compliance. Xem DESIGN.md. Không dùng inline style (CSP). */
:root {
  --navy: #0b1f3a; --navy-2: #12305a;
  --primary: #1d4ed8; --primary-h: #1e40af; --primary-soft: #e8eefc;
  --bg: #f3f5f9; --card: #fff; --text: #14213d; --muted: #566179; --border: #d8dee9; --border-2: #eaeef5;
  --ok: #0f7a4d; --ok-bg: #def5e9; --danger: #b42318; --danger-bg: #fde8e6;
  --warn: #8a5a00; --warn-bg: #fff1cc; --info: #1d4ed8; --info-bg: #dfe9fd; --grey: #475066; --grey-bg: #e9ecf2;
  --radius: 10px; --shadow: 0 1px 2px rgba(11,31,58,.06), 0 4px 14px rgba(11,31,58,.05);
  --focus: 0 0 0 2px #fff, 0 0 0 4px #1d4ed8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); overflow-wrap: anywhere; }
a { color: var(--primary); }
a:hover { color: var(--primary-h); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; background: #eef1f7; padding: 1px 6px; border-radius: 4px; overflow-wrap: anywhere; word-break: break-all; }
.muted { color: var(--muted); }
.text-error { color: var(--danger); }
.prewrap { white-space: pre-wrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: #fff; color: var(--navy); padding: 8px 14px; border-radius: 6px; z-index: 10; }
.skip-link:focus { left: 8px; }

/* Header */
.site-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 24px; background: var(--navy); color: #fff; }
.site-header a { color: #fff; }
.site-header :focus-visible { box-shadow: 0 0 0 2px var(--navy), 0 0 0 4px #93b4ff; }
.site-header__brand, .brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: .2px; color: inherit; }
.brand__mark { width: 30px; height: 30px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 2px 6px; flex: 1; min-width: 0; }
.nav__link { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: #cfd9ee; font-weight: 500; font-size: 15px; }
.nav__link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav__link.is-active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.site-header__user { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 14px; }
.site-header__name { color: #e6ecf8; }
.site-header .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.site-header .btn-secondary:hover { background: rgba(255,255,255,.12); color: #fff; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--primary-soft); color: #1e3a8a; font-weight: 600; white-space: nowrap; }
.site-header .tag { background: rgba(255,255,255,.18); color: #fff; }

/* Page */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 56px; }
.page__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; margin-bottom: 18px; }
.page__head h1, h1 { font-size: 24px; line-height: 1.25; margin: 0 0 12px; }
.page__head h1 { margin: 0; }
.body--public { background: linear-gradient(180deg, var(--navy) 0, var(--navy-2) 200px, var(--bg) 200px); min-height: 100vh; }
.body--public .page { max-width: 560px; padding-top: 28px; }
.public-brand { display: flex; justify-content: center; color: #fff; margin-bottom: 24px; }
.public-brand .brand { font-size: 19px; }
.public-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card--narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card--form { max-width: 720px; }
.card--public { text-align: center; padding: 32px 28px; }
.card__title { margin: 0 0 14px; font-size: 18px; line-height: 1.3; }
.card h3 { font-size: 15px; margin: 22px 0 8px; color: var(--navy); }
.card h3:first-child { margin-top: 0; }
.card--public .card__title { font-size: 22px; }
.card--public p { color: var(--muted); }
.steps { text-align: left; list-style: none; counter-reset: s; padding: 0; margin: 18px 0; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; color: var(--text); }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.icon-circle { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--ok-bg); color: var(--ok); font-size: 32px; font-weight: 700; }
.icon-circle--grey { background: var(--grey-bg); color: var(--grey); }

/* Forms */
.form .field, .filters .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form .muted { font-size: 14px; margin: 0; }
label { font-weight: 600; font-size: 15px; }
input, select, textarea { font: inherit; color: var(--text); padding: 10px 12px; min-height: 44px; border: 1px solid #8e99b0; border-radius: 8px; background: #fff; width: 100%; }
textarea { min-height: 88px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.3); }
input::placeholder { color: #6b7590; }
.form > .btn-primary { margin-top: 12px; }
.form--block > .btn-primary { width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.filters .field { margin-bottom: 0; flex: 1 1 200px; min-width: 0; }
.filters .field--grow { flex: 2 1 260px; }
.filters .btn { min-height: 44px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; min-height: 44px; padding: 8px 18px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: #8e99b0; }
.btn-secondary:hover { background: #f1f4fa; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1c12; color: #fff; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.inline-form { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
td.actions { margin-top: 0; display: table-cell; }
td.actions > * { margin: 2px 4px 2px 0; }
.form .actions { margin-top: 4px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; border-left-width: 5px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-error { background: var(--danger-bg); border-color: #e58d84; color: #7a1a11; }
.alert-success { background: var(--ok-bg); border-color: #6fc59b; color: #0b4d31; }
.alert-info { background: var(--info-bg); border-color: #8fabf0; color: #173e9a; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-2); vertical-align: middle; overflow-wrap: break-word; }
.table td[data-label="Email"] { min-width: 220px; overflow-wrap: anywhere; }
.table td.actions { white-space: nowrap; min-width: 140px; }
.table td[data-label="Tạo lúc"], .table td[data-label="Mã"] { white-space: nowrap; }
.table td[data-label="Khách"] { min-width: 100px; }
.table thead th { background: #f6f8fc; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfe; }
.table--compact th, .table--compact td { padding: 8px 12px; font-size: 14px; vertical-align: top; }
.table--compact tbody th { width: 34%; color: var(--muted); font-weight: 600; }
.list-meta { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.empty { text-align: center; background: var(--card); border: 1px dashed #98a3ba; border-radius: var(--radius); padding: 40px 20px; color: var(--muted); margin: 0; }
.empty strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.card .empty { border: 0; padding: 20px 0; background: none; }

/* Badges: chữ đậm trên nền nhạt, tương phản >= 4.5 */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 1.4; background: var(--grey-bg); color: var(--grey); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--approved { background: var(--ok-bg); color: var(--ok); }
.badge--declined { background: var(--danger-bg); color: var(--danger); }
.badge--in-review, .badge--awaiting-user, .badge--resubmitted { background: var(--warn-bg); color: var(--warn); }
.badge--in-progress { background: var(--info-bg); color: #1741b0; }
.badge--expired, .badge--abandoned, .badge--kyc-expired, .badge--not-started, .badge--revoked { background: var(--grey-bg); color: var(--grey); }
.badge--revoked { text-decoration: line-through; }

/* Key-value, timeline */
.kv { display: grid; grid-template-columns: minmax(130px, 210px) 1fr; gap: 0 20px; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid var(--border-2); margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { font-weight: 500; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.result-block { border: 1px solid var(--border-2); background: #fbfcfe; border-radius: 8px; padding: 6px 16px; margin-bottom: 10px; }
.copybox { display: flex; flex-wrap: wrap; gap: 8px; }
.copybox__input { flex: 1 1 280px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14px; background: #f6f8fc; user-select: all; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline__item { position: relative; padding: 4px 0 14px 14px; }
.timeline__item::before { content: ""; position: absolute; left: -26px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px #fff; }
.timeline__item time { display: block; color: var(--muted); font-size: 13px; }
.warnings { padding-left: 20px; margin: 0; }
.warnings li { margin-bottom: 8px; }
.warning--error { color: var(--danger); }
.warning--warning { color: var(--warn); }
.gallery { display: flex; flex-wrap: wrap; gap: 14px; }
.gallery__item { margin: 0; width: 240px; max-width: 100%; }
.gallery__item img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #eef1f7; }
.gallery__item figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.raw summary { cursor: pointer; margin: 18px 0 8px; font-weight: 600; padding: 6px 0; }
.secret { display: block; font-size: 20px; padding: 14px 16px; user-select: all; background: #f0f4fb; border: 1px dashed #8fa3c7; border-radius: 8px; text-align: center; }
.pager { display: flex; gap: 12px; margin-top: 14px; }
.pager a { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; text-decoration: none; font-weight: 600; }
.case-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 14px; }

@media (max-width: 640px) {
  .site-header { padding: 10px 14px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; flex-basis: 100%; order: 3; padding-bottom: 2px; }
  .nav__link { white-space: nowrap; }
  .site-header { gap: 6px 12px; }
  .site-header__brand { order: 1; }
  .site-header__user { order: 2; margin-left: auto; flex-wrap: nowrap; }
  .site-header__name { display: none; }
  .site-header__user .nav__link { padding: 6px 8px; font-size: 14px; }
  .page { padding: 18px 14px 40px; }
  .card { padding: 18px 16px; }
  .page__head .btn { width: 100%; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; padding-top: 10px; }
  .kv dd { padding-top: 2px; }
  .filters .btn, .copybox .btn { width: 100%; }
  /* bảng -> thẻ trên điện thoại */
  .table--stack thead { position: absolute; left: -9999px; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table--stack td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .table--stack td[data-label="Email"], .table--stack td[data-label="Khách"] { min-width: 0; }
  .table--stack td.actions { white-space: normal; min-width: 0; display: flex; justify-content: flex-start; padding-top: 8px; flex-wrap: wrap; }
  .table--stack td.actions::before { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav__link { transition: background-color .15s, border-color .15s; }
}
.btn[hidden] { display: none; }

/* Chi tiết kết quả KYC (bố cục giống dashboard Didit) */
.result-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-h); }
.panel { border: 1px solid var(--border-2); background: #fbfcfe; border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
.panel__head h3, .panel h4 { margin: 0; }
.panel h4 { margin-top: 14px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; align-items: start; }
.panel-grid .panel { margin-bottom: 0; }
.doc-images { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px 0 4px; }
.doc-images__item { margin: 0; min-width: 0; }
.doc-images__item img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #eef1f7; }
.doc-images__item figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.hits { margin: 0; padding-left: 18px; }
@media (max-width: 640px) { .doc-images { grid-template-columns: 1fr; } }
