:root {
  --ink: #2a1718;
  --muted: #74696b;
  --wine: #8f2f45;
  --rose-soft: #f7d9dc;
  --cream: #fff8f2;
  --paper: #ffffff;
  --line: #eadfe0;
  --danger: #a72532;
  --shadow: 0 16px 44px rgba(79, 34, 42, 0.12);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--cream); font-family: "DM Sans", system-ui, sans-serif; letter-spacing: 0; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(143, 47, 69, 0.28); outline-offset: 2px; }
[hidden] { display: none !important; }

.admin-shell { min-height: 100dvh; }
.login-panel { width: min(calc(100% - 32px), 430px); margin: 0 auto; padding: 42px 0; }
.mini-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.mini-brand span { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; color: white; background: var(--wine); font-family: "Patrick Hand", cursive; font-size: 21px; }
.mini-brand strong { font-family: "Patrick Hand", cursive; font-size: 24px; font-weight: 400; }
.login-copy { margin: 76px 0 28px; }
.login-copy small, .panel-heading small, .admin-header small { color: var(--wine); font-size: 11px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin: 4px 0 12px; font-family: "Patrick Hand", cursive; font-size: 46px; font-weight: 400; line-height: 1; }
.login-copy p { color: var(--muted); }

form label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: white; }
input[readonly] { color: var(--wine); background: #f8f3f1; font-weight: 800; }
input { min-height: 48px; padding: 0 12px; }
textarea { min-height: 120px; padding: 12px; resize: vertical; }
.primary-button, .danger-button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; border: 0; border-radius: 7px; color: white; font-weight: 800; cursor: pointer; }
.primary-button { width: 100%; margin-top: 16px; background: var(--wine); }
.danger-button { padding: 0 18px; background: var(--danger); }
.form-message { min-height: 22px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.form-message.is-success { color: #2a7247; }

.dashboard { padding-bottom: 60px; }
.admin-header { position: sticky; z-index: 10; top: 0; display: flex; min-height: 74px; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(255, 248, 242, 0.96); backdrop-filter: blur(12px); }
.admin-header h1 { margin: 2px 0 0; font-size: 30px; }
.admin-actions { display: flex; align-items: center; gap: 8px; }
.admin-actions a, .admin-actions button, .panel-heading button { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--wine); background: white; font-size: 12px; font-weight: 800; text-decoration: none; cursor: pointer; }
.admin-layout { display: grid; width: min(calc(100% - 32px), 1180px); gap: 18px; margin: 20px auto 0; }
.editor-panel, .list-panel { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: 0 8px 24px rgba(79, 34, 42, 0.06); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 20px; }
.panel-heading > span { color: var(--muted); font-size: 12px; }
.image-field, .video-field { margin-bottom: 18px; }
.image-field input, .video-field > input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.image-preview { display: grid; min-height: 220px; place-items: center; align-content: center; gap: 7px; overflow: hidden; border: 1px dashed #cbb8bb; border-radius: 8px; color: var(--muted); background: #fcf6f3; cursor: pointer; text-align: center; }
.image-preview svg { width: 34px; height: 34px; color: var(--wine); }
.image-preview small { font-weight: 400; }
.image-preview img { display: block; width: 100%; height: 260px; object-fit: contain; background: white; }
.video-preview { display: grid; min-height: 116px; place-items: center; align-content: center; gap: 7px; overflow: hidden; border: 1px dashed #cbb8bb; border-radius: 8px; color: var(--muted); background: #fcf6f3; cursor: pointer; text-align: center; }
.video-preview svg { width: 30px; height: 30px; color: var(--wine); }
.video-preview small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-weight: 400; white-space: nowrap; }
.video-preview video { display: block; width: 100%; max-height: 260px; background: #171214; object-fit: contain; }
.media-remove { margin: -6px 0 18px; }
#productForm[aria-busy="true"] .image-field, #productForm[aria-busy="true"] .video-field, #productForm[aria-busy="true"] .form-grid { opacity: 0.62; pointer-events: none; }
#productForm[aria-busy="true"] .primary-button { cursor: progress; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.code-help { align-self: end; min-height: 48px; padding: 9px 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.toggle { display: flex; min-height: 46px; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; }
.toggle input { width: 18px; min-height: 18px; accent-color: var(--wine); }
.admin-list { display: grid; gap: 10px; }
.admin-item { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; }
.admin-item img { width: 76px; height: 76px; border-radius: 5px; object-fit: cover; background: #f7f1ed; }
.admin-item-copy { min-width: 0; }
.admin-item-copy strong, .admin-item-copy small { display: block; }
.admin-item-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-item-copy small { margin-top: 5px; color: var(--muted); }
.item-statuses { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.status-pill, .media-pill { display: inline-flex; min-height: 22px; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 4px; color: #2a7247; background: #e6f4eb; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.status-pill.off { color: var(--muted); background: #efeded; }
.media-pill { color: var(--wine); background: var(--rose-soft); }
.media-pill svg { width: 12px; height: 12px; }
.item-actions { display: flex; gap: 6px; }
.item-actions button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--wine); background: white; cursor: pointer; }
.item-actions button:disabled { cursor: wait; opacity: 0.55; }
.item-actions button:last-child { color: var(--danger); }
.item-actions svg { width: 17px; }
.empty-list { padding: 40px 20px; color: var(--muted); text-align: center; }

dialog { width: min(calc(100% - 32px), 380px); padding: 24px; border: 0; border-radius: 8px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(42, 23, 24, 0.52); backdrop-filter: blur(3px); }
dialog h2 { margin-bottom: 8px; }
dialog p { color: var(--muted); }
dialog > div { display: flex; justify-content: end; gap: 8px; }
dialog > div button:first-child { min-height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: white; font-weight: 800; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .admin-actions a { display: none; }
  .admin-item { grid-template-columns: 64px minmax(0, 1fr); }
  .admin-item img { width: 64px; height: 64px; }
  .item-actions { grid-column: 1 / -1; justify-content: end; }
}

@media (min-width: 900px) {
  .admin-header { padding-right: 28px; padding-left: 28px; }
  .admin-layout { grid-template-columns: minmax(360px, 0.85fr) minmax(460px, 1.15fr); align-items: start; }
  .editor-panel { position: sticky; top: 94px; max-height: calc(100dvh - 114px); overflow-y: auto; }
}
