/* ===========================================================
   ธีม "ออกผจญภัย" – แนวมังงะ/อนิเมะ (งานออกแบบต้นฉบับของเราเอง)
   เปิดใช้เมื่อ <html class="adv">  ปิด = กลับเป็นธีมมาตรฐาน
   =========================================================== */
.adv {
  --ink: #23201a; --ink-soft: #4a4336; --paper: #f5e9cd; --paper-2: #fffaf0; --paper-3: #efe0bf;
  --sea: #1f6fb2; --sea-deep: #15507f; --gold: #e0a52e; --sail: #d2402f; --leaf: #2e8b57;

  --bg: #f1e3c4; --panel: var(--paper-2); --surface-2: #f8f0dc; --hover: #fdf3d9; --stripe: #fbf4e2;
  --line: #d9c79c; --line-2: #e8dbba; --line-strong: var(--ink);
  --text: #1c1a15; --text-2: #4a4336; --muted: #7a6a50; --faint: #9c8a68;
  --brand: var(--ink); --accent: var(--sea); --accent-hover: var(--sea-deep); --accent-bg: #ddeefb; --accent-line: #9dc8e8;
  --bad-fg: #b4291a; --bad-bg: #ffe2da; --bad-dot: #e2432c; --bad-line: #e8a99a;
  --warn-fg: #8f5700; --warn-bg: #ffeec4; --warn-dot: #f0a81e; --warn-line: #e2c383;
  --ok-fg: #17663f; --ok-bg: #ddf3e1; --ok-dot: #2f9e5c; --ok-line: #a8d7b6;
  --unk-fg: #6b6250; --unk-bg: #ece2cb;
  --unk-dot: #a89a7c; --info-fg: #15507f; --info-bg: #ddeefb; --info-dot: var(--sea);
  --shadow: 3px 3px 0 rgba(35, 32, 26, .9);
  --shadow-md: 4px 5px 0 rgba(35, 32, 26, .9);
  --shadow-lg: 7px 8px 0 rgba(35, 32, 26, .92);
  --disp: "Itim", "Noto Sans Thai", "Leelawadee UI", cursive;
}

/* ---------- พื้นหลัง: กระดาษแผนที่ + สกรีนโทน + เข็มทิศจาง ---------- */
.adv body { background: var(--bg); }
.adv body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%2323201a' stroke-width='1.1' opacity='.5'%3E%3Ccircle cx='50' cy='50' r='34'/%3E%3Ccircle cx='50' cy='50' r='25'/%3E%3Cpath d='M50 8 57 43 92 50 57 57 50 92 43 57 8 50 43 43Z'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(rgba(35, 32, 26, .13) 1px, transparent 1.3px),
    radial-gradient(circle at 18% 12%, rgba(224, 165, 46, .16), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(31, 111, 178, .12), transparent 46%);
  background-size: 260px 260px, 7px 7px, 100% 100%, 100% 100%;
  background-position: right -120px top 90px, 0 0, 0 0, 0 0;
  background-repeat: no-repeat, repeat, no-repeat, no-repeat;
  opacity: .4;
}
.adv .app, .adv .scan-wrap, .adv .login-wrap, .adv #toast { position: relative; z-index: 1; }

/* ---------- ตัวอักษรหัวข้อแบบลายมือ ---------- */
.adv h1, .adv h2, .adv h3, .adv .hero-value, .adv .flow-step .v, .adv .brand-name,
.adv .btn, .adv .tabs button, .adv .card .value { font-family: var(--disp); letter-spacing: 0; }
.adv h1 { font-size: 27px; color: var(--ink); text-shadow: 2px 2px 0 var(--gold); position: relative; display: inline-block; padding-bottom: 6px; }
.adv h1::after {
  content: ""; position: absolute; left: 0; right: -6px; bottom: -2px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 8' preserveAspectRatio='none'%3E%3Cpath d='M1 5C25 1 40 7 62 4s38-4 56 1' fill='none' stroke='%23d2402f' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/100% 100%;
}
.adv h3 { font-size: 16.5px; }

/* ---------- แถบข้าง: ไม้กระดาน + เชือก + คลื่น ---------- */
.adv .sidebar {
  background: linear-gradient(180deg, #f7edd4, #efe0bf); border-right: 3px solid var(--ink);
  box-shadow: 4px 0 0 rgba(35, 32, 26, .12);
}
.adv .sidebar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 26px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20'%3E%3Cpath d='M0 13Q10 6 20 13T40 13T60 13T80 13T100 13T120 13' fill='none' stroke='%231f6fb2' stroke-width='2.4' stroke-linecap='round'/%3E%3Cpath d='M0 18Q10 12 20 18T40 18T60 18T80 18T100 18T120 18' fill='none' stroke='%2315507f' stroke-width='2' opacity='.65'/%3E%3C/svg%3E") repeat-x bottom/120px 20px;
  animation: adv-wave 7s linear infinite;
}
@keyframes adv-wave { to { background-position-x: -120px; } }
.adv .logo { background: var(--sail); border: 2.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); border-radius: 12px; animation: adv-sway 4s ease-in-out infinite; }
@keyframes adv-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.adv .brand-name { font-size: 17px; }
.adv nav a { border: 2px solid transparent; font-weight: 600; }
.adv nav a:hover { background: var(--paper-2); border-color: var(--ink); transform: translateX(3px); }
.adv nav a.active { background: var(--gold); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.adv nav a.active .ico { color: var(--ink); }
.adv nav a .ico { stroke-width: 2.1; }
.adv .side-link:hover { background: var(--paper-2); }

/* ---------- แผง/การ์ด: กรอบหมึก + เงาแข็ง ---------- */
.adv .panel, .adv .card, .adv .table-wrap, .adv .banner, .adv .hero-card, .adv .flow-steps, .adv .login-card {
  border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); background: var(--panel);
}
.adv .panel { animation: adv-in .45s cubic-bezier(.2, .9, .3, 1.2) backwards; }
@keyframes adv-in { from { opacity: 0; transform: translateY(14px) rotate(-.5deg); } }
.adv .panel:nth-of-type(2) { animation-delay: .06s; }
.adv .panel:nth-of-type(3) { animation-delay: .12s; }
.adv .grid-2 > .panel:nth-child(2) { animation-delay: .1s; }

/* ป้ายหมุดกระดาษมุมบนของแผงหลัก */
.adv .panel > .panel-head::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: var(--sail); border: 2px solid var(--ink); margin-right: 2px;
}
.adv .panel-head h3 { flex: 1; }

/* ---------- แบนเนอร์ = ป้ายประกาศล่าสมบัติ ---------- */
.adv .banner { background: var(--paper-2); position: relative; padding-left: 22px; }
.adv .banner.lv2 { background: #ffe9e2; } .adv .banner.lv1 { background: #fff3d6; } .adv .banner.lv0 { background: #e2f5e6; }
.adv .banner::before {
  content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 9px;
  background: repeating-linear-gradient(45deg, var(--sail) 0 8px, var(--gold) 8px 16px);
  border-right: 2.5px solid var(--ink); border-radius: 9px 0 0 9px;
}
.adv .banner-title b { font-family: var(--disp); font-size: 21px; }

/* ---------- การ์ดหลัก 3 ใบ = ป้ายภารกิจ ---------- */
.adv .hero-card { animation: adv-pop .5s cubic-bezier(.2, .9, .3, 1.35) backwards; }
.adv .hero:nth-child(n) .hero-card:nth-child(1) { animation-delay: .05s; transform: rotate(-.6deg); }
.adv .hero-card:nth-child(2) { animation-delay: .14s; }
.adv .hero-card:nth-child(3) { animation-delay: .23s; transform: rotate(.6deg); }
@keyframes adv-pop { from { opacity: 0; transform: translateY(18px) scale(.94) rotate(0); } }
.adv .hero-card:hover { transform: translateY(-4px) rotate(0) !important; box-shadow: var(--shadow-lg); }
.adv .hero-label { font-weight: 700; }
.adv .hero-label::before { width: 11px; height: 11px; border: 2px solid var(--ink); }
.adv .hero-value { font-size: 50px; text-shadow: 3px 3px 0 rgba(35, 32, 26, .16); }
.adv .hero-cta { border-top: 2px dashed var(--line-strong); font-weight: 700; }
.adv .hero-card:hover .hero-cta { animation: adv-nudge .6s ease-in-out infinite; }
@keyframes adv-nudge { 50% { transform: translateX(5px); } }

/* ---------- แถบสถานะการจัดการ ---------- */
.adv .flow-steps { overflow: hidden; }
.adv .flow-step { background: var(--paper-2); border-left: 2.5px solid var(--ink); }
.adv .flow-step:first-child { border-left: none; }
.adv .flow-step:hover { background: var(--gold); }
.adv .flow-step .v { font-size: 30px; }

/* ---------- ป้ายสถานะ = ตราประทับ ---------- */
.adv .badge { border: 2px solid var(--ink); box-shadow: 1.5px 1.5px 0 var(--ink); font-weight: 700; height: 25px; padding: 0 9px 0 7px; gap: 5px; }
.adv .badge i { border: 1.5px solid var(--ink); width: 8px; height: 8px; }
.adv .legend .badge { border: none; box-shadow: none; }
.adv .legend .badge i { border-width: 1.5px; }
.adv .pill { border: 2px solid var(--ink-soft); background: var(--paper-2); font-weight: 600; }
.adv .chip { border: 1.5px solid var(--ink-soft); font-weight: 600; }
.adv .stat { border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); background: var(--paper-2); }
.adv .stat:hover { background: var(--gold); transform: translateY(-2px); }

/* ---------- ปุ่ม = สติกเกอร์การ์ตูน ---------- */
.adv .btn {
  border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); border-radius: 999px;
  font-weight: 700; font-size: 14.5px; letter-spacing: .01em;
}
.adv .btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.adv .btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.adv .btn-light { background: var(--paper-2); }
.adv .btn-light:hover { background: var(--gold); }
.adv .btn-danger { background: #ffe2da; }
.adv .icon-btn { border: 2px solid var(--ink); box-shadow: 1.5px 1.5px 0 var(--ink); font-weight: 700; }
.adv .icon-btn:hover { background: var(--gold); color: var(--ink); }
.adv td .btn-sm:not(.btn-danger):not(.btn-light) { background: var(--sea); color: #fff; }

/* ---------- ตาราง = ช่องมังงะ ---------- */
.adv .table-wrap { background: var(--paper-2); }
.adv th {
  background: linear-gradient(180deg, #4a4336, #3a3327); color: #f7ecd2; font-weight: 700;
  border-bottom: 2.5px solid var(--ink); font-family: var(--disp); font-size: 13.5px; letter-spacing: .02em;
}
.adv tbody tr:nth-child(even) td { background: var(--stripe); }
.adv tbody tr:hover td { background: var(--hover); }
.adv tbody tr.clickable:hover td:first-child { box-shadow: inset 4px 0 0 var(--sail); }
.adv td { border-bottom: 1.5px solid var(--line); }
.adv tr.detail > td, .adv tr[data-detail] > td { background: #f6ecd6 !important; border-top: 2px dashed var(--ink-soft); }

/* ---------- รายการ "ควรจัดการก่อน" = บันทึกการเดินทาง ---------- */
.adv .row { border-bottom: 2px dashed var(--line); border-radius: 8px; }
.adv .row:hover { background: var(--hover); transform: translateX(5px); }
.adv .row-cta { font-weight: 700; }

/* ---------- แท็บ = ป้ายไม้ ---------- */
.adv .tabs { background: var(--paper-3); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); }
.adv .tabs button { font-weight: 700; }
.adv .tabs button.active { background: var(--gold); color: var(--ink); border: 2px solid var(--ink); box-shadow: 1.5px 1.5px 0 var(--ink); }

/* ---------- ช่องกรอก ---------- */
.adv :where(input, select, textarea) { border: 2px solid var(--ink-soft); background: var(--paper-2); border-radius: 9px; }
.adv :where(input, select, textarea):focus { border-color: var(--sea); box-shadow: 0 0 0 3px rgba(31, 111, 178, .2); }
.adv .inline-text { background: transparent; border-color: transparent; border-bottom: 2px dashed var(--ink-soft); }
.adv .inline-text:hover, .adv .inline-text:focus { background: var(--paper-2); border: 2px solid var(--ink-soft); }

/* ---------- ข้อความลอย = บอลลูนคำพูด ---------- */
.adv .toast {
  background: var(--paper-2); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 16px;
  box-shadow: var(--shadow-lg); font-weight: 700; font-family: var(--disp); font-size: 15px;
}
.adv .toast::after {
  content: ""; position: absolute; right: 26px; bottom: -14px; width: 0; height: 0;
  border: 12px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}
.adv .toast.err { background: #ffe2da; color: var(--bad-fg); }

/* ---------- กำลังโหลด = เข็มทิศหมุน ---------- */
.adv .loading::before {
  width: 46px; height: 46px; border: none; border-radius: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%2323201a' stroke-width='5'%3E%3Ccircle cx='50' cy='50' r='42'/%3E%3C/g%3E%3Cpath d='M50 14 60 50 50 86 40 50Z' fill='%23d2402f' stroke='%2323201a' stroke-width='4' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  animation: spin 1.6s cubic-bezier(.6, .1, .3, 1) infinite;
}
.adv .loading { font-family: var(--disp); font-size: 16px; }

/* ---------- ตราประจำหน้า (ขึ้นกับ data-page) ---------- */
.adv .page-head { position: relative; }
.adv .page-head::after {
  content: ""; width: 74px; height: 74px; flex: none; margin-left: auto; opacity: .9;
  background-position: center; background-repeat: no-repeat; background-size: contain;
  animation: adv-bob 3.4s ease-in-out infinite;
}
@keyframes adv-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-7px) rotate(3deg); } }
.adv[data-page="dashboard"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='40' fill='%23f5e9cd' stroke='%2323201a' stroke-width='5'/%3E%3Cpath d='M50 16 59 50 50 84 41 50Z' fill='%23d2402f' stroke='%2323201a' stroke-width='4' stroke-linejoin='round'/%3E%3Cpath d='M16 50 50 41 84 50 50 59Z' fill='%23f5e9cd' stroke='%2323201a' stroke-width='4' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.adv[data-page="machines"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M18 66h64l-10 18H28Z' fill='%23a9713a' stroke='%2323201a' stroke-width='4' stroke-linejoin='round'/%3E%3Cpath d='M50 12v52' stroke='%2323201a' stroke-width='5'/%3E%3Cpath d='M52 16h26L52 38Z' fill='%23d2402f' stroke='%2323201a' stroke-width='4' stroke-linejoin='round'/%3E%3Cpath d='M46 28H24l22 30Z' fill='%23f5e9cd' stroke='%2323201a' stroke-width='4' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.adv[data-page="programs"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='14' y='44' width='72' height='38' rx='4' fill='%23a9713a' stroke='%2323201a' stroke-width='5'/%3E%3Cpath d='M14 48a36 22 0 0 1 72 0' fill='%23e0a52e' stroke='%2323201a' stroke-width='5'/%3E%3Crect x='42' y='50' width='16' height='22' rx='3' fill='%23f5e9cd' stroke='%2323201a' stroke-width='4'/%3E%3C/svg%3E"); }
.adv[data-page="indicators"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M26 12v76' stroke='%2323201a' stroke-width='6' stroke-linecap='round'/%3E%3Cpath d='M30 16h52l-9 18 9 18H30Z' fill='%23d2402f' stroke='%2323201a' stroke-width='4.5' stroke-linejoin='round'/%3E%3Ccircle cx='50' cy='32' r='7' fill='%23f5e9cd'/%3E%3Ccircle cx='66' cy='32' r='7' fill='%23f5e9cd'/%3E%3C/svg%3E"); }
.adv[data-page="settings"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='26' fill='%23f5e9cd' stroke='%2323201a' stroke-width='5'/%3E%3Ccircle cx='50' cy='50' r='9' fill='%23a9713a' stroke='%2323201a' stroke-width='4'/%3E%3Cg stroke='%2323201a' stroke-width='5' stroke-linecap='round'%3E%3Cpath d='M50 8v18M50 74v18M8 50h18M74 50h18M20 20l13 13M67 67l13 13M80 20 67 33M33 67 20 80'/%3E%3C/g%3E%3C/svg%3E"); }
.adv[data-page="machine"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M20 16h48l14 14v54H20Z' fill='%23f5e9cd' stroke='%2323201a' stroke-width='5' stroke-linejoin='round'/%3E%3Cpath d='M32 44h36M32 58h36M32 72h22' stroke='%2323201a' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='m58 26 8 8' stroke='%23d2402f' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E"); }

/* ---------- เข้าสู่ระบบ = ท้องทะเล ---------- */
.adv .login-wrap { background: linear-gradient(180deg, #bfe4f7 0%, #6fb7de 52%, #1f6fb2 100%); }
.adv .login-wrap::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 70px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20'%3E%3Cpath d='M0 13Q10 5 20 13T40 13T60 13T80 13T100 13T120 13V20H0Z' fill='%2315507f' opacity='.75'/%3E%3C/svg%3E") repeat-x bottom/160px 40px;
  animation: adv-wave 6s linear infinite;
}
.adv .login-card { transform: rotate(-.6deg); }
.adv .login-card h2 { font-size: 23px; }

/* ---------- หน้าสแกนพนักงาน ---------- */
.adv .scan-wrap h1 { font-size: 34px; }
.adv .step .n { background: var(--gold); color: var(--ink); border: 2.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); font-family: var(--disp); }
.adv .step { border-bottom: 2px dashed var(--line); }

/* ---------- ปุ่มสลับธีม ---------- */
#btnSkin .ico { transition: transform .3s; }
.adv #btnSkin .ico { transform: rotate(-18deg); color: var(--sail); }

@media (max-width: 900px) {
  .adv .page-head::after { width: 52px; height: 52px; }
  .adv h1 { font-size: 23px; }
  .adv .hero-value { font-size: 42px; }
  .adv .sidebar { background: rgba(247, 237, 212, .95); border-bottom: 3px solid var(--ink); }
  .adv .sidebar::after { display: none; }
  .adv .hero-card { transform: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .adv .page-head::after, .adv .logo, .adv .sidebar::after, .adv .login-wrap::after { animation: none !important; }
}

/* ป้ายสถานะที่อยู่ในหัวข้อ: ใช้ฟอนต์ปกติ ไม่เอาเงาทอง */
.adv h1 .badge, .adv h3 .badge { font-family: var(--sans); text-shadow: none; font-size: 12.5px; }

/* ---------- ผู้ช่วย AI (ธีมผจญภัย) ---------- */
.adv .ai-card { border: 2.5px solid var(--ink); border-left-width: 7px; box-shadow: 3px 3px 0 var(--ink); background: var(--paper-2); }
.adv .ai-card.lv2 { border-left-color: var(--bad-dot); } .adv .ai-card.lv1 { border-left-color: var(--warn-dot); } .adv .ai-card.lv0 { border-left-color: var(--ok-dot); }
.adv .ai-callout { border: 2.5px dashed var(--ink); background: var(--paper-2); }
.adv .ai-callout .ico { color: var(--ink); }
.adv .ai-findings li { border: 2px solid var(--ink-soft); background: var(--paper); }
.adv .ai-rec { border: 2px solid var(--ink); background: #e6f1f8; }
.adv .ai-changes { border: 2px dashed var(--ink-soft); }
.adv .nav-badge { border: 2px solid var(--ink); background: var(--bad-dot); }
.adv .chat-msg .bubble { border: 2.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.adv .chat-msg.user .bubble { background: var(--sea); }
.adv .chat-msg.assistant .bubble { background: var(--paper-2); border-radius: 16px 16px 16px 4px; }
.adv .chat-suggest .chip { border: 2px solid var(--ink-soft); background: var(--paper-2); font-family: var(--disp); }
.adv[data-page="ai"] .page-head::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='m12 62 52-30 9 16-52 30Z' fill='%23a9713a' stroke='%2323201a' stroke-width='5' stroke-linejoin='round'/%3E%3Cpath d='m64 32 12-7 9 16-12 7Z' fill='%23e0a52e' stroke='%2323201a' stroke-width='5' stroke-linejoin='round'/%3E%3Ccircle cx='81' cy='33' r='5' fill='%23f5e9cd' stroke='%2323201a' stroke-width='3'/%3E%3Cpath d='m36 66 6 22M45 61l14 23' stroke='%2323201a' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E"); }
.adv .bulk-bar .inline-text { background: var(--paper-2); }
