:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #f7f6f3;
  --panel: #ffffff;
  --panel-soft: #fbfaf7;
  --panel-strong: #f3eee3;
  --accent: #c8a96a;
  --accent-strong: #a8864a;
  --accent-soft: rgba(200, 169, 106, 0.14);
  --accent-2: #d6b87a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 28px 70px rgba(31, 41, 55, 0.12);
  --shadow-soft: 0 14px 36px rgba(31, 41, 55, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(247, 246, 243, 0.84)),
    var(--paper);
}

.login-panel {
  display: grid;
  width: min(440px, 100%);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-brand {
  margin-bottom: 6px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: inset -1px 0 0 rgba(229, 231, 235, 0.8);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(168, 134, 74, 0.26);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-2), var(--accent-strong));
  box-shadow: 0 14px 28px rgba(168, 134, 74, 0.22);
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: var(--ink);
}

.brand span,
.shift-box span,
.shift-box small,
.topbar p,
.metrics span,
.section-kicker {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  height: 42px;
  padding: 0 12px;
  color: var(--muted);
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
}

.nav button.active,
.nav button:hover {
  color: var(--accent-strong);
  border-color: rgba(200, 169, 106, 0.28);
  background: var(--accent-soft);
  box-shadow: none;
}

.admin-shell {
  grid-template-columns: 1fr;
  grid-template-rows: 76px minmax(0, 1fr);
  align-content: start;
}

.admin-shell .sidebar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  height: 76px;
  min-height: 76px;
  max-height: 76px;
  overflow: hidden;
  padding: 14px 24px;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.admin-shell .brand-mark {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
}

.admin-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 6px;
  width: min(100%, 520px);
  height: 48px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.admin-nav button {
  flex: 0 0 118px;
  height: 36px;
  padding: 0 18px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  border-radius: 999px;
}

.admin-nav button.active {
  color: #fff;
  border-color: rgba(168, 134, 74, 0.28);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 22px rgba(168, 134, 74, 0.2);
}

.shift-box {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.admin-shell .shift-box {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  height: 44px;
  margin-top: 0;
  padding: 8px;
  border-radius: 999px;
  box-shadow: none;
}

.admin-shell .shift-box span,
.admin-shell .shift-box small {
  display: none;
}

.admin-shell .shift-box strong {
  padding: 0 4px 0 8px;
  white-space: nowrap;
}

.admin-shell .shift-box .secondary-button {
  height: 34px;
  border-radius: 999px;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 24px;
  padding: 28px;
}

.admin-shell .workspace {
  align-self: start;
  grid-auto-rows: max-content;
  min-height: calc(100vh - 76px);
}

.topbar,
.panel-heading,
.top-actions,
.totals div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 52px;
}

.panel-heading {
  min-height: 36px;
  margin-bottom: 16px;
}

.panel-heading + .recent-sales,
.panel-heading + .low-stock,
.panel-heading + .admin-table,
.panel-heading + .user-list {
  margin-top: 4px;
}

.topbar h1,
.topbar p,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  color: var(--ink);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.panel h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

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

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

.metrics div,
.panel,
.product-editor-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.metrics div {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 10px;
  min-height: 92px;
  padding: 18px;
}

.metrics div::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(200, 169, 106, 0));
}

.metrics div:hover,
.panel:hover,
.product-card:hover,
.cart-item:hover,
.admin-row:hover,
.user-row:hover {
  border-color: rgba(200, 169, 106, 0.5);
  box-shadow: 0 18px 46px rgba(31, 41, 55, 0.11);
}

.metrics strong {
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
}

.pos-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 24px;
  align-items: start;
}

.sale-tab {
  display: grid;
  gap: 26px;
}

#saleHistoryTab .metrics {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

#saleHistoryTab .lower-grid {
  gap: 26px;
}

.panel {
  padding: 22px;
}

.product-panel,
.cart-panel {
  min-height: 610px;
}

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

textarea {
  height: auto;
}

input::placeholder,
textarea::placeholder {
  color: #9ca3af;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(200, 169, 106, 0.16);
}

input[readonly],
input:disabled,
select:disabled {
  color: var(--muted);
  background: #f9fafb;
}

.discount-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
}

.panel-heading input {
  max-width: 300px;
}

.tabs,
.variant-pills,
.color-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabs {
  margin: 18px 0;
}

.tabs button,
.variant-pills button {
  height: 34px;
  padding: 0 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.tabs button.active,
.tabs button:hover,
.variant-pills button.active,
.variant-pills button:hover {
  color: #fff;
  border-color: rgba(168, 134, 74, 0.32);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}

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

.product-card {
  display: grid;
  min-height: 160px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 30px rgba(31, 41, 55, 0.06);
}

.product-card:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #fff, #fffaf0);
}

.product-card strong {
  font-size: 16px;
}

.product-card span,
.product-card small,
.cart-item small,
.sale-row small,
.admin-row small,
.user-row small {
  color: var(--muted);
}

.product-card .price {
  align-self: end;
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 700;
}

.stock-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.stock-line small,
.color-chips span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fafafa;
}

.cart-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cart-items {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 176px;
}

.empty-state {
  display: grid;
  min-height: 170px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
}

.cart-item,
.sale-row,
.stock-row,
.admin-row,
.user-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.cart-item,
.sale-row,
.stock-row {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.cart-item-top,
.cart-item-actions,
.sale-row-top,
.stock-row,
.sale-row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cart-item-top > div:first-child,
.sale-row-top > div:first-child,
.stock-row > div:first-child,
.admin-row > div:first-child,
.user-row > div:first-child {
  display: grid;
  gap: 5px;
}

.sale-row-actions {
  justify-content: flex-end;
}

.cart-item-pricing {
  display: grid;
  gap: 2px;
  text-align: right;
}

.cart-item-pricing s {
  color: #9ca3af;
  font-size: 12px;
}

.line-discount-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
}

.line-discount-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.line-discount {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
}

.line-discount input,
.line-discount select {
  height: 34px;
}

.qty-button,
.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.qty-button:hover,
.icon-button:hover,
.secondary-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.checkout-form,
.admin-form,
.product-editor-form,
.variant-rows,
.admin-table,
.user-list,
.recent-sales,
.low-stock {
  display: grid;
  gap: 12px;
}

.mixed-payment-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
}

.mixed-payment-header,
.mixed-payment-rows {
  display: grid;
  gap: 10px;
}

.mixed-payment-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.mixed-payment-header span {
  color: var(--warn);
  font-size: 13px;
  font-weight: 800;
}

.mixed-payment-header span.balanced {
  color: var(--success);
}

.mixed-payment-header span.overpaid {
  color: var(--danger);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.totals {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.grand-total {
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 700;
}

.primary-button,
.secondary-button,
.text-button {
  height: 42px;
  padding: 0 15px;
  border-radius: var(--radius);
}

.primary-button {
  color: #fff;
  border: 1px solid rgba(168, 134, 74, 0.28);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 30px rgba(168, 134, 74, 0.24);
  font-weight: 700;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
  box-shadow: 0 18px 36px rgba(168, 134, 74, 0.28);
}

.secondary-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.text-button {
  color: var(--danger);
  border: 0;
  background: transparent;
}

.message {
  min-height: 22px;
  color: var(--accent-strong);
  font-size: 14px;
}

.message.error {
  color: var(--danger);
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  margin-top: 0;
}

.admin-tab {
  display: grid;
  gap: 24px;
}

.admin-stock-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}

.product-editor-card {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.section-kicker {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

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

.product-editor-card textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.variant-pills button:last-child {
  border-style: dashed;
  background: #fff;
}

.variant-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 32px;
  gap: 12px;
  align-items: center;
}

.variant-remove {
  color: var(--danger);
  border: 0;
  background: transparent;
  font-size: 22px;
}

.color-chips span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  color: var(--muted);
  font-size: 12px;
}

.color-chips i {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(31, 41, 55, 0.16);
  border-radius: 50%;
}

.inventory-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.inventory-subtitle,
.inventory-summary {
  color: var(--muted);
  font-size: 13px;
}

.inventory-matrix {
  overflow-x: auto;
}

.inventory-matrix table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.inventory-matrix th,
.inventory-matrix td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
}

.inventory-matrix tbody tr:nth-child(even) {
  background: #fbfaf7;
}

.inventory-matrix tbody tr:hover {
  background: var(--accent-soft);
}

.inventory-matrix th {
  color: var(--muted);
  font-weight: 600;
}

.inventory-matrix th:first-child,
.inventory-matrix td:first-child {
  text-align: left;
}

.inventory-matrix input {
  width: 92px;
  height: 34px;
  margin: 0 auto;
  text-align: center;
}

.inventory-matrix tfoot td {
  color: var(--accent-strong);
  font-weight: 700;
}

.empty-state.compact {
  min-height: 82px;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
}

.stock-list-panel {
  position: sticky;
  top: 100px;
}

.admin-row,
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.admin-row strong,
.admin-row small,
.user-row strong,
.user-row small {
  display: block;
}

.user-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.cash-settings-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.cash-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cash-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
}

.cash-summary span {
  color: var(--muted);
  font-size: 12px;
}

.sale-edit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
}

.sale-edit-form > div:first-child,
.sale-edit-form > input[type="hidden"],
.sale-edit-form > label:nth-of-type(3),
.sale-edit-form > .sale-edit-items,
.sale-edit-form > .totals,
.sale-edit-form > .message,
.sale-edit-form > .dialog-actions {
  grid-column: 1 / -1;
}

.sale-edit-items {
  display: grid;
  gap: 12px;
  max-height: min(46vh, 480px);
  overflow: auto;
  padding-right: 4px;
}

.sale-edit-item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 90px minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.stock-row.warning strong {
  color: var(--warn);
}

dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

#saleEditDialog {
  width: min(920px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(31, 41, 55, 0.32);
}

.dialog-body {
  display: grid;
  gap: 16px;
}

.dialog-body h2,
.dialog-body p {
  margin: 0;
}

.dialog-body p {
  color: var(--muted);
}

.size-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
}

.size-choices button {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.size-choices button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

menu {
  margin: 0;
  padding: 0;
  text-align: right;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    padding: 16px;
  }

  .admin-shell .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: 76px;
    min-height: 76px;
    max-height: 76px;
    overflow: hidden;
  }

  .nav {
    display: none;
  }

  .admin-nav {
    display: flex;
    width: min(100%, 520px);
  }

  .shift-box {
    margin-left: auto;
    margin-top: 0;
  }

  .pos-grid,
  .lower-grid,
  .admin-stock-layout {
    grid-template-columns: 1fr;
  }

  .stock-list-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .workspace {
    gap: 18px;
    padding: 16px;
  }

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

  .top-actions {
    justify-content: flex-start;
  }

  .metrics,
  .admin-metrics {
    grid-template-columns: 1fr;
  }

  .user-fields,
  .sale-edit-form,
  .mixed-payment-rows,
  .cash-summary,
  .form-grid.two,
  .form-grid.three,
  .variant-row,
  .sale-edit-item {
    grid-template-columns: 1fr;
  }

  .product-editor-card {
    padding: 16px;
  }

  .inventory-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-heading input {
    max-width: none;
  }

  .panel {
    padding: 18px;
  }

  .shift-box {
    display: none;
  }

  .admin-shell .sidebar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .admin-shell .brand {
    justify-content: center;
  }

  .admin-nav {
    justify-content: stretch;
    width: 100%;
  }

  .admin-nav button {
    flex: 1 1 0;
    padding: 0 10px;
  }

  .admin-shell .shift-box {
    display: flex;
    justify-content: center;
  }
}
