:root {
  color-scheme: light;
  --ink: #24212a;
  --muted: #746e78;
  --line: #eadfe6;
  --panel: #ffffff;
  --surface: #fff8fb;
  --accent: #c34d79;
  --accent-strong: #7f2e4e;
  --accent-soft: #fff0f5;
  --mint: #dff5ee;
  --mint-strong: #3f806e;
  --peach: #ffe9d8;
  --sky: #e8f2ff;
  --sage: #477a6a;
  --ink-soft: #3d3540;
  --gold: #b97824;
  --danger: #b93c3c;
  --shadow: 0 18px 50px rgba(91, 55, 71, 0.12);
  --soft-shadow: 0 10px 28px rgba(91, 55, 71, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 240, 245, 0.96), rgba(232, 242, 255, 0.72) 360px, rgba(223, 245, 238, 0.45) 720px, rgba(255, 248, 251, 0) 980px),
    var(--surface);
  color: var(--ink);
  font-family: "Noto Sans Lao", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0;
}

body.pos-page {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 10px 18px 18px;
}

.pos-page .app-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 10px;
}

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

.store-logo {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border: 1px solid var(--line);
  border-radius: 16px;
  object-fit: contain;
  padding: 4px;
  background: #fbf7ed;
  box-shadow: 0 14px 32px rgba(127, 46, 78, 0.13);
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.45rem, 2.4vw, 2.05rem);
  color: #2a2028;
  font-family: "Noto Serif Lao", "Noto Sans Lao", serif;
  font-weight: 900;
}

h2 {
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.topbar-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.topbar-actions,
.checkout-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pos-view-tabs {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.pos-view-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.pos-view-tab.active {
  border-color: #efc6d5;
  background: linear-gradient(180deg, #fff8fb, #ffeef5);
  color: var(--accent-strong);
  box-shadow: 0 6px 16px rgba(164, 60, 98, 0.1);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.connection-pill.online {
  border-color: #b9eadb;
  background: #effbf6;
  color: #2f735f;
}

.connection-pill.offline {
  border-color: #efd6a8;
  background: #fff7e6;
  color: #8b6418;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.mode-button {
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button {
  background: linear-gradient(180deg, #d75b88, var(--accent));
  color: #fff;
  box-shadow: 0 10px 22px rgba(195, 77, 121, 0.22);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #fff7fa;
  color: var(--accent-strong);
  border-color: #edccd6;
}

.danger-button {
  background: #fff1f1;
  color: var(--danger);
  border-color: #f0c7c7;
}

.icon-button {
  width: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--line);
  color: var(--ink);
  font-size: 1.25rem;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 18px;
  align-items: stretch;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.pos-page .front-panel {
  min-height: 0;
}

.front-panel[hidden] {
  display: none !important;
}

.catalog-panel,
.checkout-panel,
.records-panel,
.admin-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.catalog-panel,
.records-panel,
.admin-panel {
  padding: 18px;
}

.admin-panel:not([hidden]) {
  display: block;
  width: 100%;
}

.catalog-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.admin-grid {
  display: block;
  min-height: 0;
}

.admin-mobile-nav,
.admin-section-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--soft-shadow);
  scrollbar-width: none;
}

.admin-mobile-nav::-webkit-scrollbar,
.admin-section-tabs::-webkit-scrollbar {
  display: none;
}

.admin-section-tabs button,
.admin-mobile-nav a {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.admin-section-tabs button.active,
.admin-mobile-nav a.active {
  border-color: #efc6d5;
  background: linear-gradient(180deg, #fff8fb, #ffeef5);
  color: var(--accent-strong);
  box-shadow: 0 6px 16px rgba(164, 60, 98, 0.1);
}

.sales-overview {
  scroll-margin-top: 14px;
}

.sales-overview.front-panel {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.pos-page .sales-overview.front-panel,
.pos-page .records-panel.front-panel {
  overflow-y: auto;
  padding-bottom: 4px;
}

.sales-overview:target {
  animation: sales-highlight 1.2s ease;
}

.admin-access-card {
  width: min(420px, calc(100vw - 28px));
}

.admin-access-card .primary-button {
  width: 100%;
  margin-top: 14px;
}

@keyframes sales-highlight {
  0%, 100% { filter: none; }
  35% { filter: drop-shadow(0 0 10px rgba(164, 60, 98, 0.28)); }
}

.admin-stack {
  display: contents;
}

.admin-summary-panel {
  order: -3;
  background:
    linear-gradient(135deg, rgba(255, 240, 245, 0.92), rgba(232, 242, 255, 0.74)),
    rgba(255, 255, 255, 0.94);
}

.admin-alert-panel {
  order: -2;
}

.admin-products-panel {
  order: -1;
}

.admin-add-panel,
.admin-settings-panel,
.admin-sales-panel {
  background: rgba(255, 255, 255, 0.94);
}

.admin-form {
  display: grid;
  gap: 10px;
}

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

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-product-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #fffbfd);
  box-shadow: 0 8px 22px rgba(91, 55, 71, 0.07);
}

.admin-thumb {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 76% 20%, rgba(255, 255, 255, 0.62), transparent 21%),
    linear-gradient(135deg, var(--product-color, #a43c62), rgba(36, 32, 29, 0.84));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.admin-thumb[style*="background-image"] {
  background-size: contain;
  background-color: #fff;
}

.admin-product-row h3,
.admin-product-row p {
  margin: 0;
}

.admin-product-row p {
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-product-buttons {
  display: grid;
  grid-template-columns: 42px 42px 42px;
  gap: 8px;
  align-items: center;
}

.login-panel {
  width: min(520px, 100%);
  margin: 70px auto 0;
}

.compact-head {
  margin-bottom: 10px;
}

.variant-editor {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fbfafb;
}

.variant-editor-list {
  display: grid;
  gap: 8px;
}

.variant-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr 96px 42px;
  gap: 8px;
  align-items: center;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.report-grid article {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 14px;
}

.admin-summary-panel .metric:nth-child(1) {
  background: linear-gradient(135deg, #fff4f8, #ffffff);
  border-color: #efc6d5;
}

.admin-summary-panel .metric:nth-child(2) {
  background: linear-gradient(135deg, #eefbf6, #ffffff);
  border-color: #b9eadb;
}

.admin-summary-panel .metric:nth-child(3) {
  background: linear-gradient(135deg, #fff8e8, #ffffff);
  border-color: #f2d6a8;
}

.admin-summary-panel .metric:nth-child(4) {
  background: linear-gradient(135deg, #eef5ff, #ffffff);
  border-color: #c9dcf7;
}

.report-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.45;
}

.report-filter {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, #fff8fb, #f5fbff);
}

.stock-alert-list {
  display: grid;
  gap: 10px;
}

.stock-alert-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #efd6a8;
  border-radius: 10px;
  background: #fffaf0;
}

.stock-alert-row.stock-out {
  border-color: #e9b8b8;
  background: #fff3f3;
}

.stock-alert-row.stock-low {
  border-color: #edc19b;
  background: #fff7ef;
}

.stock-alert-row.stock-medium {
  border-color: #ead7a8;
  background: #fffbed;
}

.stock-alert-row strong,
.stock-alert-row span {
  display: block;
}

.stock-alert-row strong {
  line-height: 1.35;
}

.stock-alert-row span {
  color: #7b642d;
  font-size: 0.82rem;
  font-weight: 800;
}

.compact-empty {
  min-height: 88px;
}

.checkout-panel {
  position: sticky;
  top: 78px;
  padding: 14px;
  height: 100%;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-rows: auto auto auto minmax(54px, auto) auto auto auto auto;
  gap: 8px;
  background:
    linear-gradient(180deg, rgba(255, 240, 245, 0.72), rgba(255, 255, 255, 0.92) 180px),
    #fff;
}

.panel-head,
.checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.catalog-tools {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(180px, 280px) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.barcode-card {
  grid-column: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid #f0cad8;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 240, 245, 0.96), rgba(232, 242, 255, 0.82)),
    #fff;
  box-shadow: 0 10px 26px rgba(195, 77, 121, 0.09);
}

.barcode-box {
  display: grid;
  gap: 4px;
}

.barcode-box span {
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 900;
}

.barcode-box input {
  min-height: 40px;
  border-color: #eab9cc;
  border-radius: 14px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.94);
}

.barcode-focus-btn {
  min-height: 40px;
  padding-inline: 10px;
}

.scan-status {
  grid-column: 1 / -1;
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.scan-status[data-type="success"] {
  color: var(--mint-strong);
}

.scan-status[data-type="error"] {
  color: var(--danger);
}

.search-box,
.field {
  display: grid;
  gap: 6px;
}

.search-box span,
.field span,
.total-row span,
.change-line span,
.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 63, 85, 0.14);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 63, 85, 0.14);
}

.category-tabs {
  display: flex;
  gap: 8px;
  align-items: end;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.category-tab {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--muted);
  padding: 0 14px;
  font-weight: 800;
}

.category-tab.active {
  background: #2b2530;
  color: #fff;
  border-color: #24201d;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 2px 4px 4px 2px;
  scrollbar-width: thin;
}

.product-card {
  min-height: 166px;
  border: 1px solid #eadfe6;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #fffbfd);
  padding: 12px;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr) auto;
  gap: 8px;
  box-shadow: var(--soft-shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.product-card:hover {
  border-color: #efbfd0;
  box-shadow: 0 16px 34px rgba(127, 46, 78, 0.13);
  transform: translateY(-2px);
}

.product-card:focus-visible {
  outline: 3px solid rgba(195, 77, 121, 0.28);
  outline-offset: 2px;
}

.product-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.product-art {
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 76% 20%, rgba(255, 255, 255, 0.62), transparent 21%),
    linear-gradient(135deg, var(--product-color), rgba(36, 32, 29, 0.84));
  position: relative;
  min-height: 68px;
}

.product-art.has-image {
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #fff;
}

.product-art.has-image::before,
.product-art.has-image::after {
  display: none;
}

.product-art::before,
.product-art::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.86);
}

.product-art::before {
  width: 54px;
  height: 48px;
  left: 18px;
  top: 16px;
  border-radius: 20px 20px 8px 8px;
  clip-path: polygon(18% 0, 38% 12%, 50% 0, 62% 12%, 82% 0, 100% 28%, 82% 40%, 82% 100%, 18% 100%, 18% 40%, 0 28%);
}

.product-art::after {
  width: 32px;
  height: 52px;
  right: 20px;
  bottom: 8px;
  border-radius: 18px 18px 6px 6px;
  opacity: 0.9;
}

.product-name {
  margin: 0 0 4px;
  font-size: 0.94rem;
  font-weight: 900;
  line-height: 1.28;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.price-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-weight: 900;
  color: var(--ink);
}

.price-row span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: #fff4f8;
  color: var(--accent-strong);
}

.stock-low {
  color: var(--danger);
}

.stock-out {
  color: var(--danger);
  font-weight: 900;
}

.stock-medium {
  color: #8b6418;
  font-weight: 800;
}

.stock-good {
  color: var(--sage);
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbf6f9;
}

.payment-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f6f8;
}

.payment-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.payment-button.active {
  border-color: var(--line);
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 4px 12px rgba(54, 39, 32, 0.07);
}

.agent-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid #d8bdc8;
  border-radius: 14px;
  background: #fff7f9;
}

.agent-fields[hidden] {
  display: none;
}

.agent-fields .field-wide {
  grid-column: 1 / -1;
}

.mode-button {
  min-height: 36px;
  background: transparent;
  color: var(--muted);
}

.mode-button.active {
  background: #fff;
  color: var(--accent-strong);
  border-color: var(--line);
  box-shadow: 0 4px 14px rgba(54, 39, 32, 0.08);
}

.cart-list {
  display: grid;
  gap: 6px;
  min-height: 54px;
  max-height: 154px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  align-content: start;
  margin: 0;
  padding-right: 4px;
}

.empty-state {
  min-height: 104px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #e4c0ce;
  border-radius: 16px;
  padding: 18px;
}

.checkout-panel .empty-state {
  min-height: 54px;
  padding: 10px;
  font-size: 0.9rem;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(91, 55, 71, 0.06);
}

.cart-item h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.cart-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.qty-controls {
  display: grid;
  grid-template-columns: 34px 38px 34px;
  align-items: center;
  gap: 4px;
}

.qty-controls button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff7fa;
  font-weight: 900;
}

.qty-controls span {
  text-align: center;
  font-weight: 900;
}

.totals {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}

.total-row,
.change-line,
.grand-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.total-row input {
  max-width: 118px;
  min-height: 34px;
}

.total-row.muted,
.grand-total {
  grid-column: 1 / -1;
}

.grand-total {
  padding: 7px 12px;
  border-radius: 14px;
  background: #2b2530;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 900;
}

.grand-total strong {
  color: #fff;
}

.change-line {
  margin: 0;
}

.insights {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 0;
}

.metric {
  min-height: 82px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  align-content: center;
  gap: 6px;
  box-shadow: var(--soft-shadow);
}

.metric strong {
  font-size: 1.35rem;
}

.metric.warn strong {
  color: var(--gold);
}

.metric-wide {
  grid-column: span 2;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-weight: 700;
}

dialog {
  width: min(680px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 33, 29, 0.46);
}

.dialog-card {
  padding: 18px;
  background: #fff;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  margin-top: 16px;
}

.receipt-card pre {
  white-space: pre-wrap;
  background: #fbf8f5;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  max-height: 55vh;
  overflow: auto;
  width: min(100%, var(--receipt-preview-width, 80mm));
  margin-inline: auto;
  font-size: var(--receipt-font-size, 12px);
  line-height: 1.45;
}

.receipt-paper-field {
  margin-top: 12px;
}

body[data-receipt-paper="58mm"] {
  --receipt-preview-width: 58mm;
  --receipt-print-width: 58mm;
  --receipt-font-size: 10px;
}

body[data-receipt-paper="80mm"] {
  --receipt-preview-width: 80mm;
  --receipt-print-width: 80mm;
  --receipt-font-size: 11px;
}

body[data-receipt-paper="a5"] {
  --receipt-preview-width: 148mm;
  --receipt-print-width: 148mm;
  --receipt-font-size: 12px;
}

body[data-receipt-paper="a4"] {
  --receipt-preview-width: 210mm;
  --receipt-print-width: 210mm;
  --receipt-font-size: 12px;
}

.variant-list {
  display: grid;
  gap: 10px;
}

.variant-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  text-align: left;
}

.variant-option strong,
.variant-option span {
  display: block;
}

.variant-option span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(250px, 38%);
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .catalog-panel {
    height: auto;
    min-height: 0;
  }

  .checkout-panel {
    position: static;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .insights {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 8px;
  }

  .pos-view-tabs {
    margin: 0 0 8px;
    padding: 5px;
  }

  .pos-view-tab {
    min-height: 40px;
    padding: 0 6px;
    font-size: 0.82rem;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 8px;
    padding: 4px 0 8px;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .store-logo {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
  }

  .topbar-subtitle {
    display: none;
  }

  .topbar-actions,
  .checkout-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions {
    grid-template-columns: minmax(0, 1fr) minmax(82px, auto) 64px;
  }

  .topbar-actions > * {
    min-width: 0;
  }

  .pos-topbar-actions {
    grid-template-columns: 1fr 1fr 72px;
    grid-template-areas: "sales new admin";
  }

  .pos-status { display: none; }
  .pos-sales-link { grid-area: sales; }
  .pos-new-sale { grid-area: new; }
  .pos-admin-access { grid-area: admin; }

  .pos-new-sale {
    padding-inline: 10px;
    font-size: 0.82rem;
  }

  .pos-admin-access {
    padding-inline: 6px;
    font-size: 0.78rem;
  }

  .workspace {
    grid-template-rows: minmax(0, 1fr) 292px;
    gap: 8px;
    height: auto;
  }

  .admin-mobile-nav {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    gap: 6px;
    margin: 0 -12px 12px;
    padding: 8px 12px;
    overflow-x: auto;
    border-block: 1px solid var(--line);
    background: rgba(245, 246, 248, 0.96);
    box-shadow: 0 8px 18px rgba(32, 31, 36, 0.08);
    scrollbar-width: none;
  }

  .admin-mobile-nav::-webkit-scrollbar {
    display: none;
  }

  .admin-mobile-nav a {
    flex: 0 0 auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 800;
  }

  .form-grid,
  .report-grid,
  .stock-alert-row {
    grid-template-columns: 1fr;
  }

  .catalog-tools {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .catalog-tools .category-tabs {
    grid-column: 1 / -1;
  }

  .barcode-card {
    grid-template-columns: minmax(0, 1fr) 62px;
    gap: 6px;
    padding: 6px;
    border-radius: 12px;
  }

  .barcode-focus-btn {
    width: 100%;
    min-height: 36px;
    padding-inline: 4px;
    font-size: 0.72rem;
  }

  .barcode-box span,
  .catalog-tools .search-box span,
  .scan-status {
    display: none;
  }

  .barcode-box input,
  .catalog-tools input {
    min-height: 36px;
    border-radius: 10px;
  }

  .catalog-panel {
    height: auto;
    min-height: 0;
    padding: 10px;
  }

  .catalog-panel .panel-head {
    margin-bottom: 6px;
  }

  .catalog-panel .section-kicker {
    display: none;
  }

  .catalog-panel h2 {
    font-size: 0.98rem;
  }

  .catalog-tools {
    gap: 6px;
    margin-bottom: 8px;
  }

  .category-tabs {
    gap: 5px;
  }

  .category-tab {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .insights {
    grid-template-columns: 1fr 1fr;
  }

  .sales-overview.front-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-wide {
    grid-column: 1 / -1;
  }

  .admin-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    width: 100%;
  }

  .admin-stack {
    display: contents;
  }

  .admin-summary-panel { order: 1; }
  .admin-alert-panel { order: 2; }
  .admin-products-panel { order: 3; }
  .admin-add-panel { order: 4; }
  .admin-settings-panel { order: 5; }
  .admin-sales-panel { order: 6; }

  .admin-panel {
    width: 100%;
    min-width: 0;
    padding: 14px;
    scroll-margin-top: 64px;
  }

  .admin-summary-panel .insights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-summary-panel .metric,
  .admin-summary-panel .report-grid article {
    min-width: 0;
    padding: 12px;
  }

  .admin-summary-panel .metric strong,
  .admin-summary-panel .report-grid strong {
    overflow-wrap: anywhere;
  }

  .admin-products-panel .panel-head {
    gap: 10px;
  }

  .admin-product-row {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .admin-thumb {
    width: 48px;
    height: 48px;
  }

  .admin-product-row h3 {
    font-size: 0.94rem;
    line-height: 1.35;
  }

  .admin-product-row p {
    margin-top: 3px;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  .admin-product-buttons {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .admin-product-buttons .icon-button {
    width: 100%;
  }

  .sales-table-wrap {
    overflow: visible;
  }

  .sales-table-wrap table,
  .sales-table-wrap tbody,
  .sales-table-wrap tr,
  .sales-table-wrap td {
    display: block;
    width: 100%;
  }

  .sales-table-wrap table {
    min-width: 0;
  }

  .sales-table-wrap thead {
    display: none;
  }

  .sales-table-wrap tbody {
    display: grid;
    gap: 10px;
  }

  .sales-table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    background: #fff;
  }

  .sales-table-wrap td {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    border: 0;
    padding: 6px 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .sales-table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: left;
  }

  .variant-editor-row {
    grid-template-columns: 1fr 1fr;
  }

  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .product-card {
    min-height: 128px;
    padding: 7px;
    border-radius: 12px;
    grid-template-rows: 42px minmax(0, 1fr) auto;
    gap: 5px;
    overflow: hidden;
  }

  .checkout-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 5px;
    gap: 2px;
    border-radius: 12px;
    grid-template-rows: auto auto auto auto auto auto;
    align-content: start;
    column-gap: 6px;
  }

  .checkout-header {
    grid-column: 1;
  }

  .checkout-panel > .field:has(#customerName) {
    grid-column: 2;
  }

  .checkout-panel .mode-toggle,
  .checkout-panel .cart-list,
  .checkout-panel .totals,
  .checkout-panel .checkout-actions {
    grid-column: 1 / -1;
  }

  .checkout-panel > .field:has(#cashInput) {
    grid-column: 1;
  }

  .checkout-panel .payment-toggle {
    grid-column: 2;
  }

  .checkout-header {
    margin-bottom: 0;
  }

  .checkout-header .section-kicker {
    display: none;
  }

  .checkout-header h2 {
    font-size: 1rem;
  }

  .status-pill {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .checkout-panel > .field {
    gap: 0;
  }

  .checkout-panel > .field > span {
    display: none;
  }

  .checkout-panel input {
    min-height: 30px;
    border-radius: 10px;
  }

  .mode-toggle {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    border-radius: 10px;
  }

  .mode-button {
    min-height: 26px;
    padding: 0 3px;
    font-size: 0.66rem;
  }

  .cart-list {
    min-height: 76px;
    max-height: 112px;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .cart-list:has(.empty-state) {
    min-height: 0;
    max-height: 0;
  }

  .cart-list:has(.empty-state) .empty-state {
    display: none;
  }

  .checkout-panel .empty-state {
    min-height: 32px;
    padding: 4px;
    border-radius: 10px;
    font-size: 0.72rem;
  }

  .cart-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 10px;
  }

  .cart-item h3 {
    display: none;
  }

  .cart-item p {
    font-size: 0.66rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .qty-controls {
    grid-template-columns: 24px 22px 24px;
  }

  .qty-controls button {
    width: 24px;
    height: 24px;
    border-radius: 8px;
  }

  .totals {
    padding: 4px 0;
    gap: 3px 6px;
  }

  .checkout-panel .total-row.muted {
    display: none;
  }

  .total-row span,
  .change-line span {
    font-size: 0.7rem;
  }

  .total-row input {
    max-width: 74px;
    min-height: 26px;
    padding: 0 8px;
  }

  .grand-total {
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 11px;
    font-size: 0.98rem;
  }

  .payment-toggle {
    gap: 3px;
    padding: 3px;
    border-radius: 10px;
  }

  .payment-button {
    min-height: 26px;
    font-size: 0.72rem;
  }

  .checkout-panel .change-line {
    display: none;
  }

  .checkout-actions {
    gap: 6px;
  }

  .checkout-actions .secondary-button,
  .checkout-actions .primary-button {
    min-height: 30px;
    font-size: 0.78rem;
  }

  .product-art {
    min-height: 42px;
    border-radius: 10px;
  }

  .product-name {
    font-size: 0.72rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .product-meta {
    gap: 3px;
    font-size: 0.58rem;
    line-height: 1.25;
  }

  .product-meta span:not(:last-child) {
    display: none;
  }

  .price-row span {
    min-height: 24px;
    padding: 0 6px;
    font-size: 0.68rem;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .mode-button {
    padding: 0 10px;
  }

  .mode-toggle {
    grid-template-columns: 1fr 1fr;
  }

  .checkout-panel .mode-toggle {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .report-filter,
  .agent-fields {
    grid-template-columns: 1fr;
  }

  .agent-fields .field-wide {
    grid-column: auto;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions span {
    display: none;
  }
}

@media (max-width: 430px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar-actions {
    grid-template-columns: minmax(0, 1fr) minmax(78px, auto) 58px;
    gap: 6px;
  }

  .pos-topbar-actions {
    grid-template-columns: 1fr 1fr 72px;
  }

  .checkout-actions {
    grid-template-columns: 1fr;
  }

  .checkout-panel .checkout-actions {
    grid-template-columns: 1fr 1fr;
  }

  .insights {
    grid-template-columns: 1fr;
  }

  .sales-overview.front-panel {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .topbar .primary-button,
  .topbar .secondary-button,
  .connection-pill {
    min-height: 38px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  h1 {
    font-size: 1.24rem;
  }

  .catalog-panel,
  .checkout-panel,
  .records-panel,
  .admin-panel {
    border-radius: 12px;
  }

  .product-card {
    min-height: 124px;
  }

  .product-art {
    min-height: 40px;
  }
}

@media (max-width: 360px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .product-card {
    min-height: 118px;
    padding: 6px;
  }
}

@media (max-width: 680px) and (max-height: 760px) {
  .workspace {
    grid-template-rows: minmax(0, 1fr) 292px;
  }
}

@media print {
  @page {
    margin: 0;
    size: auto;
  }

  body * {
    visibility: hidden;
  }

  #receiptPreview,
  #receiptPreview * {
    visibility: visible;
  }

  #receiptPreview {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--receipt-print-width, 80mm);
    max-width: none;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    font-size: var(--receipt-font-size, 11px);
  }
}
