/* TVN — trang quản lý trên web (/app). Tối giản chữ: nút icon, giải thích nằm sau chữ "i" nhỏ.
   Sáng / tối: chưa chọn thì theo máy; nút mặt trời / mặt trăng (/ui/theme.js) ghi html[data-theme], nhớ chung với cả thichvenha.com.
   Màu chính cùng tông xanh lơ với site (ui/site.css): sáng #0e7490 (đủ tương phản cho chữ nhỏ), tối #22d3ee. */
:root {
  --bg: #edf1f4; --surface: #ffffff; --sunk: #f4f7f9; --ink: #17222b; --muted: #556572; --line: #d4dbe1;
  --accent: #0e7490; --accent-ink: #ffffff; --accent-soft: #dcf1f6; --ok: #15803d; --warn: #a96500; --bad: #b42318; --bad-soft: #fff3f2;
  --thumb: #dfe7ee; --shadow: 0 10px 30px rgba(16, 24, 32, .18); --tip-bg: #18222c; --tip-ink: #eef3f7;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1317; --surface: #151c22; --sunk: #11171c; --ink: #e4ebf0; --muted: #93a3af; --line: #27323b;
    --accent: #22d3ee; --accent-ink: #03081f; --accent-soft: #0c3340; --ok: #3fbf6f; --warn: #f0a733; --bad: #f06459; --bad-soft: #2a1513;
    --thumb: #1c252d; --shadow: 0 10px 30px rgba(0, 0, 0, .5); --tip-bg: #e9eef2; --tip-ink: #111820;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1317; --surface: #151c22; --sunk: #11171c; --ink: #e4ebf0; --muted: #93a3af; --line: #27323b;
  --accent: #22d3ee; --accent-ink: #03081f; --accent-soft: #0c3340; --ok: #3fbf6f; --warn: #f0a733; --bad: #f06459; --bad-soft: #2a1513;
  --thumb: #1c252d; --shadow: 0 10px 30px rgba(0, 0, 0, .5); --tip-bg: #e9eef2; --tip-ink: #111820;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---------- khung ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .06em; color: var(--ink); text-decoration: none; font-size: 14px; }
.brand .logo { width: 26px; height: 26px; }
.tabs { display: flex; gap: 4px; margin-left: 6px; }
.tab { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none;
  font-weight: 600; font-size: 14px; }
.tab[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.grow { flex: 1 1 auto; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
  font-weight: 700; overflow: hidden; flex: none; text-decoration: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
main { max-width: 1120px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
@media (max-width: 640px) {
  .tab span { display: none; }
  .tab { padding: 0 10px; }
  .top .chips { display: none; }
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--sunk); font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip .ic { width: 15px; height: 15px; }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }

/* nút icon */
.ibtn { width: 38px; height: 38px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-grid; place-items: center; cursor: pointer; flex: none; text-decoration: none; }
.ibtn .ic { width: 19px; height: 19px; }
.ibtn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ibtn.warn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.ibtn:disabled { opacity: .45; cursor: default; }
/* nút sáng / tối (/ui/theme.js): đang sáng hiện mặt trăng, đang tối hiện mặt trời */
.theme-t .sun, :root[data-theme="dark"] .theme-t .moon { display: none; }
:root[data-theme="dark"] .theme-t .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-t .moon { display: none; }
  :root:not([data-theme="light"]) .theme-t .sun { display: block; }
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.warn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn:disabled { opacity: .5; cursor: default; }
.ibs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* chữ "i" giải thích: bấm / rê chuột mới hiện */
.i { position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border-radius: 50%; flex: none; vertical-align: middle;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font: italic 600 13px/1 Georgia, "Times New Roman", serif; cursor: help; }
.i .tip { display: none; position: absolute; right: -6px; top: calc(100% + 6px); width: min(260px, 76vw); padding: 9px 11px; border-radius: 9px;
  background: var(--tip-bg); color: var(--tip-ink); font: 400 12.5px/1.5 var(--font); text-align: left; box-shadow: var(--shadow); z-index: 30; }
.i:hover .tip, .i:focus .tip, .i[aria-expanded="true"] .tip { display: block; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel > h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel > h2 .ic { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }

/* ---------- ô nhập ---------- */
.field { min-width: 0; height: 38px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); }
.field:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.sel { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 4px 0 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--sunk); color: var(--muted); max-width: 100%; }
.sel select { border: 0; background: transparent; color: var(--ink); height: 36px; min-width: 0; max-width: 190px; cursor: pointer; }
.sel select:focus { outline: none; }
.sel:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sel.on { border-color: var(--accent); color: var(--accent); }
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bar .field[type="search"] { flex: 1 1 160px; }

/* ---------- Gallery ---------- */
.cards { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
@media (max-width: 420px) { .cards { grid-template-columns: 1fr 1fr; gap: 10px; } }
.card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); display: grid; grid-template-rows: auto auto; min-width: 0; }
.card.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--thumb); display: grid; place-items: center; color: var(--muted); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb > .ic { width: 34px; height: 34px; }
.pick { position: absolute; inset: 0; border: 0; padding: 0; background: transparent; cursor: pointer; }
.ov { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; gap: 6px; justify-content: center; pointer-events: none; }
.ov .ibtn { width: 34px; height: 34px; background: rgba(18, 22, 28, .84); border-color: rgba(255, 255, 255, .2); color: #fff; pointer-events: auto; }
.ov .ibtn.warn { color: #ff8a80; }
.card .meta { padding: 8px 10px 9px; display: grid; gap: 1px; min-width: 0; }
.card .meta b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 7px 8px 7px 10px; background: var(--bad-soft); color: var(--bad);
  font-size: 13px; font-weight: 600; }
.ask .ibtn { width: 30px; height: 30px; }
.ask .ibs { flex-wrap: nowrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty .ic { width: 40px; height: 40px; }

/* ---------- danh sách (khách, tầng, phòng, máy) ---------- */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
.row .nm { flex: 1 1 auto; min-width: 0; display: grid; }
.row .nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .nm span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .n { min-width: 2em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.row .ibtn { width: 34px; height: 34px; }
.row.ask-row { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 7px 8px 7px 10px; border-top-color: transparent; font-weight: 600; font-size: 13px; }
.add { display: flex; gap: 8px; }
.add .field { flex: 1 1 auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--sunk); font-size: 13.5px; }
.tag .n { color: var(--muted); font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.tag button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; }
.tag button .ic { width: 14px; height: 14px; }
.tag.ask-tag { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.tag.ask-tag button { color: var(--bad); }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.dlg.flat { padding: 0; }
p.flat { margin: 0; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }

/* công tắc */
.sw { position: relative; width: 40px; height: 24px; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.sw span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; pointer-events: none; }
.sw span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.sw input:checked + span { background: var(--accent); }
.sw input:checked + span::after { transform: translateX(16px); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- trang chủ /app ---------- */
.hub { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.tile { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center; padding: 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile .ico svg { width: 26px; height: 26px; }
.tile b { display: block; font-size: 15px; }
.tile span { font-size: 13px; color: var(--muted); }

/* ---------- tài khoản ---------- */
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who .avatar { width: 48px; height: 48px; font-size: 18px; }
.who div { min-width: 0; display: grid; }
.who b { font-size: 16px; overflow-wrap: anywhere; }
.who span { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.kv { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv .lbl { color: var(--muted); font-size: 13px; min-width: 7em; }
.handle { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.handle b { color: var(--accent); }
.buy { max-width: 440px; justify-self: center; width: 100%; justify-items: start; }
.buy .qr { justify-self: stretch; }
.agree { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.agree input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.paid-ok { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; }
.paid-ok .ic { width: 26px; height: 26px; }
.spin.sm { width: 16px; height: 16px; margin: 0; border-width: 2px; }
.price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
/* 1.0.28: mua thêm máy (số lượng) + duyệt máy nhân viên (mã xác nhận, chọn máy thu hồi) */
.step { display: inline-flex; align-items: center; gap: 6px; }
.step .field { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.buy .stack { width: 100%; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); width: 100%; }
label.f .field { width: 100%; color: var(--ink); font-size: 14px; }
.pcode { display: inline-flex; gap: 6px; }
.pcode span { width: 34px; height: 40px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--sunk);
  font: 700 20px/1 var(--mono); color: var(--ink); }
label.row { cursor: pointer; }
label.row input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.ibtn.sure { color: #fff; background: var(--bad); border-color: var(--bad); }
.btn.sure { background: var(--bad); color: #fff; }

/* ---------- hộp thoại ---------- */
dialog { width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 12, 16, .5); }
.dlg { padding: 18px; display: grid; gap: 12px; }
.dlg-head { display: flex; align-items: center; gap: 10px; }
.dlg-head h2 { flex: 1 1 auto; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.dlg label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.dlg label.f .field, .dlg label.f .sel { width: 100%; }
.dlg .sel select { max-width: none; flex: 1 1 auto; }
.pre { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--sunk); overflow: hidden; }
.pre span { padding: 0 2px 0 10px; color: var(--muted); font-size: 13px; white-space: nowrap; font-family: var(--mono); }
.pre input { flex: 1 1 auto; min-width: 0; height: 38px; border: 0; background: transparent; padding: 0 10px 0 0; font-family: var(--mono); font-size: 13.5px; }
.pre input:focus { outline: none; }
.pre:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.err { color: var(--bad); font-size: 13px; min-height: 1.2em; }
.qr { display: grid; place-items: center; padding: 6px 0; }
.qr canvas { width: 220px; height: 220px; image-rendering: pixelated; border-radius: 10px; background: #fff; }
.link { display: flex; gap: 8px; }
.link input { flex: 1 1 auto; font-family: var(--mono); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 10px); padding: 9px 14px; border-radius: 11px; background: var(--tip-bg); color: var(--tip-ink);
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spin { width: 28px; height: 28px; margin: 40px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: sp .9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } .toast, .sw span, .sw span::after { transition: none; } }
