/* RestoAI – hệ thống token giao diện */
:root {
  --ink: #1E2321;
  --ink-2: #4A524E;
  --muted: #7B847F;
  --surface: #F4F6F2;
  --panel: #FFFFFF;
  --line: #E1E5DE;
  --basil: #2F6B4F;
  --basil-d: #234F3B;
  --basil-l: #E6F0EA;
  --night: #15302A;
  --saffron: #E3A72F;
  --saffron-l: #FCF3DF;
  --chili: #C2412D;
  --chili-l: #FBE9E5;
  --sky: #2B6CB0;
  --r-sm: 6px; --r: 10px; --r-lg: 16px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-primary: #2F6B4F; --bs-primary-rgb: 47,107,79;
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--ink);
  --bs-link-color: var(--basil); --bs-link-hover-color: var(--basil-d);
  --bs-link-color-rgb: 47,107,79;
}
html, body { background: var(--surface); color: var(--ink); font-family: var(--font); font-size: 14.5px; }
.num, .money, td.r, th.r { font-variant-numeric: tabular-nums; }
td.r, th.r { text-align: right; }
h1, .h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2, .h2 { font-size: 1.25rem; font-weight: 700; }
h3, .h3 { font-size: 1.05rem; font-weight: 600; }
a { text-decoration: none; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }

.btn-primary { --bs-btn-bg: var(--basil); --bs-btn-border-color: var(--basil); --bs-btn-hover-bg: var(--basil-d); --bs-btn-hover-border-color: var(--basil-d); --bs-btn-active-bg: var(--basil-d); --bs-btn-disabled-bg: var(--basil); --bs-btn-disabled-border-color: var(--basil); }
.btn-outline-primary { --bs-btn-color: var(--basil); --bs-btn-border-color: var(--basil); --bs-btn-hover-bg: var(--basil); --bs-btn-hover-border-color: var(--basil); --bs-btn-active-bg: var(--basil-d); }
.btn-ai { background: var(--saffron); color: var(--night); border: 0; font-weight: 600; }
.btn-ai:hover { background: #d4961f; color: var(--night); }
.form-control:focus, .form-select:focus { border-color: var(--basil); box-shadow: 0 0 0 .2rem rgba(47,107,79,.18); }
.text-basil { color: var(--basil) !important; }
.text-chili { color: var(--chili) !important; }
.bg-basil-l { background: var(--basil-l) !important; }

/* ---------- Khung ứng dụng ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--night); color: #cfdcd5; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; color: #fff; font-weight: 700; font-size: 1.15rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--saffron); color: var(--night); display: grid; place-items: center; font-weight: 800; }
.nav-group { margin-top: 14px; }
.nav-group > span { display: block; font-size: .75rem; color: #8fa89c; padding: 4px 12px; }
.sidebar a.nav-l { display: flex; align-items: center; gap: 10px; color: #dbe6e0; padding: 7px 12px; border-radius: 8px; font-size: .93rem; }
.sidebar a.nav-l i { font-size: 1.05rem; opacity: .85; width: 18px; }
.sidebar a.nav-l:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.nav-l.active { background: var(--basil); color: #fff; }
.sidebar a.nav-l.ai { color: var(--saffron); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1010; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 10px 22px; }
.content { padding: 22px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 2px 0 0; }

/* Thanh lệnh AI */
.ai-bar { flex: 1; max-width: 640px; position: relative; }
.ai-bar input { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 16px 9px 40px; font-size: .95rem; }
.ai-bar input:focus { outline: none; border-color: var(--saffron); background: #fff; box-shadow: 0 0 0 4px var(--saffron-l); }
.ai-bar .spark { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--saffron); font-size: 1.1rem; }
.ai-pop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: 0 12px 32px rgba(21,48,42,.14); white-space: pre-line; display: none; max-height: 60vh; overflow: auto; }
.ai-pop.show { display: block; }

/* Thẻ */
.card-x { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.card-x > .card-t { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-x > .card-t h3 { margin: 0; }
.table-x { width: 100%; }
.table-x th { font-weight: 600; color: var(--muted); font-size: .82rem; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; }
.table-x td { border-bottom: 1px solid #eef1ec; padding: 9px 10px; vertical-align: middle; }
.table-x tr:last-child td { border-bottom: 0; }
.table-x tbody tr:hover { background: #fafbf9; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface); color: var(--ink-2); }
.pill.ok { background: var(--basil-l); color: var(--basil-d); }
.pill.warn { background: var(--saffron-l); color: #8a5d00; }
.pill.bad { background: var(--chili-l); color: var(--chili); }
.pill.info { background: #e6eef8; color: var(--sky); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface); }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }

/* ---------- Dashboard AI: một dải chỉ số đọc theo thứ tự ---------- */
.flow { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.flow .k { padding: 16px 18px; border-right: 1px solid var(--line); position: relative; }
.flow .k:last-child { border-right: 0; }
.flow .k small { color: var(--muted); display: block; font-size: .8rem; }
.flow .k b { display: block; font-size: 1.55rem; font-weight: 700; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
.flow .k .d { font-size: .8rem; }
.up { color: var(--basil); } .down { color: var(--chili); }
.ai-panel { background: var(--night); color: #e8efe9; border-radius: var(--r-lg); padding: 20px; }
.ai-panel h3 { color: var(--saffron); display: flex; gap: 8px; align-items: center; }
.ai-panel .adv { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.ai-panel .adv:last-child { border-bottom: 0; }
.alert-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #eef1ec; align-items: flex-start; }
.alert-row:last-child { border-bottom: 0; }
.alert-row .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; }
.dot.danger { background: var(--chili); } .dot.warning { background: var(--saffron); } .dot.info { background: var(--sky); }
.rank { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.rank .bar { height: 6px; background: var(--basil-l); border-radius: 3px; flex: 1; overflow: hidden; }
.rank .bar i { display: block; height: 100%; background: var(--basil); }

/* ---------- POS ---------- */
body.pos .content { padding: 0; }
.pos-grid { display: grid; grid-template-columns: 290px 1fr 390px; height: calc(100vh - 57px); }
.pos-col { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.pos-col.mid { background: var(--surface); }
.pos-col .hd { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pos-col .bd { flex: 1; overflow-y: auto; padding: 10px 12px; }
.tbl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tbl { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; background: #fff; min-height: 70px; position: relative; text-align: left; }
.tbl b { display: block; font-size: .92rem; }
.tbl small { color: var(--muted); font-size: .75rem; }
.tbl.s0 { background: #fff; }
.tbl.s1 { background: var(--basil-l); border-color: #b8d4c4; }
.tbl.s2 { background: var(--saffron-l); border-color: #f0d79a; }
.tbl.sel { outline: 3px solid var(--basil); outline-offset: 1px; }
.tbl .flag { position: absolute; top: 6px; right: 6px; font-size: .9rem; }
.tbl.req { animation: ring 1s ease-in-out infinite alternate; }
@keyframes ring { from { box-shadow: 0 0 0 0 rgba(194,65,45,.0); } to { box-shadow: 0 0 0 4px rgba(194,65,45,.35); } }
.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.cat-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 13px; white-space: nowrap; font-size: .88rem; }
.cat-tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.mi { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform .08s; }
.mi:active { transform: scale(.97); }
.mi img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--surface); }
.mi .t { padding: 7px 9px; }
.mi .t b { display: block; font-size: .86rem; line-height: 1.25; font-weight: 600; }
.mi .t span { color: var(--basil); font-weight: 700; font-size: .86rem; }
.mi.off { opacity: .45; cursor: not-allowed; }
.mi .tag { position: absolute; }
.order-line { display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.order-line .nm { font-weight: 600; font-size: .9rem; }
.order-line .sub { color: var(--muted); font-size: .78rem; }
.order-line .qty { display: inline-flex; align-items: center; gap: 6px; }
.order-line .qty button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: #fff; line-height: 1; }
.order-line.cancel { opacity: .45; text-decoration: line-through; }
.st { font-size: .7rem; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.st0 { background: #eee; color: #555; } .st1 { background: var(--saffron-l); color: #8a5d00; } .st2 { background: #e6eef8; color: var(--sky); }
.st3 { background: var(--basil-l); color: var(--basil-d); } .st4 { background: #e9ecea; color: #5d6762; } .st5 { background: var(--chili-l); color: var(--chili); }
.totals { border-top: 1px solid var(--line); padding: 10px 12px; background: #fff; }
.totals .row-t { display: flex; justify-content: space-between; font-size: .9rem; padding: 2px 0; }
.totals .grand { font-size: 1.35rem; font-weight: 800; }
.ai-sug { background: var(--saffron-l); border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: .84rem; }
.ai-sug button { border: 0; background: #fff; border-radius: 999px; padding: 3px 10px; margin: 3px 3px 0 0; font-size: .8rem; }

/* ---------- KDS ---------- */
body.kds { background: #101a17; color: #e8efe9; }
.kds-top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: #0b1311; position: sticky; top: 0; z-index: 5; }
.kds-top a, .kds-top button { color: #cfdcd5; }
.kds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; padding: 16px 18px; align-items: start; }
.ticket { background: #fff; color: var(--ink); border-radius: 12px; overflow: hidden; }
.ticket .th { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; background: #dfe7e2; }
.ticket .th b { font-size: 1.1rem; }
.ticket.late .th { background: #f6c9bf; }
.ticket.warm .th { background: #f7e3b0; }
.ticket.prio { box-shadow: 0 0 0 4px var(--chili); }
.ticket .it { padding: 9px 12px; border-top: 1px solid #edf0ec; display: flex; gap: 10px; align-items: flex-start; }
.ticket .it .q { font-size: 1.25rem; font-weight: 800; min-width: 30px; }
.ticket .it.cooking { background: #eef4fb; }
.ticket .it .note { color: var(--chili); font-weight: 600; font-size: .85rem; }

/* ---------- Trang khách (Shop / QR) ---------- */
body.guest { background: #fbfbf8; }
.g-head { background: var(--night); color: #fff; padding: 18px 16px 22px; }
.g-head h1 { color: #fff; font-size: 1.35rem; margin: 0; }
.g-wrap { max-width: 1080px; margin: 0 auto; padding: 0 14px 120px; }
.g-cats { position: sticky; top: 0; z-index: 5; background: #fbfbf8; padding: 10px 0; }
.g-item { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.g-item img { width: 92px; height: 92px; border-radius: 12px; object-fit: cover; }
.g-item h4 { font-size: 1rem; margin: 0 0 2px; font-weight: 600; }
.g-item p { color: var(--muted); font-size: .84rem; margin: 0 0 6px; }
.g-item .price { color: var(--basil); font-weight: 700; }
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 14px; display: flex; gap: 10px; align-items: center; z-index: 20; box-shadow: 0 -6px 18px rgba(0,0,0,.06); }
.chat-fab { position: fixed; right: 16px; bottom: 84px; width: 54px; height: 54px; border-radius: 50%; background: var(--saffron); color: var(--night); border: 0; font-size: 1.4rem; z-index: 25; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.chat-box { position: fixed; right: 16px; bottom: 148px; width: min(360px, calc(100vw - 32px)); height: 460px; background: #fff; border-radius: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.2); display: none; flex-direction: column; z-index: 26; overflow: hidden; }
.chat-box.show { display: flex; }
.chat-box .ch { background: var(--night); color: #fff; padding: 12px 14px; }
.chat-box .cm { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 11px; border-radius: 12px; font-size: .9rem; white-space: pre-line; }
.msg.me { align-self: flex-end; background: var(--basil); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; }

/* ---------- Sơ đồ bàn ---------- */
.floor { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); min-height: 520px; background-image: radial-gradient(#dfe4dc 1px, transparent 1px); background-size: 20px 20px; overflow: auto; }
.floor .ft { position: absolute; width: 136px; height: 100px; border-radius: 14px; border: 2px solid #cfd6cc; background: #fff; padding: 9px 11px; cursor: pointer; user-select: none; }
.floor .ft.s1 { background: var(--basil-l); border-color: var(--basil); }
.floor .ft.s2 { background: var(--saffron-l); border-color: var(--saffron); }
.floor .ft b { font-size: 1rem; display: block; }
.floor .ft small { display: block; color: var(--ink-2); font-size: .76rem; }
.floor.edit .ft { cursor: move; border-style: dashed; }

/* Toast */
.toast-x { position: fixed; right: 18px; bottom: 18px; z-index: 2000; background: var(--ink); color: #fff; border-radius: 10px; padding: 11px 16px; box-shadow: 0 10px 28px rgba(0,0,0,.2); max-width: 380px; }
.toast-x.danger { background: var(--chili); } .toast-x.warning { background: #8a5d00; }

@media (max-width: 1200px) {
  .pos-grid { grid-template-columns: 240px 1fr 340px; }
  .flow { grid-template-columns: repeat(3, 1fr); }
  .flow .k:nth-child(3) { border-right: 0; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; z-index: 1050; transition: left .2s; }
  .sidebar.open { left: 0; }
  .pos-grid { grid-template-columns: 1fr; height: auto; }
  .flow { grid-template-columns: repeat(2, 1fr); }
  .flow .k { border-bottom: 1px solid var(--line); }
  .content { padding: 14px; }
  .topbar { padding: 8px 12px; }
}
@media print { .sidebar, .topbar, .no-print { display: none !important; } .app { display: block; } .content { padding: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
