/* ============================================
   SỔ BÁN HÀNG — Design system mới (oklch, ấm áp)
   ============================================ */
:root {
  --hue: 240;
  --base-size: 17px;

  --bg:        oklch(0.985 0.008 85);   /* trắng ngà ấm */
  --bg-2:      oklch(0.965 0.012 85);
  --bg-3:      oklch(0.94  0.014 85);
  --paper:     #ffffff;
  --ink:       oklch(0.25 0.02 250);
  --ink-2:     oklch(0.42 0.02 250);
  --ink-3:     oklch(0.6  0.02 250);
  --line:      oklch(0.9  0.012 85);
  --line-2:    oklch(0.85 0.014 85);

  --primary:      oklch(0.58 0.13 var(--hue));
  --primary-2:    oklch(0.48 0.14 var(--hue));
  --primary-soft: oklch(0.94 0.04 var(--hue));
  --primary-ink:  oklch(0.35 0.13 var(--hue));
  --primary-line: oklch(0.85 0.06 var(--hue));

  --success:      oklch(0.58 0.14 155);
  --success-soft: oklch(0.94 0.05 155);
  --success-ink:  oklch(0.38 0.12 155);
  --success-line: oklch(0.86 0.08 155);

  --danger:       oklch(0.58 0.19 25);
  --danger-soft:  oklch(0.95 0.045 25);
  --danger-ink:   oklch(0.42 0.17 25);
  --danger-line:  oklch(0.88 0.07 25);

  --warn:         oklch(0.72 0.15 70);
  --warn-soft:    oklch(0.95 0.06 70);

  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 28px;

  --shadow-sm: 0 1px 2px oklch(0.4 0.02 250 / 0.06), 0 2px 6px oklch(0.4 0.02 250 / 0.04);
  --shadow-md: 0 2px 6px oklch(0.4 0.02 250 / 0.06), 0 8px 24px oklch(0.4 0.02 250 / 0.08);
  --shadow-lg: 0 8px 30px oklch(0.4 0.02 250 / 0.12), 0 30px 60px oklch(0.4 0.02 250 / 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  font-size: var(--base-size);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- Layout ---------- */
.app-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px 40px;
}
.app-page-wide { max-width: 720px; }

/* ---------- Top bar ---------- */
.topbar {
  padding: 14px 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-sub { font-size: 14px; color: var(--ink-3); margin-top: 2px; font-weight: 500; }
.topbar-back {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1.5px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .06s ease;
}
.topbar-back:active { transform: scale(0.94); }
.topbar-action {
  background: var(--primary-soft);
  border-color: var(--primary-line);
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 56px;
  padding: 14px 20px;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.06s ease;
  line-height: 1.2;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px oklch(0.55 0.13 var(--hue) / 0.35);
}
.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 14px oklch(0.55 0.14 155 / 0.35);
}
.btn-danger { background: var(--danger); color: white; }
.btn-ghost {
  background: var(--bg-2);
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-dashed {
  background: transparent;
  border: 2px dashed var(--line-2);
  color: var(--primary);
  border-radius: 18px;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 15px; border-radius: 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card-sm { border-radius: 18px; padding: 16px; }

/* ---------- Inputs ---------- */
.field-label {
  display: block;
  font-size: 14px;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.input {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 18px;
  background: var(--paper);
  outline: none;
  transition: border-color .12s ease;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select.input { appearance: auto; }

/* ---------- Icon chip ---------- */
.icon-chip {
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-chip-52 { width: 52px; height: 52px; }
.icon-chip-44 { width: 44px; height: 44px; border-radius: 14px; }
.icon-chip-36 { width: 36px; height: 36px; border-radius: 12px; }
.tone-primary { background: var(--primary-soft); color: var(--primary-ink); }
.tone-success { background: var(--success-soft); color: var(--success-ink); }
.tone-danger  { background: var(--danger-soft);  color: var(--danger-ink); }
.tone-neutral { background: var(--bg-3); color: var(--ink-2); }

/* ---------- Chip / badge ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-danger  { background: var(--danger-soft);  color: var(--danger-ink); }
.chip-success { background: var(--success-soft); color: var(--success-ink); }
.chip-primary { background: var(--primary-soft); color: var(--primary-ink); }
.chip-neutral { background: var(--bg-3); color: var(--ink-2); }

.code-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

/* ---------- Utility ---------- */
.money { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.section-label {
  font-size: 14px;
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}
.muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-2); }

/* ---------- Menu tiles (trang chính) ---------- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.menu-tile {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  min-height: 128px;
  transition: transform .06s ease;
}
.menu-tile:active { transform: scale(0.98); }
.menu-tile .tile-label { font-size: 18px; font-weight: 700; color: var(--ink); }
.menu-tile .tile-sub { font-size: 14px; color: var(--ink-3); margin-top: 2px; font-weight: 500; }

/* ---------- Summary cards ---------- */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-card { padding: 16px; border-radius: var(--radius); }
.summary-card.tone-primary { border: 1.5px solid var(--primary-line); background: var(--primary-soft); }
.summary-card.tone-danger  { border: 1.5px solid var(--danger-line);  background: var(--danger-soft); }
.summary-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }

/* ---------- List item cards ---------- */
.item-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.item-card.clickable { cursor: pointer; transition: transform .06s ease; }
.item-card.clickable:active { transform: scale(0.99); }
.list-stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Banner cảnh báo ---------- */
.warn-banner {
  background: var(--danger-soft);
  border: 1.5px solid var(--danger-line);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}

/* ---------- PIN ---------- */
.pin-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pin-dots { display: flex; justify-content: center; gap: 18px; }
.pin-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--line-2);
  background: transparent;
  transition: all .12s ease;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 320px;
}
.pin-key {
  height: 72px;
  border-radius: 22px;
  border: none;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  font-size: 30px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .06s ease;
}
.pin-key:active { transform: scale(0.94); background: var(--bg-2); }
.pin-key.pin-key-ghost { background: transparent; box-shadow: none; }

/* ---------- Bảng kế toán ---------- */
.invoice-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.invoice-head {
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.acc-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.acc-table th {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  text-align: right;
  background: var(--bg);
}
.acc-table th:first-child { text-align: left; }
.acc-table td { padding: 12px; text-align: right; border-top: 1px solid var(--line); vertical-align: top; }
.acc-table td:first-child { text-align: left; }

.sum-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.sum-row.big { padding: 14px 0; }
.sum-divider { height: 1px; background: var(--line); margin: 2px 0; }

/* ---------- Tabs lịch sử ---------- */
.filter-tabs { display: flex; gap: 8px; }
.filter-tab {
  flex: 1;
  padding: 10px 12px;
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.filter-tab.active { border-color: var(--ink); background: var(--ink); color: white; }

.date-heading {
  font-size: 14px; color: var(--ink-3); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
  margin: 20px 0 10px; padding-left: 4px;
}

/* ---------- Bottom bar ---------- */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border-top: 1.5px solid var(--line);
  z-index: 20;
}
.bottom-bar-inner { max-width: 560px; margin: 0 auto; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: oklch(0.2 0.02 250 / 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal-box {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toast-in .25s ease;
  border: 1.5px solid transparent;
}
.toast-success { background: var(--success-soft); color: var(--success-ink); border-color: var(--success-line); }
.toast-error   { background: var(--danger-soft);  color: var(--danger-ink);  border-color: var(--danger-line); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-3);
}
.empty-state svg { margin-bottom: 12px; }
.empty-state p { font-size: 17px; margin: 0; font-weight: 500; }

/* ---------- Receipt line card ---------- */
.line-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 14px 14px 14px 16px;
}
.line-amount-strip {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--success-soft);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.line-amount-strip.export { background: var(--primary-soft); }
.mini-input-label { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; }
.mini-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 20px;
  font-weight: 700;
  background: var(--bg);
  min-height: 50px;
  outline: none;
}
.mini-input:focus { border-color: var(--primary); }

/* ---------- Search box ---------- */
.search-box {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.search-box input {
  border: none; outline: none; background: transparent;
  flex: 1; min-height: 52px; font-size: 16px; padding: 0;
}

/* ---------- Avatar ---------- */
.avatar {
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Trash icon button ---------- */
.trash-btn {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--bg-2); border: none;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  color: var(--danger-ink);
}

/* Desktop */
@media (min-width: 640px) {
  .app-page { padding-left: 24px; padding-right: 24px; }
}
