/* Colors follow the user's Telegram theme (variables set by telegram-web-app.js). */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 12px 16px 96px;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg2);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 20px; margin: 4px 0 12px; }

.screen.center { text-align: center; padding-top: 48px; }
.big-icon { font-size: 56px; }

.status { color: var(--hint); padding: 24px 0; text-align: center; }
.status:empty { display: none; }

.list { display: flex; flex-direction: column; gap: 10px; }

.card {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius);
}
.card img {
  width: 84px;
  height: 84px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg2);
}
.card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card .name { font-weight: 600; }
.card .desc { color: var(--hint); font-size: 13px; }
.card .price { font-weight: 600; }
.card .meta { color: var(--hint); font-size: 13px; }
.card .bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper .qty { min-width: 26px; text-align: center; font-weight: 600; }

.add-button {
  border: none;
  border-radius: 17px;
  padding: 8px 16px;
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
  cursor: pointer;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 17px;
}
.hint { color: var(--hint); font-size: 13px; }

form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--hint); }
input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--btn); }
.invalid input, .invalid textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #323232;
  color: #fff;
  white-space: pre-line;
  z-index: 10;
}

#fallback-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px;
  background: var(--bg);
}
#fallback-button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--btn);
  color: var(--btn-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#fallback-button:disabled { opacity: 0.6; }

/* --- admin panel (admin.html) ----------------------------------------------------- */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.page-head h1 { margin-bottom: 8px; }

.link-button {
  border: none;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: 13px;
  padding: 4px 0;
  cursor: pointer;
}

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tab.active { background: var(--btn); color: var(--btn-text); font-weight: 600; }

.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--bg);
  white-space: nowrap;
}
.badge.needs { background: var(--btn); color: var(--btn-text); }

.order-row {
  width: 100%;
  border: none;
  border-left: 4px solid transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.order-row.needs { border-left-color: var(--btn); }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-top .name { flex: 1; }
.order-row .badge { background: var(--bg2); }

.section {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.section h2 { font-size: 15px; margin: 0; color: var(--hint); font-weight: 600; }
.section .total-row { margin-top: 4px; padding: 8px 0 0; border-top: 1px solid var(--bg2); border-radius: 0; }

.item-row { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--bg2); }
.item-row .amount { font-weight: 600; white-space: nowrap; }
.weight-field { margin-top: 6px; }
.weight-field input { background: var(--bg2); font-size: 17px; }
.hint.warn { color: var(--danger); }

.copy-row { display: flex; align-items: baseline; gap: 8px; }
.copy-row .meta { width: 88px; flex: none; }
.copy-row .value { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.comment { padding: 8px; background: var(--bg2); border-radius: 8px; white-space: pre-line; }

.proof { display: flex; flex-direction: column; gap: 6px; }
.proof-image { width: 100%; border-radius: 8px; }

.actions { background: none; padding: 0; }
.secondary-button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--link);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.secondary-button.danger { color: var(--danger); }

.history-row { display: flex; gap: 8px; font-size: 13px; }
.history-row span:nth-child(2) { flex: 1; }

/* --- admin: navigation, catalog, settings ------------------------------------------ */

.nav { display: flex; gap: 4px; margin: -4px 0 10px; padding: 4px; background: var(--bg); border-radius: var(--radius); }
.nav[hidden] { display: none; }
.nav-item {
  flex: 1;
  padding: 8px 4px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.nav-item.active { background: var(--btn); color: var(--btn-text); font-weight: 600; }

.product-admin.inactive img, .product-admin.inactive .no-photo { opacity: 0.4; }
.no-photo {
  width: 84px;
  height: 84px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bg2);
  font-size: 28px;
}
.name-button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.switch { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.switch input { width: 20px; height: 20px; accent-color: var(--btn); }

.form-field { color: var(--hint); }
.form-field input, .form-field textarea { background: var(--bg2); font-size: 16px; }
.form-field .tabs { margin: 0; }
.form-field .tab { background: var(--bg2); }
.form-field .tab.active { background: var(--btn); }
.hint { white-space: pre-line; }

.photo-section { align-items: stretch; }
#photo-preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; background: var(--bg2); }
#photo-preview[hidden] { display: none; }
.photo-section .secondary-button { background: var(--bg2); }

.inline-form { display: flex; align-items: flex-end; gap: 8px; }
.inline-form .form-field { flex: 1; }
.inline-form .add-button { padding: 11px 16px; }
