:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #222726;
  --muted: #6f7774;
  --line: #dfe3df;
  --paper: #ffffff;
  --canvas: #f5f2ed;
  --charcoal: #202423;
  --teal: #2ea98e;
  --teal-dark: #237d6c;
  --mint: #d8efe8;
  --red: #df4d50;
  --yellow: #f3ce4f;
  --shadow: 0 18px 50px rgba(41, 49, 46, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
}

.brand-mark::before,
.brand-mark i {
  position: absolute;
  width: 19px;
  height: 28px;
  border-radius: 60% 60% 45% 45%;
  background: #ef686a;
  content: "";
  transform-origin: 50% 82%;
}

.brand-mark::before {
  transform: translateY(-8px);
}

.brand-mark i:nth-child(1) {
  background: #6bc4ad;
  transform: rotate(120deg) translateY(-8px);
}

.brand-mark i:nth-child(2) {
  background: #c796be;
  transform: rotate(240deg) translateY(-8px);
}

.brand-mark i:nth-child(3) {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--yellow);
}

.brand-mark.small {
  width: 30px;
  height: 30px;
  transform: scale(0.66);
  transform-origin: left center;
  margin-right: -8px;
}

.login-screen {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: 32px clamp(18px, 5vw, 74px);
  overflow: hidden;
  grid-template-rows: auto 1fr auto;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.86), rgba(245, 242, 237, 0.96)),
    radial-gradient(circle at 50% 45%, #fff, #eee8df);
}

.ambient {
  position: absolute;
  border-radius: 50%;
  opacity: 0.65;
  pointer-events: none;
}

.ambient-left {
  top: -160px;
  left: -120px;
  width: 560px;
  height: 560px;
  background: #f4e7d8;
}

.ambient-right {
  right: -90px;
  bottom: -130px;
  width: 430px;
  height: 430px;
  background: #dcefe6;
}

.login-brand {
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  font-weight: 850;
  letter-spacing: -0.06em;
}

.login-brand > span:last-child > span {
  color: var(--teal-dark);
  font-weight: 600;
}

.login-card {
  z-index: 1;
  align-self: center;
  width: min(430px, 100%);
  margin: 28px auto;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(213, 215, 208, 0.9);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-card h1 {
  margin: 8px 0 8px;
  font-size: clamp(1.9rem, 5vw, 2.65rem);
  letter-spacing: -0.05em;
}

.login-copy {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.45;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
}

.employee-select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #ccd3cf;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.employee-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(46, 169, 142, 0.12);
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 24px 0 18px;
}

.pin-display i {
  width: 14px;
  height: 14px;
  border: 2px solid #aeb8b4;
  border-radius: 50%;
  background: transparent;
  transition: 150ms ease;
}

.pin-display i.is-filled {
  border-color: var(--teal-dark);
  background: var(--teal);
  transform: scale(1.12);
}

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

.keypad button {
  min-height: 54px;
  border: 0;
  border-radius: 14px;
  background: #e8f3ef;
  color: #245c51;
  font-size: 1.35rem;
  font-weight: 750;
  transition: transform 100ms ease, background 100ms ease;
}

.keypad button:hover {
  background: #d7ebe4;
}

.keypad button:active {
  transform: scale(0.97);
}

.keypad .keypad-secondary {
  background: #f1f1ee;
  color: #737a77;
}

.login-button {
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  border: 0;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 850;
}

.login-button:disabled {
  cursor: not-allowed;
  background: #c9cecb;
}

.form-message {
  min-height: 20px;
  margin: 12px 0 -6px;
  color: var(--red);
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
}

.login-footer {
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.8rem;
}

.connection-pill,
.status-button,
#network-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.connection-pill i,
.status-button i,
#network-state i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9ba39f;
}

.is-online i {
  background: #35ba72;
  box-shadow: 0 0 0 4px rgba(53, 186, 114, 0.12);
}

.is-offline i {
  background: #eea645;
  box-shadow: 0 0 0 4px rgba(238, 166, 69, 0.12);
}

.pos-shell {
  display: grid;
  min-height: 100vh;
  grid-template-rows: 64px minmax(0, 1fr) 34px;
  background: #eef0ed;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 16px;
  background: var(--charcoal);
  color: #fff;
}

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

.icon-button,
.topbar-button,
.status-button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.icon-button {
  width: 40px;
  font-size: 1.2rem;
}

.compact-brand {
  display: flex;
  align-items: center;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.employee-chip {
  display: grid;
  margin-left: 8px;
  line-height: 1.15;
}

.employee-chip strong {
  max-width: 220px;
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-chip span {
  color: #aeb6b2;
  font-size: 0.68rem;
}

.status-button,
.topbar-button {
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 750;
}

.status-button b,
.history-button b {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.68rem;
}

.workspace {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.75fr);
  overflow: hidden;
}

.catalog-pane,
.order-pane {
  min-width: 0;
  min-height: 0;
}

.catalog-pane {
  padding: clamp(18px, 2.5vw, 32px);
  overflow: auto;
  background: #fff;
}

.order-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border-left: 1px solid #d4d8d4;
  background: #f5f6f4;
}

.pane-heading,
.order-heading,
.products-header,
.orders-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pane-heading h1,
.order-heading h2,
.products-header h2,
.orders-dialog h2,
.payment-dialog h2 {
  margin: 4px 0 0;
  letter-spacing: -0.035em;
}

.pane-heading h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
}

.store-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--mint);
  color: #286759;
  font-size: 0.75rem;
  font-weight: 800;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  margin: 22px 0 16px;
  padding: 0 14px;
  border: 1px solid #d8deda;
  border-radius: 14px;
  background: #fafbf9;
  color: #919a96;
}

.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 9px;
}

.category-button {
  min-height: 54px;
  padding: 10px 12px;
  overflow: hidden;
  border: 0;
  border-radius: 13px;
  background: var(--category-color, #68706d);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 850;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button.is-active {
  outline: 3px solid color-mix(in srgb, var(--category-color, #68706d), white 60%);
  outline-offset: 2px;
}

.products-header {
  margin: 26px 0 12px;
}

.products-header h2 {
  font-size: 1.12rem;
}

.products-header span {
  color: var(--muted);
  font-size: 0.75rem;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.product-card {
  display: grid;
  min-height: 132px;
  padding: 14px;
  border: 1px solid #dde2de;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 5px 15px rgba(40, 50, 46, 0.05);
  text-align: left;
  transition: 120ms ease;
}

.product-card:hover {
  border-color: var(--product-color, var(--teal));
  transform: translateY(-2px);
  box-shadow: 0 9px 24px rgba(40, 50, 46, 0.1);
}

.product-card:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
  opacity: 0.5;
}

.product-card::before {
  width: 34px;
  height: 7px;
  border-radius: 999px;
  background: var(--product-color, var(--teal));
  content: "";
}

.product-card strong {
  align-self: end;
  margin-top: 12px;
  font-size: 0.86rem;
  line-height: 1.25;
}

.product-card small {
  color: var(--muted);
}

.product-card b {
  margin-top: 8px;
  color: var(--teal-dark);
  font-size: 1rem;
}

.empty-state,
.cart-empty {
  display: grid;
  min-height: 230px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-state span,
.cart-empty p {
  max-width: 300px;
  margin: 6px auto 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.order-heading {
  padding: 20px 18px 16px;
  border-bottom: 1px solid #dce0dc;
  background: #d8efea;
}

.order-heading h2 {
  font-size: 1.35rem;
}

.history-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(35, 125, 108, 0.24);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--teal-dark);
  font-size: 0.75rem;
  font-weight: 800;
}

.history-button b {
  background: rgba(35, 125, 108, 0.12);
}

.cart-list {
  padding: 12px;
  overflow: auto;
}

.cart-row {
  display: grid;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid #dfe3df;
  border-radius: 13px;
  background: #fff;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.cart-row-name {
  min-width: 0;
}

.cart-row-name strong,
.cart-row-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-row-name strong {
  font-size: 0.82rem;
}

.cart-row-name small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
}

.quantity-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quantity-control button {
  width: 28px;
  height: 28px;
  border: 1px solid #d6ddd8;
  border-radius: 8px;
  background: #f6f8f6;
  color: var(--ink);
  font-weight: 900;
}

.quantity-control span {
  min-width: 22px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.cart-row > strong {
  min-width: 72px;
  font-size: 0.78rem;
  text-align: right;
}

.cart-empty > span {
  color: #a1cfc2;
  font-size: 3rem;
}

.cart-empty strong {
  color: #6a726f;
}

.order-summary {
  padding: 14px 18px;
  border-top: 1px solid #dce0dc;
  background: #fff;
}

.order-summary > div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.76rem;
}

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

.order-summary .order-total {
  align-items: end;
  margin-top: 12px;
  color: var(--ink);
  font-size: 0.95rem;
}

.order-total strong {
  font-size: 1.5rem;
}

.stage-limit {
  margin: 10px 0 0;
  color: #977225;
  font-size: 0.67rem;
  text-align: right;
}

.order-actions {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--charcoal);
  grid-template-columns: 0.7fr 1.3fr 1fr;
}

.order-actions button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
}

.order-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.danger-button {
  background: var(--red);
}

.secondary-button {
  background: #5e6562;
}

.pay-button {
  background: #36bd42;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  overflow: hidden;
  border-top: 1px solid #d7dad7;
  background: #f8f9f7;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

dialog {
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(20, 30, 27, 0.28);
}

dialog::backdrop {
  background: rgba(26, 31, 30, 0.62);
  backdrop-filter: blur(5px);
}

.payment-dialog {
  width: min(480px, calc(100% - 24px));
  padding: 0;
}

.payment-dialog form {
  position: relative;
  padding: 32px;
}

.dialog-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #edf0ed;
  color: #626a67;
  font-size: 1.45rem;
}

.payment-dialog .dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.payment-amount {
  margin: 24px 0;
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -0.05em;
}

.payment-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.payment-options button {
  display: grid;
  min-height: 116px;
  place-content: center;
  gap: 8px;
  border: 1px solid #d8dfda;
  border-radius: 16px;
  background: #f7faf8;
  color: var(--ink);
}

.payment-options button:hover {
  border-color: var(--teal);
  background: #eaf7f2;
}

.payment-options span {
  color: var(--teal-dark);
  font-size: 1.7rem;
  font-weight: 900;
}

.payment-dialog p {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.orders-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: min(760px, calc(100vh - 36px));
  padding: 24px;
}

.local-orders-list {
  display: grid;
  gap: 9px;
  max-height: 560px;
  margin-top: 20px;
  overflow: auto;
}

.local-order-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dde2df;
  border-radius: 14px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.local-order-row strong,
.local-order-row small {
  display: block;
}

.local-order-row small {
  margin-top: 3px;
  color: var(--muted);
}

.sync-badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff0d8;
  color: #936521;
  font-size: 0.66rem;
  font-weight: 850;
}

.sync-badge.is-synced {
  background: #dff3e7;
  color: #2b7c4c;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 50px;
  z-index: 30;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--charcoal);
  color: #fff;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.8fr);
  }

  .category-grid,
  .product-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .topbar-button {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 800px) {
  .pos-shell {
    min-height: 100dvh;
    grid-template-rows: auto auto 34px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 9px 12px;
  }

  .topbar-actions {
    width: 100%;
  }

  .status-button,
  .topbar-button {
    flex: 1;
  }

  .workspace {
    display: block;
    overflow: auto;
  }

  .catalog-pane {
    overflow: visible;
  }

  .order-pane {
    min-height: 620px;
    border-top: 1px solid #d4d8d4;
    border-left: 0;
  }

  .statusbar span:last-child {
    display: none;
  }
}

@media (max-width: 560px) {
  .login-screen {
    padding: 20px 14px;
  }

  .ambient-left {
    width: 340px;
    height: 340px;
  }

  .login-card {
    border-radius: 22px;
  }

  .login-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .menu-button,
  .compact-brand {
    display: none;
  }

  .employee-chip {
    margin-left: 0;
  }

  .category-grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .catalog-pane {
    padding: 18px 12px;
  }

  .pane-heading {
    align-items: flex-start;
  }

  .store-badge {
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .order-actions .pay-button {
    grid-column: 1 / -1;
  }

  .statusbar {
    justify-content: center;
  }

  .statusbar #last-sync {
    display: none;
  }

  .payment-options {
    grid-template-columns: 1fr;
  }

  .local-order-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .local-order-row .sync-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
