/* Shop CRM — tông đen ấm + vàng đồng, nền kem; chữ to dễ đọc, dùng tốt trên điện thoại */
:root {
  --ink: #16181D; --ink-2: #4B5160; --ink-3: #8A90A0;
  --gold: #B08D57; --gold-2: #C9A96E; --gold-soft: #F4ECDF; --gold-ink: #7A5C2E;
  --canvas: #F6F3EE; --surface: #FFFFFF; --surface-2: #FAF8F4;
  --line: #E8E2D8; --line-soft: #F1ECE4;
  --danger: #C0392B; --danger-soft: #FBEAE8; --ok: #2E7D4F; --ok-soft: #E7F4EC; --warn: #B7791F; --warn-soft: #FDF3E1;
  --vip: #16181D; --gold-t: #B08D57; --silver: #8C95A3; --normal: #CFC7BA;
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --shadow: 0 1px 3px rgba(22,24,29,.06), 0 4px 14px rgba(22,24,29,.04);
  --shadow-lg: 0 20px 50px rgba(22,24,29,.22);
  --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;
  --side: 232px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }
button { cursor: pointer; }
a { color: var(--gold-ink); text-decoration: none; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .num { font-variant-numeric: tabular-nums; }
.right { text-align: right; } .nowrap { white-space: nowrap; }

/* ---------- đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 10% -10%, #EFE3CE 0%, transparent 60%), var(--canvas); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); width: 380px; max-width: 100%; padding: 40px 32px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); display: grid; place-items: center; flex-shrink: 0; }
.logo-mark svg { width: 22px; height: 22px; }
.login-card .logo { justify-content: center; font-size: 22px; }
.login-card p.sub { text-align: center; color: var(--ink-3); margin: 6px 0 26px; }

/* ---------- khung ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: var(--ink); color: #D9D4CA; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 18px 12px; z-index: 20; }
.side .logo { color: #fff; padding: 4px 8px 20px; }
.side .logo-mark { background: #23262E; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #C5C0B6; font-weight: 500; margin-bottom: 2px; position: relative; }
.nav a:hover { background: #20232A; color: #fff; }
.nav a.on { background: #262A33; color: #fff; }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--gold-2); }
.nav .ic { width: 20px; text-align: center; font-size: 16px; }
.nav .badge { margin-left: auto; background: var(--gold); color: #fff; font-size: 12px; font-weight: 700; border-radius: 20px; padding: 0 8px; line-height: 20px; }
.side .new-order { margin: 6px 0 16px; width: 100%; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #2A2D35; font-size: 13px; }
.side-foot b { color: #fff; font-weight: 600; display: block; }
.side-foot a { color: #9A9486; }
.main { margin-left: var(--side); flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1280px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top .grow { flex: 1; }
.bottom-nav { display: none; }

/* ---------- thành phần ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; white-space: nowrap; transition: .15s; }
.btn:hover { border-color: var(--gold-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2A2E37; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.gold:hover { background: #9C7B48; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-soft); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h2 { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .lbl { color: var(--ink-3); font-size: 13px; font-weight: 500; }
.stat .val { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.stat.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.dark .lbl, .stat.dark .sub { color: #A9A398; }
.up { color: var(--ok); } .down { color: var(--danger); }

label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2); transition: .15s; }
.input:focus { outline: none; border-color: var(--gold); background: #fff; box-shadow: 0 0 0 3px rgba(176,141,87,.15); }
textarea.input { resize: vertical; min-height: 70px; }
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.form.f4 { grid-template-columns: repeat(4, 1fr); } .form.f3 { grid-template-columns: repeat(3, 1fr); }
.form-sec { grid-column: 1 / -1; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--gold-ink); margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search input { padding-left: 38px; }
.search::before { content: '⌕'; position: absolute; left: 13px; top: 50%; transform: translateY(-52%); color: var(--ink-3); font-size: 19px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select.input { width: auto; padding: 8px 10px; font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .7; margin-left: 4px; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: var(--surface-2); }
.t td.r, .t th.r { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.name-cell b { font-weight: 600; display: block; }
.name-cell span { font-size: 13px; color: var(--ink-3); }

.tier { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tier-VIP { background: var(--ink); color: var(--gold-2); }
.tier-Vàng { background: var(--gold-soft); color: var(--gold-ink); }
.tier-Bạc { background: #EEF0F3; color: #5B6473; }
.tier-Thường { background: #F3F0EA; color: #8A8172; }
.tier-Mới { background: #E9F2FB; color: #2B6CB0; }
.st { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-done { background: var(--ok-soft); color: var(--ok); }
.st-new { background: #E9F2FB; color: #2B6CB0; }
.st-ship { background: var(--warn-soft); color: var(--warn); }
.st-cancel { background: var(--danger-soft); color: var(--danger); }
.tag { display: inline-block; background: var(--line-soft); color: var(--ink-2); border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 1px 3px 1px 0; }

.task { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.task:last-child { border-bottom: none; }
.task .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; font-size: 18px; background: var(--gold-soft); }
.task .ico.refill { background: #FBEAF1; } .task .ico.warranty { background: #E8EEF7; } .task .ico.birthday { background: #FFF1DC; } .task .ico.winback { background: #EEF0F3; } .task .ico.custom { background: var(--ok-soft); }
.task .body { flex: 1; min-width: 0; }
.task .body b { font-weight: 600; }
.task .meta { font-size: 13px; color: var(--ink-3); }
.task .acts { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; padding-left: 50px; }
.late { color: var(--danger); font-weight: 600; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 10px; }
.empty .big { font-size: 30px; margin-bottom: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 14px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--gold); }

/* hồ sơ khách */
.profile { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar { width: 58px; height: 58px; border-radius: 16px; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; font-weight: 700; font-size: 22px; flex-shrink: 0; }
.profile .who { flex: 1; min-width: 200px; }
.profile .who h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.contact { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); } .kv dd { word-break: break-word; }
.order-card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.order-card .h { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.order-card .h .grow { flex: 1; }
.order-card .it { display: flex; gap: 10px; font-size: 14px; padding: 4px 0; }
.order-card .it .grow { flex: 1; }
.note { padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.note .meta { font-size: 12.5px; color: var(--ink-3); }
.pref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pref { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; }
.pref .l { font-size: 12px; color: var(--ink-3); font-weight: 600; }

/* đơn mới */
.items-table { width: 100%; border-collapse: collapse; }
.items-table td { padding: 6px 4px; vertical-align: top; }
.items-table th { font-size: 12px; color: var(--ink-3); text-align: left; padding: 4px; font-weight: 600; }
.item-row { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; margin-bottom: 10px; display: grid; grid-template-columns: 150px 1fr 140px 70px 150px 36px; gap: 10px; align-items: end; }
.item-row.admin { grid-template-columns: 150px 1fr 140px 70px 150px 130px 36px; }
.item-row .extra { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; font-size: 15px; max-width: 380px; margin-left: auto; }
.totals .grand { font-size: 20px; font-weight: 700; }
.picker { position: relative; }
.picker-list { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 30; margin-top: 4px; max-height: 320px; overflow: auto; }
.picker-list button { display: flex; width: 100%; text-align: left; padding: 10px 14px; border: none; background: none; gap: 10px; align-items: center; border-bottom: 1px solid var(--line-soft); }
.picker-list button:hover { background: var(--surface-2); }
.picked { display: flex; align-items: center; gap: 12px; background: var(--gold-soft); border: 1px solid #E6D5B8; border-radius: 12px; padding: 12px 14px; }
.picked .grow { flex: 1; }

/* biểu đồ cột */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 20px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar .b { width: 100%; max-width: 44px; background: var(--gold-2); border-radius: 6px 6px 2px 2px; min-height: 2px; position: relative; }
.bar .b.cur { background: var(--ink); }
.bar .v { font-size: 11px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.bar .m { font-size: 12px; color: var(--ink-3); }
.hbar { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.hbar .n { width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { flex: 1; height: 10px; background: var(--line-soft); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--gold); border-radius: 6px; }
.hbar .v { width: 110px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* nhập dữ liệu */
.drop { border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 26px; text-align: center; background: var(--surface-2); }
.drop.over { border-color: var(--gold); background: var(--gold-soft); }
.steps { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.steps div { flex: 1; min-width: 150px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.steps b { display: block; color: var(--gold-ink); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.warn-row td { background: #FFFBF2; }
.map-sel { padding: 4px 6px; font-size: 12px; border-radius: 6px; border: 1px solid var(--line); background: #fff; max-width: 140px; }

/* hộp thoại */
.modal-bg { position: fixed; inset: 0; background: rgba(22,24,29,.45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 600px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: 980px; }
.modal-h { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h2 { flex: 1; }
.modal-b { padding: 20px 22px; overflow: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.x { border: none; background: none; font-size: 24px; color: var(--ink-3); line-height: 1; padding: 0 4px; }
@keyframes fade { from { opacity: 0; } }
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: fade .2s; max-width: 90vw; }
.toast.err { background: var(--danger); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 14px; color: var(--ink-3); }
.hint { background: var(--gold-soft); border: 1px solid #EBDCC3; color: var(--gold-ink); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.m-only { display: none; }

/* ---------- điện thoại ---------- */
@media (max-width: 900px) {
  .side { display: none; }
  .main { margin-left: 0; padding: 16px 14px 96px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); z-index: 50; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; color: #A9A398; font-size: 11px; font-weight: 500; padding: 4px 0; position: relative; }
  .bottom-nav a .ic { font-size: 19px; }
  .bottom-nav a.on { color: #fff; }
  .bottom-nav a.plus .ic { background: var(--gold); color: #fff; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; margin-top: -18px; font-size: 24px; box-shadow: 0 6px 16px rgba(176,141,87,.45); }
  .bottom-nav .badge { position: absolute; top: 0; right: 22%; background: var(--gold); color: #fff; font-size: 10px; border-radius: 10px; padding: 0 5px; }
  .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: 1fr 1fr; }
  .form { grid-template-columns: 1fr; } .form.f4, .form.f3 { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .card { padding: 16px; border-radius: 14px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .stat .val { font-size: 20px; }
  h1 { font-size: 20px; }
  .hide-m { display: none !important; }
  .m-only { display: block; }
  .item-row, .item-row.admin { grid-template-columns: 1fr 1fr; }
  .item-row .name-f { grid-column: 1 / -1; }
  .item-row .extra { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .pref-grid { grid-template-columns: 1fr; }
  .modal-bg { padding: 0; place-items: end stretch; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; width: 100%; }
  .hbar .n { width: 90px; } .hbar .v { width: 80px; }
}
