/* Betty Davey shop admin. Large, high-contrast, touch-friendly: it's used
   by Betty and her helper, often on a phone or tablet. */
:root {
  --brand: #6e1d67;
  --brand-dark: #55044e;
  --accent: #df36e6;
  --bg: #fbf7f8;
  --card: #fff;
  --ink: #222;
  --muted: #666;
  --border: #e6dde3;
  --danger: #b3261e;
  --ok: #1e7b34;
  --warn: #b35c00;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--brand); }
h1 { font-size: 1.7rem; margin: 0.4em 0 0.6em; }
h2 { font-size: 1.25rem; margin: 0 0 0.6em; }
h3 { font-size: 1.05rem; }

/* ---- header ---- */
header#nav { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.nav-top { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; }
.link-btn { background: none; border: 0; color: #fff; font: inherit; font-size: 0.95rem; text-decoration: underline; cursor: pointer; margin-left: auto; padding: 4px; }
.link-btn.dark { color: var(--brand); margin: 0; }
.nav-links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.nav-links a { color: #fff; text-decoration: none; padding: 10px 14px; border-radius: var(--radius) var(--radius) 0 0; font-weight: 600; opacity: 0.85; }
.nav-links a.active { background: var(--bg); color: var(--brand); opacity: 1; }
.badge { display: inline-block; min-width: 1.5em; padding: 0 0.4em; border-radius: 1em; background: var(--accent); color: #fff; font-size: 0.8em; text-align: center; }
.badge[hidden] { display: none; }
.publish-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; margin: 0 -16px; padding: 8px 16px; background: #f1e7ef; color: var(--ink); font-size: 0.95rem; }
.publish-bar.has-changes { background: #fff3cd; }
.publish-actions { display: flex; gap: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); margin-right: 4px; }

main#app { max-width: 760px; margin: 0 auto; padding: 16px; }
.centered { min-height: 80vh; display: flex; align-items: center; justify-content: center; }

/* ---- cards / forms ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card--action { border: 2px solid var(--brand); }
.login { width: 100%; max-width: 420px; }
.login h1 { text-align: center; }
.login small { font-size: 0.6em; color: var(--muted); font-weight: 400; }
label, .field__label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; margin-top: 4px; padding: 12px; font: inherit; border: 1px solid #c9bfc6; border-radius: var(--radius); background: #fff;
}
input:focus, select:focus, textarea:focus, .richtext-editor:focus { outline: 3px solid rgba(110, 29, 103, 0.35); outline-offset: 1px; }
.field { margin-bottom: 20px; }
.field-hint, .hint { color: var(--muted); font-size: 0.9rem; margin: 2px 0 6px; font-weight: 400; }
.req { color: var(--danger); }
label.checkbox { display: flex; gap: 10px; align-items: center; font-weight: 600; }
label.checkbox input { width: 24px; height: 24px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 18px; }
legend { font-weight: 700; padding: 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.richtext-toolbar { display: flex; gap: 6px; margin-bottom: 6px; }
.richtext-btn { min-width: 44px; min-height: 40px; border: 1px solid #c9bfc6; background: #fff; border-radius: 6px; font-size: 1rem; cursor: pointer; }
.richtext-editor { min-height: 120px; padding: 12px; border: 1px solid #c9bfc6; border-radius: var(--radius); background: #fff; }
.richtext-editor ul { margin: 0; padding-left: 1.4em; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px; border: 0; border-radius: var(--radius); font: 600 1rem/1.2 inherit; font-family: inherit; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn.big { min-height: 56px; font-size: 1.15rem; padding: 14px 26px; }
.btn.full-width { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn { min-width: 40px; min-height: 40px; border: 1px solid #c9bfc6; background: #fff; border-radius: 6px; font-size: 1.1rem; cursor: pointer; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:disabled { opacity: 0.35; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

/* ---- lists ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.tabs--wrap { flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; text-decoration: none; white-space: nowrap; }
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
ul.item-list, ul.order-list { list-style: none; margin: 0 0 20px; padding: 0; }
.item-row, .order-row { display: flex; gap: 14px; align-items: center; padding: 14px; margin-bottom: 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.item-row:hover, .order-row:hover { border-color: var(--brand); }
.item-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: #eee; flex: none; }
.item-thumb.placeholder { display: inline-block; }
.item-title { display: block; font-weight: 700; }
.item-meta { display: block; color: var(--muted); font-size: 0.9rem; }
.order-row { flex-direction: column; align-items: stretch; gap: 4px; }
.order-row__who { font-weight: 700; font-size: 1.1rem; }
.order-row__meta { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); padding: 20px; text-align: center; background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #fff3cd; color: #6b4c00; font-size: 0.8rem; font-weight: 600; vertical-align: middle; }
.warn { color: var(--danger); }

/* ---- order detail ---- */
.status { font-size: 0.7em; padding: 3px 10px; border-radius: 999px; background: #eee; vertical-align: middle; }
.status--paid { background: #fff3cd; }
.status--shipped { background: #d7f0dc; }
.status--needs_review, .status--cancelled, .status--refunded { background: #f9dedc; }
.address { font: 1.35rem/1.45 Georgia, serif; margin: 0 0 12px; white-space: pre-wrap; }
.lines { list-style: none; padding: 0; margin: 0 0 10px; }
.lines li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.lines .right { margin-left: auto; }
.history { list-style: none; padding: 0; font-size: 0.95rem; }
.history li { padding: 4px 0; }
.note-row { display: flex; gap: 8px; }
.note-row input { margin: 0; }
.danger-zone { margin: 24px 0; padding: 12px 16px; border: 1px solid #f0c7c3; border-radius: var(--radius); background: #fff; }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--danger); }

/* ---- photos ---- */
.image-field { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.image-field img { width: 140px; height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.image-field__actions { display: flex; flex-direction: column; gap: 6px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 10px; }
.photo-tile { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.photo-tile input { font-size: 0.85rem; padding: 6px; }
.photo-tile__actions { display: flex; justify-content: space-between; margin-top: 6px; }
dialog.picker { width: min(720px, 94vw); max-height: 88vh; border: 0; border-radius: 12px; padding: 18px; }
dialog.picker::backdrop { background: rgba(0, 0, 0, 0.5); }
.picker__head { display: flex; justify-content: space-between; align-items: center; }
.upload-btn { display: inline-flex; width: 100%; }
.picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.picker__item { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.picker__item:hover, .picker__item:focus { border-color: var(--brand); }
.picker__item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; }

/* ---- list fields ---- */
.list-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: #fdfbfc; }
.list-row__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.list-row__head span { display: flex; gap: 4px; }

/* ---- product options table ---- */
.opt-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.opt-table th { text-align: left; font-size: 0.85rem; color: var(--muted); padding: 4px; }
.opt-table td { padding: 4px; vertical-align: middle; }
.opt-table input { margin: 0; padding: 8px; }
.opt-table td:nth-child(2) input, .opt-table td:nth-child(3) input { width: 90px; }
.stock-edit { display: flex; gap: 4px; align-items: center; }
@media (max-width: 600px) {
  .opt-table thead { display: none; }
  .opt-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .opt-table td:first-child { grid-column: 1 / -1; }
  .opt-table td:nth-child(2) input, .opt-table td:nth-child(3) input { width: 100%; }
}

/* ---- settings ---- */
.theme-list { list-style: none; padding: 0; }
.theme-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }

/* ---- misc ---- */
.loading { color: var(--muted); }
.error { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: 92vw; padding: 14px 20px; border-radius: var(--radius); background: #222; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.3); z-index: 100; font-weight: 600; }
.toast--error { background: var(--danger); }
