:root {
  --ink: #142033;
  --ink-soft: #3d4d66;
  --muted: #6b7a90;
  --line: rgba(20, 32, 51, 0.10);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --bg0: #e8f2f4;
  --bg1: #f7f1e8;
  --bg2: #d9ebe7;
  --teal: #0f6e6a;
  --teal-deep: #0a4f4c;
  --amber: #e0a100;
  --coral: #d65a3a;
  --sky: #4aa3b5;
  --success: #1f8a5b;
  --danger: #c0392b;
  --warning: #c98900;
  --shadow: 0 18px 50px rgba(20, 32, 51, 0.10);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Sora", "Segoe UI", sans-serif;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(74, 163, 181, 0.28), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(224, 161, 0, 0.18), transparent 50%),
    radial-gradient(800px 500px at 70% 100%, rgba(15, 110, 106, 0.16), transparent 55%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, var(--bg2));
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--teal-deep); text-decoration: none; }
a:hover { color: var(--teal); }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35em;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, #0f3f45 0%, #12353f 45%, #1a2b38 100%);
  color: #f4f7f8;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  z-index: 40;
  box-shadow: 8px 0 30px rgba(10, 30, 40, 0.18);
}
.brand-link { display: flex; gap: 0.75rem; align-items: center; color: inherit; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--amber), #f0c14b);
  color: #1a2332; font-family: var(--font-display); font-weight: 700;
  box-shadow: 0 8px 20px rgba(224, 161, 0, 0.35);
}
.brand-text strong { display: block; font-size: 1.15rem; font-family: var(--font-display); }
.brand-text small { color: rgba(255,255,255,0.65); font-size: 0.75rem; }
.side-nav { margin-top: 1.75rem; display: flex; flex-direction: column; gap: 0.25rem; flex: 1; overflow: auto; }
.side-nav a {
  color: rgba(255,255,255,0.78);
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.side-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; transform: translateX(2px); }
.side-nav a.is-active {
  background: linear-gradient(90deg, rgba(224,161,0,0.28), rgba(74,163,181,0.18));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--amber);
}
.side-foot { color: rgba(255,255,255,0.4); font-size: 0.75rem; padding: 0.75rem 0.5rem 0; }
.sidebar-backdrop { display: none; }

.app-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.5rem 0.5rem;
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
}
.topbar-title h1 { font-size: 1.55rem; margin: 0; }
.topbar-title p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }
.topbar-user { margin-left: auto; display: flex; gap: 0.6rem; align-items: center; }
.user-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.nav-toggle { display: none; }

.content { padding: 0.5rem 1.5rem 2rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  backdrop-filter: blur(8px);
}
.panel + .panel { margin-top: 1rem; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.panel-head h2 { font-size: 1.2rem; margin: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat {
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255,255,255,0.92), rgba(255,255,255,0.72));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: riseIn .45s ease both;
}
.stat:nth-child(2) { animation-delay: .05s; }
.stat:nth-child(3) { animation-delay: .1s; }
.stat:nth-child(4) { animation-delay: .15s; }
.stat::after {
  content: "";
  position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(15,110,106,0.18), transparent 70%);
}
.stat .label { color: var(--muted); font-size: 0.82rem; font-weight: 500; }
.stat .value { font-family: var(--font-display); font-size: 1.7rem; margin-top: 0.35rem; }
.stat.amber .value { color: #9a6a00; }
.stat.teal .value { color: var(--teal-deep); }
.stat.coral .value { color: var(--coral); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 0; cursor: pointer;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 110, 106, 0.28);
}
.btn-accent {
  background: linear-gradient(135deg, var(--amber), #c98900);
  color: #1a2332;
  box-shadow: 0 10px 24px rgba(224, 161, 0, 0.28);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost {
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; border-radius: 10px; }
.btn-block { width: 100%; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.85rem; }
.form-group { margin-bottom: 0.85rem; }
.form-group label {
  display: block; margin-bottom: 0.35rem;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft);
}
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
  border-color: rgba(15, 110, 106, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 110, 106, 0.12);
}
textarea.form-control { min-height: 96px; resize: vertical; }

.table-wrap { overflow: auto; border-radius: 14px; }
table.data {
  width: 100%; border-collapse: collapse; min-width: 640px;
}
table.data th, table.data td {
  text-align: left; padding: 0.75rem 0.7rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
table.data th {
  color: var(--muted); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600;
}
table.data tr:hover td { background: rgba(15, 110, 106, 0.04); }
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
}
.badge-ok { background: rgba(31,138,91,0.12); color: var(--success); }
.badge-warn { background: rgba(224,161,0,0.18); color: #8a6200; }
.badge-danger { background: rgba(192,57,43,0.12); color: var(--danger); }
.badge-muted { background: rgba(107,122,144,0.14); color: var(--ink-soft); }

.alert {
  padding: 0.85rem 1rem; border-radius: 12px; margin-bottom: 1rem;
  border: 1px solid transparent; font-size: 0.92rem;
}
.alert-success { background: rgba(31,138,91,0.12); border-color: rgba(31,138,91,0.25); color: #145c3d; }
.alert-error { background: rgba(192,57,43,0.1); border-color: rgba(192,57,43,0.25); color: #8a241c; }
.alert-info { background: rgba(74,163,181,0.12); border-color: rgba(74,163,181,0.25); color: #1d5561; }

.empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 0.35rem; }

.toolbar { display: flex; gap: 0.65rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .form-control { max-width: 280px; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Auth / login */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
}
.auth-hero {
  position: relative;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(10, 55, 58, 0.88), rgba(20, 32, 51, 0.72)),
    radial-gradient(circle at 20% 20%, rgba(224,161,0,0.35), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(74,163,181,0.4), transparent 45%),
    linear-gradient(135deg, #0d4f4c, #1a2b38 55%, #243447);
}
.auth-hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.5;
  animation: drift 18s linear infinite;
}
.auth-hero-inner { position: relative; z-index: 1; max-width: 520px; }
.auth-brand {
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 4.5rem);
  line-height: 0.95;
  margin-bottom: 0.75rem;
  animation: riseIn .6s ease both;
}
.auth-hero p {
  font-size: 1.05rem; color: rgba(255,255,255,0.82);
  max-width: 28ch; animation: riseIn .7s ease .08s both;
}
.auth-panel {
  display: grid; place-items: center; padding: 2rem;
}
.auth-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: riseIn .55s ease .05s both;
}
.auth-card h2 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 1.4rem; }

/* POS */
.pos-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
  min-height: calc(100vh - 110px);
}
.pos-search-bar { display: flex; gap: 0.6rem; margin-bottom: 0.85rem; }
.pos-search-bar .form-control { font-size: 1.05rem; padding: 0.9rem 1rem; }
.product-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.7rem;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 0.2rem;
}
.product-tile {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.88);
  border-radius: 14px;
  padding: 0.85rem;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.product-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(15,110,106,0.4);
  box-shadow: 0 12px 24px rgba(20,32,51,0.08);
}
.product-tile .name { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.product-tile .meta { color: var(--muted); font-size: 0.75rem; }
.product-tile .price { margin-top: 0.45rem; color: var(--teal-deep); font-weight: 700; }
.cart-panel { display: flex; flex-direction: column; }
.cart-list { flex: 1; overflow: auto; max-height: 42vh; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.cart-item .qty-row { display: flex; align-items: center; gap: 0.35rem; }
.cart-item input.qty {
  width: 56px; text-align: center; padding: 0.35rem;
  border-radius: 8px; border: 1px solid var(--line);
}
.cart-totals { margin-top: auto; padding-top: 0.85rem; }
.total-row {
  display: flex; justify-content: space-between;
  margin-bottom: 0.4rem; color: var(--ink-soft); font-size: 0.92rem;
}
.total-row.grand {
  font-family: var(--font-display);
  font-size: 1.45rem; color: var(--ink); margin-top: 0.5rem;
}
.kbd {
  display: inline-block; padding: 0.1rem 0.4rem;
  border-radius: 6px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.7); font-size: 0.72rem; color: var(--muted);
}
.shortcuts { color: var(--muted); font-size: 0.78rem; margin-top: 0.6rem; }

.age-chip {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(15, 110, 106, 0.10);
  color: var(--teal-deep);
  font-size: 0.72rem;
  font-weight: 600;
}
.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(12, 22, 34, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  width: min(420px, 100%);
  background: var(--surface-solid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
}
.modal-card h3 { margin: 0 0 .35rem; font-family: "Fraunces", serif; }
.modal-card .sub { color: var(--muted); margin: 0 0 1rem; font-size: .9rem; }

.inline-add { display: flex; gap: .45rem; align-items: center; }
.inline-add .form-control { flex: 1; }
.inline-add .btn { flex: 0 0 auto; min-width: 2.5rem; }
.check-inline {
  display: flex; align-items: center; gap: .5rem;
  margin: .35rem 0 .65rem; font-size: .9rem; color: var(--ink-soft);
}
.pagination {
  display: flex; align-items: center; gap: .75rem;
  margin-top: 1rem; flex-wrap: wrap;
}
.pagination .page-meta { color: var(--muted); font-size: .85rem; }
.thumb {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: 8px; background: rgba(20,32,51,0.06);
  display: block;
}
.thumb-lg { width: 96px; height: 96px; border-radius: 12px; }
.thumb-empty {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(20,32,51,0.06); display: inline-block;
}
.void-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.gift-banner { font-weight: 700; letter-spacing: .04em; margin: 6px 0; }

.receipt {
  width: 80mm; max-width: 100%;
  font-family: "Consolas", "Courier New", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.35;
  padding: 12px;
  background: #fff;
  color: #111;
}
.receipt h2 { font-size: 16px; text-align: center; margin: 0 0 4px; }
.receipt .center { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.receipt td { padding: 3px 0; vertical-align: top; word-break: break-word; }
.receipt .line { border-top: 1px dashed #999; margin: 8px 0; }
.receipt .total-row {
  display: flex; justify-content: space-between;
  font-family: inherit; font-size: 12px; padding: 2px 0;
  border: 0; background: transparent;
}
.receipt .total-row.grand { font-weight: 700; margin-top: 4px; }

/* Thermal / receipt print-only layout */
@media print {
  @page { size: 80mm auto; margin: 2mm; }
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 80mm;
  }
  body * { visibility: hidden !important; }
  .receipt, .receipt * { visibility: visible !important; }
  .no-print, .sidebar, .sidebar-backdrop, .topbar, .app-shell > aside,
  .flash-wrap, nav, .btn { display: none !important; }
  .app-main, .content, main, .app-shell { margin: 0 !important; padding: 0 !important; }
  .receipt {
    position: absolute; left: 0; top: 0;
    width: 76mm; max-width: 76mm;
    margin: 0; padding: 2mm;
    background: #fff !important; color: #000 !important;
    box-shadow: none !important; border: 0 !important;
    border-radius: 0 !important;
    font-size: 11px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .receipt h2 { font-size: 14px; }
  .receipt .line { border-top-color: #000; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { background-position: 0 0; }
  to { background-position: 28px 28px; }
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .pos-layout { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { min-height: 38vh; padding: 2rem; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop.is-open {
    display: block; position: fixed; inset: 0;
    background: rgba(10,20,30,0.45); z-index: 35;
  }
  .app-main { margin-left: 0; }
  .nav-toggle {
    display: inline-flex;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; padding: 0.45rem 0.7rem; cursor: pointer;
  }
  .form-row, .form-row-3, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .topbar { padding-inline: 1rem; }
  .content { padding-inline: 1rem; }
  .user-chip { display: none; }
}
