:root {
  --bg: var(--tg-theme-bg-color, #f7f8fa);
  --text: var(--tg-theme-text-color, #17212b);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --button: var(--tg-theme-button-color, #3390ec);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --line: rgba(23, 33, 43, 0.12);
  --ok: #148a45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

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

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

p {
  margin: 4px 0 0;
  color: var(--hint);
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.tab.active {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  margin-bottom: 12px;
}

input[type="search"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

th {
  color: var(--hint);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.product-name {
  font-weight: 650;
}

.muted {
  color: var(--hint);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(51, 144, 236, 0.12);
  color: var(--button);
  white-space: nowrap;
}

.order-button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  white-space: nowrap;
}

.cancel-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.quantity-stepper {
  display: grid;
  grid-template-columns: 36px 42px 36px;
  align-items: center;
  width: 114px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.quantity-button {
  width: 36px;
  height: 36px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.quantity-button:first-child {
  border-right: 1px solid var(--line);
}

.quantity-button:last-child {
  border-left: 1px solid var(--line);
}

.quantity-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 36px;
  font-weight: 650;
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 8px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  margin: auto;
  max-width: 420px;
  border-radius: 8px;
  background: rgba(23, 33, 43, 0.92);
  color: #fff;
  padding: 12px 14px;
  text-align: center;
}

.hidden {
  display: none !important;
}

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

  h1 {
    font-size: 20px;
  }

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