/* Admin panel: mobile-first. */
* { box-sizing: border-box; }

:root {
  --bg: #f5f5f4;
  --card: #fff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --primary: #b45309;
  --primary-text: #fff;
  --danger: #b91c1c;
  --ok: #15803d;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); }

.center { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.narrow { max-width: 420px; margin: 0 auto; padding: 2rem 1rem; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; gap: 0.5rem; }
.row > * { flex: 1; }

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.875rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  padding: 0.6rem 0.7rem;
  border: 1px solid #d6d3d1;
  border-radius: 0.5rem;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #d6d3d1;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-block { width: 100%; }
.btn-link { font: inherit; background: none; border: 0; color: var(--primary); padding: 0.5rem; cursor: pointer; }
.icon-btn {
  font: inherit;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.3; }

.divider { text-align: center; color: var(--muted); font-size: 0.875rem; margin: 1.25rem 0; border-top: 1px solid var(--line); }
.divider span { position: relative; top: -0.7em; background: var(--bg); padding: 0 0.5rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: #1c1917;
  color: #fafaf9;
}
.topbar h1 { flex: 1; font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar select { flex: 1; width: auto; }
.topbar .btn-link { color: #fbbf24; }

.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 3.1rem; z-index: 1; }
.tab { flex: 1; font: inherit; font-weight: 600; padding: 0.75rem; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { padding: 1rem; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; padding: 1rem; }

/* Category card */
.category { padding: 0; overflow: hidden; }
.category-head { display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem 0.75rem; background: #fafaf9; border-bottom: 1px solid var(--line); }
.category-head h2 { flex: 1; cursor: pointer; }

.product { display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); }
.product:last-of-type { border-bottom: 0; }
.product-name { flex: 1; min-width: 0; cursor: pointer; overflow-wrap: anywhere; }
.product.soldout .product-name { color: var(--muted); text-decoration: line-through; }
.price-input { width: 5.5rem; flex: none; text-align: right; font-variant-numeric: tabular-nums; padding: 0.45rem 0.5rem; }
/* Two-size price: two narrow fields side by side */
.prices { display: flex; gap: 0.25rem; flex: none; }
.prices .price-input { width: 4.25rem; }
/* Two-price row on phones: name full width on the top line, prices and buttons below. */
@media (max-width: 30rem) {
  .product.two-prices { flex-wrap: wrap; row-gap: 0.35rem; }
  .product.two-prices .product-name { flex: 1 1 60%; overflow-wrap: normal; }
  .product.two-prices .prices { margin-left: auto; }
}
.price-input.saved { border-color: var(--ok); outline: 2px solid var(--ok); }
.price-input.failed { border-color: var(--danger); outline: 2px solid var(--danger); }
.add-product { display: block; width: 100%; text-align: left; padding: 0.75rem; border-top: 1px solid var(--line); }

/* Stock toggle */
.switch { position: relative; flex: none; width: 2.75rem; height: 1.6rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #d6d3d1; border-radius: 1rem; transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 0.2rem; left: 0.2rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(1.15rem); }

/* Screen card */
.screen-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.screen-head h2 { flex: 1; cursor: pointer; }
.orientation { margin: 0.25rem 0 0.75rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.25rem 0.75rem; margin: 0.5rem 0; }
.checks label { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--text); font-size: 1rem; padding: 0.3rem 0; }
.checks input { width: 1.2rem; height: 1.2rem; }
.checks.single { grid-template-columns: 1fr; }

/* Photos */
.thumb { width: 2.25rem; height: 2.25rem; flex: none; object-fit: contain; border-radius: 0.4rem; background: #e6f6f6; cursor: pointer; }
.badge { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 1rem; padding: 0.05rem 0.5rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field-label { font-size: 0.875rem; color: var(--muted); }
.image-field { display: flex; align-items: center; gap: 0.75rem; }
.image-preview { width: 5rem; height: 5rem; flex: none; object-fit: contain; border-radius: 0.5rem; background: #e6f6f6; border: 1px solid var(--line); }
.image-field-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.image-field-actions .btn-link { padding: 0.25rem 0; }

/* Settings */
.settings { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem 1rem; align-items: center; }
.settings .btn { grid-column: 1 / -1; }
.settings-info p { margin: 0.25rem 0 0; }
.logo-preview { width: 5rem; height: 5rem; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fafaf9; border: 1px solid var(--line); }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 50%; vertical-align: -0.2rem; }

dialog { border: 0; border-radius: 0.75rem; padding: 1.25rem; width: min(420px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  background: #1c1917;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  max-width: calc(100vw - 2rem);
}
.toast.error { background: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 1rem; }
