/* =========================================================
   Trang chủ quán
   ========================================================= */
body.admin { background: var(--cream) var(--noise); }
.small { font-size: 12.5px; }

.alogin { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: var(--cream) var(--noise); }
.alogin[hidden] { display: none; }
.alogin__card { width: min(400px, 100%); padding: 36px 28px; border-radius: 28px; background: var(--paper); box-shadow: var(--shadow-l); display: grid; gap: 14px; justify-items: center; text-align: center; }
.alogin__card h1 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 34px; }
.alogin__card p { margin: -6px 0 6px; }
.alogin__card .input { text-align: center; font-size: 18px; letter-spacing: .14em; }
.alogin__ico { width: 56px; height: 56px; color: var(--clay); }

.ahead { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px var(--pad); background: rgba(246, 238, 226, .9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.ahead__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.ahead .btn { min-height: 42px; padding: 0 16px; font-size: 14px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf-l); box-shadow: 0 0 0 4px rgba(143, 174, 94, .2); animation: blink 2s infinite; }
.live.err i { background: var(--clay); animation: none; }
@keyframes blink { 50% { opacity: .35; } }

.atabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 14px var(--pad) 4px; }
.atabs::-webkit-scrollbar { display: none; }
.atabs button { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--paper); font-weight: 600; font-size: 14.5px; }
.atabs button[aria-selected="true"] { background: var(--cocoa); color: var(--paper); border-color: var(--cocoa); }
.abadge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--clay); color: #fff; font-style: normal; font-size: 12px; font-weight: 700; }

.amain { padding: 16px var(--pad) 60px; max-width: 1400px; margin: 0 auto; }
.apanel { display: grid; gap: 16px; animation: fadeup .4s var(--ease-out); }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } }
.acard { padding: 20px; border-radius: 22px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow-s); }
.acard h2 { margin: 0; font-size: 17px; font-weight: 700; }
.acard__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.acard__head p { margin: 4px 0 0; font-size: 13px; }
.acard__head .input { width: auto; }
.agrid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 980px) { .agrid { grid-template-columns: 1fr; } }
.input--sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.chip-btn { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip-btn[aria-pressed="true"] { background: var(--cocoa); color: var(--paper); border-color: var(--cocoa); }
.note { margin: 0; padding: 12px 16px; border-radius: 14px; background: var(--plaster); font-size: 14px; }
.note--warn { background: #FBEBC9; color: #6B4810; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kpi { padding: 18px 20px; border-radius: 20px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow-s); }
.kpi small { display: block; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.kpi b { display: block; margin-top: 4px; font-family: var(--f-display); font-weight: 400; font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); }
.kpi--hero { background: var(--cocoa-3) var(--noise); color: var(--paper); border-color: transparent; }
.kpi--hero small, .kpi--hero span { color: #C9B8A3; }
.kpi--hero b { font-size: 38px; }
.kpi--alert { border-color: var(--clay); box-shadow: 0 0 0 2px rgba(192, 104, 58, .2); }

/* Biểu đồ cột */
.chart { position: relative; height: 240px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: #E7DCCB; stroke-width: 1; }
.chart .tick { font-family: var(--f-mono); font-size: 11px; fill: var(--ink-soft); }
.chart .xl { font-size: 12px; fill: var(--cocoa-2); font-family: var(--f-body); }
.chart .xl.today { font-weight: 700; fill: var(--cocoa); }
.chart .bar { fill: var(--clay); transition: opacity .2s; }
.chart .bar.dim { opacity: .45; }
.chart .val { font-family: var(--f-mono); font-size: 11.5px; font-weight: 600; fill: var(--cocoa); }
.chart .hit { fill: transparent; cursor: default; }
.ctip { position: absolute; z-index: 3; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: var(--cocoa-3); color: var(--paper); font-size: 12.5px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow-m); }
.ctip b { display: block; font-family: var(--f-mono); font-size: 14px; }
.chart-table table, .tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.chart-table th, .chart-table td, .tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.chart-table td:last-child, .chart-table th:last-child { text-align: right; font-family: var(--f-mono); }

.dsum { display: grid; gap: 8px; }
.dsum__row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.dsum__row b { font-family: var(--f-mono); }
.top { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: t; display: grid; gap: 6px; }
.top li { counter-increment: t; display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.top li::before { content: counter(t); font-family: var(--f-mono); font-size: 12px; color: var(--ink-soft); }
.top li b { font-family: var(--f-mono); font-size: 13px; }

/* danh sách */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.alist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.item { padding: 16px; border-radius: 18px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow-s); display: grid; gap: 8px; }
.item.unread { border-color: var(--leaf); box-shadow: 0 0 0 2px rgba(78, 107, 53, .18); }
.item.dim { opacity: .55; }
.item__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item__head b { font-family: var(--f-mono); font-size: 15px; }
.item__time { margin-left: auto; font-size: 12.5px; color: var(--ink-soft); }
.item p { margin: 0; font-size: 14.5px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.item ul { margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.item li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.item li small { color: var(--ink-soft); }
.item__foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item__foot .sum { margin-right: auto; font-family: var(--f-mono); font-weight: 700; }
.item__foot button, .sbtn { min-height: 34px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: #fff; font-size: 13px; font-weight: 600; }
.item__foot button.primary { background: var(--cocoa); border-color: var(--cocoa); color: var(--paper); }
.stars { color: var(--gold); letter-spacing: 1px; }
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--plaster); }
.tag--new { background: #F8E1D6; color: var(--clay-d); }
.tag--making { background: #FBEBC9; color: #8A5A14; }
.tag--served, .tag--confirmed, .tag--arrived { background: #E3EBD6; color: var(--leaf); }
.tag--cancelled { background: #eee; color: #888; }
.tag--paid { background: var(--leaf); color: #fff; }
.tag--unpaid { background: #FBEBC9; color: #8A5A14; }
.empty { padding: 30px; text-align: center; color: var(--ink-soft); border: 1.5px dashed var(--line-2); border-radius: 18px; grid-column: 1 / -1; }
.bday { margin: 18px 0 8px; font-family: var(--f-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--clay-d); }
.brow { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; margin-bottom: 8px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); }
.brow__time { font-family: var(--f-display); font-size: 24px; }
.brow__who b { display: block; }
.brow__who span { font-size: 13px; color: var(--ink-soft); }
.brow__btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.brow.cancelled { opacity: .5; }
@media (max-width: 640px) { .brow { grid-template-columns: 54px 1fr; } .brow__btns { grid-column: 1 / -1; justify-content: flex-start; } }
.srow { display: grid; grid-template-columns: 90px 70px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.srow b { font-family: var(--f-mono); }
.srow.void { opacity: .45; text-decoration: line-through; }
@media (max-width: 720px) { .srow { grid-template-columns: 80px 1fr auto; } .srow .srow__items { grid-column: 1 / -1; order: 5; } }

/* QR */
.qrform { display: grid; gap: 12px; }
.qrform h2 { font-size: 20px; }
.qrform p { margin: 0; }
.qrform__row { display: grid; grid-template-columns: 2fr 1fr .6fr .6fr; gap: 10px; }
.qrform__btns { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) { .qrform__row { grid-template-columns: 1fr 1fr; } .qrform__row .field:first-child { grid-column: 1 / -1; } }
.qrgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.qrcard { display: grid; justify-items: center; gap: 6px; padding: 18px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--line); text-align: center; break-inside: avoid; }
.qrcard__brand { font-family: var(--f-script); font-size: 20px; color: var(--cocoa); }
.qrcard img { width: 160px; height: 160px; }
.qrcard b { font-size: 18px; }
.qrcard small { font-size: 12px; color: var(--ink-soft); }
.qrcard a { font-size: 11px; color: var(--ink-soft); word-break: break-all; }
@media print {
  body.admin { background: #fff; }
  .ahead, .atabs, .qrform, .alogin { display: none !important; }
  .apanel:not(#tab-qr) { display: none !important; }
  #tab-qr { display: block !important; }
  .qrgrid { grid-template-columns: repeat(3, 1fr); }
  .qrcard { border: 1.5px dashed #999; }
}

/* ---------- Cài đặt ---------- */
.keywarn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.keywarn .sbtn { margin-left: auto; }
.sgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.sform { display: grid; gap: 14px; margin: 0; min-width: 0; }
fieldset.sform { border: 1px solid var(--line); }
.sform legend { float: left; width: 100%; padding: 0; margin: 0 0 -4px; font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sform legend + * { clear: both; }
.sform > p { margin: 0; font-size: 13.5px; }
.sform--wide { grid-column: 1 / -1; }
.frow { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.suffix { display: flex; align-items: center; gap: 8px; }
.suffix .input { flex: 1; min-width: 0; }
.suffix em { font-style: normal; font-size: 14px; color: var(--ink-soft); }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; font-size: 15px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__ui { position: relative; width: 50px; height: 30px; flex: none; border-radius: 99px; background: #D9CBB8; transition: background .25s; }
.switch__ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .3s var(--ease); }
.switch input:checked + .switch__ui { background: var(--leaf); }
.switch input:checked + .switch__ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__ui { outline: 2.5px solid var(--clay); outline-offset: 2px; }
.floorf { display: grid; grid-template-columns: 120px 1fr 2fr; gap: 10px; align-items: end; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.floorf img { width: 120px; height: 64px; object-fit: cover; border-radius: 12px 12px 6px 6px; }
@media (max-width: 640px) { .floorf { grid-template-columns: 1fr; } .floorf img { width: 100%; height: 90px; } }
.socat { margin-bottom: 14px; }
.socat h3 { margin: 0 0 8px; font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.sochips { display: flex; flex-wrap: wrap; gap: 6px; }
.sochip { position: relative; }
.sochip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sochip span { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff; font-size: 13.5px; font-weight: 600; transition: all .2s; }
.sochip input:checked + span { background: #F8E1D6; border-color: var(--clay); color: var(--clay-d); text-decoration: line-through; }
.sochip input:checked + span::after { content: 'Tạm hết'; text-decoration: none; display: inline-block; font-size: 10.5px; padding: 2px 6px; border-radius: 99px; background: var(--clay); color: #fff; }
.sochip input:focus-visible + span { outline: 2.5px solid var(--clay); outline-offset: 2px; }
.qrprev { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qrprev img { width: 150px; height: 150px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.keys h2 { font-size: 18px; }
.keys .btn { justify-self: start; }
.savebar { position: sticky; bottom: 16px; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 20px; border-radius: 18px; background: rgba(42, 24, 16, .94); color: var(--paper); box-shadow: var(--shadow-l); backdrop-filter: blur(8px); }
.savebar span { margin-right: auto; font-size: 14px; }
.savebar .btn { min-height: 44px; }
.savebar .btn--ghost { --fg: var(--paper); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .3); }
.savebar.dirty span::before { content: '●'; color: var(--gold); margin-right: 8px; }
@media (max-width: 900px) { .sgrid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .savebar { flex-wrap: wrap; } .savebar span { width: 100%; } .savebar .btn { flex: 1; } }
