/* Owner's menu & settings editor. Same paper palette as the site, denser layout. */
:root {
  --paper: #FBF8F1; --paper-2: #F1EBDC; --white: #FFFFFF;
  --ink: #1E1A16; --ink-2: #5E554A; --rule: #CBBFAA;
  --green: #2F6B3A; --green-dark: #235229; --green-tint: #E6EFE3;
  --red: #B6321F; --red-tint: #F7E6E2; --gold: #E0A81E; --focus: #1F5FBF;
  --display: "Alfa Slab One", Georgia, serif;
  --body: "Barlow", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h2 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0; }
h3.sub { font-size: 17px; margin: 22px 0 4px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
code { background: var(--paper-2); padding: 1px 5px; border-radius: 4px; font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: var(--radius); border: 1.5px solid var(--rule); background: var(--white); font-weight: 700; font-size: 15px; text-decoration: none; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-primary[disabled] { background: #B9C8BA; border-color: #B9C8BA; cursor: not-allowed; }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { min-width: 36px; padding: 0 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

.field { display: grid; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: 15px; }
.field small { font-weight: 400; color: var(--ink-2); }
input[type=text], input[type=number], input[type=url], input[type=search], input[type=password], input[type=time], input[type=date], textarea, select, .select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--white); font-size: 16px; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); outline: 3px solid rgba(47, 107, 58, .25); outline-offset: 0; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 8px 0 12px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--green); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.form-error { color: var(--red); font-weight: 600; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--white); border: 1.5px solid var(--rule); border-radius: 16px; padding: 28px 24px; text-align: center; }
.login-mark { width: 90px; height: 56px; fill: var(--ink); margin: 0 auto 8px; --paper: #fff; }
.login h1 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 0; }
.login .field { text-align: left; margin-top: 16px; }

/* bar */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 16px; background: var(--paper); border-bottom: 3px dotted var(--rule); }
.bar-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--display); font-size: 20px; }
.bar-mark { width: 40px; height: 25px; fill: var(--ink); }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; font-weight: 700; color: var(--ink-2); }
.tab.active { background: var(--green); color: #fff; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.dirty { font-weight: 700; color: var(--red); font-size: 14px; }
.flash { padding: 10px 16px; font-weight: 600; background: var(--green-tint); color: var(--green-dark); }
.flash.error { background: var(--red-tint); color: var(--red); }

/* panels */
.panel { padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }
.panel-menu, .panel-sets { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .panel-menu, .panel-sets { grid-template-columns: 1fr; } }
.cats { background: var(--white); border: 1.5px solid var(--rule); border-radius: 12px; padding: 12px; position: sticky; top: 64px; }
@media (max-width: 860px) { .cats { position: static; } }
.cats-head, .items-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cat-list { display: grid; gap: 4px; max-height: 50vh; overflow: auto; }
.cat-btn { display: flex; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; font-weight: 600; }
.cat-btn.active { background: var(--green); color: #fff; }
.cat-btn .count { color: var(--ink-2); font-weight: 400; }
.cat-btn.active .count { color: rgba(255, 255, 255, .8); }
.cat-edit { border-top: 1px dotted var(--rule); margin-top: 12px; padding-top: 12px; }
.filter { max-width: 320px; }

.item-list { display: grid; gap: 6px; }
.item-row { display: grid; grid-template-columns: 56px 1fr auto auto; gap: 12px; align-items: center; padding: 8px 10px; background: var(--white); border: 1.5px solid var(--rule); border-radius: 10px; }
.item-row.hidden-item { opacity: .6; }
.item-row .thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--paper-2); display: grid; place-items: center; color: var(--rule); font-size: 22px; }
.item-row .name { font-weight: 700; }
.item-row .meta { color: var(--ink-2); font-size: 14px; }
.item-row .price { font-weight: 700; font-variant-numeric: tabular-nums; }
.item-row .cat-tag { color: var(--ink-2); font-size: 13px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--paper-2); font-size: 12px; font-weight: 700; margin-left: 6px; vertical-align: 1px; }
.item-row .acts { display: flex; gap: 4px; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(30, 26, 22, .5); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 50; background: var(--paper); display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0, 0, 0, .2); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--rule); }
.drawer-head .close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; padding: 16px 20px; }
.drawer-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: var(--paper); }

.photo-block { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.photo-preview { width: 140px; height: 140px; border-radius: 12px; background: var(--paper-2); display: grid; place-items: center; overflow: hidden; flex: 0 0 auto; border: 1.5px dashed var(--rule); text-align: center; font-size: 14px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: grid; gap: 8px; justify-items: start; }

/* option groups */
.group { border: 1.5px solid var(--rule); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--white); }
.group-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.group-head input[type=text] { flex: 1; min-width: 160px; }
.group-head select { width: auto; }
.group-head .switch { margin: 0; font-size: 14px; }
.group.shared { background: var(--green-tint); border-color: #B9CFB9; }
.group.shared .shared-label { font-weight: 700; }
.choices { display: grid; gap: 6px; }
.choice-row { display: grid; grid-template-columns: 1fr 110px auto auto; gap: 6px; align-items: center; }
.choice-row .price { text-align: right; }
.choice-row .def { font-size: 13px; color: var(--ink-2); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.used-by { font-size: 13px; color: var(--ink-2); margin-top: 6px; }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-card { background: var(--white); border: 1.5px solid var(--rule); border-radius: 10px; overflow: hidden; }
.photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo-card .pc-body { padding: 8px; font-size: 13px; color: var(--ink-2); display: grid; gap: 6px; }

/* config */
.config { display: grid; gap: 14px; }
.card { background: var(--white); border: 1.5px solid var(--rule); border-radius: 12px; padding: 16px; display: grid; gap: 10px; }
.hours { display: grid; gap: 6px; }
.hour-row { display: grid; grid-template-columns: 110px auto 1fr 1fr; gap: 8px; align-items: center; }
.hour-row .day { font-weight: 700; }
.hour-row input[type=time] { min-height: 38px; padding: 6px 8px; }
@media (max-width: 640px) { .hour-row { grid-template-columns: 90px auto 1fr 1fr; } }

/* backups */
.hist { display: grid; gap: 6px; }
.hist-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--white); }
.hist-row .when { font-weight: 600; }
.hist-row .what { color: var(--ink-2); }

/* Spanish fields (v1.2) */
.es-block { border-left: 3px solid var(--green-tint, #DCE9DC); padding-left: 12px; margin: 2px 0 12px; }
.es-block .field:last-child { margin-bottom: 0; }
.group-head input.es, .choice-row input.es { font-style: italic; }
.choice-row { grid-template-columns: 1fr 1fr 110px auto auto; }
@media (max-width: 640px) { .choice-row { grid-template-columns: 1fr 1fr; } .choice-row .price { grid-column: 1; } }
.item-row .es-name { display: block; font-weight: 400; color: var(--ink-2); font-style: italic; font-size: 14px; }
.tag-warn { background: #FFF3C4; color: #7A5A00; }

.cat-edit-toggle { display: none; } /* phones only (below) */

/* ---------- phones and small tablets (v1.2.1) ----------
   The category list used to be one long scrolling row that forced the whole
   page wider than the screen; it now wraps into chips, and nothing else may
   grow past the viewport. */
@media (max-width: 860px) {
  .panel-menu, .panel-sets { grid-template-columns: minmax(0, 1fr); }
  .cats, .items, .panel { min-width: 0; }
  .cat-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: none; overflow: visible; }
  .cat-btn { width: auto; border: 1.5px solid var(--rule); border-radius: 999px; padding: 6px 12px; font-size: 15px; }
  .cat-btn.active { border-color: var(--green); }
  .cat-edit { display: none; }
  .cats.editing .cat-edit { display: block; }
  .cat-edit-toggle { display: inline-flex; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .panel { padding: 12px; }
  .bar { gap: 8px 10px; padding: 8px 12px; }
  .bar-brand { font-size: 18px; }
  .tabs { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 8px 10px; }
  .bar-right .btn { min-height: 38px; padding: 0 12px; font-size: 14px; }
  .bar-right a.btn-quiet { display: none; } /* "View site" — the Cowboy's mark on the left opens it */
  .dirty { display: none; } /* the enabled Save button says it */
  .cats-head h2, .items-head h2 { font-size: 18px; }
  .items-head .row { width: 100%; }
  .filter { max-width: none; flex: 1; min-width: 0; }
  .item-row { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px 10px; }
  .item-row .thumb { width: 44px; height: 44px; font-size: 18px; }
  .item-row .acts { grid-column: 1 / -1; justify-content: flex-end; }
  .photo-block { flex-wrap: wrap; }
  .photo-preview { width: 110px; height: 110px; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 14px; padding-right: 14px; }
  .group-head input[type=text] { min-width: 120px; }
  .hist-row { flex-wrap: wrap; }
  .notice-es { flex-direction: column; align-items: flex-start; }
  /* hours: day + switch on one line, the two times on the next */
  .hour-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 8px; padding-bottom: 8px; border-bottom: 1px dotted var(--rule); }
  .hour-row:last-child { border-bottom: 0; }
  .hour-row .switch { justify-self: end; }
  .hour-row input[type=time] { width: 100%; min-width: 0; }
}
.notice-es { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; padding: 10px 12px; border-radius: 10px; background: #FFF3C4; color: #4A3900; font-size: 14px; }
.tag-auto { background: #DCE8F8; color: #173E7A; }
.es-tools { margin-top: 6px; }
