/* Craftfiti Backoffice — CI ร้าน (สีจาก craftfitibkk.com: ink / cream / yellow / red) */
:root {
  --ink: #15110D; --ink-2: #1E1812; --ink-3: #0E0B08; --line: #3A3128;
  --cream: #F6F2EA; --muted: #CFC6B6; --dim: #9C9282;
  --yellow: #F5D547; --gold: #C9A83A; --red: #A3232B;
}
* { box-sizing: border-box; }
html { background: var(--ink-3); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--cream);
  font-family: 'Prompt', 'Poppins', system-ui, sans-serif; font-size: 16px; line-height: 1.45;
  background: radial-gradient(120% 60% at 50% -10%, #2A2117 0%, var(--ink) 55%, var(--ink-3) 100%) fixed;
}
a { color: inherit; text-decoration: none; }
.wrap { max-width: 880px; margin: 0 auto; padding: 22px 18px 40px; }

/* ---- header ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.top img { height: 30px; width: auto; display: block; }
.badge {
  font: 600 12px/1 'Poppins', sans-serif; letter-spacing: .14em; text-transform: uppercase;
  padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.badge--owner { background: var(--red); border-color: var(--red); color: #fff; }
.hello { margin: 22px 0 18px; }
.hello h1 { margin: 0; font: 900 34px/1.05 'Playfair Display', serif; letter-spacing: .01em; }
.hello h1 span { color: var(--yellow); }
.hello p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* ---- เว็บร้าน (ปุ่มเด่นบนสุด) ---- */
.shop {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 16px;
  background: var(--yellow); color: var(--ink); box-shadow: 0 8px 24px rgba(245, 213, 71, .18);
}
.shop .ic { background: var(--ink); color: var(--yellow); }
.shop b { display: block; font-size: 19px; font-weight: 600; }
.shop .txt small { font: 500 13.5px "Poppins", sans-serif; color: var(--ink); opacity: .7; }

/* ---- หมวด ---- */
section { margin-top: 28px; }
.sec-h { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 12px; }
.sec-h em { font: 700 12px/1 'Poppins', sans-serif; font-style: normal; letter-spacing: .2em; color: var(--yellow); }
.sec-h h2 { margin: 0; font-size: 18px; font-weight: 500; }
.sec-h::after { content: ''; flex: 1; height: 1px; background: var(--line); transform: translateY(-4px); }
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .grid { grid-template-columns: 1fr 1fr; } .hello h1 { font-size: 42px; } }

/* ---- การ์ดระบบ ---- */
.card {
  display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 14px 16px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.card:hover { border-color: var(--gold); background: #261E16; }
.card:active, .shop:active { transform: scale(.98); }
.card:focus-visible, .shop:focus-visible, .btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.ic {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(245, 213, 71, .12); color: var(--yellow);
}
.ic svg { width: 23px; height: 23px; }
.txt { flex: 1; min-width: 0; }
.txt b { display: block; font-size: 17px; font-weight: 500; }
.txt small { display: block; color: var(--muted); font-size: 14px; margin-top: 1px; }
.go { flex: none; width: 22px; height: 22px; color: var(--dim); }
.card:hover .go { color: var(--yellow); }
.lock { font: 600 10.5px/1 'Poppins', sans-serif; letter-spacing: .08em; color: var(--yellow); border: 1px solid var(--gold); border-radius: 6px; padding: 3px 5px; margin-left: 6px; vertical-align: 2px; }

/* กดแล้วต้องเห็นว่ากำลังเปิด (ระบบ GAS บางตัวโหลดช้า) */
.is-opening { border-color: var(--yellow) !important; }
.is-opening .go { border: 2.5px solid var(--line); border-top-color: var(--yellow); border-radius: 50%; animation: spin .7s linear infinite; }
.is-opening .go path { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- ท้ายหน้า ---- */
.foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--dim); font-size: 14px; }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ---- หน้าล็อกอิน ---- */
.login { max-width: 380px; margin: 0 auto; padding: 48px 20px; }
.login .top { border: 0; justify-content: center; }
.login .top img { height: 34px; }
.panel { margin-top: 26px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 18px; padding: 24px 20px; }
.panel h1 { margin: 0 0 4px; font: 900 28px/1.1 'Playfair Display', serif; }
.panel p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.panel label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.panel input {
  width: 100%; font: 500 18px 'Poppins', sans-serif; color: var(--cream); background: var(--ink-3);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px;
}
.panel input:focus { outline: none; border-color: var(--yellow); }
.btn {
  width: 100%; margin-top: 14px; border: 0; border-radius: 12px; padding: 14px; cursor: pointer;
  background: var(--yellow); color: var(--ink); font: 600 17px 'Prompt', sans-serif;
}
.btn[disabled] { opacity: .7; cursor: wait; }
.err { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(163, 35, 43, .2); border: 1px solid var(--red); color: #FFD9D9; font-size: 14.5px; }
.back { display: block; text-align: center; margin-top: 18px; color: var(--muted); font-size: 14.5px; text-decoration: underline; text-underline-offset: 3px; }

/* ---- หน้าแรก = หัวข้อหมวด · แตะแล้วเข้าหมวด (ใช้ #hash ปุ่มย้อนกลับมือถือใช้ได้) ---- */
.view { display: none; padding-top: 18px; }
.view:target { display: block; }
body:has(.view:target) .home { display: none; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 148px; padding: 16px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 18px; position: relative;
  transition: transform .12s ease, border-color .15s ease;
}
.tile:hover { border-color: var(--gold); }
.tile:active { transform: scale(.97); }
.tile:focus-visible, .back-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.tile .ic { position: absolute; top: 16px; left: 16px; width: 48px; height: 48px; }
.tile .ic svg { width: 26px; height: 26px; }
.tile b { font-size: 19px; font-weight: 600; line-height: 1.25; }
.tile small { color: var(--muted); font-size: 14px; }
.tile--shop { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.tile--shop .ic { background: var(--ink); color: var(--yellow); }
.tile--shop small { color: var(--ink); opacity: .7; font-family: 'Poppins', sans-serif; font-size: 12.5px; }
.tile.is-opening { border-color: var(--ink) !important; opacity: .8; }
.back-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 15px; padding: 8px 12px 8px 6px; margin-left: -6px; border-radius: 10px; }
.back-btn svg { width: 20px; height: 20px; }
.back-btn:hover { color: var(--yellow); }
.view-h { display: flex; align-items: center; gap: 14px; margin: 10px 0 18px; }
.view-h .ic { width: 52px; height: 52px; }
.view-h em { font: 700 12px/1 'Poppins', sans-serif; font-style: normal; letter-spacing: .2em; color: var(--yellow); }
.view-h h2 { margin: 4px 0 0; font-size: 26px; font-weight: 600; line-height: 1.2; }
.tile .count { position: absolute; top: 16px; right: 16px; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; font: 600 13px 'Poppins', sans-serif; background: rgba(245,213,71,.14); color: var(--yellow); }
.tile--shop { grid-column: 1 / -1; min-height: 96px; }
/* fix: ไอคอนไม่ทับชื่อ */
.tile { justify-content: flex-start; }
.tile .ic { position: static; margin-bottom: auto; }
.tile b { margin-top: 14px; }
.tile--shop { flex-direction: row; align-items: center; gap: 14px; min-height: 84px; }
.tile--shop .ic { margin: 0; }
.tile--shop b { margin: 0; display: block; }
.tile--shop .shop-txt { display: flex; flex-direction: column; }
