/* =====================================================================
   CAFE POS — Hệ thống giao diện dùng chung
   Bảng màu lấy cảm hứng từ cà phê: nâu espresso, kem, hổ phách.
   ===================================================================== */

:root {
  --bg:          #f4f1ec;
  --surface:     #ffffff;
  --surface-2:   #faf8f5;
  --ink:         #211a14;
  --ink-2:       #4a3f37;
  --muted:       #857a70;
  --line:        #e5ded4;
  --line-2:      #d8cec0;

  --brand:       #6b4a33;
  --brand-dark:  #513626;
  --brand-soft:  #f0e7de;
  --accent:      #d9832b;
  --accent-soft: #fdf1e2;

  --ok:          #10795a;
  --ok-soft:     #e3f5ee;
  --warn:        #b3761a;
  --warn-soft:   #fdf2dd;
  --danger:      #b53228;
  --danger-soft: #fceae8;
  --info:        #2a6099;
  --info-soft:   #e7f0f9;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(33,26,20,.06), 0 1px 3px rgba(33,26,20,.05);
  --shadow-2: 0 4px 12px rgba(33,26,20,.08), 0 2px 4px rgba(33,26,20,.04);
  --shadow-3: 0 12px 32px rgba(33,26,20,.14);

  --sidebar-w: 236px;
  --header-h:  60px;

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.muted   { color: var(--muted); }
.small   { font-size: 13px; }
.tiny    { font-size: 12px; }
.strong  { font-weight: 650; }
.mono    { font-family: var(--mono); }
.center  { text-align: center; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.hidden  { display: none !important; }
.money   { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}

/* ---------------------------------------------------------------- Bố cục */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(175deg, #3b2a1e 0%, #2a1d15 100%);
  color: #e8ddd2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  background: var(--accent);
  color: #2a1d15;
  border-radius: 9px;
  font-size: 18px;
}
.sidebar-brand b { display: block; color: #fff; font-size: 15px; line-height: 1.2; }
.sidebar-brand span { font-size: 11.5px; color: #b7a696; letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 10px 10px 24px; flex: 1; }
.nav-label {
  padding: 14px 10px 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9d8b7b;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: #ddd0c3;
  font-size: 14.5px;
  transition: background .12s, color .12s;
}
.nav a .ic { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--accent); color: #2a1d15; font-weight: 600; }
.nav a.active .ic { opacity: 1; }
.nav .badge-count {
  margin-left: auto;
  background: rgba(255,255,255,.16);
  color: #fff;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11.5px;
}
.nav a.active .badge-count { background: rgba(0,0,0,.18); color: #2a1d15; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .spacer { flex: 1; }

.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--line);
  border-radius: 8px; width: 38px; height: 38px;
  font-size: 18px; cursor: pointer; color: var(--ink);
}

.content { padding: 22px 20px 48px; flex: 1; }
.content.narrow { max-width: 900px; }

/* ------------------------------------------------------------- Thành phần */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.sidebar-right { grid-template-columns: minmax(0,1fr) 340px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 8px; }
.row .spacer { flex: 1; }

/* ---- Thẻ số liệu ---- */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.stat .label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat .sub.up { color: var(--ok); }
.stat .sub.down { color: var(--danger); }
.stat.accent { border-left: 3px solid var(--accent); }

/* ---- Nút ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #2a1d15; }
.btn-accent:hover { background: #c4741f; border-color: #c4741f; color: #2a1d15; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #0c6047; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #932720; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15.5px; }
.btn-block { width: 100%; }

/* ---- Nhãn trạng thái ---- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.tag-ok     { background: var(--ok-soft);     color: var(--ok); }
.tag-warn   { background: var(--warn-soft);   color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info   { background: var(--info-soft);   color: var(--info); }
.tag-muted  { background: #efeae3;            color: var(--muted); }
.tag-brand  { background: var(--brand-soft);  color: var(--brand); }

/* ---- Biểu mẫu ---- */
.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

input[type=text], input[type=password], input[type=number], input[type=email],
input[type=date], input[type=time], input[type=tel], input[type=search],
select, textarea {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23857a70' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(107,74,51,.13);
}
input[readonly] { background: var(--surface-2); color: var(--muted); }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14.5px; }
.check input[type=checkbox], .check input[type=radio] {
  width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; margin: 0;
}

.input-group { display: flex; }
.input-group input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; height: 40px; }

.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line);
}

/* ---- Bảng ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .icon { font-size: 40px; opacity: .45; display: block; margin-bottom: 10px; }

/* ---- Thông báo ---- */
.alert {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
  display: flex; gap: 9px; align-items: flex-start;
}
.alert-success { background: var(--ok-soft);     color: #0b5f47; border-color: #bfe5d8; }
.alert-error   { background: var(--danger-soft); color: #8e2921; border-color: #f2ccc8; }
.alert-info    { background: var(--info-soft);   color: #1f4a77; border-color: #c9ddf0; }
.alert-warning { background: var(--warn-soft);   color: #8a5a10; border-color: #f0dcb4; }

.flash-stack {
  position: fixed; top: 14px; right: 14px; z-index: 900;
  width: min(380px, calc(100vw - 28px));
  display: flex; flex-direction: column; gap: 8px;
}
.flash-stack .alert { box-shadow: var(--shadow-2); margin: 0; animation: slideIn .22s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---- Bộ lọc ---- */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r) var(--r) 0 0;
}
.filters .field { margin: 0; min-width: 140px; }
.filters .field > label { font-size: 12px; margin-bottom: 3px; }

/* ---- Phân trang ---- */
.pager { display: flex; gap: 5px; align-items: center; padding: 14px 18px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 34px; height: 34px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-size: 14px; color: var(--ink-2); background: var(--surface);
}
.pager a:hover { background: var(--surface-2); }
.pager .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---- Hộp thoại ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(33,26,20,.5);
  display: none; align-items: center; justify-content: center; z-index: 800; padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-3); animation: pop .16s ease;
}
.modal.wide { width: min(860px, 100%); }
@keyframes pop { from { opacity: 0; transform: scale(.97) } to { opacity: 1; transform: none } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-head .close { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Dòng tổng tiền (giỏ hàng, hoá đơn, kết ca) ---- */
.sum-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; color: var(--ink-2); }
.sum-line.total {
  font-size: 20px; font-weight: 750; color: var(--ink);
  padding-top: 8px; margin-top: 6px; border-top: 1px dashed var(--line-2);
}
.sum-line.discount { color: var(--ok); }

/* ---- Bộ tăng/giảm số lượng ---- */
.qty-box { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.qty-box button {
  width: 30px; height: 30px; border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 7px; font-size: 17px; line-height: 1; cursor: pointer; color: var(--ink);
  display: grid; place-items: center;
}
.qty-box button:active { background: var(--brand-soft); }
.qty-box .q { min-width: 34px; text-align: center; font-weight: 650; font-size: 15px; }
.qty-box .del { margin-left: 6px; border-color: transparent; color: var(--danger); font-size: 15px; }

/* ---- Lựa chọn dạng thẻ (biến thể, topping, nhóm tuỳ chọn) ---- */
.opt-group { margin-bottom: 16px; }
.opt-group h4 { margin: 0 0 8px; font-size: 14px; }
.opt-group .req { color: var(--danger); font-size: 12.5px; font-weight: 500; }
.opt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.opt-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 9px;
  cursor: pointer; font-size: 14px; background: var(--surface); min-height: 46px;
}
.opt-chip.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.opt-chip .plus { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.opt-chip input { display: none; }

/* ---- Danh sách bản ghi bấm được (đơn đang mở, kết quả tìm khách) ---- */
.order-list { display: grid; gap: 9px; }
.open-order {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: var(--ink);
}
.open-order:hover { border-color: var(--accent); }
.open-order .lead { flex: 1; min-width: 0; }
.open-order .code { font-weight: 700; font-size: 14.5px; }
.open-order .meta { font-size: 12.5px; color: var(--muted); }

/* ---- Biểu đồ ---- */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.chart-bars .bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.chart-bars .bar {
  width: 100%; max-width: 44px; min-height: 3px;
  background: linear-gradient(180deg, var(--accent), #c4741f);
  border-radius: 4px 4px 0 0; position: relative; transition: opacity .12s;
}
.chart-bars .bar:hover { opacity: .8; }
.chart-bars .bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

.progress { height: 7px; background: var(--brand-soft); border-radius: 20px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 20px; }

/* ---- Trang trắng (đăng nhập, cài đặt) ---- */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 12% -10%, rgba(217,131,43,.18), transparent 60%),
    linear-gradient(160deg, #3b2a1e, #23180f);
}
.auth-card {
  width: min(430px, 100%);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.auth-head { padding: 26px 28px 18px; text-align: center; }
.auth-head .logo {
  width: 54px; height: 54px; margin: 0 auto 12px;
  background: var(--accent); color: #2a1d15;
  border-radius: 15px; display: grid; place-items: center; font-size: 27px;
}
.auth-head h1 { font-size: 21px; margin-bottom: 3px; }
.auth-body { padding: 0 28px 26px; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-sm); margin-bottom: 18px; }
.tabs button {
  flex: 1; height: 36px; border: 0; background: transparent; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-1); }

/* Bàn phím số cho đăng nhập PIN */
.pin-display {
  display: flex; justify-content: center; gap: 12px; margin: 6px 0 18px;
}
.pin-display i {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--line-2); display: block; transition: background .12s, transform .12s;
}
.pin-display i.on { background: var(--brand); transform: scale(1.12); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  height: 58px; border: 1px solid var(--line-2); background: var(--surface);
  border-radius: var(--r); font: inherit; font-size: 22px; font-weight: 600;
  color: var(--ink); cursor: pointer; transition: background .1s, transform .06s;
}
.keypad button:active { background: var(--brand-soft); transform: scale(.97); }
.keypad button.wide { grid-column: span 1; font-size: 16px; }

/* ---------------------------------------------------------- Đáp ứng mobile */
@media (max-width: 900px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.sidebar-right { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 768px) {
  .menu-toggle { display: grid; place-items: center; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim {
    display: none; position: fixed; inset: 0; background: rgba(33,26,20,.45); z-index: 55;
  }
  .sidebar-scrim.open { display: block; }
  .content { padding: 16px 14px 40px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0,1fr); }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar h1 { font-size: 16px; }
  table.data { font-size: 13.5px; }
  table.data th, table.data td { padding: 9px 10px; }
  .filters { padding: 12px 14px; }
  .filters .field { min-width: calc(50% - 5px); flex: 1; }
}

/* ---------------------------------------------------------------- In ấn */
@media print {
  .sidebar, .topbar, .no-print, .flash-stack { display: none !important; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
  .content { padding: 0; }
}
