:root {
  --ink: #173120;
  --muted: #617267;
  --green: #0f5a2f;
  --green-2: #19703c;
  --leaf: #2a9f49;
  --lime: #79bf31;
  --sun: #ddbd08;
  --sun-soft: #fff8c9;
  --mist: #f5faf6;
  --panel: #ffffff;
  --line: #d9e7dd;
  --line-strong: #b8d0bf;
  --danger: #a63124;
  --danger-soft: #fff0ee;
  --ok: #176b3a;
  --ok-soft: #edf8f0;
  --shadow: 0 12px 32px rgba(15, 90, 47, 0.12);
  --radius: 8px;
  --header-height: 82px;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--mist);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.4;
}

body {
  margin: 0;
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.app-shell {
  margin: 0 auto;
  max-width: 880px;
  min-height: 100vh;
  padding: 16px 16px 112px;
}

.admin-shell {
  margin: 0 auto;
  max-width: 1240px;
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 14px;
  position: sticky;
  top: 10px;
  z-index: 20;
}

.app-shell .topbar {
  position: static;
}

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

.brand img {
  display: block;
  height: 54px;
  object-fit: contain;
  width: 86px;
}

.brand h1 {
  font-size: 1.12rem;
  line-height: 1.1;
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

.panel,
.admin-panel,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 16px;
  padding: 16px;
}

.panel-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header h2,
.admin-panel h2,
.section-title {
  font-size: 1.05rem;
  margin: 0;
}

.panel-header p,
.muted,
.small-muted {
  color: var(--muted);
}

.small-muted {
  font-size: 0.86rem;
}

.identity-summary {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.identity-main {
  min-width: 0;
}

.identity-main strong {
  display: block;
  font-size: 1.05rem;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.identity-form-grid {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.25fr) auto;
  margin-bottom: 14px;
}

.field label {
  color: var(--ink);
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.field input,
.field textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  display: block;
  min-height: 46px;
  padding: 10px 12px;
  width: 100%;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(42, 159, 73, 0.16);
  outline: none;
}

.place-tools {
  display: grid;
  gap: 12px;
}

.place-toolbar {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) auto;
}

.place-search input {
  min-height: 42px;
}

.selected-place {
  background: #f7fbf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 180px;
  padding: 8px 10px;
}

.selected-place span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.selected-place strong {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
  line-height: 1.15;
}

.selected-place.has-place {
  background: var(--ok-soft);
  border-color: #b7d9c1;
}

.selected-place.has-place strong {
  color: var(--green);
}

.place-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.place-section {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 10px;
}

.place-section h3 {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.place-buttons {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(auto-fill, minmax(118px, 132px));
  justify-content: start;
}

.place-button,
.chip,
.tab-button,
.secondary-button,
.primary-button,
.danger-button,
.ghost-button {
  align-items: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  font-weight: 750;
  justify-content: center;
  min-height: 40px;
  padding: 9px 11px;
  text-decoration: none;
}

.place-button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--green);
  flex-direction: column;
  gap: 2px;
  justify-content: flex-start;
  min-height: 52px;
  padding: 8px 10px;
  text-align: left;
}

.place-code {
  display: block;
  font-size: 0.96rem;
  font-weight: 850;
  line-height: 1.1;
  width: 100%;
}

.place-note {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  width: 100%;
}

.place-button.is-selected .place-note {
  color: rgba(255, 255, 255, 0.78);
}

.place-button.is-selected,
.chip.is-active,
.tab-button.is-active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.chip {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--green);
  font-size: 0.88rem;
  min-height: 34px;
  padding: 7px 10px;
}

.identity-continue {
  min-width: 130px;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.primary-button:hover {
  background: #0a4b28;
}

.secondary-button {
  background: var(--sun-soft);
  border-color: #ecd86a;
  color: #4f4300;
}

.ghost-button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--green);
}

.danger-button {
  background: var(--danger-soft);
  border-color: #e1b7b0;
  color: var(--danger);
}

.alert {
  background: var(--danger-soft);
  border: 1px solid #e1b7b0;
  border-radius: var(--radius);
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 14px;
  padding: 12px;
}

.success-note {
  background: var(--ok-soft);
  border: 1px solid #b7d9c1;
  border-radius: var(--radius);
  color: var(--ok);
  font-weight: 700;
  padding: 12px;
}

.category-tabs {
  background: #eaf4ed;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 16px;
  padding: 4px;
}

.tab-button {
  background: transparent;
  color: var(--green);
}

.menu-group {
  margin-bottom: 20px;
}

.menu-group h3 {
  font-size: 0.95rem;
  margin: 0 0 10px;
}

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

.product-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(15, 90, 47, 0.07);
  display: grid;
  grid-template-rows: auto auto;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

.product-card.has-quantity {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 90, 47, 0.12);
}

.product-media {
  aspect-ratio: 1 / 0.9;
  background: #dfe8e2;
  min-height: 132px;
  overflow: hidden;
  position: relative;
}

.product-media img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.product-media-placeholder {
  align-items: center;
  background:
    radial-gradient(circle at 70% 20%, rgba(221, 189, 8, 0.26), transparent 38%),
    linear-gradient(135deg, #dcebe1, #f8fbf9);
  display: flex;
  justify-content: center;
}

.product-media-placeholder > span {
  color: rgba(15, 90, 47, 0.2);
  font-size: 3rem;
  font-weight: 900;
}

.product-overlay {
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.44) 0%,
    rgba(0, 0, 0, 0.12) 46%,
    rgba(0, 0, 0, 0.62) 100%
  );
  color: #fff;
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: space-between;
  padding: 10px;
  position: absolute;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.product-card h4 {
  color: #fff;
  font-size: 0.98rem;
  line-height: 1.13;
  margin: 0;
}

.price {
  color: currentColor;
  font-weight: 800;
}

.qty-control {
  align-items: center;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
}

.qty-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 1.05rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  line-height: 1;
  width: 34px;
}

.qty-button.plus {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.qty-value {
  font-weight: 900;
  min-width: 22px;
  text-align: center;
}

.cart-bar {
  align-items: center;
  background: var(--green);
  border-radius: var(--radius);
  bottom: 12px;
  box-shadow: 0 16px 38px rgba(15, 90, 47, 0.25);
  color: #fff;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  left: 50%;
  max-width: 888px;
  padding: 12px;
  position: fixed;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  z-index: 30;
}

.cart-bar strong {
  display: block;
}

.cart-actions {
  display: flex;
  gap: 8px;
}

.cart-bar .cart-actions .secondary-button {
  background: #fff;
  border-color: #fff;
}

.cart-bar .cart-actions .ghost-button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
}

.modal-backdrop {
  align-items: center;
  background: rgba(13, 31, 19, 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: fixed;
  z-index: 60;
}

.modal-card {
  max-height: calc(100vh - 32px);
  max-width: 560px;
  overflow: auto;
  padding: 18px;
  width: 100%;
}

.modal-card h2 {
  margin: 0 0 8px;
}

.line-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 14px 0;
  overflow: hidden;
}

.line-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr auto;
  padding: 10px 12px;
}

.line-row:last-child {
  border-bottom: 0;
}

.total-row {
  align-items: center;
  display: flex;
  font-size: 1.1rem;
  font-weight: 900;
  justify-content: space-between;
  margin: 12px 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.loading-state {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 14px;
  justify-items: center;
  min-height: 60vh;
  text-align: center;
}

.loading-state img {
  max-width: 220px;
  width: 60vw;
}

.admin-body {
  background: #f3f8f5;
}

.admin-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 390px) 1fr;
}

.admin-panel {
  padding: 16px;
}

.admin-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  font-weight: 750;
  margin-bottom: 4px;
}

.metric strong {
  display: block;
  font-size: 1.25rem;
}

.place-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 4px;
}

.admin-place {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: left;
}

.admin-place.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(25, 112, 60, 0.12);
}

.admin-place.has-open {
  border-left: 5px solid var(--sun);
}

.admin-place strong {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 850;
  padding: 4px 8px;
}

.status-open {
  background: var(--sun-soft);
  color: #665600;
}

.status-paid {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-voided {
  background: var(--danger-soft);
  color: var(--danger);
}

.order-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
  overflow: hidden;
}

.order-head {
  align-items: flex-start;
  background: #f8fbf9;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.order-head h3 {
  font-size: 1rem;
  margin: 0;
}

.order-lines {
  display: grid;
}

.order-line {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr auto;
  padding: 9px 12px;
}

.admin-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-top: 14px;
}

.admin-add-order {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 14px;
  padding: 14px;
}

.admin-add-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-add-head h3 {
  font-size: 1rem;
  margin: 0 0 3px;
}

.admin-add-fields {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.admin-products {
  display: grid;
  gap: 12px;
}

.admin-product-category h4 {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.admin-product-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-product-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
  padding: 9px;
}

.admin-product-row strong,
.admin-product-row span {
  display: block;
}

.admin-product-row strong {
  color: var(--green);
  line-height: 1.15;
}

.admin-product-row span {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 2px;
}

.admin-stepper {
  align-items: center;
  display: grid;
  flex: 0 0 auto;
  gap: 6px;
  grid-template-columns: 34px 24px 34px;
}

.admin-stepper button {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--green);
  font-size: 1.1rem;
  font-weight: 900;
  min-height: 34px;
}

.admin-stepper button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.admin-stepper span {
  color: var(--ink);
  font-weight: 900;
  margin: 0;
  text-align: center;
}

.admin-cart-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding: 10px;
}

.admin-cart-preview div {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.login-card {
  margin: 14vh auto 0;
  max-width: 420px;
}

.hash-line {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .admin-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .place-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px 10px 108px;
  }

  .topbar {
    align-items: flex-start;
    position: static;
  }

  .brand img {
    height: 46px;
    width: 74px;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .panel,
  .admin-panel {
    padding: 13px;
  }

  .identity-form-grid,
  .admin-add-fields,
  .place-toolbar {
    grid-template-columns: 1fr;
  }

  .identity-continue {
    width: 100%;
  }

  .selected-place {
    min-width: 0;
  }

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

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

  .product-card h4 {
    font-size: 0.9rem;
  }

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

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

  .cart-bar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .admin-shell .topbar {
    flex-direction: column;
  }

  .admin-shell .topbar .cart-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .admin-shell .topbar .cart-actions button {
    width: 100%;
  }

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

@media (max-width: 360px) {
  .place-buttons {
    grid-template-columns: 1fr;
  }
}
