/* ==========================================================================
   the control room: plain and functional, in the shop's colours
   ========================================================================== */

.admin-shell { min-height: 100vh; }
.admin-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--gutter); border-bottom: 1px solid var(--line); background: var(--unbleached); }
.admin { max-width: 1100px; margin: 0 auto; padding: var(--s6) var(--gutter) var(--s8); font-size: 0.95rem; }
.admin--login { max-width: 380px; padding-top: var(--s8); }
.admin-login { background: var(--unbleached); padding: var(--s6); border-radius: 24px; }
.admin-login h1 { font-size: var(--t-lg); }

.admin__bar { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; margin-bottom: var(--s5); }
.admin__bar h1 { font-size: var(--t-lg); margin: 0; }
.admin__tabs { display: flex; gap: 2px; background: var(--sand); padding: 3px; border-radius: 999px; margin-inline-end: auto; }
.admin__tabs button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-size: var(--t-sm); }
.admin__tabs button[aria-current] { background: var(--unbleached); font-weight: 600; box-shadow: 0 1px 2px #4a3b2e22; }
.studio-switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); background: var(--unbleached); border-radius: 18px; padding: var(--s3) var(--s4); margin-bottom: var(--s5); box-shadow: inset 4px 0 0 var(--kraft); }
.studio-switch.is-on { box-shadow: inset 4px 0 0 var(--sage-deep); }
.studio-switch b { display: block; }
.studio-switch small { color: var(--bark-soft); }
.switch { display: inline-flex; align-items: center; gap: var(--s2); border: 0; background: none; cursor: pointer; padding: 6px; font: inherit; font-weight: 600; color: var(--kraft-deep); flex: none; }
.switch__track { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--sand); box-shadow: inset 0 0 0 1px var(--line); transition: background .2s var(--ease); }
.switch__knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #4a3b2e44; transition: transform .2s var(--ease); }
.switch[aria-checked="true"] { color: var(--sage-deep); }
.switch[aria-checked="true"] .switch__track { background: var(--sage-deep); }
.switch[aria-checked="true"] .switch__knob { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 2px; border-radius: 999px; }
.switch__label { min-width: 3.6em; text-align: start; }
@media (prefers-reduced-motion: reduce) { .switch__track, .switch__knob { transition: none; } }
.admin__tools { display: flex; gap: var(--s3); margin-bottom: var(--s5); flex-wrap: wrap; }
.admin .chips { margin-bottom: var(--s5); }
.chip small { opacity: .65; margin-inline-start: 4px; }

.table { width: 100%; border-collapse: collapse; background: var(--unbleached); border-radius: 18px; overflow: hidden; }
.table th { text-align: start; font-size: 0.8rem; color: var(--bark-soft); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 14px; border-bottom: 1px solid #b08a6222; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: end; white-space: nowrap; }
.table .actions { text-align: end; white-space: nowrap; }
.table .thumb { width: 64px; }
.table .thumb .pebble { width: 48px; border-radius: 40%; }
.table input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.table tr.is-hidden td { opacity: .55; }
.stock-pill { display: inline-block; min-width: 34px; padding: 2px 10px; border-radius: 999px; background: var(--sage-mist); color: #3f4c35; font-weight: 600; text-align: center; }
.stock-pill--low { background: #EAD8C0; color: var(--kraft-deep); }
.stock-pill--out { background: #F0D5CC; color: var(--danger); }
.pre-left { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--bark-soft); white-space: nowrap; }
.pre-left--gone { color: var(--danger); font-weight: 600; }
.ed-note { margin: 6px 0 0; font-size: var(--t-sm); color: var(--bark-soft); }

.cat-new input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--unbleached); flex: 1; min-width: 160px; }

.orders { display: grid; gap: var(--s4); }
.order { background: var(--unbleached); border-radius: 20px; padding: var(--s5); }
.order--cancelled { opacity: .6; }
.order__head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.order__head h3 { margin: 0; font-size: var(--t-md); }
.order__when { margin-inline-start: auto; font-size: 0.8rem; color: var(--bark-soft); }
.order__who { display: grid; grid-template-columns: max-content 1fr; gap: 4px var(--s4); margin: 0 0 var(--s4); font-size: var(--t-sm); }
.order__who dt { color: var(--bark-soft); }
.order__who dd { margin: 0; }
.order__items { list-style: none; padding: var(--s3) 0; margin: 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.order__items li { display: flex; justify-content: space-between; gap: var(--s4); padding: 4px 0; }
.order__items small { color: var(--bark-soft); }
.order__foot { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; margin-top: var(--s4); }
.order__total b { font-size: var(--t-md); }
.order__status { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); }
.order__status select { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }

/* ---- the editor --------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 40; background: #4a3b2e66; display: grid; place-items: start center; overflow-y: auto; padding: var(--s6) var(--s3); }
.modal__box { width: min(860px, 100%); background: var(--linen); border-radius: 24px; padding: var(--s5) var(--s6) var(--s6); }
.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s4); }
.modal__head h2 { margin: 0; font-size: var(--t-lg); }
.modal__foot { position: sticky; bottom: calc(-1 * var(--s6)); display: flex; justify-content: space-between; align-items: center; margin: var(--s5) calc(-1 * var(--s6)) calc(-1 * var(--s6)); padding: var(--s4) var(--s6); background: var(--linen); border-top: 1px solid var(--line); border-radius: 0 0 24px 24px; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s5); }
.ed-grid .field { margin-bottom: var(--s4); }

/* The product editor: one card per job, read top to bottom. */
.ed-sec { background: var(--unbleached); border-radius: 18px; padding: var(--s4) var(--s5) var(--s3); margin-bottom: var(--s3); }
.ed-sec .ed-h { margin: 0 0 var(--s1); }
.ed-hint { font-size: var(--t-sm); color: var(--bark-soft); margin: 0 0 var(--s3); max-width: 60ch; }
.ed-h + .ed-fields, .ed-h + .field, .ed-h + .ed-imgs { margin-top: var(--s3); }
.ed-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s4); }
.ed-sec .field { margin-bottom: var(--s4); }
.field--wide { grid-column: 1 / -1; }
.field > span small { font-weight: 400; margin-inline-start: 4px; }
.ed-sec .field input, .ed-sec .field textarea, .ed-sec .field select { background: #fff; }
.editor:has([data-bind="customizable"]:not(:checked)) .ed-when-custom { display: none; }
.ed-sec--ar { background: var(--sage-mist); }
.ed-sec--ar .field > span { font-weight: 500; color: var(--bark-soft); }
.ed-sec--ar .field textarea, .ed-sec--ar .field input { font-family: "Noto Naskh Arabic", var(--font-body); }
.ed-ar-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 var(--s4); }

.ed-h { font-family: var(--font-body); font-weight: 600; font-size: 1rem; margin: var(--s5) 0 var(--s3); }
.ed-h small { font-weight: 400; }
.ed-imgs { display: flex; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.ed-img { position: relative; width: 96px; aspect-ratio: 4/5; border-radius: 14px; overflow: hidden; background: var(--sand); }
.ed-img img { width: 100%; height: 100%; object-fit: cover; }
.ed-img button { position: absolute; top: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #fffd; cursor: pointer; line-height: 1; }
.ed-img button[data-action="ed-img-left"] { left: 4px; }
.ed-img button[data-action="ed-img-remove"] { right: 4px; }
.ed-img__cover { position: absolute; left: 4px; bottom: 4px; font-size: 0.7rem; background: var(--bark); color: var(--linen); padding: 2px 8px; border-radius: 99px; }
.ed-upload { position: relative; width: 96px; aspect-ratio: 4/5; border: 1.5px dashed var(--kraft); border-radius: 14px; display: grid; place-items: center; text-align: center; font-size: var(--t-sm); cursor: pointer; color: var(--kraft-deep); padding: 6px; }
.ed-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ed-upload:focus-within { outline: 2px solid var(--sage-deep); }

.ed-group { border: 1px solid var(--line); background: var(--linen); border-radius: 14px; padding: var(--s3) var(--s4); margin-bottom: var(--s3); }
.ed-group__head { display: flex; align-items: flex-end; gap: var(--s4); }
.ed-group__head .field { flex: 1; max-width: 280px; margin-bottom: var(--s3); }
.ed-group__head .text-link { margin: 0 0 var(--s4) auto; }
.ed-vals__head, .ed-vals__row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 70px 40px 28px; gap: var(--s2); align-items: center; }
.ed-vals__head { font-size: 0.8rem; color: var(--bark-soft); padding-bottom: 4px; }
.ed-vals__row { margin-bottom: var(--s2); }
.ed-vals__row input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; }
.ed-vals__row input[type="color"] { width: 40px; height: 36px; padding: 2px; }
.ed-x { width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--bark-soft); cursor: pointer; font-size: 1.1rem; }
.ed-x:hover { background: var(--sand); color: var(--bark); }

.ed-row { display: flex; gap: var(--s2); align-items: center; margin-bottom: var(--s2); flex-wrap: wrap; }
.ed-row input, .ed-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; flex: 1; min-width: 120px; }
.ed-small { max-width: 110px; flex: none !important; min-width: 70px !important; }
.set-items { list-style: none; padding: 0; margin: 0 0 var(--s3); }
.set-items li { display: flex; align-items: center; gap: var(--s3); padding: 6px 0; border-bottom: 1px solid #b08a6222; }
.set-items li span { flex: 1; }
.set-items input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }

.admin-head .wordmark img { height: 80px; }
.table td[data-label]::before { display: none; }

/* ---- phones: tables become stacked cards --------------------------------- */

@media (max-width: 640px) {
  .admin-head { padding-block: var(--s2); }
  .admin-head .wordmark img { height: 60px; }
  .admin { padding-top: var(--s5); }

  .admin__bar { gap: var(--s3); }
  .admin__out { margin-inline-start: auto; }
  .admin__tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .admin__tabs button { flex: 1 0 auto; padding: 8px 12px; }
  .admin__tools .btn { flex: 1; }
  .admin .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .admin .chips .chip { flex: none; }

  .table, .table tbody, .table tr, .table td { display: block; }
  .table { background: none; border-radius: 0; overflow: visible; }
  .table thead { display: none; }
  .table tr { background: var(--unbleached); border-radius: 18px; padding: var(--s3) var(--s4); margin-bottom: var(--s3); }
  .table td { padding: 0; border: 0; text-align: start; }
  .table .num, .table .actions { text-align: start; }
  .table td[data-label]::before { display: inline; content: attr(data-label) " "; color: var(--bark-soft); font-size: 0.8rem; margin-inline-end: 6px; }
  .table td.empty { padding: var(--s4) 0; }

  .table--products tr { display: grid; grid-template-columns: 56px 1fr auto; grid-template-areas: "pic name name" "pic price stock" "pic edit edit"; gap: 4px var(--s3); align-items: center; }
  .table--products .thumb { display: block; grid-area: pic; width: auto; align-self: start; }
  .table--products .thumb .pebble { width: 56px; }
  .table--products td:nth-child(2) { grid-area: name; }
  .table--products .price-cell { grid-area: price; }
  .table--products .stock-cell { grid-area: stock; text-align: end; }
  .table--products .actions { grid-area: edit; margin-top: var(--s2); }
  .table--products .actions .btn, .table--sets .actions .btn { width: 100%; }

  .table--sets td + td { margin-top: var(--s2); }

  .table--cats tr { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); align-items: center; }
  .table--cats td:nth-child(-n+2) { grid-column: 1 / -1; }
  .cat-new input { flex-basis: 100%; }
  .table--cats .count-cell { align-self: center; }
  .table--cats .actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s3); }

  .order { padding: var(--s4); }
  .order__who { grid-template-columns: 1fr; gap: 0; }
  .order__who dt { margin-top: var(--s2); font-size: 0.8rem; }
  .order__items li { flex-wrap: wrap; }
  .order__status { margin-inline-start: 0; width: 100%; }
  .order__status select { flex: 1; }

  .ed-grid { grid-template-columns: 1fr; }
  .modal { padding: var(--s3) var(--s2); }
  .modal__box { padding: var(--s4); border-radius: 20px; }
  .ed-fields { grid-template-columns: 1fr; }
  .ed-sec { padding: var(--s3) var(--s3) var(--s2); }
  .modal__foot { bottom: calc(-1 * var(--s4)); margin: var(--s4) calc(-1 * var(--s4)) calc(-1 * var(--s4)); padding: var(--s3) var(--s4); border-radius: 0 0 20px 20px; }
  .ed-vals__head, .ed-vals__row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px 28px; gap: 6px; }
  .ed-vals__head span:first-child { display: none; }
  .ed-vals__row { padding-bottom: var(--s2); border-bottom: 1px dashed var(--line); margin-bottom: var(--s3); }
  .ed-vals__row input:first-child { grid-column: 1 / -1; }
  .ed-group { padding: var(--s3); }
  .set-items li { flex-wrap: wrap; }
}

/* ---- emails ---- */
.emails__tools { align-items: center; justify-content: space-between; }
.emails__tools p { margin: 0; }
.emails__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.table--emails .email-cell a { color: var(--bark); text-decoration: none; word-break: break-all; }
.table--emails .email-cell a:hover { text-decoration: underline; }
.table--emails .date-cell { color: var(--bark-soft); white-space: nowrap; }
.table--emails .actions { text-align: end; }
@media (max-width: 640px) {
  .table--emails tr { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s3); align-items: center; }
  .table--emails .email-cell { grid-column: 1 / -1; font-weight: 600; }
  .table--emails .actions { grid-row: 2; grid-column: 2; }
  .emails__actions { width: 100%; }
}
.ed-ar-sub { font-size: var(--t-sm); font-weight: 600; margin: 0 0 var(--s2); }

/* ---- password ---- */
.pw { max-width: 440px; background: var(--unbleached); border-radius: 20px; padding: var(--s5) var(--s5) var(--s5); }
.pw h2 { font-size: var(--t-lg); margin: 0 0 var(--s2); }
.pw > p.muted { font-size: var(--t-sm); margin: 0 0 var(--s4); }
.pw .field input[type="password"], .pw .field input[type="text"] { background: #fff; }
.pw__done { color: var(--sage-deep); font-weight: 600; }
