:root {
  --red: #b5262b;
  --red-dark: #8d1f24;
  --red-soft: #fae9ea;
  --ink: #1c1c1d;
  --muted: #6c6e73;
  --paper: #ffffff;
  --canvas: #f6f5f3;
  --line: #e4e1dd;
  --card: #ffffff;
  --shadow: 0 12px 32px rgba(40, 28, 24, 0.09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

:root[data-theme="dark"] {
  --ink: #f5f2ee;
  --muted: #b8b5b0;
  --paper: #20201f;
  --canvas: #161615;
  --line: #3a3937;
  --card: #232322;
  --red-soft: #462326;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

button { cursor: pointer; }

.skip-link {
  position: fixed;
  z-index: 30;
  left: 16px;
  top: -80px;
  padding: 10px 14px;
  color: #fff;
  background: var(--red);
  border-radius: 10px;
}

.skip-link:focus { top: 12px; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 93%, transparent);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  width: min(1240px, calc(100% - 40px));
  min-height: 72px;
  margin: auto;
}

.brand {
  flex: 0 0 auto;
  color: var(--red);
  font-size: 1.34rem;
  font-weight: 850;
  letter-spacing: -0.055em;
  text-decoration: none;
}

.brand span { color: var(--ink); font-weight: 480; }

.breadcrumb {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumb a { overflow: hidden; text-decoration: none; text-overflow: ellipsis; }
.breadcrumb a:hover { color: var(--red); }
.crumb-separator { opacity: 0.55; }

.header-actions { display: flex; align-items: center; gap: 9px; }

.pill-link, .icon-button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--card);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.pill-link { padding: 0 13px; }
.icon-button { width: 38px; padding: 0; font-size: 1.05rem; }
.button { padding: 0 15px; }
.button:hover, .pill-link:hover, .icon-button:hover { transform: translateY(-1px); border-color: #c9c2bc; }
.button:focus-visible, .pill-link:focus-visible, .icon-button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--red) 35%, transparent); outline-offset: 2px; }
.button.primary { border-color: var(--red); color: #fff; background: var(--red); }
.button.primary:hover { background: var(--red-dark); }
.button.danger { color: #a82026; border-color: #e7b8ba; background: #fff7f7; }
:root[data-theme="dark"] .button.danger { background: #432528; border-color: #7f4649; color: #ffd6d6; }
.button.ghost { background: transparent; }
.button.small { min-height: 32px; padding: 0 10px; font-size: .78rem; border-radius: 8px; }
.button[disabled] { cursor: not-allowed; opacity: .55; transform: none; }

#app { width: min(1240px, calc(100% - 40px)); min-height: calc(100vh - 166px); margin: 0 auto; padding: 44px 0 58px; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: min(1240px, calc(100% - 40px));
  margin: auto;
  padding: 26px 0 36px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .82rem;
}

.hero { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 28px; align-items: stretch; margin: 4px 0 38px; }

.hero-copy, .hero-mark {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 58px);
  border-radius: 26px;
}

.hero-copy { min-height: 288px; color: #fff; background: linear-gradient(120deg, #a91f25, #d35356); }
.hero-copy::after { position: absolute; right: -70px; bottom: -130px; width: 330px; height: 330px; content: ""; border: 36px solid rgba(255,255,255,.15); border-radius: 50%; }
.hero-copy > * { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 10px; color: var(--red); font-size: .74rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.hero .eyebrow { color: #ffdfe0; }
h1, h2, h3, p { margin-top: 0; }
.hero h1 { max-width: 650px; margin-bottom: 14px; font-size: clamp(2rem, 4.6vw, 4rem); line-height: 1; letter-spacing: -.07em; }
.hero p:last-child { max-width: 600px; margin: 0; color: rgba(255,255,255,.84); font-size: 1.05rem; }
.hero-mark { display: flex; flex-direction: column; justify-content: flex-end; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.hero-mark::before { position: absolute; top: -54px; right: -35px; width: 184px; height: 184px; content: ""; border: 24px solid var(--red-soft); border-radius: 50%; }
.hero-mark strong { position: relative; z-index: 1; display: block; color: var(--red); font-size: 3.5rem; line-height: .9; letter-spacing: -.09em; }
.hero-mark span { position: relative; z-index: 1; margin-top: 12px; color: var(--muted); font-size: .92rem; }

.section-heading, .toolbar, .admin-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading h1, .toolbar h1, .admin-header h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.08; letter-spacing: -.05em; }
.section-heading p, .toolbar p, .admin-header p { max-width: 720px; margin: 7px 0 0; color: var(--muted); }
.section-label { margin: 0 0 14px; color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.grid.products { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); }

.catalog-card { position: relative; display: block; overflow: hidden; color: inherit; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 0 rgba(0,0,0,.02); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.catalog-card:hover { z-index: 1; transform: translateY(-4px); border-color: #d7bebf; box-shadow: var(--shadow); }
.card-visual { position: relative; display: grid; min-height: 154px; overflow: hidden; place-items: center; color: var(--red); background: linear-gradient(135deg, #f1e5e3, #e5d6d2); }
:root[data-theme="dark"] .card-visual { background: linear-gradient(135deg, #463634, #322b29); }
.card-visual.large { min-height: 430px; border-radius: var(--radius); }
.card-visual img { position: absolute; width: 100%; height: 100%; object-fit: cover; inset: 0; }
.card-visual .placeholder { font-size: 3rem; font-weight: 850; letter-spacing: -.1em; }
.card-visual.has-image .placeholder { display: none; }
.card-body { padding: 17px 17px 18px; }
.card-body h3 { margin: 4px 0 8px; font-size: 1.05rem; line-height: 1.2; letter-spacing: -.025em; }
.card-body .description { min-height: 42px; margin: 0; color: var(--muted); font-size: .88rem; }
.meta, .product-code { margin: 12px 0 0; color: var(--muted); font-size: .78rem; }
.product-code { color: var(--red); font-weight: 760; letter-spacing: .04em; }

.search { width: min(380px, 100%); min-height: 42px; padding: 0 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--card); }

.empty-state { padding: 48px 24px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; background: var(--paper); }
.empty-state h2 { margin-bottom: 8px; color: var(--ink); font-size: 1.25rem; }
.empty-state p { margin-bottom: 18px; }

.product-layout { display: grid; grid-template-columns: minmax(300px, .94fr) minmax(0, 1.06fr); gap: clamp(28px, 5vw, 66px); align-items: start; }
.gallery-main { overflow: hidden; min-height: 420px; border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.gallery-main img { display: block; width: 100%; height: 100%; min-height: 420px; object-fit: contain; background: #ece8e3; }
:root[data-theme="dark"] .gallery-main img { background: #292725; }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.gallery-thumb { width: 74px; height: 74px; overflow: hidden; padding: 0; border: 2px solid transparent; border-radius: 12px; background: var(--paper); }
.gallery-thumb.active, .gallery-thumb:hover { border-color: var(--red); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-detail h1 { margin: 0 0 26px; font-size: clamp(2rem, 3.5vw, 3.2rem); line-height: 1; letter-spacing: -.065em; }
.product-detail .product-code { margin-bottom: 8px; }
.block-title { margin: 31px 0 12px; font-size: 1rem; letter-spacing: -.02em; }
.specs { margin: 0; border-top: 1px solid var(--line); }
.spec-row { display: grid; grid-template-columns: minmax(115px, .36fr) 1fr; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.spec-row dt { color: var(--muted); font-size: .86rem; }
.spec-row dd { margin: 0; font-weight: 600; font-size: .9rem; }
.price-table { width: 100%; overflow: hidden; border: 1px solid var(--line); border-collapse: separate; border-spacing: 0; border-radius: 12px; background: var(--card); }
.price-table th, .price-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: .88rem; }
.price-table tr:last-child td { border-bottom: 0; }
.price-table th { color: var(--muted); font-size: .73rem; letter-spacing: .06em; text-transform: uppercase; }
.price-detail { display: block; font-size: .74rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 28px; }
.archived-notice { margin-bottom: 25px; padding: 13px 15px; color: #7d4300; border: 1px solid #e6c594; border-radius: 11px; background: #fff5df; }
:root[data-theme="dark"] .archived-notice { color: #ffe2aa; border-color: #725428; background: #3b2e1b; }

.admin-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-nav { position: sticky; top: 92px; padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.admin-nav a { display: block; padding: 10px 11px; color: var(--muted); border-radius: 9px; font-size: .88rem; font-weight: 650; text-decoration: none; }
.admin-nav a:hover, .admin-nav a.active { color: var(--red); background: var(--red-soft); }
.admin-content { min-width: 0; }
.admin-header { align-items: center; }
.admin-header .actions { margin: 0; }

.panel { padding: clamp(18px, 3vw, 28px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.panel + .panel { margin-top: 20px; }
.panel h2 { margin: 0 0 5px; font-size: 1.16rem; letter-spacing: -.03em; }
.panel > p { color: var(--muted); }
.table-wrap { overflow-x: auto; margin: -2px; padding: 2px; }
.admin-table { width: 100%; min-width: 650px; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 13px 11px; text-align: left; border-bottom: 1px solid var(--line); font-size: .88rem; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.admin-table tr:last-child td { border-bottom: 0; }
.row-name { font-weight: 720; }
.row-code { color: var(--red); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.badge { display: inline-flex; padding: 4px 7px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; font-size: .72rem; }

.form-panel { max-width: 760px; }
.field { margin-top: 18px; }
.field:first-child { margin-top: 0; }
.field label { display: block; margin-bottom: 6px; font-size: .87rem; font-weight: 720; }
.field input, .field textarea, .field select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--paper); }
.field textarea { min-height: 102px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--red); }
.field input[type="file"] { padding: 8px; cursor: pointer; }
.help { margin: 6px 0 0; color: var(--muted); font-size: .78rem; }
.check-row { display: flex !important; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: .82rem !important; font-weight: 600 !important; }
.check-row input { width: auto !important; min-height: auto !important; }
.media-preview, .media-preview-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.media-preview { align-items: center; min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--muted); font-size: .77rem; }
.media-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 7px; background: var(--canvas); }
.media-preview-grid .media-preview { display: grid; gap: 5px; justify-items: start; }
.media-preview-grid .media-preview img { width: 84px; height: 84px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 25px; }
.dynamic-list { display: grid; gap: 8px; }
.dynamic-row { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(160px, 1fr) auto; gap: 8px; align-items: center; }
.dynamic-row.price-row { grid-template-columns: .65fr .65fr .8fr .7fr .55fr auto; }
.dynamic-row input { min-width: 0; }
.remove-row { width: 35px; min-height: 38px; border: 1px solid #e2b7b8; border-radius: 9px; color: #a82026; background: transparent; }

.login-wrap { display: grid; min-height: 61vh; place-items: center; }
.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 7px; font-size: 1.82rem; letter-spacing: -.05em; }
.login-card p { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.stat { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.stat strong { display: block; font-size: 1.55rem; letter-spacing: -.05em; }
.stat span { color: var(--muted); font-size: .75rem; }
.import-feedback { margin-top: 18px; }
.issue-list { max-height: 190px; margin: 12px 0; padding: 0; overflow: auto; list-style: none; border: 1px solid var(--line); border-radius: 10px; }
.issue-list li { padding: 9px 11px; border-bottom: 1px solid var(--line); font-size: .84rem; }
.issue-list li:last-child { border-bottom: 0; }
.issue-list.error-list li { color: #aa2027; }
.import-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.import-table th, .import-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: .84rem; }
.bulk-upload-card { max-width: 860px; }
.bulk-upload-card code { padding: 2px 5px; border-radius: 5px; background: var(--paper); color: var(--red); font-size: .84em; }
.bulk-report { max-width: 860px; }

.toast { position: fixed; z-index: 60; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 13px 16px; color: #fff; border-radius: 11px; background: #262424; box-shadow: 0 12px 30px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9c2228; }

.modal-backdrop { position: fixed; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(15, 14, 13, .62); inset: 0; }
.modal { width: min(100%, 480px); max-height: calc(100vh - 40px); overflow: auto; padding: 25px; color: var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 20px 70px rgba(0,0,0,.35); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.modal h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.03em; }
.modal p { color: var(--muted); font-size: .86rem; }
.modal-close { width: 34px; min-height: 34px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: transparent; font-size: 1.35rem; line-height: 1; }
.qr-image { display: block; width: min(100%, 320px); aspect-ratio: 1; margin: 20px auto; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.modal-url { display: block; overflow-wrap: anywhere; padding: 10px; color: var(--muted); border-radius: 8px; background: var(--canvas); font-size: .76rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.lightbox .modal { width: min(100%, 900px); padding: 12px; }
.lightbox img { display: block; width: 100%; max-height: calc(100vh - 100px); object-fit: contain; border-radius: 10px; background: #fff; }

.loading { display: grid; min-height: 300px; place-items: center; color: var(--muted); }
.loading::before { width: 22px; height: 22px; margin-right: 8px; content: ""; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

@media (max-width: 900px) {
  .hero, .product-layout, .admin-shell { grid-template-columns: 1fr; }
  .hero-mark { min-height: 160px; }
  .admin-nav { position: static; display: flex; gap: 4px; overflow-x: auto; padding: 8px; }
  .admin-nav a { white-space: nowrap; }
  .product-layout { gap: 28px; }
  .gallery-main, .gallery-main img { min-height: 340px; }
}

@media (max-width: 640px) {
  .header-inner, #app, .site-footer { width: min(100% - 28px, 1240px); }
  .header-inner { gap: 10px; min-height: 64px; }
  .breadcrumb { display: none; }
  .brand { margin-right: auto; }
  .pill-link { padding: 0 10px; font-size: .78rem; }
  #app { padding-top: 27px; }
  .site-footer { flex-direction: column; }
  .hero-copy, .hero-mark { padding: 28px; border-radius: 19px; }
  .hero-copy { min-height: 242px; }
  .section-heading, .toolbar, .admin-header { align-items: flex-start; flex-direction: column; }
  .search { width: 100%; }
  .grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .grid.products { grid-template-columns: 1fr 1fr; }
  .card-visual { min-height: 122px; }
  .card-body { padding: 12px; }
  .card-body .description { display: none; }
  .card-body h3 { font-size: .9rem; }
  .meta { margin-top: 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dynamic-row, .dynamic-row.price-row { grid-template-columns: 1fr 1fr; }
  .dynamic-row .remove-row { grid-column: 2; justify-self: end; }
  .gallery-main, .gallery-main img { min-height: 280px; }
}
