:root {
  --bg: #f3f4f6;
  --card: #fff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #111827;
  --accent: #f59e0b;
  --wa: #25d366;
  --ok: #15803d;
  --danger: #9f1239;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}
[hidden] { display: none !important; }

.app-top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.app-top-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand strong { display: block; font-size: 0.95rem; line-height: 1.15; }
.brand small { color: var(--muted); font-size: 0.8rem; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.btn-burger {
  display: none;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.btn-burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.uber-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.45);
}
.uber-menu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 81;
  width: min(300px, 88vw);
  height: 100%;
  height: 100dvh;
  background: #fff;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.18);
  padding: 14px 12px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
.uber-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--border);
}
.uber-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.uber-menu-visits {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.uber-menu-visits span { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.uber-menu-visits strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--accent); }
body.uber-menu-open { overflow: hidden; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-ghost { background: transparent; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-danger { color: var(--danger); border-color: #fecdd3; background: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 14px; }
.hero-line {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 14px;
}
.hero-ico { font-size: 2rem; line-height: 1; }
.hero-line h1 { margin: 0 0 6px; font-size: 1.35rem; }
.hero-line p { margin: 0 0 12px; color: var(--muted); font-size: 0.95rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.filters {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filters-row input,
.filters-row select,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.filters-row input,
.filters-row select { flex: 1 1 160px; max-width: 280px; }
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.meta-line { color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 8px;
}
.pager-info {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 7rem;
  text-align: center;
}
.card {
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #111827 center/cover no-repeat;
  position: relative;
  border: 0;
  padding: 0;
  cursor: zoom-in;
}
.card-cover.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  background: linear-gradient(135deg, #1f2937, #111827);
  cursor: default;
}
.card-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.card-body h2 { margin: 0; font-size: 1.05rem; }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #f3f4f6;
  color: #374151;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.off { background: #fee2e2; color: #991b1b; }
.badge.ver { background: #e0e7ff; color: #3730a3; }
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.card-actions .btn { flex: 1; }

.admin-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.admin-head h1 { margin: 0; font-size: 1.25rem; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.tab.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }

.product-form, .dialog-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.product-form { margin-top: 14px; }
.dialog-card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.dialog-wide { max-width: min(640px, calc(100vw - 24px)); }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }
.field-title { display: block; margin-bottom: 6px; font-size: 0.9rem; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; }
.fg-full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.gal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.gal-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
}
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.gal-cover {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--accent);
  color: #111;
  padding: 2px 6px;
  border-radius: 6px;
}
.feat-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.feat-n {
  width: 28px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}
.feat-row input { flex: 1; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; font: inherit; }
.char-title { margin: 12px 0 8px; font-size: 1rem; }
.char-list {
  margin: 0 0 12px;
  padding-left: 1.25rem;
  color: var(--text);
}
.char-list li { margin: 0 0 6px; font-size: 0.92rem; }
.detail-gal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.detail-gal-item {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111 center/cover no-repeat;
  cursor: default;
  padding: 0;
}

.order-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.order-card h3 { margin: 0 0 6px; font-size: 1rem; }
.order-card p { margin: 0 0 4px; font-size: 0.88rem; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(640px, calc(100vw - 24px));
  width: 100%;
  max-height: min(92vh, 900px);
  overflow: auto;
}
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }

.detail-name { margin: 0 0 4px; font-size: 1.2rem; }
.detail-lines { margin: 0 0 12px; color: var(--muted); font-size: 0.92rem; }
.detail-lines p { margin: 0 0 4px; }

.lightbox {
  max-width: min(920px, calc(100vw - 16px));
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 0;
  background: #0b1220;
  color: #fff;
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(2, 6, 23, 0.82); }
.lightbox img {
  display: block;
  width: 100%;
  max-height: min(78vh, 860px);
  object-fit: contain;
  background: #000;
}
.lb-close, .lb-nav {
  position: absolute;
  z-index: 2;
  border: none;
  background: rgba(255,255,255,0.14);
  color: #fff;
  cursor: pointer;
  border-radius: 12px;
  font-size: 1.4rem;
  line-height: 1;
}
.lb-close { top: 10px; right: 10px; width: 40px; height: 40px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 44px; height: 44px; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-count {
  margin: 0;
  padding: 8px 12px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: #cbd5e1;
}
.lightbox { position: relative; }

@media (max-width: 899px) {
  .top-actions-desktop { display: none !important; }
  .btn-burger { display: inline-flex; }
  .brand small { font-size: 0.72rem; }
  .brand strong { font-size: 0.88rem; }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .card-body { padding: 8px; gap: 4px; }
  .card-body h2 { font-size: 0.88rem; line-height: 1.2; }
  .card-meta { font-size: 0.72rem; gap: 4px; }
  .card-actions { gap: 4px; margin-top: 4px; }
  .card-actions .btn { padding: 7px 6px; font-size: 0.75rem; }
  .badge { font-size: 0.65rem; padding: 1px 6px; }
}
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .filters-row input,
  .filters-row select { max-width: none; flex: 1 1 100%; }
}
