/* หลังร้าน (ใช้ตัวแปรและปุ่มจาก style.css) */
.admin { background: #f7f1ef; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; }

/* เข้าสู่ระบบ */
.login { display: grid; place-items: center; min-height: 100dvh; padding: 20px; background: radial-gradient(circle at 20% 10%, #f6dede, transparent 50%), radial-gradient(circle at 90% 90%, #e6eedf, transparent 45%), var(--bg); }
.login-card { width: min(400px, 100%); padding: 34px 30px 26px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.login-card .field { text-align: left; }
.login-logo { width: 56px; height: 56px; margin: 0 auto 12px; }
.login-card h1 { font-size: 24px; font-family: 'Noto Serif Thai', var(--serif); }
.login-card > p.muted { margin: 4px 0 22px; }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.demo-hint { margin: 14px 0 6px; padding: 8px; border-radius: 10px; background: var(--blush); font-size: 14px; color: var(--muted); }
.back-link { font-size: 14px; color: var(--muted); }

/* โครง */
.a-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.a-top .brand { margin-right: 0; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs button { position: relative; display: flex; align-items: center; gap: 7px; padding: 9px 14px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-weight: 500; cursor: pointer; }
.tabs button:hover { background: var(--blush); }
.tabs button.on { background: var(--ink); color: #fff; }
.tab-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--rose); color: #fff; font: 600 12px/20px var(--sans); font-style: normal; text-align: center; }
.a-main { max-width: 1100px; margin: 0 auto; padding: 24px 24px 60px; }
.a-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.a-head h2 { font-size: 26px; font-family: 'Noto Serif Thai', var(--serif); }
.a-head h2 small { font: 400 15px var(--sans); color: var(--muted); margin-left: 6px; }
.a-head-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); }
.search input { width: 180px; padding: 10px 0; border: 0; outline: none; font: inherit; color: var(--ink); background: none; }
.a-empty { padding: 40px 20px; border: 1px dashed var(--line); border-radius: 18px; background: #fff; text-align: center; color: var(--muted); }
.a-empty b { display: block; color: var(--ink); font-size: 18px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.tile { padding: 16px 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.tile span { display: block; color: var(--muted); font-size: 14px; }
.tile b { font-size: 26px; }
.a-chips { margin-bottom: 14px; }
.chip small { opacity: .65; margin-left: 2px; }

/* คำสั่งซื้อ */
.olist, .plist, .mlist { display: flex; flex-direction: column; gap: 10px; }
.orow { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; text-align: left; cursor: pointer; transition: box-shadow .2s, transform .15s; }
.orow:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.orow-pics { display: flex; flex: none; }
.orow-pics img { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; border: 2px solid #fff; }
.orow-pics img + img { margin-left: -18px; }
.orow-main { flex: 1; min-width: 0; }
.orow-main b, .orow-main small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.orow-main small { color: var(--muted); }
.orow-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.od { padding: 16px 24px 24px; }
.od-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--muted); }
.od-items { margin-bottom: 12px; }
.od-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.od-item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.od-item span { flex: 1; }
.od h4 { margin: 18px 0 8px; font-family: var(--sans); font-size: 15px; }
.kv { display: grid; grid-template-columns: 76px 1fr; gap: 6px 12px; margin: 0; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv .ic { width: 16px; height: 16px; color: var(--green); vertical-align: -3px; }
.card-msg { font-style: italic; }
.od-slip img { max-height: 280px; border-radius: 12px; border: 1px solid var(--line); }
.od-change { margin-top: 18px; }

/* สินค้า */
.prow { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.prow.is-hidden { opacity: .6; }
.prow img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.prow-main { flex: 1; min-width: 0; }
.prow-main b, .prow-main small { display: block; }
.prow-main small { color: var(--muted); }
.prow-price { min-width: 80px; text-align: right; color: var(--rose-dark); }
.prow-actions { display: flex; align-items: center; gap: 6px; }
.switch { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border: 0; border-radius: 999px; background: none; cursor: pointer; font-size: 13.5px; color: var(--muted); }
.switch i { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #d9cfcd; transition: background .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on i { background: var(--sage); }
.switch.on i::after { transform: translateX(16px); }
.switch span { min-width: 30px; }
.a-form-modal { width: min(620px, calc(100vw - 32px)); }
.pform { padding: 18px 24px 22px; }
.img-drop { display: block; width: 180px; margin: 0 auto 6px; border: 2px dashed var(--line); border-radius: 18px; cursor: pointer; overflow: hidden; text-align: center; transition: border-color .2s; }
.img-drop:hover { border-color: var(--rose); }
.img-drop > span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; aspect-ratio: 1; padding: 12px; }
.img-drop img { width: 100%; height: 100%; object-fit: cover; }
.img-drop > span:has(img) { padding: 0; }
.img-drop .ic { width: 30px; height: 30px; color: var(--rose); }
.img-drop small { color: var(--muted); font-size: 12.5px; }
.checks { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 10px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--rose); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* สมาชิก */
.mrow { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.mrow .avatar { width: 42px; height: 42px; font-size: 18px; }
.mrow-main { flex: 1; min-width: 0; }
.mrow-main b { display: block; }
.mrow-main small { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.mrow-main .ic { width: 15px; height: 15px; color: var(--green); }
.mrow-end { text-align: right; }
.mrow-end small { display: block; color: var(--muted); }

/* ตั้งค่า */
.panel { margin-bottom: 18px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.panel h3 { margin: 0 0 12px; font: 600 17px var(--sans); }
.panel h3 ~ h3 { margin-top: 18px; }

/* ยืนยัน */
.confirm-modal { width: min(400px, calc(100vw - 32px)); }
.confirm { padding: 24px; }
.confirm h3 { font: 600 19px var(--sans); }
.confirm p { margin: 8px 0 20px; color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  /* backdrop-filter ทำให้แถบเมนู position: fixed ข้างในยึดกับหัวแทนจอ */
  .a-top { padding: 10px 16px; gap: 10px; backdrop-filter: none; background: #fff; }
  .a-top .brand-text { display: none; }
  .a-top .btn { margin-left: auto; }
  /* เมนูเป็นแถบล่าง */
  .tabs { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; justify-content: space-around; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
  .tabs button { flex-direction: column; gap: 2px; flex: 1; padding: 6px 4px; font-size: 12px; }
  .tabs button.on { background: var(--blush); color: var(--rose-dark); }
  .tab-badge { position: absolute; top: 2px; left: 55%; }
  .a-main { padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); }
  .a-head-tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .orow { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .orow-end { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .prow { flex-wrap: wrap; }
  .prow-price { min-width: 0; }
  .prow-actions { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
  .prow-actions .switch { margin-right: auto; }
  .row2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .panel { padding: 18px; }
  .od, .pform { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
