:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --text: #17211f;
  --muted: #66736f;
  --line: #dce4e1;
  --line-strong: #c6d2ce;
  --teal: #087f73;
  --teal-dark: #04685e;
  --teal-soft: #e6f4f1;
  --amber: #b86e00;
  --amber-soft: #fff4df;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 16px 40px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 14px;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.08;
  font-weight: 760;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 720;
}

.topbar p,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 42px auto;
  gap: 8px;
}

.topbar-actions .button,
.admin-actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "order"
    "summary"
    "table";
  gap: 12px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 33, 31, 0.06);
}

.order-panel {
  grid-area: order;
  padding: 16px;
}

.table-panel {
  grid-area: table;
  overflow: hidden;
}

.table-panel > .panel-heading {
  align-items: center;
  margin-bottom: 0;
  padding: 18px 24px;
}

.table-panel .button-secondary {
  flex: 0 0 auto;
}

.table-wrap {
  border-top: 1px solid var(--line);
}

.summary-stack {
  grid-area: summary;
  display: grid;
  gap: 12px;
}

.summary-stack .panel,
.admin-panel {
  padding: 16px;
}

.admin-panel {
  grid-area: admin;
}

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

.form-grid,
.inline-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #34413e;
  font-size: 13px;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.full-width {
  grid-column: 1 / -1;
}

.is-hidden {
  display: none !important;
}

.button,
.icon-button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 720;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
  will-change: transform;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:active,
.icon-button:active {
  transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
.stepper button:focus-visible,
.menu-row button:focus-visible,
.order-actions button:focus-visible {
  outline: 3px solid rgba(8, 127, 115, 0.22);
  outline-offset: 2px;
}

.button-primary {
  background: var(--teal);
  color: #fff;
  font-size: 16px;
}

.button-primary:hover {
  background: var(--teal-dark);
  box-shadow: 0 10px 22px rgba(8, 127, 115, 0.22);
}

.button-secondary,
.icon-button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
  padding: 0 14px;
}

.button-secondary:hover,
.icon-button:hover {
  background: var(--teal-soft);
  border-color: rgba(8, 127, 115, 0.38);
  color: var(--teal-dark);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
}

.stepper button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 20px;
  font-weight: 780;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.stepper button:hover {
  transform: translateY(-1px);
  background: #d6eee9;
  border-color: rgba(8, 127, 115, 0.4);
  box-shadow: 0 8px 18px rgba(8, 127, 115, 0.14);
}

.stepper button:active {
  transform: translateY(0);
}

  .table-wrap {
    overflow: visible;
    max-height: none;
  }

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

thead {
  display: none;
}

  tbody {
    display: grid;
    gap: 10px;
    padding: 16px;
  }

tr {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

th,
td {
  padding: 0;
  border-bottom: 0;
  text-align: left;
  font-size: 14px;
  white-space: normal;
}

th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

td {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfa;
  color: #4d5a56;
  font-size: 12px;
  font-weight: 760;
}

td.note-cell {
  min-width: 0;
  white-space: normal;
  color: var(--muted);
}

.number {
  text-align: left;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  padding: 36px 14px;
  display: block;
}

.empty-row::before {
  content: "";
}

.total-panel {
  display: grid;
  gap: 12px;
}

.total-panel strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  color: var(--teal-dark);
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-row span,
.summary-item,
.menu-row,
.order-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.metric-row span {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.metric-row b {
  color: var(--text);
}

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

.summary-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px 12px;
  align-items: center;
}

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

.summary-item strong {
  color: var(--text);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.inline-form {
  grid-template-columns: 1fr;
  align-items: end;
}

#menuForm {
  grid-template-columns: 1fr;
}

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

.menu-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.menu-row small {
  color: var(--muted);
}

.menu-row button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  color: var(--text);
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.menu-row button.danger {
  color: var(--danger);
}

.menu-row button:hover {
  transform: translateY(-1px);
  background: var(--teal-soft);
  border-color: rgba(8, 127, 115, 0.38);
  color: var(--teal-dark);
}

.menu-row button.danger:hover {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.3);
  color: var(--danger);
}

.menu-row button:active {
  transform: translateY(0);
}

.order-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.order-actions::before {
  display: none;
}

.order-actions button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 720;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.order-actions button.danger {
  color: var(--danger);
}

.order-actions button:hover {
  transform: translateY(-1px);
  background: var(--teal-soft);
  border-color: rgba(8, 127, 115, 0.38);
  color: var(--teal-dark);
}

.order-actions button.danger:hover {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.3);
  color: var(--danger);
}

.order-actions button:active {
  transform: translateY(0);
}

@media (hover: none) {
  .button:hover,
  .icon-button:hover,
  .stepper button:hover,
  .menu-row button:hover,
  .order-actions button:hover {
    transform: none;
    box-shadow: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border-radius: 8px;
  background: #17211f;
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  cursor: pointer;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::after {
  content: "＋";
  color: var(--teal-dark);
  font-size: 20px;
  font-weight: 760;
}

details[open] summary::after {
  content: "−";
}

details summary span {
  display: grid;
  gap: 2px;
}

details summary strong {
  font-size: 17px;
}

details summary small {
  color: var(--muted);
  font-size: 13px;
}

.admin-content {
  margin-top: 16px;
}

@media (min-width: 761px) {
  .app-shell {
    padding: 24px;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
  }

  h1 {
    font-size: clamp(34px, 4vw, 42px);
  }

  .topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .workspace {
    grid-template-columns: 360px minmax(0, 1fr) 320px;
    grid-template-areas:
      "order table summary";
    gap: 16px;
  }

  .admin-workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .panel {
    box-shadow: var(--shadow);
  }

  .order-panel,
  .summary-stack .panel,
  .admin-panel {
    padding: 18px;
  }

  .table-panel > .panel-heading {
    padding: 20px 26px;
  }

  input,
  select,
  textarea,
  .button,
  .icon-button {
    min-height: 42px;
  }

  .button-primary {
    font-size: 14px;
  }

  .stepper {
    grid-template-columns: 42px 1fr 42px;
  }

  .stepper button {
    min-height: 42px;
  }

  .table-wrap {
    overflow: auto;
    max-height: 560px;
  }

  table {
    min-width: 760px;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
    padding: 0;
  }

  tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
  }

  th,
  td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }

  th:first-child,
  td:first-child {
    padding-left: 26px;
  }

  th:last-child,
  td:last-child {
    padding-right: 26px;
  }

  .actions-heading {
    text-align: left;
  }

  td {
    display: table-cell;
  }

  td::before {
    content: none;
  }

  td.note-cell {
    min-width: 160px;
  }

  .number {
    text-align: right;
  }

  .order-actions {
    display: flex;
  }

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

  .inline-form {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 0.5fr) auto;
  }

  #menuForm {
    grid-template-columns: minmax(150px, 0.8fr) minmax(0, 1fr) 110px auto;
  }

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

@media (min-width: 761px) and (max-width: 1120px) {
  .workspace {
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-areas:
      "order summary"
      "table table";
  }

  .total-panel strong {
    font-size: 30px;
  }
}

@media (min-width: 761px) and (max-width: 1120px) {
  .admin-grid,
  .menu-manager {
    grid-template-columns: 1fr;
  }
}
