:root {
  --bg: #fff3ec;
  --bg-deep: #ffe4ec;
  --ink: #4a3040;
  --ink-soft: #5c3a48;
  --muted: #8a6574;
  --line: #f5d0c8;
  --card: #fffaf8;
  --accent: #e8899a;
  --accent-dark: #c45f74;
  --accent-soft: #ffb6c4;
  --accent-glow: rgba(232, 137, 154, 0.28);
  --peach: #ffc9a8;
  --ok: #2f7a58;
  --ok-bg: #e7f6ef;
  --err: #b13d52;
  --err-bg: #ffe8ee;
  --warn: #c46a2d;
  --btn: #e8899a;
  --btn-text: #fffaf8;
  --shadow: 0 12px 28px rgba(196, 95, 116, 0.14);
  --radius: 22px;
  --font: "Nunito", "Segoe UI", sans-serif;
  --font-display: "Comfortaa", "Nunito", sans-serif;
  --space: 16px;
  --tap: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 182, 196, 0.5) 0 18%, transparent 19%),
    radial-gradient(circle at 88% 22%, rgba(255, 201, 168, 0.5) 0 14%, transparent 15%),
    radial-gradient(circle at 70% 78%, rgba(232, 137, 154, 0.22) 0 20%, transparent 21%),
    linear-gradient(165deg, #fff3ec, #ffe4ec 55%, #ffe8d8);
  background-attachment: fixed;
  line-height: 1.45;
  overflow-x: clip;
}

a {
  color: var(--accent-dark);
}

.app {
  width: min(100%, 428px);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
  padding:
    max(0px, env(safe-area-inset-top))
    max(0px, env(safe-area-inset-right))
    max(0px, env(safe-area-inset-bottom))
    max(0px, env(safe-area-inset-left));
  position: relative;
  overflow-x: clip;
}

.topbar {
  padding: 18px var(--space) 10px;
  text-align: center;
  animation: fade-rise 0.55s ease both;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent-dark);
  margin-bottom: 4px;
  line-height: 1.2;
}

.page-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.seller-mode-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 10px auto 0;
  max-width: 420px;
  padding: 4px;
  background: rgba(255, 250, 251, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(154, 61, 92, 0.08);
}

.seller-mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 4px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink-soft);
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  overflow-wrap: normal;
  text-align: center;
  line-height: 1.15;
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quick-pick {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffaf8;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.quick-pick:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.seller-mode-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #d66f8c 0%, var(--accent) 100%);
  box-shadow: 0 6px 14px var(--accent-glow);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  margin: 0 auto 8px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent-dark);
}

.content {
  padding: 8px var(--space) 32px;
}

.content-solo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding-top: 24px;
  padding-bottom: 28px;
}

.flash {
  margin: 0 var(--space) 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid transparent;
  animation: fade-rise 0.4s ease both;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content .flash,
.entry-hero .flash {
  margin-left: 0;
  margin-right: 0;
}

.flash-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #a8d9c0;
}

.flash-err {
  background: var(--err-bg);
  color: var(--err);
  border-color: #f0a8b6;
}

.lock-banner {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.98rem;
  font-weight: 700;
  border: 2px solid transparent;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lock-banner--open {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #a8d9c0;
}

.lock-banner--closed {
  background: #fff1e4;
  color: var(--warn);
  border-color: #f0c49a;
}

.lock-banner-now {
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0.85;
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}

.check-label input {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--accent-dark);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  animation: fade-rise 0.55s ease both;
  min-width: 0;
  max-width: 100%;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 1rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 18px;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: inherit;
  line-height: 1.2;
  text-decoration: none;
  color: var(--btn-text);
  background: var(--btn);
  border: 2px solid var(--accent-dark);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 8px 18px var(--accent-glow);
}

.btn:hover,
button:hover {
  background: var(--accent-dark);
}

.btn:active,
button:active {
  transform: translateY(2px) scale(0.99);
}

.btn-primary:active {
  box-shadow: 0 4px 0 #c45f74, 0 8px 16px var(--accent-glow);
}

.btn-primary {
  background: linear-gradient(135deg, #ffb6c4 0%, var(--accent) 55%, var(--accent-dark) 100%);
  border-color: var(--accent-dark);
  box-shadow: 0 8px 0 #c45f74, 0 12px 22px var(--accent-glow);
  animation: soft-glow 2.8s ease-in-out infinite;
}

.btn-ok {
  background: var(--ok);
  border-color: #1f5a3f;
  box-shadow: 0 8px 18px rgba(47, 122, 88, 0.22);
  animation: none;
}

.btn-danger {
  background: var(--err);
  border-color: #8a2b3c;
  box-shadow: 0 8px 18px rgba(177, 61, 82, 0.22);
  animation: none;
}

.btn-ghost {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
  box-shadow: none;
  animation: none;
}

.btn-sm {
  min-height: 44px;
  font-size: 1rem;
  padding: 8px 12px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

/* —— Trang nhập mã —— */
.code-entry .content-solo {
  align-items: stretch;
}

.entry-hero {
  text-align: center;
  padding: 28px 20px 24px;
  background: var(--card);
  border: 3px solid #ffd5c8;
  border-radius: 32px;
  box-shadow: 0 12px 0 rgba(232, 137, 154, 0.16), var(--shadow);
  animation: fade-rise 0.65s ease both;
}

.entry-eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--accent);
}

.entry-logo {
  display: block;
  width: min(260px, 72vw);
  height: auto;
  margin: 2px auto 18px;
  border-radius: 28px;
  box-shadow:
    0 10px 0 rgba(232, 137, 154, 0.14),
    0 14px 28px rgba(154, 61, 92, 0.16);
  animation: brand-soft 3.2s ease-in-out infinite;
}

.brand-hero {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 7.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-dark);
}

.entry-hero .sub,
.code-entry .sub {
  margin: 0 0 24px;
  font-size: 1.02rem;
  color: var(--muted);
  font-weight: 600;
}


.entry-form {
  text-align: left;
}

.code-digits {
  letter-spacing: 0.4em;
  text-align: center;
  font-size: 1.55rem;
  font-weight: 800;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 8px;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sell-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 calc(var(--space) * -1) 10px;
  padding: 8px var(--space) 10px;
  background: linear-gradient(180deg, rgba(255, 243, 236, 0.98) 0%, rgba(255, 243, 236, 0.92) 100%);
  backdrop-filter: blur(10px);
}

.search-shell {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  min-height: calc(var(--tap) + 4px);
  padding: 4px 4px 4px 2px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(154, 61, 92, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: var(--tap);
  margin: 0;
  padding: 10px 8px 10px 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent;
  box-shadow: none !important;
  font-size: 1.05rem;
  font-weight: 700;
}

.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--tap) - 4px);
  min-width: calc(var(--tap) - 4px);
  min-height: calc(var(--tap) - 4px);
  padding: 0;
  border-radius: 16px;
  box-shadow: none;
  animation: none;
  background: linear-gradient(135deg, #ffd5c8 0%, #ffb6c4 100%);
  color: var(--accent-dark);
  border-color: transparent;
}

.voice-btn .voice-icon {
  flex: 0 0 auto;
  display: block;
}

.voice-btn.listening {
  background: var(--err);
  border-color: #8a2b3c;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(177, 61, 82, 0.2);
  animation: soft-glow 1.2s ease-in-out infinite;
}

.voice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.voice-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 0;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: rgba(255, 250, 251, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.voice-status-who {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffd5c8, #ffb6c4);
  color: var(--accent-dark);
}

.voice-status-text {
  flex: 1;
  min-width: 0;
}

.voice-status.is-ai {
  border-color: #f0b8c4;
  background: linear-gradient(135deg, rgba(255, 250, 251, 0.98), rgba(255, 228, 236, 0.55));
  box-shadow: 0 4px 14px rgba(196, 95, 116, 0.1);
}

.voice-status.is-error {
  color: var(--err);
  background: var(--err-bg);
  border-color: #f0a8b6;
}

.group-rail {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.group-rail::-webkit-scrollbar {
  display: none;
}

.group-chip {
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 800;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  box-shadow: none;
  animation: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.group-chip.active {
  color: #fff;
  background: linear-gradient(135deg, #d66f8c 0%, var(--accent) 100%);
  border-color: var(--accent-dark);
  box-shadow: 0 6px 14px var(--accent-glow);
}

.group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25em;
  margin-left: 4px;
  padding: 1px 7px;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 999px;
  background: rgba(154, 61, 92, 0.12);
  color: var(--accent-dark);
  vertical-align: middle;
}

.group-chip.active .group-count {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.group-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
}

.group-label-count {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.menu-groups {
  display: grid;
  gap: 12px;
}

.menu-group-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.menu-grid {
  display: grid;
  gap: 14px;
}

.menu-grid--rows {
  gap: 10px;
}

.badge-group {
  background: #f3e0e8;
  color: var(--accent-dark);
  margin-right: 6px;
}

.menu-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(154, 61, 92, 0.08);
  animation: fade-rise 0.5s ease both;
}

.menu-item--row {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  animation: none;
}

.menu-item-meta {
  min-width: 0;
}

.menu-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.qty-step {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}

.qty-step .qty-btn {
  width: 40px;
  min-height: 40px;
  min-width: 40px;
  font-size: 1.25rem;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
}

.qty-step .qty-value {
  min-width: 1.6rem;
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.1rem;
}

.sold-btn--compact {
  width: auto;
  min-width: 88px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.95rem;
  border-radius: 14px;
}

/* display:grid/flex ghi đè [hidden] trên một số trình duyệt mobile */
[hidden],
.menu-item[hidden],
.menu-group[hidden],
.is-hidden {
  display: none !important;
}

.menu-item:nth-child(2) { animation-delay: 0.05s; }
.menu-item:nth-child(3) { animation-delay: 0.1s; }
.menu-item:nth-child(4) { animation-delay: 0.15s; }

.menu-item-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.menu-item--row .menu-item-name {
  font-size: 1.05rem;
  line-height: 1.25;
}

.menu-item-price {
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 700;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-head > :first-child {
  min-width: 0;
  flex: 1;
}

.card-head .badge {
  flex: 0 0 auto;
  margin-top: 2px;
  text-align: right;
  white-space: nowrap;
}

.qty-row {
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  gap: 10px;
  align-items: center;
}

.qty-btn {
  width: var(--tap);
  min-height: var(--tap);
  font-size: 1.6rem;
  padding: 0;
  border-radius: 18px;
  box-shadow: none;
  animation: none;
  background: #fff;
  color: var(--accent-dark);
  border-color: var(--line);
}

.qty-value {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 900;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.sold-btn {
  background: linear-gradient(135deg, #4ca87a 0%, var(--ok) 100%);
  border-color: #1f5a3f;
  font-size: 1.15rem;
  box-shadow: 0 8px 18px rgba(47, 122, 88, 0.22);
  animation: none;
}

.today-summary {
  position: sticky;
  bottom: 0;
  margin: 16px calc(var(--space) * -1) 0;
  padding: 14px var(--space) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(135deg, #c45f74 0%, #e8899a 100%);
  color: #fffaf8;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 -8px 24px rgba(196, 95, 116, 0.18);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.db-status {
  margin: 0 0 18px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.db-status.is-mysql {
  color: #1f6b3a;
  border-color: rgba(46, 125, 70, 0.35);
  background: rgba(46, 125, 70, 0.1);
}

.db-status.is-sqlite {
  color: #8a4b00;
  border-color: rgba(180, 110, 20, 0.4);
  background: rgba(255, 186, 73, 0.25);
}

.deploy-hint {
  margin: 0 0 16px;
  line-height: 1.45;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: 0;
  padding: 10px;
  text-align: center;
  text-decoration: none;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(154, 61, 92, 0.06);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.nav-btn.active {
  background: linear-gradient(135deg, #ffb6c4 0%, var(--accent) 100%);
  border-color: var(--accent-dark);
  color: #fff;
}

.stat-grid {
  display: grid;
  gap: 12px;
}

.stat-card {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(154, 61, 92, 0.07);
  min-width: 0;
  max-width: 100%;
}

.stat-label {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stat-value {
  margin-top: 6px;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent-dark);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stat-card-login.is-ok {
  border-color: #b7e0cb;
  background: linear-gradient(180deg, #f4fcf7, var(--card));
}

.stat-card-login.is-warn {
  border-color: #f0d0b8;
  background: linear-gradient(180deg, #fff7f0, var(--card));
}

.stat-card-login .stat-value {
  margin-top: 10px;
}

.report-quick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.report-quick .btn {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 0.92rem;
}

.report-quick .btn.is-active,
.btn-ghost.is-active {
  background: linear-gradient(135deg, #ffb6c4 0%, var(--accent) 100%);
  border-color: var(--accent-dark);
  color: #fff;
}

.report-hero .hint {
  margin-top: 4px;
}

.report-day-list {
  display: grid;
  gap: 12px;
}

.report-day {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(154, 61, 92, 0.06);
}

.report-day__head {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.report-day__head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.report-day__title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.02rem;
  font-weight: 900;
  color: var(--accent-dark);
  line-height: 1.25;
}

.report-day__head .btn,
.report-day__link {
  flex: 0 0 auto;
  width: auto;
  max-width: 42%;
  min-height: 40px;
  padding: 6px 12px;
  white-space: nowrap;
  font-size: 0.88rem;
}

.report-day__meta {
  margin: 0;
}

.report-math {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff7f9, #fffaf8);
}

.report-math--compact {
  margin-top: 0;
  padding: 10px 12px;
}

.report-math__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(245, 208, 200, 0.85);
}

.report-math__row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.report-math__row:first-child {
  padding-top: 0;
}

.report-math__row--result {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.report-math__label {
  font-weight: 700;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 58%;
}

.report-math__val {
  font-weight: 900;
  color: var(--accent-dark);
  text-align: right;
  white-space: nowrap;
}

.report-math__val--minus {
  color: var(--err);
}

.report-math__row--result .report-math__val {
  font-size: 1.15rem;
  color: var(--ok);
}

.report-math__row--result.is-neg .report-math__val {
  color: var(--err);
}

.sale-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sale-detail-qty {
  flex-shrink: 0;
  font-weight: 800;
  color: var(--accent-dark);
  white-space: nowrap;
}

.export-actions {
  display: grid;
  gap: 10px;
}

.report-day__actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.stat-card.is-editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.edit-nhap-form .form-group:last-of-type {
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

table.data th {
  font-weight: 800;
  background: rgba(249, 228, 235, 0.7);
}

table.data .num {
  text-align: right;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.badge-on {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-off {
  background: #f3e8ec;
  color: #7a5a66;
}

.list-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.muted {
  color: var(--muted);
}

.center {
  text-align: center;
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }

.empty-state {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.logout-link {
  display: block;
  margin-top: 20px;
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  min-height: 44px;
  line-height: 44px;
}

@keyframes fade-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes soft-glow {
  0%, 100% {
    box-shadow: 0 8px 18px var(--accent-glow);
  }
  50% {
    box-shadow: 0 10px 28px rgba(196, 92, 122, 0.42);
  }
}

@keyframes brand-soft {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

/* Khung “máy điện thoại” chỉ khi màn hẹp hơn desktop */
@media (min-width: 429px) and (max-width: 767px) {
  .app {
    border-left: 1px solid rgba(239, 200, 213, 0.7);
    border-right: 1px solid rgba(239, 200, 213, 0.7);
    box-shadow: 0 0 48px rgba(154, 61, 92, 0.1);
    background: rgba(255, 250, 251, 0.35);
  }
}

@media (min-width: 390px) {
  html {
    font-size: 19px;
  }
}

/* Điện thoại ≤767px: bảng → thẻ dọc, tránh tràn ngang */
@media (max-width: 767px) {
  .content {
    padding-left: var(--space);
    padding-right: var(--space);
  }

  .btn,
  button,
  .btn-sm,
  .sold-btn {
    min-height: 44px;
  }

  .admin-nav .nav-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .table-wrap {
    overflow: visible;
  }

  table.data thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  table.data,
  table.data tbody {
    display: block;
    width: 100%;
  }

  table.data tr {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(154, 61, 92, 0.06);
  }

  table.data tr:last-child {
    margin-bottom: 0;
  }

  table.data td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 0;
    border-bottom: 1px solid rgba(245, 208, 200, 0.7);
    text-align: right;
  }

  table.data td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  table.data td:first-child {
    padding-top: 0;
  }

  table.data td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 42%;
    font-weight: 800;
    color: var(--ink-soft);
    text-align: left;
  }

  table.data td > .td-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
    flex: 1;
    text-align: right;
  }

  table.data td.num {
    white-space: normal;
    text-align: right;
    font-weight: 800;
  }

  table.data td .muted {
    display: block;
  }

  .list-actions .btn,
  .list-actions button {
    width: 100%;
  }

  .seller-mode-tab {
    min-height: 44px;
  }

  .code-digits {
    letter-spacing: 0.28em;
  }
}

/* Điện thoại nhỏ */
@media (max-width: 380px) {
  html {
    font-size: 17px;
  }

  :root {
    --space: 14px;
    --tap: 52px;
  }

  .entry-hero {
    padding: 22px 16px 20px;
    border-radius: 22px;
  }

  .entry-logo {
    width: min(220px, 74vw);
    border-radius: 22px;
    margin-bottom: 16px;
  }

  .brand-hero {
    font-size: 2rem;
  }

  .admin-nav {
    gap: 8px;
  }

  .nav-btn {
    min-height: 48px;
    font-size: 0.92rem;
    padding: 8px;
  }

  .btn-row {
    gap: 8px;
  }

  .btn-row .btn,
  .btn-row button {
    min-height: 44px;
    font-size: 0.98rem;
    padding: 8px 10px;
  }

  .group-chip {
    min-height: 44px;
    padding: 7px 12px;
    font-size: 0.9rem;
  }

  .menu-group-title {
    font-size: 1rem;
  }

  .menu-item--row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .menu-item-actions {
    justify-content: space-between;
  }

  .sold-btn--compact {
    flex: 1;
  }

  .panel {
    padding: 14px;
  }

  .search-shell {
    grid-template-columns: 40px 1fr auto;
  }

  .stat-value {
    font-size: 1.25rem;
  }
}

@media (max-width: 400px) {
  .seller-mode-nav {
    max-width: 100%;
    grid-template-columns: 1fr 1fr;
    border-radius: 22px;
    gap: 6px;
    padding: 6px;
  }

  .seller-mode-tab {
    font-size: 0.9rem;
    padding: 10px 8px;
    min-height: 46px;
  }
}

@media (max-width: 340px) {
  .qty-row {
    grid-template-columns: 48px 1fr 48px;
    gap: 8px;
  }

  .qty-btn {
    width: 48px;
    min-height: 48px;
  }

  .seller-mode-nav {
    max-width: 100%;
    gap: 4px;
  }

  .seller-mode-tab {
    font-size: 0.84rem;
    padding: 8px 6px;
  }

  .quick-pick {
    min-height: 38px;
    font-size: 0.86rem;
    padding: 6px 10px;
  }

  .code-digits {
    letter-spacing: 0.2em;
    font-size: 1.35rem;
  }
}

/* —— Desktop web (tự nhận diện ≥768px) —— */
@media (min-width: 768px) {
  :root {
    --space: 22px;
    --tap: 48px;
    --radius: 20px;
  }

  html {
    font-size: 17px;
  }

  .app {
    width: min(100% - 48px, 920px);
    margin: 0 auto;
    min-height: 100vh;
    border: 0;
    box-shadow: none;
    background: transparent;
    padding-bottom: 28px;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px 20px;
    padding: 22px var(--space) 12px;
    text-align: left;
  }

  .topbar .back-link {
    grid-column: 1;
    margin: 0;
    justify-self: start;
  }

  .topbar .brand {
    grid-column: 1;
    margin: 0;
    font-size: 1.55rem;
  }

  .topbar:has(.back-link) .brand {
    grid-column: 2;
  }

  .topbar .page-title,
  .topbar .seller-mode-nav {
    grid-column: 1 / -1;
    justify-self: stretch;
    margin-top: 4px;
  }

  .topbar .page-title {
    text-align: left;
    font-size: 1.05rem;
  }

  .seller-mode-nav {
    max-width: 420px;
    margin-left: 0;
  }

  .content {
    padding: 10px var(--space) 40px;
  }

  .content-solo {
    max-width: 440px;
    margin: 0 auto;
    width: 100%;
  }

  .entry-hero {
    max-width: 420px;
    margin: 0 auto;
  }

  .flash {
    max-width: none;
  }

  .admin-nav,
  .app:has(.admin-nav) .admin-nav,
  body.is-admin .admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .admin-nav .nav-btn {
    width: auto;
    flex: 0 0 auto;
    min-width: 118px;
    padding: 10px 16px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .panel {
    padding: 20px 22px;
  }

  .btn-row {
    max-width: 420px;
  }

  .list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .list-actions .btn,
  .list-actions button {
    width: auto;
    min-width: 96px;
  }

  .sell-toolbar {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .menu-grid--rows {
    gap: 12px;
  }

  .menu-item--row {
    padding: 14px 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .menu-item--row:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 24px rgba(154, 61, 92, 0.12);
  }

  .today-summary {
    margin-left: 0;
    margin-right: 0;
    border-radius: 18px 18px 0 0;
  }

  .report-quick {
    max-width: 480px;
  }

  .db-status {
    display: inline-flex;
    width: auto;
    margin-bottom: 18px;
  }
}

@media (min-width: 1024px) {
  .app {
    width: min(100% - 64px, 1180px);
  }

  .topbar {
    padding-top: 26px;
  }

  .topbar .brand {
    font-size: 1.7rem;
  }

  .topbar .page-title,
  .topbar .seller-mode-nav {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    margin-top: 0;
    max-width: 460px;
  }

  .topbar .page-title {
    text-align: right;
  }

  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-card-login {
    grid-column: 1 / -1;
  }

  /* Bán hàng: cột trái menu, cột phải tổng hôm nay */
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-areas:
      "toolbar summary"
      "label summary"
      "hint summary"
      "menu summary"
      "empty summary"
      "logout summary";
    column-gap: 28px;
    align-items: start;
  }

  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > .sell-toolbar { grid-area: toolbar; }
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > .group-label { grid-area: label; }
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > .hint { grid-area: hint; }
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > .menu-groups { grid-area: menu; }
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > [data-search-empty] { grid-area: empty; }
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > .today-summary {
    grid-area: summary;
    position: sticky;
    top: 20px;
    margin: 0;
    padding: 22px 18px;
    border-radius: 22px;
    box-shadow: var(--shadow);
    align-self: start;
    line-height: 1.4;
  }
  body.is-seller .content:has(.sell-toolbar):has(.today-summary) > .logout-link {
    grid-area: logout;
    justify-self: start;
    margin-top: 12px;
  }

  .admin-nav .nav-btn {
    min-width: 126px;
  }

  .report-day-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .app {
    width: min(100% - 80px, 1280px);
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-card-login {
    grid-column: span 2;
  }

  body.is-seller .content:has(.sell-toolbar):has(.today-summary) {
    grid-template-columns: minmax(0, 1fr) 320px;
    column-gap: 32px;
  }

  .menu-grid--rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
