:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  --bg: #f3f5f7;
  --border: #d6dbe1;
  --danger: #b42318;
  --ink: #20242a;
  --muted: #69727d;
  --panel: #ffffff;
  --primary: #c9152f;
  --primary-dark: #9f1025;
  --sidebar: #24282d;
  --teal: #087e8b;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f4;
}

.auth-shell {
  width: min(780px, 100%);
  min-height: 420px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(32, 36, 42, .12);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  color: #fff;
  background: #24282d;
  border-top: 5px solid var(--primary);
}
.auth-brand img { width: min(230px, 100%); filter: brightness(0) invert(1); }
.auth-brand h1 { max-width: 280px; margin: 28px 0 0; font-size: 25px; line-height: 1.25; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px; }
.auth-form h2 { margin: 0 0 28px; font-size: 24px; }
label { display: grid; gap: 7px; color: #454c54; font-weight: 600; }
.auth-form label + input, .auth-form input + label { margin-top: 16px; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aeb6bf;
  border-radius: 4px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(8, 126, 139, .25);
  outline-offset: 1px;
  border-color: var(--teal);
}

button.primary, button.secondary, .text-button {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 4px;
  font-weight: 650;
}
button.primary { color: #fff; background: var(--primary); border: 1px solid var(--primary); }
button.primary:hover { background: var(--primary-dark); }
button.secondary { color: var(--ink); background: #fff; border: 1px solid #aeb6bf; }
button.secondary:hover { background: #edf0f2; }
.auth-form button.primary { margin-top: 24px; }
.text-link { margin-top: 18px; color: #066974; text-align: center; }
.form-error { margin: 14px 0 0; color: var(--danger); font-weight: 600; }
.form-success { margin: 14px 0 0; color: #14713b; font-weight: 600; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 5;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  color: #fff;
  background: #20242a;
  border-bottom: 3px solid var(--primary);
}
.topbar img { width: 94px; filter: brightness(0) invert(1); }
.topbar strong { font-size: 16px; }
.topbar .account { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.topbar .account span { display: grid; text-align: right; }
.topbar .account small { color: #bcc3ca; }
.topbar .secondary { min-height: 34px; color: #fff; background: transparent; border-color: #737b84; }
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 22px;
}
.icon-button:hover { background: rgba(255,255,255,.1); }
#menu-toggle { display: none; }

.workspace { min-height: 100vh; padding-top: 64px; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); padding: 20px 12px; background: var(--sidebar); }
.sidebar nav { display: grid; gap: 5px; }
.nav-item {
  min-height: 42px;
  padding: 8px 12px;
  color: #d7dce1;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 3px;
  text-align: left;
}
.nav-item:hover { background: #343941; }
.nav-item.active { color: #fff; background: #3a4048; border-left-color: #f0445d; }
.content { min-width: 0; padding: 30px clamp(18px, 4vw, 52px) 60px; }
.view { display: none; }
.view.active { display: block; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-header h1 { margin: 0; font-size: 26px; }
.status-line { min-height: 20px; margin: 5px 0 0; color: var(--muted); }
.filters { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(190px, 280px); gap: 14px; margin-bottom: 16px; }
.filters label span, .form-grid label span { font-size: 13px; }

.product-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
  align-items: start;
}
.product-card {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.product-card-open {
  width: 100%;
  display: grid;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: left;
}
.product-card-open:hover { background: #f7f8f9; }
.product-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f1f3f5;
  border-bottom: 1px solid var(--border);
}
.product-card-media img { width: 100%; height: 100%; object-fit: cover; }
.product-card-placeholder { color: var(--muted); font-size: 13px; }
.product-card-copy {
  min-width: 0;
  min-height: 104px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 15px 16px;
}
.product-card-copy strong, .product-card-copy span { overflow-wrap: anywhere; }
.product-card-copy strong { font-size: 15px; line-height: 1.35; }
.product-card-copy span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.product-card-copy time { margin-top: 4px; color: var(--muted); font-size: 12px; }
.product-card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  background: #f7f8f9;
  border-top: 1px solid var(--border);
}
.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 42px 24px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.table-wrap { width: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid #e2e6ea; text-align: left; vertical-align: middle; }
th { color: #505861; background: #f7f8f9; font-size: 12px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7fafb; }
td img.product-thumb { width: 64px; height: 48px; object-fit: contain; background: #fff; }
td.actions { width: 1%; white-space: nowrap; text-align: right; }
.row-link { padding: 0; color: #066974; background: none; border: 0; font-weight: 650; text-align: left; }
.danger-button { min-height: 34px; padding: 6px 10px; color: var(--danger); background: #fff; border: 1px solid #d8a19c; border-radius: 4px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; }
.empty-row { padding: 32px; color: var(--muted); text-align: center; }

dialog { width: min(1000px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(24, 28, 32, .58); }
.compact { width: min(650px, calc(100vw - 32px)); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 20px; }
.dialog-header .icon-button { color: #343a40; }
.editor-dialog form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 22px; }
.form-grid .wide { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; align-self: end; min-height: 40px; }
.checkbox-row input { width: 18px; min-height: 18px; }
.dialog-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; background: #f7f8f9; border-top: 1px solid var(--border); }
.editor-dialog .form-error { padding: 0 22px; }
.detail-dialog #product-detail { padding: 22px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 24px; }
.detail-grid div { min-width: 0; }
.detail-grid dt { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; }
.detail-grid dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.media-band { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.media-band h3 { margin: 0 0 12px; font-size: 16px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.image-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #f7f8f9; border: 1px solid var(--border); border-radius: 4px; }
.image-item { position: relative; min-width: 0; }
.image-item .danger-button { position: absolute; right: 6px; bottom: 6px; background: rgba(255,255,255,.94); }
.download-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: 20px; max-width: min(380px, calc(100vw - 40px)); padding: 12px 16px; color: #fff; background: #20242a; border-left: 4px solid #2aa668; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.error { border-left-color: #f0445d; }

@media (max-width: 800px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 160px; padding: 28px; }
  .auth-brand h1 { margin-top: 16px; font-size: 20px; }
  .auth-form { padding: 30px 26px; }
  #menu-toggle { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .topbar strong { display: none; }
  .topbar .account span { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 4; left: 0; width: 232px; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 22px 14px 48px; }
  .filters, .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .section-header { align-items: start; }
  .product-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-card-copy { min-height: 112px; padding: 12px; }
  th, td { padding: 10px; }
}

@media (max-width: 430px) {
  .product-card-grid { grid-template-columns: 1fr; }
}
