:root {
  --bg: #07111f;
  --surface: rgba(15, 23, 42, 0.94);
  --surface-2: rgba(30, 41, 59, 0.92);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #22c55e;
  --secondary: #38bdf8;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 24px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.12), transparent 28%),
    linear-gradient(180deg, #020617 0%, #0b1220 100%);
}
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell {
  width: min(100%, 1380px);
  margin: 0 auto;
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.card, .stat-card, .product-card, .history-item, .modal-box { backdrop-filter: blur(14px); }
.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 18px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--secondary);
  font-weight: 700;
}
.hero h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; }
.intro { margin: 12px 0 0; color: var(--muted); line-height: 1.55; max-width: 70ch; }
.hero-actions { display: grid; gap: 12px; align-content: start; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  min-height: 48px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 700;
  transition: transform .16s ease, opacity .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #052e16; }
.btn-secondary { background: var(--secondary); color: #082f49; }
.btn-warning { background: var(--warning); color: #451a03; }
.btn-danger { background: var(--danger); }
.btn-ghost { background: transparent; border: 1px solid var(--line-strong); }
.btn-icon { width: 48px; padding: 0; display: inline-grid; place-items: center; font-size: 1.35rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card-highlight { background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(15, 23, 42, 0.96)); }
.stat-label { display: block; color: var(--muted); margin-bottom: 8px; font-size: .92rem; }
.stat-value { display: block; font-size: clamp(1.35rem, 2vw, 2rem); }
.layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.85fr); gap: 18px; align-items: start; }
.main-panel, .side-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.sidebar { display: grid; gap: 18px; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.toolbar-group { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.toolbar-group-grow { flex: 1 1 460px; }
.field-wrap { display: flex; flex-direction: column; gap: 8px; min-width: 170px; }
.field-grow { flex: 1 1 260px; }
label { color: var(--muted); font-size: .92rem; font-weight: 600; }
input, select, textarea {
  width: 100%;
  background: rgba(2, 6, 23, 0.78);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(56, 189, 248, 0.65); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12); }
textarea { min-height: 112px; resize: vertical; }
.summary-line { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 16px 0 18px; }
.badge { display: inline-flex; align-items: center; padding: 9px 12px; border-radius: 999px; font-weight: 700; background: rgba(56, 189, 248, 0.14); border: 1px solid rgba(56, 189, 248, 0.18); color: #d7f5ff; }
.sync-status { color: var(--muted); font-size: .92rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.product-card {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.94), rgba(10, 15, 28, 0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.product-gallery {
  display: grid;
  grid-template-columns: 1fr;
  background: #020617;
}
.product-gallery img { width: 100%; height: 220px; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; padding: 10px; overflow: auto; }
.gallery-thumbs img { width: 58px; height: 58px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.product-fallback { min-height: 220px; display: grid; place-items: center; color: var(--muted); padding: 18px; text-align: center; }
.product-body { padding: 16px; display: grid; gap: 14px; }
.product-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.product-title { margin: 0; font-size: 1.1rem; }
.product-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: .9rem; }
.description { margin: 0; color: var(--muted); line-height: 1.5; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini-card { background: rgba(2, 6, 23, 0.48); border: 1px solid rgba(148, 163, 184, 0.14); border-radius: 16px; padding: 12px; }
.mini-label { display: block; color: var(--muted); font-size: .82rem; margin-bottom: 6px; }
.mini-value { display: block; font-weight: 700; }
.product-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.product-actions .btn { padding-inline: 8px; }
.history-list { display: grid; gap: 10px; max-height: 420px; overflow: auto; }
.history-item { background: rgba(2, 6, 23, 0.46); border: 1px solid rgba(148, 163, 184, 0.14); border-radius: 16px; padding: 12px 14px; }
.history-item strong { display: block; margin-bottom: 4px; }
.history-item small { display: block; color: var(--muted); margin-top: 6px; }
.empty-state { border: 1px dashed rgba(148, 163, 184, 0.32); border-radius: 18px; padding: 26px 18px; text-align: center; color: var(--muted); }
.modal { width: min(760px, calc(100vw - 18px)); border: 0; padding: 0; background: transparent; }
.modal::backdrop { background: rgba(2, 6, 23, 0.74); backdrop-filter: blur(4px); }
.modal-box { width: 100%; background: rgba(11, 18, 32, 0.98); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head, .modal-body, .modal-foot { padding: 18px; }
.modal-head { display: flex; justify-content: space-between; gap: 14px; align-items: start; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-head p { margin: 6px 0 0; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-span-2 { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.preview-item { position: relative; border: 1px solid var(--line); background: rgba(2, 6, 23, 0.42); border-radius: 16px; overflow: hidden; }
.preview-item img { width: 100%; height: 100px; object-fit: cover; }
.preview-caption { padding: 8px; color: var(--muted); font-size: .8rem; word-break: break-word; }
.preview-remove { position: absolute; right: 8px; top: 8px; width: 28px; height: 28px; border-radius: 999px; background: rgba(239, 68, 68, 0.95); color: white; border: 0; cursor: pointer; }
.existing-images-box { display: grid; gap: 8px; }
@media (max-width: 1100px) {
  .hero, .layout { grid-template-columns: 1fr; }
  .hero-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { padding: 12px; }
  .hero, .main-panel, .side-card, .stat-card { padding: 16px; border-radius: 22px; }
  .hero-actions, .product-actions { display: grid; }
  .product-actions, .stats-grid, .form-grid, .meta-grid { grid-template-columns: 1fr; }
  .toolbar, .toolbar-group, .toolbar-group-grow { width: 100%; }
  .field-wrap, .field-grow { min-width: 100%; }
  .btn { width: 100%; }
  .product-head { flex-direction: column; }
  .history-list { max-height: none; }
  .modal { width: 100vw; max-width: 100vw; margin: 0; }
  .modal-box { min-height: 100dvh; border-radius: 0; }
  .modal-head, .modal-body, .modal-foot { padding: 16px 14px; }
  .modal-foot { position: sticky; bottom: 0; background: rgba(11, 18, 32, 0.98); }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card-highlight { grid-column: 1 / -1; }
  .hero h1 { font-size: 1.8rem; }
}
