:root {
  --ink: #12201b;
  --muted: #5d6f67;
  --line: #d5e0da;
  --bg: #eef3f0;
  --bg-2: #e2ebe6;
  --card: #ffffff;
  --accent: #2a6b5a;
  --accent-2: #1f5346;
  --accent-soft: #d9ebe4;
  --warn: #b7791f;
  --danger: #9b2c2c;
  --ok: #276749;
  --shadow: 0 12px 30px rgba(18, 32, 27, 0.08);
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #16352c 0%, #12201b 100%);
  color: #e8f2ed;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.sidebar__brand {
  font-weight: 700;
  letter-spacing: .04em;
  padding: .35rem .5rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: .75rem;
}
.sidebar__brand img {
  display: block;
  width: 100%;
  max-width: 190px;
  height: auto;
  margin: 0 auto;
}
.sidebar__brand small {
  display: block;
  text-align: center;
  opacity: .65;
  font-weight: 500;
  margin-top: .45rem;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  width: min(280px, 100%);
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 12px;
}
.brand-logo--sm {
  width: auto;
  height: 36px;
  margin: 0;
  border-radius: 6px;
}
.pos-top__brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.pos-top__brand span { opacity: .9; }

.nav-link {
  display: block;
  color: #cfe0d8;
  padding: .65rem .8rem;
  border-radius: 10px;
  text-decoration: none;
}
.nav-link:hover, .nav-link.is-active {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}

.main {
  padding: 1.5rem 1.75rem 2.5rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -.02em;
}
.page-head p {
  margin: .35rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat__label { color: var(--muted); font-size: .85rem; }
.stat__value { font-size: 1.55rem; font-weight: 700; margin-top: .25rem; letter-spacing: -.02em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: .65rem 1rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { background: var(--bg-2); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(1.05); }
.btn-sm { padding: .4rem .7rem; font-size: .88rem; }
.btn-block { width: 100%; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  text-align: left;
  padding: .75rem .65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
}
table.data tr:hover td { background: #f7faf8; }

.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-2);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
label.field {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-size: .9rem;
  font-weight: 600;
}
label.field span.hint { font-weight: 500; color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="tel"], input[type="url"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
textarea { min-height: 110px; resize: vertical; }
.check {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 600;
}
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.code-previews {
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 640px) {
  .code-previews { grid-template-columns: 1fr; }
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
}
.badge-ok { background: #e6ffed; color: var(--ok); }
.badge-off { background: #edf2f0; color: var(--muted); }
.badge-warn { background: #fefcbf; color: var(--warn); }

.pager {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.pager a, .pager span {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.pager .is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Toast / modal (no browser popups) */
#toast-root {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  width: min(360px, calc(100vw - 2rem));
}
.toast {
  background: #12352c;
  color: #fff;
  padding: .85rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}
.toast-success { background: #1f5346; }
.toast-error { background: #9b2c2c; }
.toast-info { background: #234e52; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 22, 18, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 25px 60px rgba(0,0,0,.2);
}
.modal h3 { margin: 0 0 .5rem; }
.modal p { margin: 0 0 1.1rem; color: var(--muted); line-height: 1.45; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% 30%, #d9ebe4, transparent),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.4rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 1.25rem; }

/* POS layout */
.pos-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 56px 1fr;
  background: #dfe8e3;
}
.pos-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: #12352c;
  color: #eef6f2;
}
.pos-top__actions { display: flex; gap: .5rem; align-items: center; }
.pos-body {
  display: grid;
  grid-template-columns: 2fr 1fr;
  min-height: 0;
}
.pos-catalog {
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.pos-tools {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
}
.pos-tools input[type="search"],
.pos-tools input[type="text"] {
  flex: 1;
  min-width: 180px;
}
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .85rem;
}
.pos-tile {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  text-align: center;
  transition: transform .15s ease, box-shadow .15s ease;
  user-select: none;
}
.pos-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.pos-tile__img {
  aspect-ratio: 1;
  object-fit: cover;
  width: 100%;
  background: var(--bg-2);
}
.pos-tile__price {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.55);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.45));
}
.pos-tile__stock {
  position: absolute;
  top: .45rem;
  right: .45rem;
  background: rgba(18,32,27,.85);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .45rem;
  border-radius: 999px;
  z-index: 2;
}
.pos-tile__title {
  padding: .65rem .55rem .75rem;
  font-weight: 700;
  font-size: .92rem;
  line-height: 1.25;
}
.pos-tile.is-category .pos-tile__price { display: none; }

.pos-till {
  background: #fff;
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}
.pos-till__head {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.pos-till__head h2 {
  margin: 0 0 .55rem;
  font-size: 1.05rem;
}
.pos-lines {
  overflow: auto;
  padding: .5rem .75rem;
}
.pos-line {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: .65rem;
  align-items: center;
  padding: .55rem .25rem;
  border-bottom: 1px solid #edf2f0;
}
.pos-line img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-2);
}
.pos-line__title { font-weight: 700; font-size: .92rem; }
.pos-line__meta { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.pos-line__price { font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-line__qty {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-top: .35rem;
}
.pos-line__qty button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
}
.pos-totals {
  border-top: 1px solid var(--line);
  padding: .9rem 1rem 1rem;
  background: #f7faf8;
}
.pos-totals .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: .35rem;
  color: var(--muted);
}
.pos-totals .total {
  margin-top: .45rem;
  padding-top: .55rem;
  border-top: 1px solid var(--line);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
}
.sale-btn {
  margin-top: .85rem;
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: .06em;
  padding: 1rem;
  border-radius: 12px;
}
.sale-btn:disabled { opacity: .45; cursor: not-allowed; }
.sale-btn:not(:disabled):hover { background: var(--accent-2); }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .55rem;
  margin-top: 1rem;
}
.pin-pad button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  font-size: 1.25rem;
  font-weight: 700;
}
.pin-display {
  letter-spacing: .35em;
  font-size: 1.6rem;
  text-align: center;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf8;
  min-height: 58px;
}

.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 22, 18, .72);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .pos-body { grid-template-columns: 1fr; }
  .pos-till { border-left: 0; border-top: 1px solid var(--line); max-height: 48vh; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .grid-stats { grid-template-columns: 1fr; }
}
