* { box-sizing: border-box; }

:root {
  --bg: #f1f5f4;
  --card: #ffffff;
  --ink: #10201d;
  --muted: #64748b;
  --line: #e2e8e6;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: #d9f2ee;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 26px -18px rgba(15, 23, 42, .35);
}

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

button, a, input, select { -webkit-tap-highlight-color: rgba(15, 118, 110, .15); }
.tab, .btn, .product, .temp-btn, .stepper button { touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(34px + env(safe-area-inset-bottom));
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 90% -10%, #d7efe9 0%, transparent 60%),
    radial-gradient(900px 480px at 0% -5%, #e8f3ef 0%, transparent 55%),
    var(--bg);
}

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }

small { font-size: .78rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), #109a8c);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: 0 10px 20px -12px rgba(15, 118, 110, .95);
}

.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }

.header-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: .82rem;
  padding: 9px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.stock-badge {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  font-weight: 700;
  font-size: .82rem;
  padding: 9px 14px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}
.stock-badge[hidden] { display: none; }

.tabs {
  display: flex;
  gap: 6px;
  margin-top: 18px;
  padding: 6px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--accent); background: #f1f8f6; }
.tab.active {
  background: linear-gradient(140deg, var(--accent), #109a8c);
  color: #fff;
  box-shadow: 0 8px 16px -10px rgba(15, 118, 110, .95);
}

#app { padding-top: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.card-head h2 { margin: 0; font-size: 1.02rem; }
.card-head .sub { margin: 3px 0 0; font-size: .78rem; color: var(--muted); }

.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-tools input { width: auto; }

.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hint { color: var(--muted); font-size: .84rem; line-height: 1.7; margin: 0 0 14px; }
.hint.center, .center { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 22px 10px; font-size: .9rem; line-height: 1.8; margin: 0; }
.strong { font-weight: 700; }

.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 18px;
  align-items: start;
}
.pos-layout .card { margin-bottom: 0; }

.product-group + .product-group { margin-top: 20px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: .92rem;
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.group-count {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  background: #f1f5f4;
  border-radius: 999px;
  padding: 2px 8px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.product {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.product:hover { border-color: var(--accent-2); transform: translateY(-2px); box-shadow: 0 12px 22px -18px rgba(15, 118, 110, .9); }
.product:active { transform: scale(.98); }
.product-name { font-weight: 700; font-size: .98rem; word-break: break-word; }
.product-price {
  font-size: .8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 10px;
}
.product-cat {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  background: #f1f5f4;
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}
.product-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.sold-today { font-size: .72rem; color: var(--muted); }
.temp-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  vertical-align: middle;
}
.temp-badge.cold { background: #e0f2fe; color: #0369a1; }
.temp-badge.hot { background: #ffedd5; color: #c2410c; }
.product-multi { cursor: default; }
.product-multi:hover { transform: none; border-color: var(--line); box-shadow: none; }
.temp-buttons { display: flex; gap: 8px; width: 100%; }
.temp-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.temp-btn span {
  font-size: .68rem;
  font-weight: 700;
  background: #eef2f1;
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.temp-btn.cold:hover { border-color: #7dd3fc; background: #f0f9ff; color: #0369a1; }
.temp-btn.hot:hover { border-color: #fdba74; background: #fff7ed; color: #c2410c; }
.qty-badge {
  position: absolute;
  inset-inline-end: 10px;
  top: 10px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: .76rem;
  font-weight: 700;
}

.cart { position: sticky; top: 88px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 14px; }
.field > span { font-weight: 600; }

input, select {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
  width: 100%;
}
input:focus, select:focus {
  outline: 3px solid rgba(20, 184, 166, .18);
  border-color: var(--accent-2);
}
input::placeholder { color: #9aa8a4; }

.cart-lines { min-height: 40px; }

.cart-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.cl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-info strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-info span { font-size: .76rem; color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 5px; }
.stepper button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.stepper button:hover { border-color: var(--accent); color: var(--accent); }
.stepper span { min-width: 20px; text-align: center; font-weight: 700; }

.cl-total { min-width: 56px; text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; }

.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0 14px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
  font-weight: 600;
  color: var(--muted);
}
.cart-total strong { font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.cart-total strong small { font-size: .8rem; color: var(--muted); font-weight: 600; }

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s, color .15s, filter .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(140deg, var(--accent), #109a8c);
  color: #fff;
  box-shadow: 0 10px 20px -12px rgba(15, 118, 110, .95);
}
.btn-primary:not(:disabled):hover { filter: brightness(1.06); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.btn-danger-ghost { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger-ghost:not(:disabled):hover { background: var(--danger-soft); }
.btn-block { width: 100%; padding: 13px 16px; font-size: .98rem; }
.btn.small { padding: 7px 12px; font-size: .8rem; border-radius: 10px; }

.link-btn {
  background: none;
  border: 0;
  padding: 2px;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat small { color: var(--muted); font-size: .72rem; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); }
thead th { font-size: .76rem; color: var(--muted); font-weight: 700; background: #f8faf9; white-space: nowrap; }
tbody tr:hover { background: #fafcfb; }
tfoot td { font-weight: 700; border-bottom: 0; background: #f8faf9; }
td input, td select { padding: 7px 9px; }

.cell-input { width: 100%; min-width: 80px; }

.stock-stepper { justify-content: flex-start; }
.stock-input { width: 84px; text-align: center; font-variant-numeric: tabular-nums; padding: 8px 6px; }
.stock-input.low-input { width: 76px; }
.stock-row.warn { background: #fffbeb; }
.stock-row.danger { background: #fef2f2; }
.stock-row td { vertical-align: middle; }
.used-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.used-day { display: block; font-size: .72rem; color: var(--muted); }

.order-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: .9rem;
}
.order-row:last-child { border-bottom: 0; }
.order-time { color: var(--muted); font-size: .78rem; min-width: 62px; font-variant-numeric: tabular-nums; }
.order-items { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.order-total { font-weight: 700; min-width: 62px; text-align: end; font-variant-numeric: tabular-nums; }

.add-product {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.add-product .btn { width: 100%; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.settings-grid .field { margin-bottom: 6px; }

.install-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: 12px;
}
.install-box strong { font-size: .9rem; }
.install-box p { margin: 3px 0 0; color: #0b5f57; font-size: .78rem; }

.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.neutral { background: #eef2f1; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 14px);
  background: #0f2b26;
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; }
  .cart { position: static; }
}

@media (max-width: 900px) {
  .add-product { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

@media (max-width: 720px) {
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .header-badge { display: none; }
  .tab { padding: 10px 8px; font-size: .85rem; }
  .tab .long { display: none; }
  .stats { grid-template-columns: 1fr; }
  .stat { padding: 12px 14px; }
  .stat strong { font-size: 1.35rem; }
  .card { padding: 16px; border-radius: 14px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .order-time { min-width: 52px; }
}

@media print {
  body { background: #fff; }
  .topbar, .tabs, .toast, .no-print, button { display: none !important; }
  #app { padding-top: 0; }
  .card { box-shadow: none; border-color: #d1d5db; break-inside: avoid; }
  .stat { border-color: #d1d5db; }
  input, select { border: 0; padding: 0; background: transparent; appearance: none; -webkit-appearance: none; }
}
