:root {
    --bg: #f6f2f4;
    --surface: #ffffff;
    --surface-2: #f1e9ee;
    --text: #23161d;
    --muted: #6f5d67;
    --border: #e2d5dc;
    --primary: #8e2f5c;
    --primary-text: #ffffff;
    --primary-soft: #f6dbe8;
    --danger: #b3261e;
    --ok: #1f7a4d;
    --warn-bg: #fff3d6;
    --warn-text: #6a4b00;
    --busy: #e5533a;
    --busy-soft: #fde3dc;
    --hold: #f2a516;
    --hold-soft: #fff0cc;
    --free-soft: #ffffff;
    --radius: 14px;
    --tap: 48px;
    --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .05);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161014;
        --surface: #21181d;
        --surface-2: #2b2026;
        --text: #f3e9ee;
        --muted: #b49fab;
        --border: #3b2e35;
        --primary: #e283b0;
        --primary-text: #23161d;
        --primary-soft: #43263a;
        --danger: #ff8a80;
        --ok: #6fd4a0;
        --warn-bg: #3c3015;
        --warn-text: #f5d98a;
        --busy: #ff7b63;
        --busy-soft: #4a2420;
        --hold: #ffc04d;
        --hold-soft: #45361a;
        --free-soft: #21181d;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1rem; margin: .75rem 0 .25rem; }
a { color: var(--primary); }
small { font-size: .85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.empty { color: var(--muted); padding: 1.5rem 0; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: .6rem .8rem; border-radius: 10px; }
.ok { color: var(--ok); font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 1rem;
    padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top));
    background: var(--primary); color: var(--primary-text);
}
.brand { color: inherit; text-decoration: none; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { display: flex; gap: .25rem; margin-left: auto; overflow-x: auto; }
.topnav a {
    color: inherit; text-decoration: none; padding: .45rem .7rem; border-radius: 999px; white-space: nowrap;
    min-height: 40px; display: inline-flex; align-items: center;
}
.topnav a.active { background: rgb(255 255 255 / .2); }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; gap: .25rem .75rem; }
    .topnav { order: 3; width: 100%; margin-left: 0; }
    .clock { margin-left: auto; }
}

.content { padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
.page { max-width: 1100px; margin: 0 auto; }
.page-wide { max-width: 1500px; }
.page-narrow { max-width: 560px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }

/* ---------- Buttons & form controls ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    min-height: var(--tap); padding: .5rem 1rem;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    touch-action: manipulation;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 40px; padding: .3rem .7rem; font-size: .9rem; }
.btn-lg { min-height: 56px; font-size: 1.1rem; padding: .6rem 1.4rem; }
.btn-block { width: 100%; }
.icon-btn {
    min-width: 40px; min-height: 40px; border: 0; border-radius: 10px;
    background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px;
    min-height: var(--tap); padding: .45rem .7rem; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--primary); flex: none; }
input[type="color"] { padding: .2rem; }
.page-head input[type="date"] { width: auto; }
.select-sm { min-height: 36px; padding: .2rem .4rem; font-size: .9rem; width: auto; max-width: 100%; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; border: 0; padding: 0; }
.field label, .field legend { font-weight: 600; font-size: .95rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; margin-bottom: .85rem; }
.field-row .field { margin-bottom: 0; }
/* Nhãn có ô chọn: để chữ (kể cả <b>) chảy liền một dòng, ô chọn đứng đầu. */
.check { display: block; position: relative; padding: .6rem 0 .6rem 2.1rem; min-height: 44px; font-weight: 400 !important; cursor: pointer; }
.check > input { position: absolute; left: 0; top: .6rem; margin: 0; }
details summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--muted); }

.chip {
    display: inline-flex; align-items: center; gap: .4rem;
    min-height: 44px; padding: .25rem .8rem .25rem .3rem;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.chip-on { background: var(--primary-soft); border-color: var(--primary); font-weight: 700; }
.badge { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: var(--primary-soft); margin-right: .25rem; }
.badge-danger { background: var(--busy-soft); color: var(--danger); }

.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg-btn { flex: 1 1 auto; min-height: var(--tap); border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; padding: 0 .8rem; }
.seg-on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 700; }

/* ---------- Cards, lists, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.list-row {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .75rem; min-height: 56px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.card .list-row { margin-bottom: .4rem; cursor: pointer; }
.row-on { border-color: var(--primary); background: var(--primary-soft); }
.swatch { width: 18px; height: 18px; border-radius: 6px; flex: none; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.card .table-wrap, .card > .table { border: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .55rem .65rem; border-bottom: 1px solid var(--border); text-align: left; }
.table th.num, .table td.num { text-align: right; }
.table thead th { background: var(--surface-2); font-size: .88rem; white-space: nowrap; }
.table tfoot th { background: var(--surface-2); }
.table td input[type="time"] { min-width: 110px; }

/* ---------- Home tiles ---------- */
.hero-title { text-align: center; margin: .5rem 0 1.25rem; font-size: clamp(1.4rem, 4vw, 2.2rem); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem; }
.tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
    min-height: 130px; padding: 1rem; text-align: center;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px;
    font: inherit; font-size: 1.1rem; font-weight: 700; text-decoration: none; cursor: pointer;
    box-shadow: var(--shadow); touch-action: manipulation;
}
.tile:hover { border-color: var(--primary); }
.tile-icon { font-size: 2.2rem; line-height: 1; }
.tile-in { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
@media (max-width: 480px) {
    .tiles { grid-template-columns: 1fr 1fr; gap: .6rem; }
    .tile { min-height: 110px; font-size: 1rem; }
}

/* ---------- Avatars ---------- */
.avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar-text { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); }
.avatar-sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar-lg { width: 96px; height: 96px; margin-top: .5rem; }

/* ---------- Turn board ---------- */
.turn-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1rem; align-items: start; }
@media (max-width: 960px) { .turn-layout { grid-template-columns: 1fr; } .queue { order: -1; } }
.turn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; }
@media (max-width: 520px) { .turn-grid { grid-template-columns: 1fr; } }
.turn-card {
    position: relative; display: flex; flex-direction: column; gap: .5rem;
    padding: .8rem; border-radius: var(--radius);
    background: var(--free-soft); border: 2px solid var(--border); box-shadow: var(--shadow);
}
.turn-card.status-busy { background: var(--busy-soft); border-color: var(--busy); }
.turn-card.status-freehold { background: var(--hold-soft); border-color: var(--hold); }
.turn-card.is-next { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.next-badge { position: absolute; top: -10px; right: 10px; background: var(--primary); color: var(--primary-text); font-size: .72rem; font-weight: 800; padding: .15rem .55rem; border-radius: 999px; }
.turn-head { display: flex; align-items: center; gap: .65rem; cursor: pointer; }
.turn-name { display: flex; flex-direction: column; min-width: 0; }
.turn-name strong { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; text-align: center; }
.turn-stats div { display: flex; flex-direction: column; background: rgb(127 127 127 / .08); border-radius: 8px; padding: .25rem; }
.turn-stats span { font-size: .72rem; }
.turn-status { font-size: .85rem; font-weight: 600; color: var(--muted); }
.turn-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.turn-actions .btn { flex: 1 1 auto; }
.queue { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; position: sticky; top: 70px; }
.queue h2 { margin-top: 0; }
.queue ol, .queue ul { margin: 0; padding-left: 1.3rem; }
.queue li { padding: .25rem 0; }
.queue li b, .queue li .muted { float: right; }
@media (max-width: 960px) { .queue { position: static; } }

/* ---------- Bill editor ---------- */
.bill-editor { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .bill-editor { grid-template-columns: 1fr; } }
.be-services, .be-cart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; }
.be-cart { position: sticky; top: 70px; }
@media (max-width: 1000px) { .be-cart { position: static; } }
.be-workers { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .75rem; }
.be-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .6rem; -webkit-overflow-scrolling: touch; }
.tab {
    --tab-color: var(--primary);
    flex: none; min-height: var(--tap); padding: 0 1rem; border-radius: 12px;
    border: 2px solid var(--tab-color); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}
.tab-on { background: var(--tab-color); color: #fff; }
.be-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .55rem; }
@media (max-width: 420px) { .be-items { grid-template-columns: 1fr 1fr; } }
.svc {
    display: flex; flex-direction: column; align-items: flex-start; gap: .15rem;
    min-height: 82px; padding: .6rem .7rem; text-align: left;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text);
    font: inherit; cursor: pointer; touch-action: manipulation;
}
.svc:active { transform: scale(.98); }
.svc-name { font-weight: 600; }
.svc-price { font-weight: 800; color: var(--primary); }
.svc-off { font-size: .8rem; color: var(--danger); }
.be-cashier { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.cart { width: 100%; border-collapse: collapse; margin-bottom: .5rem; }
.cart td { padding: .4rem .2rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: .3rem .75rem; margin: .5rem 0 1rem; align-items: center; }
.totals dt { display: flex; gap: .4rem; align-items: center; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.35rem; font-weight: 800; }
.tip-split { background: var(--surface-2); border-radius: 10px; padding: .6rem; margin-bottom: .85rem; }
.tip-row { display: grid; grid-template-columns: 1fr 120px; gap: .5rem; align-items: center; margin-top: .4rem; }
.be-save { display: flex; gap: .5rem; }
.be-save .btn { flex: 1; }

/* ---------- Bills ---------- */
.summary-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: .75rem; }
.bill-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }
@media (max-width: 420px) { .bill-list { grid-template-columns: 1fr; } }
.bill-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.bill-card header, .bill-card footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; align-items: center; }
.bill-card ul { list-style: none; margin: 0; padding: 0; }
.bill-card li { display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0; }

/* ---------- Receipt ---------- */
.receipt { max-width: 340px; margin: 0 auto; background: #fff; color: #000; padding: 1rem; border: 1px dashed #999; font-size: 14px; }
.receipt h2 { margin: 0; }
.receipt p { margin: .3rem 0; }
.receipt-lines { width: 100%; border-collapse: collapse; margin: .5rem 0; border-top: 1px dashed #999; }
.receipt-lines td { padding: .2rem 0; }
.receipt-lines .grand td { font-weight: 800; font-size: 1.1rem; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 40; }
.modal {
    position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
    background: var(--surface); border-radius: 18px; box-shadow: 0 10px 40px rgb(0 0 0 / .3);
}
.modal-wide { width: min(760px, calc(100vw - 24px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1rem; }
@media (max-width: 520px) {
    .modal { top: auto; bottom: 0; transform: translateX(-50%); width: 100vw; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- Keypad ---------- */
.keypad { display: flex; flex-direction: column; gap: .75rem; }
.keypad-display {
    min-height: 60px; display: flex; align-items: center; justify-content: center;
    font-size: 2rem; letter-spacing: .3em; font-variant-numeric: tabular-nums;
    background: var(--surface-2); border-radius: 12px;
}
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.key {
    min-height: 64px; border-radius: 14px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-size: 1.6rem; font-weight: 700;
    cursor: pointer; touch-action: manipulation; user-select: none;
}
.key:active { background: var(--primary-soft); }
.key-soft { background: var(--surface-2); font-size: 1.3rem; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
    bottom: max(1rem, env(safe-area-inset-bottom)); max-width: min(560px, calc(100vw - 24px));
    padding: .8rem 1.1rem; border-radius: 12px; font-weight: 600; color: #fff; box-shadow: 0 6px 24px rgb(0 0 0 / .25); cursor: pointer;
}
.toast-ok { background: #1f7a4d; }
.toast-error { background: #b3261e; }

/* ---------- Errors / print ---------- */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: .7rem 1rem; background: var(--warn-bg); color: var(--warn-text);
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

@media print {
    .topbar, .no-print, .toast, #blazor-error-ui { display: none !important; }
    body, .content { background: #fff; padding: 0; color: #000; }
    .receipt { border: 0; max-width: none; }
    .table-wrap { border: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------- Giai đoạn 2 ---------- */
.section-gap { margin-top: 1rem; }
.two-col-even { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two-col-even { grid-template-columns: 1fr; } }
.field-row-tight { grid-template-columns: 1fr auto; margin-bottom: .3rem; }
.danger-text { color: var(--danger); font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; min-height: 32px; }
.print-only { display: none; }
code { background: var(--surface-2); padding: 0 .3rem; border-radius: 6px; font-size: .9em; }
textarea { min-height: 0; resize: vertical; }

.gift-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .75rem 0; }
.gift-info div { display: flex; flex-direction: column; background: var(--surface-2); border-radius: 10px; padding: .5rem .7rem; }
.gift-info span { font-size: .8rem; }
.reward-box { display: flex; flex-direction: column; gap: .25rem; background: var(--primary-soft); border-radius: 10px; padding: .55rem .7rem; margin-top: .4rem; }

/* Lịch hẹn */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .35rem; margin-bottom: 1rem; }
.day-chip { display: flex; flex-direction: column; align-items: center; gap: .05rem; min-height: 64px; padding: .35rem .2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.day-chip span { font-size: .78rem; color: var(--muted); }
.day-chip b { font-size: 1.2rem; }
.day-chip small { font-size: .7rem; color: var(--primary); min-height: 1em; }
.day-today { border-color: var(--primary); }
.day-on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.day-on span, .day-on small { color: inherit; }
.appt-list { display: flex; flex-direction: column; gap: .5rem; }
.appt-card { display: flex; gap: .9rem; align-items: flex-start; padding: .7rem .85rem; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--primary); border-radius: 12px; cursor: pointer; }
.appt-time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4.8rem; }

/* Máy check-in của khách */
.kiosk { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, var(--primary-soft), var(--bg)); }
.kiosk-card { width: min(480px, 100%); background: var(--surface); border-radius: 24px; padding: 1.25rem; box-shadow: 0 10px 40px rgb(0 0 0 / .12); display: flex; flex-direction: column; gap: .9rem; }
.kiosk-title { text-align: center; margin: 0; color: var(--primary); }
.kiosk-sub { text-align: center; margin: 0; font-size: 1.1rem; }
.kiosk-phone { text-align: center; font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 700; letter-spacing: .05em; font-variant-numeric: tabular-nums; background: var(--surface-2); border-radius: 14px; padding: .6rem; }
.kiosk-keys .key { min-height: 72px; font-size: 1.9rem; }
.kiosk-done { text-align: center; font-size: 4rem; margin: 0; color: var(--ok); }
.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.rate-btn { display: flex; flex-direction: column; align-items: center; gap: .3rem; min-height: 110px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.rate-btn span { font-size: 2.6rem; }

@media print {
    .print-only { display: block; }
    .modal-backdrop { display: none; }
    .modal { position: static; transform: none; box-shadow: none; width: auto; max-height: none; }
    .modal-head { display: none; }
}

/* Công thức tính */
.formula-card { margin-bottom: 1rem; }
.formula-card h2 { margin-top: 0; }
.formula-grid { display: grid; grid-template-columns: 1fr minmax(260px, 420px); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .formula-grid { grid-template-columns: 1fr; } }
.example { background: var(--surface-2); border-radius: 12px; padding: .75rem .9rem; border-left: 4px solid var(--primary); }
.example h3 { margin-top: 0; }
.example ul { margin: .25rem 0 .5rem; padding-left: 1.2rem; }
.example .table { background: var(--surface); border-radius: 8px; }
.formula { margin: .35rem 0; font-variant-numeric: tabular-nums; }

/* Loại máy */
.device-badge { color: inherit; text-decoration: none; font-size: .78rem; font-weight: 700; padding: .2rem .55rem; border: 1px solid rgb(255 255 255 / .5); border-radius: 999px; white-space: nowrap; }
.kiosk-gear { position: fixed; right: 10px; bottom: 10px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--muted); opacity: .35; text-decoration: none; font-size: 1.2rem; }
.kiosk-gear:hover, .kiosk-gear:focus-visible { opacity: 1; }

/* Liên thông 3 máy: thông báo tức thì + hoạt động hôm nay */
.live-alerts { position: fixed; top: 70px; right: 12px; z-index: 55; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 24px)); }
.live-alert { display: flex; align-items: center; gap: .6rem; text-align: left; padding: .7rem .85rem; border-radius: 12px; border: 1px solid var(--border); border-left: 5px solid var(--primary); background: var(--surface); color: var(--text); font: inherit; box-shadow: 0 8px 24px rgb(0 0 0 / .18); cursor: pointer; animation: live-in .25s ease-out; }
.live-clockin { border-left-color: var(--ok); }
.live-clockout { border-left-color: var(--muted); }
.live-customercheckin { border-left-color: var(--hold); }
.live-billpaid { border-left-color: var(--primary); }
.live-icon { font-size: 1.3rem; flex: none; }
.live-text { flex: 1; font-weight: 600; }
.live-time { font-size: .8rem; color: var(--muted); white-space: nowrap; }
@keyframes live-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.activity-feed { margin-bottom: 1rem; }
.activity-feed ul { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.activity-feed li { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.activity-feed li:last-child { border-bottom: 0; }
.live-dot { color: var(--ok); font-size: .8rem; font-weight: 700; }
@media (max-width: 640px) { .live-alerts { top: auto; bottom: 12px; } }

/* Đồng ý nhận tin (TCPA) */
.check.consent { font-size: .82rem; line-height: 1.35; color: var(--muted); }
.consent-btn { border-color: var(--primary); color: var(--primary); }
.consent-note { font-size: .75rem; color: var(--muted); text-align: center; margin: -.4rem 0 0; }

/* Máy cà thẻ */
.card-pay { display: flex; flex-direction: column; gap: .7rem; text-align: center; }
.card-amount { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-wait { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tiện lợi: tip nhanh, tiền thối, số liệu hôm nay, bước bắt đầu */
.quick-tips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.quick-tips .chip { min-height: 38px; padding: .2rem .7rem; font-size: .88rem; }
.change-due { min-height: var(--tap); display: flex; align-items: center; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.back-note { display: flex; align-items: center; gap: .6rem; color: var(--muted); }
.kiosk-progress { text-align: center; margin: 0; padding: .6rem .8rem; border-radius: 12px; background: var(--primary-soft); font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.kpi { display: flex; flex-direction: column; gap: .1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; }
.kpi span { font-size: .8rem; color: var(--muted); }
.kpi b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.setup { margin-bottom: 1rem; border-left: 5px solid var(--primary); }
.setup ol { list-style: none; padding: 0; margin: 0 0 .8rem; }
.setup li { display: flex; gap: .6rem; padding: .35rem 0; }
.setup li.done { color: var(--muted); text-decoration: line-through; }
.keypad:focus { outline: none; }

/* Huỷ bill / hoàn tiền / chốt ca */
.refund-line { color: var(--danger); }
.cash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.cash-table td, .cash-table th { padding: .35rem .5rem; }
.cash-table .num input { width: 6rem; text-align: right; }
.cash-total { font-size: 1.15rem; }
.diff-ok { color: var(--ok); font-weight: 700; }
.diff-bad { color: var(--danger); font-weight: 700; }
.zreport { max-width: 420px; margin: 0 auto; font-variant-numeric: tabular-nums; }
.zreport h2 { text-align: center; margin: .2rem 0; }
.zreport dl { display: grid; grid-template-columns: 1fr auto; gap: .15rem .8rem; margin: .4rem 0; }
.zreport dt { color: var(--muted); }
.zreport dd { margin: 0; text-align: right; }
.zreport hr { border: 0; border-top: 1px dashed var(--border); margin: .5rem 0; }
.audit-json { white-space: pre-wrap; word-break: break-word; font-size: .78rem; max-width: 36rem; }
@media print { .zreport { max-width: none; } .zreport dt { color: #000; } }
.plain-list { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .5rem; margin-bottom: 1rem; }

/* Hướng dẫn sử dụng */
.hd { max-width: 980px; }
.hd .toc { columns: 2 260px; padding-left: 1.3rem; }
.hd .toc li { margin: .2rem 0; }
.hd section { scroll-margin-top: 70px; }
.hd video { width: 100%; border: 1px solid var(--border); border-radius: 12px; background: #000; margin: .4rem 0 .2rem; }
.hd .vcap { font-size: .85rem; color: var(--muted); margin-bottom: .8rem; }
.hd ol, .hd ul { padding-left: 1.3rem; }
.hd li { margin: .25rem 0; }
.hd .tip { background: var(--primary-soft); border-radius: 10px; padding: .6rem .8rem; margin: .6rem 0; }
.hd .formula { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border-radius: 8px; padding: .5rem .7rem; display: block; margin: .4rem 0; }
.hd .table td, .hd .table th { vertical-align: top; }
