/* Cầm Đồ Hoàng Tiến Phát — giao diện app */
:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --ink: #1b2130;
  --ink-2: #3a4152;
  --muted: #6c7282;
  --line: #e3dfd6;
  --line-2: #efece5;
  --brand: #16233f;
  --brand-2: #22335a;
  --gold: #c08a1e;
  --gold-soft: #f6ead0;
  --blue: #2a5fb0; --blue-soft: #e5edf9;
  --green: #1d7d52; --green-soft: #e1f2e9;
  --red: #b8392a; --red-soft: #fbe6e2;
  --amber: #b06a00; --amber-soft: #fbefd9;
  --gray-soft: #eceae5;
  --side-ink: #c9cfdd;
  --shadow: 0 1px 2px rgba(20, 25, 40, .05), 0 4px 16px rgba(20, 25, 40, .05);
  --radius: 12px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11141b; --surface: #191d26; --surface-2: #1f2430; --ink: #e9ebf0; --ink-2: #c8ccd6; --muted: #8d93a3;
    --line: #2c3240; --line-2: #242a36; --brand: #0c1222; --brand-2: #1a2440; --gold: #e0ad45; --gold-soft: #3a2f17;
    --blue: #7aa7ec; --blue-soft: #1c2a42; --green: #5cc495; --green-soft: #15322a; --red: #f08575; --red-soft: #3b1f1c;
    --amber: #f0b45a; --amber-soft: #3a2c14; --gray-soft: #262b36; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11141b; --surface: #191d26; --surface-2: #1f2430; --ink: #e9ebf0; --ink-2: #c8ccd6; --muted: #8d93a3;
  --line: #2c3240; --line-2: #242a36; --brand: #0c1222; --brand-2: #1a2440; --gold: #e0ad45; --gold-soft: #3a2f17;
  --blue: #7aa7ec; --blue-soft: #1c2a42; --green: #5cc495; --green-soft: #15322a; --red: #f08575; --red-soft: #3b1f1c;
  --amber: #f0b45a; --amber-soft: #3a2c14; --gray-soft: #262b36; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body.cd-body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--font); font-variant-numeric: tabular-nums; }
body.cd-noscroll { overflow: hidden; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
small { font-size: 12.5px; }
.cd-ic { width: 18px; height: 18px; flex: none; }
.cd-boot, .cd-loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 60px 16px; color: var(--muted); }
.cd-t-muted { color: var(--muted); } .cd-t-red { color: var(--red); } .cd-t-green { color: var(--green); } .cd-t-amber { color: var(--amber); } .cd-t-gold { color: var(--gold); }
.cd-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; letter-spacing: .3px; }
.cd-mb { margin: 0 0 12px; }
.cd-pre { white-space: pre-line; margin: 0; }
.r { text-align: right; }

/* ---------- shell ---------- */
.cd-shell { display: flex; min-height: 100vh; }
.cd-side {
  width: 248px; flex: none; background: var(--brand); color: var(--side-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; gap: 14px;
}
.cd-brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px 6px; }
.cd-logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, #e6b54e, #b07c12); color: #1a1408; font-weight: 800; letter-spacing: .2px; font-size: 13px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
}
.cd-brand-name { color: #fff; font-weight: 700; font-size: 15.5px; line-height: 1.2; }
.cd-brand-sub { font-size: 12px; opacity: .7; }
.cd-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.cd-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; text-decoration: none; font-weight: 500; }
.cd-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.cd-nav a.active { background: rgba(224,173,69,.14); color: #f3cf7e; }
.cd-side-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.cd-side-user-txt { flex: 1; min-width: 0; line-height: 1.25; }
.cd-side-user-txt b { color: #fff; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cd-side-user-txt small { opacity: .7; }
.cd-side .cd-icon-btn { color: var(--side-ink); }
.cd-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cd-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.cd-top h1 { font-size: 19px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-top-search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; width: min(380px, 40vw); color: var(--muted); }
.cd-top-search input { border: 0; outline: 0; background: transparent; padding: 9px 0; font: inherit; color: var(--ink); width: 100%; }
.cd-view { padding: 22px 28px 60px; max-width: 1360px; width: 100%; }
.cd-scrim, .cd-bottom, .cd-only-m { display: none; }

/* ---------- buttons, inputs ---------- */
.cd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 9px;
  padding: 9px 15px; font: 600 14px/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.cd-btn:active { transform: translateY(1px); }
.cd-btn:disabled { opacity: .6; cursor: default; }
.cd-btn-primary { background: var(--brand); color: #fff; }
.cd-btn-primary:hover { background: var(--brand-2); }
.cd-btn-gold { background: linear-gradient(140deg, #e6b54e, #c08a1e); color: #1a1408; }
.cd-btn-gold:hover { filter: brightness(1.05); }
.cd-btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.cd-btn-ghost:hover { border-color: var(--muted); }
.cd-btn-danger { background: var(--red); color: #fff; }
.cd-btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.cd-btn-sm .cd-ic { width: 15px; height: 15px; }
.cd-btn-lg { padding: 13px 20px; font-size: 15.5px; border-radius: 11px; }
.cd-btn-block { width: 100%; }
.cd-icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.cd-icon-btn:hover { background: var(--gray-soft); color: var(--ink); }
.cd-input {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 40px;
}
.cd-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.cd-input:disabled { background: var(--surface-2); color: var(--muted); }
.cd-input.cd-invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
textarea.cd-input { resize: vertical; min-height: 60px; }
.cd-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cd-field > span, .cd-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cd-field > span i { color: var(--red); font-style: normal; }
.cd-hint { color: var(--muted); font-size: 12px; }
.cd-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.cd-check input { width: 17px; height: 17px; accent-color: var(--brand); }
.cd-affix { display: flex; align-items: stretch; }
.cd-affix .cd-input { border-radius: 9px 0 0 9px; }
.cd-affix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.cd-affix input[data-money] { font-size: 17px; font-weight: 700; }
.cd-rate { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.cd-seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.cd-seg label { cursor: pointer; }
.cd-seg input { position: absolute; opacity: 0; pointer-events: none; }
.cd-seg span { display: block; padding: 6px 13px; border-radius: 7px; font-weight: 500; font-size: 13.5px; color: var(--ink-2); }
.cd-seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.cd-seg input:focus-visible + span { outline: 2px solid var(--gold); }
.cd-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cd-chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); padding: 6px 13px; border-radius: 999px; font: 500 13.5px var(--font); cursor: pointer; }
.cd-chip:hover { border-color: var(--muted); }
.cd-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.cd-chips-sm .cd-chip { padding: 4px 10px; font-size: 12.5px; }
.cd-chips-xs { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cd-chips-xs .cd-chip { padding: 2px 8px; font-size: 12px; }
.cd-range-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cd-range { flex: 1; min-width: 160px; accent-color: var(--gold); height: 28px; }

.cd-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cd-badge[data-tone="blue"] { background: var(--blue-soft); color: var(--blue); }
.cd-badge[data-tone="green"] { background: var(--green-soft); color: var(--green); }
.cd-badge[data-tone="red"] { background: var(--red-soft); color: var(--red); }
.cd-badge[data-tone="amber"] { background: var(--amber-soft); color: var(--amber); }
.cd-badge[data-tone="gold"] { background: var(--gold-soft); color: var(--gold); }
.cd-badge[data-tone="gray"] { background: var(--gray-soft); color: var(--muted); }
.cd-alert { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 12px; border: 1px solid transparent; }
.cd-alert-err { background: var(--red-soft); color: var(--red); }
.cd-alert-info { background: var(--blue-soft); color: var(--ink-2); }
.cd-alert-warn { background: var(--amber-soft); color: var(--ink-2); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.cd-spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: cdspin .7s linear infinite; display: inline-block; }
@keyframes cdspin { to { transform: rotate(360deg); } }

.cd-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: var(--gray-soft); }
.cd-avatar-sm { width: 34px; height: 34px; font-size: 12.5px; }
.cd-avatar-ph { display: inline-grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-weight: 700; }

/* ---------- cards ---------- */
.cd-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.cd-card + .cd-card { margin-top: 16px; }
.cd-card-flush { padding: 0; overflow: hidden; }
.cd-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.cd-card-head h3 { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cd-card-head a { font-size: 13px; color: var(--blue); text-decoration: none; font-weight: 500; }
.cd-pad { padding: 16px 18px 0; }
.cd-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.cd-grid2 > .cd-card + .cd-card { margin-top: 0; }
.cd-step { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: 12.5px; }
.cd-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cd-dot-red { background: var(--red); } .cd-dot-amber { background: var(--amber); }
.cd-empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.cd-empty .cd-ic { width: 34px; height: 34px; opacity: .5; }
.cd-empty p { margin: 8px 0 12px; }

/* ---------- dashboard ---------- */
.cd-hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.cd-hello h2 { font-size: 22px; font-weight: 700; }
.cd-hello p { margin: 3px 0 0; color: var(--muted); }
.cd-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.cd-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; text-decoration: none; box-shadow: var(--shadow); position: relative; overflow: hidden; min-width: 0; }
.cd-kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--k); }
a.cd-kpi:hover { border-color: var(--k); }
.cd-kpi[data-tone="blue"] { --k: var(--blue); } .cd-kpi[data-tone="red"] { --k: var(--red); } .cd-kpi[data-tone="amber"] { --k: var(--amber); }
.cd-kpi[data-tone="green"] { --k: var(--green); } .cd-kpi[data-tone="gold"] { --k: var(--gold); }
.cd-kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; font-weight: 500; }
.cd-kpi-top .cd-ic { color: var(--k); }
.cd-kpi-val { font-size: 23px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-kpi-val small { font-size: 13px; color: var(--muted); font-weight: 500; }
.cd-kpi-sub { font-size: 12.5px; color: var(--muted); }
.cd-kpi-sub b { color: var(--ink-2); }
.cd-legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.cd-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cd-dot-thu, .cd-bar-thu { background: var(--green); }
.cd-dot-chi, .cd-bar-chi { background: var(--brand-2); }
:root[data-theme="dark"] .cd-bar-chi, :root[data-theme="dark"] .cd-dot-chi { background: var(--blue); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cd-bar-chi, :root:not([data-theme="light"]) .cd-dot-chi { background: var(--blue); } }
.cd-bars { display: flex; align-items: flex-end; gap: 4px; height: 190px; padding-top: 6px; }
.cd-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; min-width: 0; }
.cd-bar-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--line); }
.cd-bar-pair i { width: 38%; max-width: 12px; min-height: 2px; border-radius: 3px 3px 0 0; }
.cd-bar span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.cd-bar:nth-child(even) span { visibility: hidden; }
.cd-feed-row, .cd-mini { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--line-2); text-decoration: none; }
.cd-feed-row:last-child, .cd-mini:last-child { border-bottom: 0; }
.cd-feed-row:hover, .cd-mini:hover { background: var(--surface-2); }
.cd-feed-main, .cd-mini-main { flex: 1; min-width: 0; }
.cd-feed-main b, .cd-mini-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cd-feed-main small, .cd-mini-main small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-mini-end { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cd-mini-end small { color: var(--muted); }
.cd-feed-type { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--gray-soft); color: var(--ink-2); white-space: nowrap; }
.cd-feed-type[data-loai="giai_ngan"] { background: var(--blue-soft); color: var(--blue); }
.cd-feed-type[data-loai="dong_lai"] { background: var(--gold-soft); color: var(--gold); }
.cd-feed-type[data-loai="tra_goc"] { background: var(--amber-soft); color: var(--amber); }
.cd-feed-type[data-loai="chuoc"] { background: var(--green-soft); color: var(--green); }
.cd-feed-type[data-loai="thanh_ly"] { background: var(--red-soft); color: var(--red); }

/* ---------- list & table ---------- */
.cd-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cd-toolbar p { margin: 0; }
.cd-toolbar-wrap { flex-wrap: wrap; justify-content: flex-start; }
.cd-search { flex: 1; display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 13px; color: var(--muted); max-width: 640px; }
.cd-search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.cd-search input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink); padding: 11px 0; width: 100%; }
#cd-tabs { margin-bottom: 14px; }
.cd-list-sum { color: var(--muted); font-size: 13.5px; margin: 0 2px 10px; }
.cd-list-sum b { color: var(--ink); }
.cd-table { width: 100%; border-collapse: collapse; }
.cd-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.cd-table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.cd-table td small { display: block; color: var(--muted); }
.cd-table tbody tr:last-child td { border-bottom: 0; }
.cd-table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.cd-table tr[data-href] { cursor: pointer; }
.cd-table tr[data-href]:hover td { background: var(--surface-2); }
.cd-table th.r, .cd-table td.r { text-align: right; }
.cd-table .cd-void td { opacity: .5; text-decoration: line-through; }
.cd-table .cd-void td small { text-decoration: none; }
.cd-code { font-weight: 700; letter-spacing: .3px; }
.cd-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cd-who b { display: block; }
.cd-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 13.5px; }
.cd-cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.cd-cust-grid .cd-card + .cd-card { margin-top: 0; }
.cd-cust { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; text-decoration: none; padding: 14px; }
.cd-cust:hover { border-color: var(--gold); }
.cd-cust-main { flex: 1; min-width: 0; }
.cd-cust-main b { display: block; } .cd-cust-main small { display: block; color: var(--muted); }
.cd-cust-stats { width: 100%; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 10px; }
.cd-cust-stats b { color: var(--ink); }

/* ---------- form ---------- */
.cd-back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 13.5px; margin-bottom: 12px; }
.cd-back:hover { color: var(--ink); }
.cd-form { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.cd-fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.cd-span2 { grid-column: 1 / -1; }
.cd-form-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.cd-form-actions { display: flex; flex-direction: column; gap: 10px; }
.cd-sum h3 { font-size: 15.5px; margin-bottom: 12px; }
.cd-dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 13.5px; }
.cd-dl dt { color: var(--muted); }
.cd-dl dd { margin: 0; text-align: right; }
.cd-dl-info dd { text-align: left; }
.cd-dl-info { grid-template-columns: 130px 1fr; }
.cd-sum-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; }
.cd-sum-total span { font-size: 13px; color: var(--muted); }
.cd-sum-total b { font-size: 19px; }
.cd-sum-gold { background: var(--gold-soft); }
.cd-sum-try { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.cd-photo { display: flex; gap: 14px; align-items: center; }
.cd-photo-img { width: 92px; height: 92px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); overflow: hidden; flex: none; }
.cd-photo-img img { width: 100%; height: 100%; object-fit: cover; }
.cd-photo-img .cd-ic { width: 34px; height: 34px; opacity: .6; }
.cd-photo-side { display: flex; flex-direction: column; gap: 8px; }
.cd-photo-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.cd-photo-btns label { cursor: pointer; }
.cd-photo-st { color: var(--green); font-size: 12px; min-height: 16px; }
.cd-lookup { display: flex; align-items: center; gap: 12px; margin: 0; }
.cd-lookup > div { flex: 1; }

/* ---------- detail ---------- */
.cd-dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cd-dhead-title { display: flex; align-items: center; gap: 10px; }
.cd-dhead-title h2 { font-size: 24px; letter-spacing: .3px; }
.cd-dhead p { margin: 4px 0 0; font-size: 13.5px; }
.cd-dhead-act { display: flex; gap: 8px; }
.cd-actbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cd-act { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; padding: 13px 15px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-family: var(--font); color: var(--ink); box-shadow: var(--shadow); }
.cd-act span { grid-row: span 2; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.cd-act b { font-size: 15px; }
.cd-act small { color: var(--muted); }
.cd-act:hover { border-color: var(--gold); }
.cd-act-main { background: var(--brand); border-color: var(--brand); color: #fff; }
.cd-act-main small { color: #c9cfdd; }
.cd-act-main span { background: rgba(255,255,255,.12); color: #f3cf7e; }
.cd-act-main:hover { background: var(--brand-2); }
.cd-act-warn span { background: var(--red-soft); color: var(--red); }
.cd-dgrid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.cd-dcol { min-width: 0; }
.cd-person { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.cd-person-img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; cursor: zoom-in; display: grid; place-items: center; font-size: 24px; flex: none; }
.cd-person h4 { font-size: 18px; }
.cd-person p { margin: 3px 0 0; color: var(--muted); }
.cd-asset-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin-bottom: 14px; cursor: zoom-in; }
.cd-meter { display: inline-block; width: 110px; height: 7px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; vertical-align: middle; margin-right: 8px; }
.cd-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--green)); }
.cd-bigmoney { padding: 4px 0 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.cd-bigmoney small { color: var(--muted); display: block; }
.cd-bigmoney b { font-size: 30px; letter-spacing: -.5px; }
.cd-calc { display: flex; flex-direction: column; gap: 10px; }
.cd-calc .cd-card-head { margin-bottom: 4px; }
.cd-zoom { width: 100%; height: auto; border-radius: 8px; display: block; }

/* ---------- modal ---------- */
.cd-modal-wrap { position: fixed; inset: 0; background: rgba(12, 16, 28, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: cdfade .15s; }
@keyframes cdfade { from { opacity: 0; } }
.cd-modal { background: var(--surface); border-radius: 16px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: cdpop .18s ease-out; }
.cd-modal-wide { width: min(860px, 100%); }
@keyframes cdpop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.cd-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--line-2); }
.cd-modal-head h3 { font-size: 17px; }
.cd-modal-body { padding: 16px 18px; overflow-y: auto; }
.cd-modal-body p { margin: 0 0 8px; }
.cd-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line-2); }
.cd-payform { display: flex; flex-direction: column; gap: 13px; }
.cd-paycust { display: flex; align-items: center; gap: 11px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; margin-bottom: 14px; }
.cd-paycust > div:nth-child(2) { flex: 1; min-width: 0; }
.cd-paycust small { display: block; color: var(--muted); }
.cd-payinfo { font-size: 13.5px; color: var(--ink-2); background: var(--blue-soft); padding: 9px 12px; border-radius: 9px; }
.cd-paytotal { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.cd-paytotal > div { display: flex; justify-content: space-between; gap: 10px; }
.cd-paytotal span { color: var(--muted); }
.cd-paytotal-main { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; align-items: center; }
.cd-paytotal-main span { color: var(--ink) !important; font-weight: 600; }
.cd-paytotal-main b { font-size: 22px; color: var(--gold); }
.cd-paytotal > small { color: var(--muted); font-style: italic; text-align: right; }

/* ---------- toasts ---------- */
.cd-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.cd-toast { display: flex; align-items: center; gap: 9px; background: var(--ink); color: var(--surface); padding: 11px 15px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 500; animation: cdpop .2s; transition: opacity .3s, transform .3s; }
.cd-toast[data-tone="ok"] .cd-ic { color: #6fd3a0; }
.cd-toast[data-tone="err"] { background: var(--red); color: #fff; }
.cd-toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- logs, settings, reports ---------- */
.cd-logs { display: flex; flex-direction: column; }
.cd-log { display: grid; grid-template-columns: 130px 90px 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.cd-log:last-child { border-bottom: 0; }
.cd-log-t { color: var(--muted); font-size: 12.5px; }
.cd-log-d a { color: var(--ink); }
.cd-log-u { font-weight: 600; font-size: 13px; }
.cd-log-warn { background: color-mix(in srgb, var(--amber-soft) 50%, transparent); }
.cd-settings { max-width: 860px; }
.cd-settings textarea { font-size: 13.5px; }
.cd-sticky-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); display: flex; justify-content: flex-end; margin-top: 8px; }
.cd-range-dates { display: flex; align-items: center; gap: 8px; }
.cd-range-dates .cd-input { width: auto; }

/* ---------- login (trang /dang-nhap/) ---------- */
.lg { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.lg-side { background: radial-gradient(900px 500px at 90% 0%, #2c4170 0%, transparent 60%), radial-gradient(700px 500px at 0% 100%, rgba(224,173,69,.18), transparent 60%), var(--brand); color: #c9cfdd; display: flex; align-items: center; justify-content: center; padding: 48px; }
.lg-side-in { max-width: 420px; }
.lg-logo { width: 64px; height: 64px; border-radius: 16px; font-size: 20px; margin-bottom: 26px; }
.lg-side h1 { color: #fff; font-size: 32px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 6px; }
.lg-side p { margin: 0 0 26px; font-size: 16px; }
.lg-side ul { list-style: none; padding: 0; margin: 0 0 30px; display: grid; gap: 12px; }
.lg-side li { position: relative; padding-left: 28px; font-size: 15px; }
.lg-side li::before { content: ""; position: absolute; left: 0; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: rgba(224,173,69,.2); box-shadow: inset 0 0 0 5px #e0ad45; }
.lg-contact { font-size: 13.5px; opacity: .75; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; }
.lg-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px 20px; background: var(--bg); }
.lg-card { width: min(400px, 100%); }
.lg-card h2 { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.lg-sub { color: var(--muted); margin: 0 0 22px; }
.lg-brand-m { display: none; }
.lg-form { display: flex; flex-direction: column; gap: 16px; }
.lg-input { min-height: 50px; font-size: 16px; padding: 12px 14px; border-radius: 11px; }
.lg-pass { position: relative; display: block; }
.lg-pass .lg-input { padding-right: 50px; }
.lg-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; background: transparent; color: var(--muted); border-radius: 9px; cursor: pointer; display: grid; place-items: center; }
.lg-eye:hover, .lg-eye[aria-pressed="true"] { color: var(--ink); background: var(--gray-soft); }
.lg-form .cd-btn-lg { min-height: 52px; font-size: 16px; margin-top: 4px; }
.lg-foot { color: var(--muted); font-size: 13.5px; text-align: center; margin: 18px 0 0; }
.lg-home { color: var(--muted); font-size: 13.5px; text-decoration: none; }
.lg-home:hover { color: var(--ink); }
@media (max-width: 860px) {
  .lg { grid-template-columns: 1fr; }
  .lg-side { display: none; }
  .lg-main { justify-content: flex-start; padding-top: 0; gap: 0; background: linear-gradient(var(--brand) 0 210px, var(--bg) 210px); }
  .lg-brand-m { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-align: center; padding: 34px 0 30px; font-size: 19px; }
  .lg-brand-m .cd-logo { width: 56px; height: 56px; border-radius: 14px; font-size: 18px; }
  .lg-home { margin-top: 18px; }
  .lg-card { background: var(--surface); border-radius: 18px; padding: 24px 20px; box-shadow: 0 16px 40px rgba(10,14,24,.14); }
  .lg-card h2, .lg-sub { text-align: center; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cd-form { grid-template-columns: 1fr; }
  .cd-form-side { position: static; }
  .cd-dgrid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .cd-grid2 { grid-template-columns: 1fr; }
  .cd-top-search { display: none; }
}
@media (max-width: 760px) {
  body.cd-body { font-size: 15px; }
  .cd-side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .22s ease; }
  .cd-side.open { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.3); }
  .cd-scrim { display: block; position: fixed; inset: 0; background: rgba(10,14,24,.45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .cd-scrim.open { opacity: 1; pointer-events: auto; }
  .cd-only-m { display: inline-grid; }
  .cd-top { padding: 10px 12px; gap: 8px; }
  .cd-top h1 { font-size: 17px; }
  .cd-view { padding: 14px 16px calc(88px + env(safe-area-inset-bottom)); }
  .cd-bottom {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .cd-bottom a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; }
  .cd-bottom a.active { color: var(--brand); font-weight: 600; }
  :root[data-theme="dark"] .cd-bottom a.active { color: var(--gold); }
  .cd-bottom .cd-ic { width: 22px; height: 22px; }
  .cd-bottom-new { justify-content: center; }
  .cd-bottom-new .cd-ic { width: 46px !important; height: 46px !important; padding: 12px; border-radius: 50%; background: linear-gradient(140deg, #e6b54e, #c08a1e); color: #1a1408; margin-top: -18px; box-shadow: 0 6px 16px rgba(192,138,30,.4); }
  .cd-fgrid { grid-template-columns: 1fr; }
  .cd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cd-kpi { padding: 12px 13px; }
  .cd-kpi-val { font-size: 18px; }
  .cd-hello h2 { font-size: 19px; }
  .cd-hello .cd-btn { display: none; }
  .cd-toolbar > .cd-btn span { display: none; }
  .cd-card { padding: 15px; }
  .cd-pad { padding: 14px 15px 0; }
  /* bảng → thẻ */
  .cd-table-rows thead { display: none; }
  .cd-table-rows, .cd-table-rows tbody, .cd-table-rows tr, .cd-table-rows td { display: block; width: 100%; }
  .cd-table-rows tr { padding: 12px 15px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .cd-table-rows td { padding: 0; border: 0; text-align: left !important; }
  .cd-table-rows td::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
  .cd-table-rows td:not([data-l])::before { content: none; }
  .cd-table-rows td[data-l="Khách"], .cd-table-rows td[data-l="Tài sản"] { grid-column: 1 / -1; }
  .cd-table-rows td[data-l="Khách"]::before, .cd-table-rows td[data-l="Mã"]::before { content: none; }
  .cd-dhead-act .cd-btn { padding: 8px 11px; }
  .cd-actbar { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cd-act { padding: 11px 12px; column-gap: 9px; }
  .cd-act span { width: 32px; height: 32px; }
  .cd-act small { font-size: 11.5px; }
  .cd-log { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .cd-log-d { grid-column: 1 / -1; }
  .cd-modal-wrap { align-items: flex-end; padding: 0; }
  .cd-modal { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .cd-toasts { bottom: calc(80px + env(safe-area-inset-bottom)); right: 12px; left: 12px; max-width: none; }
  .cd-dl-info { grid-template-columns: 110px 1fr; }
  .cd-bigmoney b { font-size: 26px; }
  .cd-range-dates { width: 100%; } .cd-range-dates .cd-input { flex: 1; min-width: 0; }
}
@media print { .cd-side, .cd-top, .cd-bottom { display: none !important; } }

/* ---------- tài khoản: đổi mật khẩu, link đăng nhập ---------- */
button.cd-side-user-txt { background: none; border: 0; padding: 4px 6px; margin: -4px -6px; text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: 8px; }
button.cd-side-user-txt:hover { background: rgba(255,255,255,.06); }
button.cd-side-user-txt small { white-space: nowrap; }
.cd-linkbox { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; border-left: 3px solid var(--gold); }
.cd-linkbox > div:first-child { flex: 1 1 280px; }
.cd-linkbox b { display: block; }
.cd-linkbox small { color: var(--muted); }
.cd-linkrow { display: flex; gap: 8px; flex: 1 1 340px; }
.cd-linkrow .cd-input { font-size: 13px; }
.cd-cred { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font: 14px/1.65 var(--font); white-space: pre-wrap; word-break: break-word; margin: 10px 0 0; }

/* =================================================================
   iPhone / iPad (Safari & app ngoài màn hình chính)
   ================================================================= */
a, button, label, summary, .cd-chip, .cd-act, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cd-top { -webkit-backdrop-filter: blur(10px); }
.cd-side { height: 100vh; height: 100dvh; }
.cd-modal { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.cd-modal-body { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.cd-modal-wrap { overscroll-behavior: contain; }

/* Ô chọn ngày trên iOS: không bị co lại / lệch chữ */
input[type="date"].cd-input { -webkit-appearance: none; appearance: none; display: block; min-height: 44px; text-align: left; line-height: 1.3; }
input[type="date"].cd-input::-webkit-date-and-time-value { text-align: left; margin: 0; }
/* Ô chọn (select) đồng nhất trên iOS */
select.cd-input { -webkit-appearance: none; appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236c7282' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input[type="range"].cd-range { -webkit-appearance: auto; }

/* iOS < 16.2 chưa có color-mix → nền đặc thay thế */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .cd-top { background: var(--bg); }
  .cd-log-warn { background: var(--amber-soft); }
  .cd-alert-warn { border-color: transparent; }
}

/* Nút tải lại: chỉ hiện khi mở từ biểu tượng ngoài màn hình chính (không có thanh địa chỉ) */
.cd-refresh { display: none; }
@media (display-mode: standalone) { .cd-refresh { display: inline-grid; } }
html.cd-standalone .cd-refresh { display: inline-grid; }

/* Hướng dẫn "Thêm vào màn hình chính" */
.lg-card .cd-ios-tip { margin: 18px 0 0; }
.cd-ios-tip { position: relative; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 14px; box-shadow: var(--shadow); padding: 12px 44px 12px 12px; display: flex; gap: 12px; align-items: center; font-size: 14px; line-height: 1.45; margin-bottom: 16px; }
.cd-ios-tip[hidden] { display: none !important; }
.cd-ios-tip img { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.cd-ios-tip b { display: block; font-size: 14.5px; }
.cd-ios-tip .cd-share { display: inline-block; width: 17px; height: 17px; vertical-align: -3px; color: var(--blue); }
.cd-ios-tip button { position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; border-radius: 8px; cursor: pointer; }

/* Vùng in (phiếu cầm / biên nhận) — dùng chung cho mọi trình duyệt, kể cả Safari iPhone */
#cd-print { display: none; }
@media print {
  body.cd-printing > *:not(#cd-print) { display: none !important; }
  body.cd-printing { background: #fff !important; }
  body.cd-printing #cd-print { display: block !important; }
}
.cd-preview { background: #fff; color: #111; border-radius: 10px; padding: 18px; box-shadow: inset 0 0 0 1px var(--line); max-height: 62vh; max-height: 62dvh; overflow: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 760px) {
  /* iOS tự phóng to khi chữ trong ô nhập < 16px → để đúng 16px */
  .cd-input, .cd-search input, .cd-top-search input, .lg-input, select, textarea, input { font-size: 16px; }
  .cd-affix input[data-money] { font-size: 18px; }
  /* Tai thỏ / Dynamic Island / thanh Home */
  .cd-top { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .cd-side { padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .cd-view { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .cd-modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .lg-brand-m { padding-top: calc(34px + env(safe-area-inset-top)); }
  .lg-main { background: linear-gradient(var(--brand) 0 calc(210px + env(safe-area-inset-top)), var(--bg) calc(210px + env(safe-area-inset-top))); }
  /* Chạm dễ: tối thiểu ~44px */
  .cd-icon-btn { width: 44px; height: 44px; }
  .cd-chips-sm .cd-chip { padding: 8px 12px; font-size: 13.5px; }
  .cd-chips-xs .cd-chip { padding: 6px 10px; font-size: 13px; }
  .cd-chip { min-height: 38px; }
  .cd-btn-sm { min-height: 38px; }
  .cd-seg span { padding: 9px 14px; }
  .cd-check input { width: 22px; height: 22px; }
  .cd-nav a { padding: 12px; }
  .cd-photo-btns .cd-btn { min-height: 40px; }
}
