/* =====================================================================
   The Go-Getters CRM - Design System
   =====================================================================
   แนวทาง: ยืมโครงสร้าง / neutral / spacing / radius จาก Flux Dashboard
           (flux.dashboardpack.com) แล้วสลับสี accent เป็นสีประจำแบรนด์
           The Go-Getters

   ค่าที่ถอดมาจาก Flux ของจริง:
     - neutral ทั้งชุดอิงเฉดอมน้ำเงิน (OKLCH hue 285) ไม่ใช่เทากลาง
       ทำให้หน้าดูสะอาดและเย็นตากว่าเทาธรรมดา
     - radius 0.875rem = 14px
     - sidebar เป็นสี "อ่อนเกือบขาว" ไม่ใช่ดำแบบ template ทั่วไป
     - เน้นเส้นขอบบาง 1px แทนเงาหนา ๆ
     - card padding 1.25rem / 1.75rem
   ===================================================================== */

/* ---------------------------------------------------------------------
   1) Design Tokens
   --------------------------------------------------------------------- */
:root {
    /* ---- สีประจำแบรนด์ The Go-Getters ---- */
    --gg-dark-blue:  #164F73;
    --text-accent:   #164F73;   /* สีตัวอักษร accent: light=น้ำเงิน */
    --gg-teal:       #2AAE9B;
    --gg-teal-dark:  #229184;
    --gg-teal-soft:  #E8F7F4;
    --gg-light-teal: #A8E3D7;
    --gg-orange:     #F37B2A;
    --gg-yellow:     #F4C84A;
    --gg-red:        #EF5B63;

    /* ---- Neutral (ถอดจาก Flux: OKLCH hue 285 เฉดอมน้ำเงิน) ---- */
    --bg:            #FAFAFD;
    --card:          #FFFFFF;
    --surface:       #FFFFFF;
    --surface-2:     #F2F3FA;
    --fg:            #172033;
    --fg-strong:     #07060F;
    --fg-muted:      #62626F;
    --border:        #E7E7EE;
    --border-strong: #D8D8E3;
    --muted:         #F2F3FA;
    --muted-fg:      #62626F;

    /* ---- Sidebar (Flux ใช้สีอ่อน) ---- */
    --sidebar-bg:     #FBFBFF;
    --sidebar-fg:     #2D2D38;
    --sidebar-hover:  #F0F0FF;
    --sidebar-border: #E7E7EE;

    /* ---- สีสถานะ ---- */
    --success:    var(--gg-teal);
    --success-bg: #E8F7F4;
    --warning:    #C9971F;
    --warning-bg: #FDF6E3;
    --danger:     var(--gg-red);
    --danger-bg:  #FDECEE;
    --info:       var(--gg-dark-blue);
    --info-bg:    #E9F0F5;

    /* ---- รูปทรง ---- */
    --radius:     .875rem;
    --radius-sm:  .5rem;
    --radius-xs:  .375rem;
    --radius-lg:  1.25rem;
    --radius-pill: 999px;

    /* ---- เงา (Flux ใช้เบามาก พึ่งเส้นขอบเป็นหลัก) ---- */
    --shadow-xs: 0 1px 2px rgba(7, 6, 15, .04);
    --shadow-sm: 0 1px 3px rgba(7, 6, 15, .06), 0 1px 2px rgba(7, 6, 15, .04);
    --shadow-md: 0 4px 16px rgba(7, 6, 15, .08);
    --shadow-lg: 0 12px 32px rgba(7, 6, 15, .12);

    /* ---- ขนาด layout ---- */
    --sidebar-w:  264px;
    --navbar-h:   64px;
    --card-pad:   1.25rem;

    --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------------------------------------------------------------------
   1b) Dark theme
   ---------------------------------------------------------------------
   เปลี่ยนเฉพาะสี neutral ส่วนสีแบรนด์ (teal/red/...) คงเดิม
   สคริปต์ใน <head> ตั้ง data-theme="dark" ให้ก่อนเรนเดอร์ กันหน้าจอกระพริบ
   และตั้ง data-bs-theme="dark" ให้ Bootstrap component (dropdown/modal/input)
   ปรับตามด้วย
   --------------------------------------------------------------------- */
:root[data-theme="dark"] {
    /* โทนเขียวเข้ม (forest/teal) — สว่างขึ้นจากเดิมให้อ่านสบายตา */
    --bg:            #16241D;
    --card:          #1E3128;
    --surface:       #1E3128;
    --text-accent:   #F4C84A;   /* dark: เปลี่ยนตัวอักษรน้ำเงิน -> เหลือง */
    --surface-2:     #274035;
    --fg:            #E9EFEB;
    --fg-strong:     #FFFFFF;
    --fg-muted:      #9EABA3;
    --muted-fg:      #9EABA3;
    --border:        #2F4739;
    --border-strong: #3D5A4A;
    --muted:         #223730;

    --sidebar-bg:     #193026;
    --sidebar-fg:     #CFDAD3;
    --sidebar-hover:  #22402F;
    --sidebar-border: #264034;

    --gg-teal-soft: rgba(42, 174, 155, .16);
    --success-bg:   rgba(42, 174, 155, .16);
    --warning-bg:   rgba(244, 200, 74, .16);
    --danger-bg:    rgba(239, 91, 99, .16);
    --info-bg:      rgba(42, 174, 155, .14);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

/* ---- ปรับจุดที่ hardcode สีสว่าง ให้เข้ากับโทนเขียวเข้ม ---- */

/* navbar bg เดิม hardcode เป็นสีขาวโปร่ง ต้อง override */
:root[data-theme="dark"] .gg-navbar {
    background: rgba(22, 36, 29, .85);
}

/* sidebar ไล่เฉดเขียว บน→ล่าง ตามภาพอ้างอิง */
:root[data-theme="dark"] .gg-sidebar {
    background: linear-gradient(180deg, #204534 0%, #16281D 100%);
}

/* เมนูที่เปิดอยู่ = ไล่เฉดเทียลสว่าง ตัวหนังสือขาว */
:root[data-theme="dark"] .gg-nav-link.active {
    background: linear-gradient(135deg, rgba(42, 174, 155, .85) 0%, rgba(34, 145, 132, .6) 100%);
    color: #fff;
}
:root[data-theme="dark"] .gg-nav-link.active i { color: #fff; }

/* ---------------------------------------------------------------------
   Dark mode: KPI icon ให้ "เรืองแสง" อ่านชัด ไม่กลืนพื้นเข้ม
   ปัญหาเดิม: .blue ใช้สีน้ำเงินเข้ม (#164F73) บนพื้นดำ → มองไม่เห็น
   แก้: ใช้สีสว่างขึ้นทุกโทน + drop-shadow ให้เรืองแสงตามสีตัวเอง
   --------------------------------------------------------------------- */
:root[data-theme="dark"] .gg-kpi-icon.teal   { color: #40D6C0; background: rgba(64, 214, 192, .16); }
:root[data-theme="dark"] .gg-kpi-icon.blue   { color: #5FB0F0; background: rgba(95, 176, 240, .16); }
:root[data-theme="dark"] .gg-kpi-icon.orange { color: #FF9D52; background: rgba(255, 157, 82, .16); }
:root[data-theme="dark"] .gg-kpi-icon.yellow { color: #FFD75E; background: rgba(255, 215, 94, .16); }
:root[data-theme="dark"] .gg-kpi-icon.red    { color: #FF7D83; background: rgba(255, 125, 131, .16); }
:root[data-theme="dark"] .gg-kpi-icon i { filter: drop-shadow(0 0 4px currentColor); }

/* label ของ KPI ให้สว่างขึ้น อ่านง่าย */
:root[data-theme="dark"] .gg-kpi-label { color: #C7D3CD; }

/* ไอคอนหมวดในกล่องอันดับ (Top Sales/Performance/AOV/Order) ให้เด่น ไม่จม */
:root[data-theme="dark"] #myRankBody > div > .bi:first-child { color: var(--gg-teal); }

/* โลโก้ตัวอักษร GO (fallback) มองเห็นยากบนพื้นเข้ม เพิ่มพื้นให้ */
:root[data-theme="dark"] .gg-brand-logo { background: #fff; }

/* ---------------------------------------------------------------------
   2) Base
   --------------------------------------------------------------------- */

/*
   Inter มาก่อน Sarabun โดยตั้งใจ

   Inter ไม่มีสระ/พยัญชนะไทย เบราว์เซอร์จึงตกไปใช้ Sarabun เฉพาะอักขระไทย
   ผลคือ ตัวเลขและอังกฤษได้ความคมของ Inter (แบบ Flux)
   ส่วนภาษาไทยได้ Sarabun ตามที่ requirement กำหนด — ได้ทั้งสองอย่าง
*/
body {
    font-family: 'Inter', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ตัวเลขในตาราง/KPI ต้องเรียงตรงกันทุกหลัก ไม่งั้นเทียบยอดด้วยตาลำบาก */
.gg-num,
.gg-kpi-value,
table td.text-end,
table th.text-end,
.gg-mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.gg-mono {
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

a { text-decoration: none; }

/*
   hidden ต้องชนะ utility class ของ Bootstrap

   [hidden] ปกติได้ display:none จาก UA stylesheet ซึ่งไม่มี !important
   แต่ .d-flex ของ Bootstrap เป็น display:flex !important
   พอใช้คู่กันอย่าง <div class="alert d-flex" hidden> ผลคือ !important ชนะ
   element ที่สั่งซ่อนไว้จะโผล่ออกมาแบบเปล่า ๆ

   บรรทัดนี้ทำให้ hidden ทำงานตามที่คาดเสมอ ไม่ว่าจะใส่ class อะไรไว้
*/
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-pill);
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #c2c2d0; }

/* ---------------------------------------------------------------------
   3) โลโก้
   --------------------------------------------------------------------- */
.gg-logo-mark {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gg-teal) 0%, var(--gg-dark-blue) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: .3px;
    flex-shrink: 0;
}

.gg-logo-mark.lg { width: 48px; height: 48px; font-size: 17px; }

/* ---------------------------------------------------------------------
   4) Layout หลัก
   --------------------------------------------------------------------- */
.gg-shell {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.gg-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;

    /* sticky ตาม requirement ข้อ 14 */
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
    transition: transform .25s var(--ease);
}

.gg-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: 1rem 1.125rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--navbar-h);
}

.gg-sidebar-brand-text { min-width: 0; }

.gg-sidebar-brand-name {
    font-weight: 700;
    font-size: .875rem;
    color: var(--text-accent);
    line-height: 1.2;
    white-space: nowrap;
}

.gg-sidebar-brand-sub {
    font-size: .6875rem;
    color: var(--muted-fg);
    white-space: nowrap;
}

.gg-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .875rem .75rem;
}

/* หัวข้อกลุ่มเมนู - ตัวเล็ก ตัวใหญ่ทั้งหมด สีจาง แบบ Flux */
.gg-nav-section {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted-fg);
    padding: .875rem .625rem .375rem;
}

.gg-nav-section:first-child { padding-top: .25rem; }

.gg-nav-link {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .625rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg);
    font-size: .8125rem;
    font-weight: 500;
    transition: background-color .12s var(--ease), color .12s var(--ease);
    margin-bottom: 1px;
    position: relative;
}

.gg-nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-accent);
}

.gg-nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    color: var(--muted-fg);
    transition: color .12s var(--ease);
    flex-shrink: 0;
}

.gg-nav-link:hover i { color: var(--text-accent); }

.gg-nav-link.active {
    background: var(--gg-teal-soft);
    color: var(--gg-teal-dark);
    font-weight: 600;
}

.gg-nav-link.active i { color: var(--gg-teal); }

/* แถบเล็ก ๆ ด้านซ้ายบอกเมนูที่เปิดอยู่ */
.gg-nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--gg-teal);
}

.gg-nav-badge {
    margin-left: auto;
    font-size: .6875rem;
    font-weight: 600;
    padding: .0625rem .375rem;
    border-radius: var(--radius-pill);
    background: var(--muted);
    color: var(--muted-fg);
    line-height: 1.4;
}

.gg-nav-link.active .gg-nav-badge {
    background: var(--gg-teal);
    color: #fff;
}

.gg-nav-badge.alert {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---- ผู้ใช้ท้าย sidebar ---- */
.gg-sidebar-user {
    border-top: 1px solid var(--sidebar-border);
    padding: .75rem;
}

.gg-sidebar-user-inner {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem;
    border-radius: var(--radius-sm);
    transition: background-color .12s var(--ease);
}

.gg-sidebar-user-inner:hover { background: var(--sidebar-hover); }

.gg-sidebar-user-meta { min-width: 0; flex: 1; }

.gg-sidebar-user-name {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gg-sidebar-user-role {
    font-size: .6875rem;
    color: var(--muted-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Avatar ---- */
.gg-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--gg-dark-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6875rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: .02em;
}

.gg-avatar.sm { width: 26px; height: 26px; font-size: .625rem; }
.gg-avatar.lg { width: 44px; height: 44px; font-size: .875rem; border-radius: var(--radius); }

/* สีอวาตาร์ไล่ตามตัวอักษร ทำให้แยกคนออกจากกันได้เร็วขึ้นในตารางยาว ๆ */
.gg-avatar.c1 { background: var(--gg-dark-blue); }
.gg-avatar.c2 { background: var(--gg-teal); }
.gg-avatar.c3 { background: var(--gg-orange); }
.gg-avatar.c4 { background: #7C5CBF; }
.gg-avatar.c5 { background: #C9971F; }
.gg-avatar.c6 { background: #4A8FBF; }

/* อวาตาร์แบบรูปจริง */
.gg-avatar.gg-avatar-img { background: var(--muted); overflow: hidden; border-radius: 50%; }
.gg-avatar.gg-avatar-img img { width: 100%; height: 100%; object-fit: cover; }

/* วงพรีวิวรูปโปรไฟล์ในฟอร์มแก้ไขผู้ใช้ */
.gg-avatar-edit {
    width: 96px; height: 96px; border-radius: 50%;
    margin: 0 auto; display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 2rem; overflow: hidden;
    background: var(--gg-dark-blue); border: 3px solid var(--border);
}
.gg-avatar-edit.c1 { background: var(--gg-dark-blue); }
.gg-avatar-edit.c2 { background: var(--gg-teal); }
.gg-avatar-edit.c3 { background: var(--gg-orange); }
.gg-avatar-edit.c4 { background: #7C5CBF; }
.gg-avatar-edit.c5 { background: #C9971F; }
.gg-avatar-edit.c6 { background: #4A8FBF; }
.gg-avatar-edit.gg-avatar-img { background: var(--muted); }
.gg-avatar-edit img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Main ---- */
.gg-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---- Navbar ---- */
.gg-navbar {
    height: var(--navbar-h);
    background: rgba(250, 250, 253, .85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;

    /* sticky ตาม requirement ข้อ 14 */
    position: sticky;
    top: 0;
    z-index: 1030;
}

.gg-navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--fg);
    font-size: 1.25rem;
    padding: .25rem;
    line-height: 1;
}

/* ---- Command palette (แบบ Flux) ---- */
.gg-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .4375rem .625rem;
    width: 100%;
    max-width: 340px;
    color: var(--muted-fg);
    font-size: .8125rem;
    cursor: pointer;
    transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}

.gg-search:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
}

.gg-search-text {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gg-kbd {
    font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
    font-size: .6875rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: .0625rem .3125rem;
    color: var(--muted-fg);
    white-space: nowrap;
}

.gg-navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.gg-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9375rem;
    transition: all .12s var(--ease);
    position: relative;
}

.gg-icon-btn:hover {
    color: var(--text-accent);
    border-color: var(--border-strong);
    background: var(--muted);
}

.gg-icon-btn .gg-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gg-red);
    border: 1.5px solid var(--card);
}

/* ---- พื้นที่เนื้อหา ---- */
.gg-content {
    padding: 1.25rem;
    flex: 1;
}

.gg-page-head {
    margin-bottom: 1.25rem;
}

.gg-page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fg-strong);
    margin: 0 0 .1875rem;
    letter-spacing: -.01em;
}

.gg-page-sub {
    font-size: .8125rem;
    color: var(--muted-fg);
    margin: 0;
}

/* ---------------------------------------------------------------------
   5) Card
   --------------------------------------------------------------------- */
.gg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.gg-card-head {
    padding: var(--card-pad);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.gg-card-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--fg-strong);
    margin: 0;
}

.gg-card-sub {
    font-size: .75rem;
    color: var(--muted-fg);
    margin: .125rem 0 0;
}

.gg-card-body { padding: var(--card-pad); }

.gg-card-head + .gg-card-body { padding-top: 1rem; }

/* ---------------------------------------------------------------------
   6) KPI Card
   --------------------------------------------------------------------- */
.gg-kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
    height: 100%;
}

.gg-kpi:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
}

/*
   min-height บังคับให้หัวการ์ดสูงเท่ากันทุกใบ

   ป้ายบางอันยาว 2 บรรทัด (เช่น "Average Order Size") บางอันบรรทัดเดียว
   ถ้าไม่ล็อกความสูง ตัวเลขของแต่ละใบจะอยู่คนละระดับ
   มองแวบเดียวแล้วรู้สึกว่าแถวมันเบี้ยว
*/
.gg-kpi-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .625rem;
    min-height: 32px;
}

.gg-kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    flex-shrink: 0;
}

.gg-kpi-icon.teal   { background: var(--success-bg); color: var(--gg-teal); }
.gg-kpi-icon.blue   { background: var(--info-bg);    color: var(--text-accent); }
.gg-kpi-icon.orange { background: #FEF0E6;           color: var(--gg-orange); }
.gg-kpi-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.gg-kpi-icon.red    { background: var(--danger-bg);  color: var(--danger); }

/* ป้ายยาวเกิน 2 บรรทัดให้ตัดด้วย ... แทนที่จะดันการ์ดสูงขึ้นเรื่อย ๆ */
.gg-kpi-label {
    font-size: .75rem;
    color: var(--muted-fg);
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gg-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fg-strong);
    line-height: 1.15;
    letter-spacing: -.02em;
    margin-bottom: .375rem;
}

.gg-kpi-value .unit {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--muted-fg);
    margin-left: .125rem;
}

.gg-kpi-delta {
    display: flex;
    align-items: center;
    gap: .3125rem;
    font-size: .75rem;
    min-height: 20px;
}

/*
   nowrap + flex-shrink:0 สำคัญมาก

   ถ้าไม่ใส่ ชิปอย่าง "▲ +5.35" จะแตกบรรทัดกลางคำเป็น "▲" / "+5.35"
   เวลาข้อความเปรียบเทียบข้าง ๆ ยาว ดูเหมือนการ์ดพัง
*/
.gg-delta-chip {
    display: inline-flex;
    align-items: center;
    gap: .125rem;
    font-weight: 600;
    padding: .0625rem .3125rem;
    border-radius: var(--radius-xs);
    font-size: .6875rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.gg-delta-chip.up     { background: var(--success-bg); color: var(--gg-teal-dark); }
.gg-delta-chip.down   { background: var(--danger-bg);  color: var(--danger); }
.gg-delta-chip.stable { background: var(--muted);      color: var(--muted-fg); }

.gg-kpi-compare {
    color: var(--muted-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* แถบความคืบหน้าบาง ๆ ใต้ KPI */
.gg-kpi-bar {
    height: 4px;
    background: var(--muted);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-top: .75rem;
}

.gg-kpi-bar span {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--gg-teal);
    transition: width .5s var(--ease);
}

.gg-kpi-bar span.warn   { background: var(--gg-yellow); }
.gg-kpi-bar span.danger { background: var(--gg-red); }

/* ---------------------------------------------------------------------
   7) Badge สถานะผลงาน
   --------------------------------------------------------------------- */
.gg-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .6875rem;
    font-weight: 600;
    padding: .1875rem .4375rem;
    border-radius: var(--radius-xs);
    white-space: nowrap;
    line-height: 1.3;
}

.gg-badge-excellent    { background: var(--success-bg); color: var(--gg-teal-dark); }
.gg-badge-good         { background: var(--info-bg);    color: var(--text-accent); }
.gg-badge-watch        { background: var(--warning-bg); color: var(--warning); }
.gg-badge-need_support { background: var(--danger-bg);  color: var(--danger); }
.gg-badge-neutral      { background: var(--muted);      color: var(--muted-fg); }

/* ---------------------------------------------------------------------
   8) ลูกศรแนวโน้ม
   --------------------------------------------------------------------- */
.gg-trend-up     { color: var(--gg-teal); font-weight: 600; }
.gg-trend-down   { color: var(--gg-red);  font-weight: 600; }
.gg-trend-stable { color: var(--muted-fg); }

/* ---------------------------------------------------------------------
   9) ปุ่ม
   --------------------------------------------------------------------- */
.gg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    font-size: .8125rem;
    font-weight: 500;
    padding: .4375rem .75rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all .12s var(--ease);
    white-space: nowrap;
    cursor: pointer;
}

.gg-btn-primary {
    background: var(--gg-teal);
    border-color: var(--gg-teal);
    color: #fff;
}

.gg-btn-primary:hover:not(:disabled) {
    background: var(--gg-teal-dark);
    border-color: var(--gg-teal-dark);
    color: #fff;
}

.gg-btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.gg-btn-outline {
    background: var(--card);
    border-color: var(--border);
    color: var(--fg);
}

.gg-btn-outline:hover {
    background: var(--muted);
    border-color: var(--border-strong);
    color: var(--text-accent);
}

.gg-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted-fg);
}

.gg-btn-ghost:hover { background: var(--muted); color: var(--fg); }

.gg-btn-lg { padding: .625rem 1rem; font-size: .875rem; }
.gg-btn-sm { padding: .3125rem .5rem; font-size: .75rem; }

/* ---------------------------------------------------------------------
   10) ฟอร์ม
   --------------------------------------------------------------------- */
.form-label {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--fg);
    margin-bottom: .375rem;
}

.form-control,
.form-select {
    font-size: .8125rem;
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: .4375rem .625rem;
    color: var(--fg);
    background-color: var(--card);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--gg-teal);
    box-shadow: 0 0 0 3px rgba(42, 174, 155, .13);
}

.form-control::placeholder { color: #a3a3b0; }

.form-text { font-size: .75rem; color: var(--muted-fg); }

.input-group-text {
    background: var(--muted);
    border-color: var(--border);
    color: var(--muted-fg);
    font-size: .8125rem;
    border-radius: var(--radius-sm);
}

.input-group > .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > .form-control:not(:last-child),
.input-group > .input-group-text:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > :not(:first-child):not(.dropdown-menu) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ---------------------------------------------------------------------
   11) หน้า Login / Change Password
   --------------------------------------------------------------------- */
.gg-auth-body {
    background:
        radial-gradient(900px 420px at 50% -8%, rgba(42, 174, 155, .10), transparent 62%),
        var(--bg);
    min-height: 100vh;
}

.gg-auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.gg-auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem;
    width: 100%;
    max-width: 400px;
}

.gg-auth-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.gg-auth-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--fg-strong);
    line-height: 1.25;
}

.gg-auth-sub {
    font-size: .75rem;
    color: var(--muted-fg);
}

.gg-auth-hint {
    margin-top: 1.25rem;
    padding: .875rem;
    border-radius: var(--radius-sm);
    background: var(--muted);
    border: 1px solid var(--border);
}

.gg-auth-hint code {
    background: var(--card);
    border: 1px solid var(--border);
    padding: .0625rem .25rem;
    border-radius: var(--radius-xs);
    color: var(--text-accent);
    font-size: .6875rem;
}

/* ---------------------------------------------------------------------
   12) Empty / Loading / Error State
   --------------------------------------------------------------------- */
.gg-state {
    text-align: center;
    padding: 2.5rem 1.25rem;
}

.gg-state-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--muted);
    color: var(--muted-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin: 0 auto .875rem;
}

.gg-state-icon.error { background: var(--danger-bg); color: var(--danger); }

.gg-state-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: .25rem;
}

.gg-state-text {
    font-size: .8125rem;
    color: var(--muted-fg);
    margin-bottom: 1rem;
}

/* ---- Skeleton (ตาม requirement ข้อ 14) ---- */
.gg-skeleton {
    background: linear-gradient(90deg, var(--muted) 25%, #E8E9F2 50%, var(--muted) 75%);
    background-size: 200% 100%;
    animation: gg-shimmer 1.4s infinite;
    border-radius: var(--radius-xs);
}

@keyframes gg-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.gg-skeleton-line { height: 10px; margin-bottom: .5rem; }
.gg-skeleton-line.lg { height: 22px; }
.gg-skeleton-line.w-40 { width: 40%; }
.gg-skeleton-line.w-60 { width: 60%; }
.gg-skeleton-line.w-80 { width: 80%; }

/* คนที่ตั้งค่าเครื่องว่าไม่ชอบภาพเคลื่อนไหว ต้องเคารพด้วย
   บางคนเวียนหัวจริง ๆ กับ animation วน ๆ แบบนี้ */
@media (prefers-reduced-motion: reduce) {
    .gg-skeleton { animation: none; }
    * { transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------------
   13) Responsive
   --------------------------------------------------------------------- */
.gg-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 6, 15, .4);
    z-index: 1035;
    opacity: 0;
    transition: opacity .2s var(--ease);
}

.gg-backdrop.show { display: block; opacity: 1; }

@media (max-width: 991.98px) {
    .gg-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .gg-sidebar.open { transform: translateX(0); }

    .gg-navbar-toggle { display: flex; }

    .gg-search { max-width: none; }
}

@media (max-width: 575.98px) {
    .gg-content { padding: .875rem; }
    .gg-navbar { padding: 0 .875rem; }
    .gg-search-text, .gg-kbd { display: none; }
    .gg-search { max-width: 40px; justify-content: center; }
    .gg-kpi-value { font-size: 1.25rem; }
}

/* จอ 1366x768 ตาม requirement ข้อ 14 - บีบ padding ให้เห็นเนื้อหาได้มากขึ้น */
@media (min-width: 992px) and (max-width: 1400px) {
    :root { --sidebar-w: 240px; --card-pad: 1rem; }
    .gg-content { padding: 1rem; }
}

/* ---------------------------------------------------------------------
   14) Utilities
   --------------------------------------------------------------------- */
.gg-text-muted { color: var(--muted-fg) !important; }
.gg-divider { height: 1px; background: var(--border); border: 0; margin: 1rem 0; }

.dropdown-menu {
    border-color: var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: .8125rem;
    padding: .3125rem;
}

.dropdown-item {
    border-radius: var(--radius-xs);
    padding: .4375rem .5rem;
    color: var(--fg);
}

.dropdown-item:hover { background: var(--muted); color: var(--text-accent); }
.dropdown-item.text-danger:hover { background: var(--danger-bg); color: var(--danger) !important; }
.dropdown-header { font-size: .6875rem; color: var(--muted-fg); padding: .375rem .5rem; }
.dropdown-divider { margin: .3125rem 0; border-color: var(--border); }

.alert { border-radius: var(--radius-sm); font-size: .8125rem; border-width: 1px; }
.alert-danger  { background: var(--danger-bg);  border-color: #F7C9CD; color: #B5333B; }
.alert-success { background: var(--success-bg); border-color: #B3E5DC; color: #1A7A6E; }
.alert-warning { background: var(--warning-bg); border-color: #F0DFA8; color: #8A6914; }
.alert-info    { background: var(--info-bg);    border-color: #C5D8E5; color: var(--text-accent); }

/* หมุนไอคอนปุ่มรีเฟรช */
@keyframes gg-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------
   15) ตารางกรอกข้อมูลรายชั่วโมง
   --------------------------------------------------------------------- */
.gg-entry-table {
    font-size: .8125rem;
    margin-bottom: 0;
}

.gg-entry-table thead th {
    background: var(--muted);
    color: var(--muted-fg);
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    padding: .625rem .5rem;
    white-space: nowrap;

    /* หัวตารางค้างไว้ตอนเลื่อน ตาม requirement ข้อ 6
       ทีมมี CRM 12 คน เลื่อนลงไปกรอกคนท้าย ๆ แล้วจำไม่ได้ว่าคอลัมน์ไหนคืออะไร */
    position: sticky;
    top: 0;
    z-index: 2;
}

.gg-entry-table tbody td {
    padding: .5rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.gg-entry-table tbody tr:last-child td { border-bottom: 0; }
.gg-entry-table tbody tr:hover { background: #FCFCFE; }

.gg-entry-table .form-control-sm,
.gg-entry-table .form-select-sm {
    font-size: .8125rem;
    padding: .25rem .4375rem;
    border-radius: var(--radius-xs);
}

.gg-entry-table input[type="number"] {
    font-variant-numeric: tabular-nums;
    /* ซ่อนลูกศรขึ้นลง กันกดพลาดจนยอดเปลี่ยนโดยไม่รู้ตัว */
    -moz-appearance: textfield;
}

.gg-entry-table input[type="number"]::-webkit-outer-spin-button,
.gg-entry-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.gg-entry-table .is-invalid {
    border-color: var(--danger) !important;
    background: var(--danger-bg);
}

.gg-entry-table .gg-warn {
    border-color: var(--gg-orange) !important;
    background: #FEF0E6;
}

/* ค่ารอบก่อนหน้า แสดงใต้ช่องกรอกให้เทียบได้ทันทีโดยไม่ต้องเปิดหน้าอื่น */
.gg-prev-hint {
    font-size: .625rem;
    color: var(--muted-fg);
    margin-top: .1875rem;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gg-entry-actions {
    padding: var(--card-pad);
    border-top: 1px solid var(--border);
    background: var(--muted);
    border-radius: 0 0 var(--radius) var(--radius);

    /* ปุ่มบันทึกค้างท้ายจอ ไม่ต้องเลื่อนลงไปหา */
    position: sticky;
    bottom: 0;
    z-index: 3;
}

.table-responsive { border-radius: 0; }

/* ---------------------------------------------------------------------
   16) ตารางผลงาน + ตารางเปรียบเทียบ
   --------------------------------------------------------------------- */
.gg-perf-table,
.gg-cmp-table {
    font-size: .8125rem;
    margin-bottom: 0;
}

.gg-perf-table thead th,
.gg-cmp-table thead th {
    background: var(--muted);
    color: var(--muted-fg);
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    padding: .5rem;
    white-space: nowrap;

    /* Fixed Header ตาม requirement ข้อ 6 */
    position: sticky;
    top: 0;
    z-index: 2;
}

.gg-perf-table tbody td,
.gg-cmp-table tbody td {
    padding: .4375rem .5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.gg-perf-table tbody tr:hover { background: #FCFCFE; }

/* ปุ่มชื่อ CRM เปิด modal */
.gg-name-btn {
    display: flex;
    align-items: center;
    gap: .375rem;
    background: none;
    border: 0;
    padding: 0;
    color: var(--fg);
    font-weight: 600;
    font-size: .8125rem;
    max-width: 180px;
}

.gg-name-btn:hover { color: var(--gg-teal-dark); }
.gg-name-btn:hover .text-truncate { text-decoration: underline; }

/* ═══════ StatCards — รายงานเจาะลึกรายคน ═══════ */
.sc-grade { display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; border-radius: .45rem; font-weight: 800; font-size: .78rem; flex: none; }
.sc-grade.big { width: 1.9rem; height: 1.9rem; font-size: .95rem; }
.sc-g-a { background: rgba(22,163,74,.13); color: #16a34a; }
.sc-g-b { background: rgba(42,174,155,.14); color: var(--gg-teal-dark, #1f8a7b); }
.sc-g-c { background: rgba(217,119,6,.14); color: #d97706; }
.sc-g-d { background: rgba(220,38,38,.12); color: #dc2626; }
.sc-g-none { background: var(--card2, #f1f5f9); color: var(--muted-fg, #94a3b8); }
.sc-gradeline { display: flex; align-items: center; gap: .6rem; padding: .42rem 0; border-bottom: 1px dashed var(--border, #e3eaf0); }
.sc-gradeline:last-child { border-bottom: 0; }
.sc-gl-label { font-weight: 700; font-size: .8rem; width: 4.6rem; flex: none; }
.sc-gl-detail { font-size: .74rem; color: var(--muted-fg, #64748b); }
.sc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .65rem; }
.sc-tile { background: var(--card2, #f6f9fb); border: 1px solid var(--border, #e3eaf0); border-radius: .6rem; padding: .55rem .7rem; }
.sc-tile-lb { font-size: .68rem; color: var(--muted-fg, #64748b); }
.sc-tile-v { font-size: 1.05rem; font-weight: 800; }
.sc-tile-s { font-size: .68rem; color: var(--muted-fg, #64748b); }
/* จุดรั่ว */
.sc-leak { display: grid; grid-template-columns: 8rem 1fr 6.5rem; gap: .6rem; align-items: center; margin-bottom: .55rem; font-size: .78rem; }
.sc-leak-lb { font-weight: 700; }
.sc-leak-sub { display: block; font-weight: 400; color: var(--muted-fg, #64748b); font-size: .7rem; }
.sc-leak-bar { height: 16px; background: var(--card2, #f6f9fb); border: 1px solid var(--border, #e3eaf0); border-radius: .35rem; position: relative; overflow: hidden; }
.sc-leak-bar i { position: absolute; inset: 0 auto 0 0; border-radius: .3rem; }
.sc-leak-bar i.ok { background: #16a34a; }
.sc-leak-bar i.miss { background: #dc2626; }
.sc-leak-bar .kpi { position: absolute; top: -3px; bottom: -3px; left: 76.9%; width: 2px; background: var(--fg, #1b2733); opacity: .55; }
.sc-leak-amt { text-align: right; font-weight: 800; }
@media (max-width: 560px) { .sc-leak { grid-template-columns: 6.5rem 1fr 5.5rem; } }
/* การใช้รายชื่อ */
.sc-usagebar { height: 10px; background: var(--card2, #f6f9fb); border: 1px solid var(--border, #e3eaf0); border-radius: 999px; overflow: hidden; margin: .45rem 0; }
.sc-usagebar i { display: block; height: 100%; background: var(--gg-teal, #2AAE9B); border-radius: 999px; }
.sc-warnbox { font-size: .78rem; background: rgba(217,119,6,.12); border: 1px solid #d97706; border-radius: .5rem; padding: .45rem .7rem; margin: .55rem 0; }
.sc-redial { display: flex; height: 18px; border-radius: .4rem; overflow: hidden; gap: 2px; }
.sc-redial > div { background: var(--gg-teal, #2AAE9B); }

/* ── Fit Matrix — ใครถนัดถังไหน ── */
table.scf-mtx { border-collapse: separate; border-spacing: 3px; min-width: 820px; width: 100%; }
.scf-mtx th { font-size: .7rem; color: var(--muted-fg, #64748b); font-weight: 700; padding: .25rem .35rem; text-align: center; }
.scf-mtx th.rowh { text-align: left; font-size: .78rem; color: var(--fg, #1b2733); }
.scf-held, .scf-pool { font-weight: 400; font-size: .64rem; color: var(--muted-fg, #94a3b8); }
.scf-mtx td { border-radius: .5rem; padding: .4rem .3rem; text-align: center; cursor: pointer; border: 2px solid transparent; min-width: 82px; }
.scf-mtx td:hover { border-color: var(--gg-teal, #2AAE9B); }
.scf-mtx td .fi { font-size: 1rem; font-weight: 800; line-height: 1.1; }
.scf-mtx td .cd { font-size: .64rem; opacity: .85; }
.scf-hot { background: #1f8a7b; color: #fff; }
.scf-good { background: #59bfae; color: #fff; }
.scf-mid { background: var(--card2, #e8eef2); color: var(--fg, #1b2733); }
.scf-low { background: #f2c48d; color: #3d2c00; }
.scf-bad { background: #eb9a9a; color: #4a1010; }
.scf-na { background: repeating-linear-gradient(45deg, var(--card2, #f1f5f9), var(--card2, #f1f5f9) 5px, var(--border, #d9e1e8) 5px, var(--border, #d9e1e8) 7px); color: var(--muted-fg, #94a3b8); }
.scf-delta { font-size: .66rem; font-weight: 800; }
.scf-delta.up { color: #0b3d34; } .scf-delta.down { color: #5c1010; }
.scf-mid .scf-delta.up, .scf-na .scf-delta.up { color: var(--gg-teal-dark, #1f8a7b); }
.scf-mid .scf-delta.down, .scf-na .scf-delta.down { color: #dc2626; }
.scf-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .7rem; color: var(--muted-fg, #64748b); margin-top: .6rem; }
.scf-legend .sw { display: inline-block; width: .85rem; height: .85rem; border-radius: .25rem; margin-right: .3rem; vertical-align: -2px; }
.scf-explain { background: var(--card2, #f6f9fb); border: 1px solid var(--border, #d9e1e8); border-radius: .6rem; padding: .7rem .9rem; font-size: .8rem; margin-top: .8rem; }
.scf-alloc { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.scf-bucket { border: 1px solid var(--border, #d9e1e8); border-radius: .6rem; background: var(--card, #fff); }
.scf-bucket .bh { padding: .5rem .8rem; border-bottom: 2px solid var(--gg-teal, #2AAE9B); display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.scf-bucket .bh .hint { font-size: .72rem; color: var(--muted-fg, #64748b); }
.scf-bucket .bh input { width: 5rem; text-align: right; border: 1px solid var(--border-strong, #c3cfd9); border-radius: .4rem; padding: .15rem .4rem; font-size: .78rem; background: var(--card, #fff); color: var(--fg, #1b2733); font-variant-numeric: tabular-nums; }
.scf-bucket .bb { padding: .55rem .8rem .8rem; }
.scf-bucket .arow { display: grid; grid-template-columns: 5.4rem 1fr 4.2rem; gap: .5rem; align-items: center; font-size: .76rem; padding: .2rem 0; }
.scf-bucket .arow .nm { font-weight: 700; }
.scf-bucket .abar { height: 13px; background: var(--card2, #f6f9fb); border: 1px solid var(--border, #d9e1e8); border-radius: 999px; overflow: hidden; }
.scf-bucket .abar i { display: block; height: 100%; background: var(--gg-teal, #2AAE9B); border-radius: 999px; }
.scf-bucket .arow .qty { text-align: right; font-weight: 800; }
.scf-bucket .arow.dim { opacity: .5; }
.scf-bucket .arow .why { grid-column: 2 / 4; font-size: .66rem; color: var(--muted-fg, #94a3b8); margin-top: -2px; }
.scf-vpn { padding: .35rem .8rem; font-size: .74rem; border-bottom: 1px dashed var(--border, #d9e1e8); background: var(--card2, #f6f9fb); }
.scf-vpn .hint { color: var(--muted-fg, #94a3b8); font-size: .66rem; }
.scf-plan-sum { grid-column: 1 / -1; background: var(--teal-soft, rgba(42,174,155,.12)); border: 1px solid var(--gg-teal, #2AAE9B);
    border-radius: .6rem; padding: .6rem .9rem; }
.scf-plan-head { font-size: .88rem; }
.scf-plan-ppl { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .74rem; margin-top: .3rem; color: var(--muted-fg, #5c6b7a); }

/* ── Weekly Report (พื้นขาวเสมอ — เอกสารสำหรับ Export PNG) ── */
.mode-toggle { display: flex; border: 1px solid var(--border-strong, #c3cfd9); border-radius: .55rem; overflow: hidden; }
.mode-toggle button { border: 0; background: var(--card, #fff); color: var(--muted-fg, #64748b); padding: .35rem .8rem; font-size: .78rem; font-weight: 700; cursor: pointer; }
.mode-toggle button.on { background: var(--gg-teal, #2AAE9B); color: #fff; }
.sc-wr { max-width: 860px; margin: 0 auto; background: #fff; color: #17332c; border: 1px solid #dfe9e6;
    border-radius: .6rem; padding: 1.6rem 1.9rem; box-shadow: 0 1px 4px rgba(20, 60, 50, .08); }
.sc-wr h4 { font-size: .95rem; font-weight: 800; color: #1c6b5e; margin: 0 0 .55rem; }
.sc-wr-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sc-wr-logo { height: 42px; margin-bottom: .5rem; }
.sc-wr-title { font-size: 1.9rem; font-weight: 900; line-height: 1.1; color: #14443a; letter-spacing: .01em; }
.sc-wr-year { font-weight: 800; color: #14443a; }
.sc-wr-weekbadge { width: 3rem; height: 3rem; border-radius: 50%; background: #14443a; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 800; margin-top: .4rem; }
.sc-wr-infobar { display: flex; justify-content: space-between; gap: 1rem; border-top: 3px solid #14443a;
    border-bottom: 3px solid #14443a; padding: .6rem .2rem; margin: .9rem 0 1.1rem; font-size: .85rem; line-height: 1.5; }
.sc-wr-row { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1.2rem; margin-bottom: 1.1rem; align-items: start; }
@media (max-width: 700px) { .sc-wr-row { grid-template-columns: 1fr; } }
.sc-wr-chartbox { min-width: 0; }
.sc-wr-legend { display: flex; gap: .9rem; font-size: .72rem; color: #3f5a53; margin-bottom: .2rem; }
.sc-wr-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }
.sc-wr-thisweek h4, .sc-wr-months h4 { border-bottom: 2px solid #14443a; padding-bottom: .3rem; }
.sc-wr-line { display: flex; align-items: baseline; gap: .6rem; justify-content: space-between;
    border-bottom: 1px solid #e2ece9; padding: .42rem .1rem; font-size: .85rem; }
.sc-wr-line b { font-size: 1rem; }
.sc-wr-up { color: #1c6b5e; font-weight: 700; font-size: .8rem; }
.sc-wr-down { color: #b91c1c; font-weight: 700; font-size: .8rem; }
.sc-wr-sec { margin-bottom: 1.1rem; }
.sc-wr-pills { display: flex; gap: 1rem; flex-wrap: wrap; }
.sc-wr-pill { display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; font-weight: 800; }
.sc-wr-pill .pill-dark { background: #14443a; color: #fff; border-radius: 999px; padding: .35rem 1rem; font-size: .82rem; font-weight: 700; }
.sc-wr-grades { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.sc-wr-grade { display: flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; }
.sc-wr-reco { background: #f3faf8; border: 1px solid #cfe5df; border-radius: .6rem; padding: .8rem 1rem; }
.sc-wr-reco-item { display: flex; gap: .6rem; padding: .4rem 0; font-size: .82rem; line-height: 1.55; }
.sc-wr-reco-item + .sc-wr-reco-item { border-top: 1px dashed #cfe5df; }
.sc-wr-reco-ic { font-size: 1.1rem; flex: none; }
.sc-wr-foot { background: #fff7d6; border-radius: .4rem; padding: .5rem .8rem; font-size: .74rem; color: #6b5b00; }
.sc-wr-diffn { font-size: .74rem; font-weight: 800; white-space: nowrap; }
.sc-wr-focus { background: #eef7f5; border: 1px solid #bcdcd5; border-radius: .45rem; padding: .45rem .65rem;
    font-size: .78rem; margin-top: .55rem; color: #14443a; }
.sc-wr-gap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .5rem; }
.sc-wr-gap-cell { background: #f3faf8; border: 1px solid #cfe5df; border-radius: .55rem; padding: .5rem .7rem; }
.sc-wr-gap-cell span { display: block; font-size: .68rem; color: #5f7d75; }
.sc-wr-gap-cell b { font-size: 1.1rem; }
.sc-wr-gap-cell small { display: block; font-size: .68rem; color: #5f7d75; }
.sc-wr-verdict { font-size: .85rem; font-weight: 800; margin: .3rem 0 .5rem; }
.sc-wr-followup { background: #fef8ec; border: 1px solid #ecd9a8; border-radius: .6rem; padding: .7rem 1rem; }
.sc-wr-fu-item { font-size: .8rem; padding: .25rem 0; }
.sc-wr-fu-ask { font-size: .74rem; color: #8a6d1a; margin-top: .15rem; }
.sc-wr-eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 700px) { .sc-wr-eval-grid { grid-template-columns: 1fr; } }
.sc-wr-eval label { font-size: .72rem; font-weight: 700; color: #1c6b5e; display: block; margin-bottom: .25rem; }
.sc-wr-note { min-height: 3.4rem; background: #fbfdfc; border: 1px dashed #9fc5bc; border-radius: .5rem;
    padding: .45rem .6rem; font-size: .8rem; line-height: 1.55; white-space: pre-wrap; }
.sc-wr-note:focus { outline: 2px solid #2AAE9B; background: #fff; }
.sc-wr-note:empty::before { content: 'พิมพ์ที่นี่…'; color: #9db5ae; }

/* แถวคนลา/ป่วย/ลากิจ/อบรม ในตารางสรุปรายรอบ — ขีดคาดทั้งแถว + พื้นแดงจาง ๆ ให้ข้ามตาได้เลย */
.gg-row-absent td,
.gg-row-absent .gg-name-btn { text-decoration: line-through; color: var(--muted-fg, #94a3b8); }
/* ความจำเพาะต้องชนะพื้นสีรายคอลัมน์ของตารางรายงาน (td.c-*) — ใช้ tr นำหน้า */
tr.gg-row-absent td,
.gg-report-table tr.gg-row-absent td { background: rgba(220, 38, 38, .08); }
.gg-row-absent .gg-num,
.gg-row-absent .gg-trend-up,
.gg-row-absent .gg-trend-down,
.gg-report-table tr.gg-row-absent .up,
.gg-report-table tr.gg-row-absent .down { color: var(--muted-fg, #94a3b8) !important; }
.gg-row-absent .gg-avatar { opacity: .5; }
/* inline-block ทำให้เส้นขีดของ td ไม่ลากทับป้าย */
.gg-absent-badge {
    display: inline-block; margin-left: .4rem; padding: .05rem .55rem;
    border-radius: 999px; font-size: .72rem; font-weight: 700;
    background: rgba(220, 38, 38, .12); color: #dc2626;
    vertical-align: middle; white-space: nowrap;
}

/* แถวสรุปท้ายตาราง */
.gg-perf-table tfoot td {
    padding: .5rem;
    border-top: 2px solid var(--border-strong);
    white-space: nowrap;
}

.gg-foot-sup td { background: var(--gg-teal-soft); font-weight: 500; }
.gg-foot-all td { background: #FEF0E6; font-weight: 700; }

/* ---------------------------------------------------------------------
   17) DataTables - ปรับให้เข้ากับ design system
   --------------------------------------------------------------------- */
div.dt-container .dt-search input,
div.dt-container .dt-length select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .3125rem .5rem;
    font-size: .8125rem;
}

div.dt-container .dt-search input:focus {
    border-color: var(--gg-teal);
    box-shadow: 0 0 0 3px rgba(42, 174, 155, .13);
    outline: none;
}

div.dt-container .dt-info,
div.dt-container .dt-length label,
div.dt-container .dt-search label {
    font-size: .75rem;
    color: var(--muted-fg);
}

div.dt-container .dt-paging .dt-paging-button {
    border-radius: var(--radius-xs) !important;
    border: 1px solid transparent !important;
    font-size: .75rem !important;
    padding: .25rem .5rem !important;
    color: var(--fg) !important;
}

div.dt-container .dt-paging .dt-paging-button.current {
    background: var(--gg-teal) !important;
    border-color: var(--gg-teal) !important;
    color: #fff !important;
}

div.dt-container .dt-paging .dt-paging-button:hover:not(.current):not(.disabled) {
    background: var(--muted) !important;
    border-color: var(--border) !important;
}

div.dt-buttons { margin: 0; }
div.dt-buttons .dt-button { margin-right: .375rem; }

table.dataTable thead th.dt-orderable-asc,
table.dataTable thead th.dt-orderable-desc { cursor: pointer; }

/* ---------------------------------------------------------------------
   18) การพิมพ์
   --------------------------------------------------------------------- */
@media print {
    .gg-sidebar,
    .gg-navbar,
    .gg-backdrop,
    .d-print-none,
    div.dt-buttons,
    .dt-search,
    .dt-length,
    .dt-paging { display: none !important; }

    .gg-content { padding: 0 !important; }
    .gg-card { border: 1px solid #ddd !important; box-shadow: none !important; break-inside: avoid; }
    .gg-kpi { break-inside: avoid; }
    body { background: #fff !important; font-size: 11px; }
    .table-responsive { overflow: visible !important; }
}

/* ---------------------------------------------------------------------
   19) กล่องวางข้อมูลจาก CRM
   --------------------------------------------------------------------- */
.gg-paste-box {
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: .75rem;
    line-height: 1.6;
    background: #FFFEF5;
    border-color: var(--gg-yellow);

    /* ห้ามตัดบรรทัด ข้อมูลที่ก๊อบมาแยกด้วย Tab
       ถ้า wrap แล้วแถวเดียวจะดูเหมือนหลายแถว จนตรวจตาไม่ออกว่าถูกไหม */
    white-space: pre;
    overflow-x: auto;
}

.gg-paste-box:focus {
    border-color: var(--gg-orange);
    box-shadow: 0 0 0 3px rgba(243, 123, 42, .15);
    background: #fff;
}

#pasteToggle { cursor: pointer; user-select: none; }
#pasteToggle:hover { background: var(--muted); }

/* ไฮไลต์แถวที่เพิ่งถูกเติมจากการ paste ให้เห็นว่าอะไรเปลี่ยนไปบ้าง */
.gg-row-filled td {
    animation: gg-flash 1.6s var(--ease);
}

@keyframes gg-flash {
    0%   { background: var(--gg-teal-soft); }
    100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .gg-row-filled td { animation: none; background: var(--gg-teal-soft); }
}

/* ---------------------------------------------------------------------
   20) หน้าตั้งค่าทั่วไป
   --------------------------------------------------------------------- */
.gg-ws-table {
    font-size: .8125rem;
    margin-bottom: 0;
}

.gg-ws-table thead th {
    background: var(--muted);
    color: var(--muted-fg);
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    padding: .5rem;
    white-space: nowrap;
    vertical-align: bottom;
    position: sticky;
    top: 0;
    z-index: 2;
}

.gg-th-sub {
    color: var(--muted-fg);
    font-weight: 400;
    font-size: .625rem;
    text-transform: none;
    letter-spacing: 0;
}

.gg-ws-table tbody td {
    padding: .375rem .5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.gg-ws-table tbody tr:hover { background: #FCFCFE; }

.gg-ws-table tfoot td {
    padding: .5rem;
    border-top: 2px solid var(--border-strong);
    background: #FEF0E6;
    font-weight: 600;
    white-space: nowrap;
}

.gg-ws-table .form-control-sm,
.gg-ws-table .form-select-sm {
    font-size: .8125rem;
    padding: .25rem .4375rem;
    border-radius: var(--radius-xs);
}

/*
   ช่องที่แก้ได้ทาสีเหลือง

   ต้องแยกให้เห็นชัดว่าช่องไหนแก้ได้ ช่องไหนระบบคำนวณ
   ไม่งั้นคนจะพยายามพิมพ์ในช่อง "เป้ารายวัน" แล้วงงว่าทำไมพิมพ์ไม่ได้
*/
.gg-cell {
    background: #FFFEF0;
    border-color: var(--gg-yellow);
}

.gg-cell:focus {
    background: #fff;
    border-color: var(--gg-orange);
    box-shadow: 0 0 0 3px rgba(243, 123, 42, .15);
}

.gg-cell:disabled {
    background: var(--muted);
    border-color: var(--border);
}

.gg-ws-table input[type="number"] {
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}

.gg-ws-table input[type="number"]::-webkit-outer-spin-button,
.gg-ws-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* สถานะการบันทึกอัตโนมัติ — ต้องเห็นว่าบันทึกแล้วจริง ไม่งั้นคนจะไม่กล้าเชื่อ */
.gg-saving {
    background: var(--warning-bg) !important;
    border-color: var(--gg-yellow) !important;
}

.gg-saved {
    background: var(--success-bg) !important;
    border-color: var(--gg-teal) !important;
    transition: background-color .3s var(--ease), border-color .3s var(--ease);
}

.gg-logo-preview {
    width: 88px;
    height: 88px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--muted);
    flex-shrink: 0;
    overflow: hidden;
}

.gg-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* โลโก้ที่อัปโหลดเอง แสดงแทนตัวอักษร GO */
.gg-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

/* =====================================================================
   Upsale
   ===================================================================== */

/* ช่องที่ parser ไม่มั่นใจ — เน้นให้ตรวจ */
.gg-cell-low {
    background: rgba(239, 91, 99, 0.08);
    border-color: var(--gg-red);
}
.gg-cell-medium {
    background: rgba(244, 200, 74, 0.10);
    border-color: var(--gg-yellow);
}

/* หัวข้อกลุ่มในฟอร์มยาว */
.gg-form-section {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}
.gg-form-section:first-child {
    border-top: 0;
    padding-top: 0;
}
.gg-form-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gg-teal);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.gg-form-section .form-label {
    font-size: 0.7rem;
    margin-bottom: 0.125rem;
    color: var(--fg-muted);
}

/* การ์ด preview */
.gg-preview-card {
    background: var(--gg-teal-soft, rgba(42, 174, 155, 0.06));
    border: 1px solid rgba(42, 174, 155, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
}
.gg-preview-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gg-teal);
}

/* ── Upsale list ── */
.gg-chip {
    background: var(--surface-2, #f0f1f5);
    border: 1px solid var(--border);
    color: var(--fg-muted);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}
.gg-chip.active {
    background: var(--gg-teal);
    border-color: var(--gg-teal);
    color: #fff;
}
.gg-row-overdue { background: rgba(239, 91, 99, 0.04); }

/* ── Upsale detail: key-value ── */
.gg-kv {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.375rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.8125rem;
}
.gg-kv:last-child { border-bottom: 0; }
.gg-kv > span { color: var(--fg-muted); flex-shrink: 0; }
.gg-kv > strong { text-align: right; }

/* ── Timeline ── */
.gg-timeline { position: relative; padding-left: 0.5rem; }
.gg-timeline-item { display: flex; gap: 0.75rem; padding-bottom: 1rem; position: relative; }
.gg-timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 13px; top: 28px; bottom: 0;
    width: 2px;
    background: var(--border);
}
.gg-timeline-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--gg-teal-soft, rgba(42,174,155,0.12));
    color: var(--gg-teal);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    z-index: 1;
}
.gg-timeline-body { flex: 1; padding-top: 0.125rem; }

/* ── Comment ── */
.gg-comment {
    background: var(--surface-2, #f7f8fa);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

/* =====================================================================
   Upsale follow-ups
   ===================================================================== */
.gg-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; font-size: 0.7rem; font-weight: 600;
    background: var(--gg-teal); color: #fff;
}
.gg-count-danger { background: var(--gg-red); }

.gg-fu-item {
    display: flex; gap: 0.875rem; align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.gg-fu-item:last-child { border-bottom: 0; }
.gg-fu-item.overdue { background: rgba(239, 91, 99, 0.04); }
.gg-fu-item.done { opacity: 0.55; }
.gg-fu-time {
    text-align: center; flex-shrink: 0; width: 56px;
    padding-top: 0.125rem;
}
.gg-fu-time-h { font-size: 0.95rem; font-weight: 700; color: var(--gg-teal); }
.gg-fu-time-d { font-size: 0.7rem; color: var(--fg-muted); }
.gg-fu-body { flex: 1; min-width: 0; }
.gg-fu-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }

/* ── Calendar ── */
.gg-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.gg-cal-dow {
    background: var(--surface-2, #f7f8fa);
    text-align: center; padding: 0.375rem;
    font-size: 0.7rem; font-weight: 600; color: var(--fg-muted);
}
.gg-cal-cell {
    background: var(--surface, #fff);
    min-height: 84px; padding: 0.25rem;
    font-size: 0.7rem;
}
.gg-cal-cell.empty { background: var(--surface-2, #f7f8fa); }
.gg-cal-cell.today { background: rgba(42, 174, 155, 0.06); }
.gg-cal-cell.today .gg-cal-daynum {
    background: var(--gg-teal); color: #fff;
    border-radius: 50%; width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center;
}
.gg-cal-daynum { font-weight: 600; margin-bottom: 0.125rem; }
.gg-cal-event {
    display: block; padding: 1px 4px; margin-bottom: 1px;
    border-radius: 3px; background: rgba(42,174,155,0.15); color: var(--gg-teal);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-decoration: none;
}
.gg-cal-event.overdue { background: rgba(239,91,99,0.15); color: var(--gg-red); }
.gg-cal-more { color: var(--fg-muted); padding-left: 4px; }

/* =====================================================================
   Upsale board (หน้าเดียวจบ)
   ===================================================================== */
.gg-board-table th {
    font-size: 0.72rem;
    white-space: nowrap;
    vertical-align: middle;
}
.gg-board-table td { vertical-align: middle; }
.gg-board-table textarea { resize: vertical; min-height: 38px; }

/* แถวสำเร็จ (CRM ทำเสร็จ) — เขียวทั้งแถบ ให้เห็นชัด */
.gg-row-success > td { background: rgba(42, 174, 155, 0.16) !important; }
.gg-row-success:hover > td { background: rgba(42, 174, 155, 0.22) !important; }
.gg-row-success td:first-child { box-shadow: inset 4px 0 0 var(--gg-teal); }

/* ชิปเล็กบอกสถานะ checklist ของ CRM (ฝั่ง manager ดู) */
.gg-mini-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.65rem;
    background: var(--surface-2, #eef0f4);
    color: var(--fg-muted);
    border: 1px solid var(--border);
}
.gg-mini-chip.on {
    background: var(--gg-teal);
    color: #fff;
    border-color: var(--gg-teal);
}

/* บล็อกรายละเอียดลูกค้า (คัดลอกได้) ในบอร์ด manager */
.gg-detail-block {
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre-line;
    background: var(--surface-2, #f7f8fa);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.625rem;
    max-height: 160px;
    overflow-y: auto;
}

/* กระดิ่งแจ้งเตือน — สั่นเมื่อมีของใหม่ */
@keyframes gg-bell-shake {
    0%, 50%, 100% { transform: rotate(0); }
    5%, 15%, 25%, 35% { transform: rotate(14deg); }
    10%, 20%, 30%, 40% { transform: rotate(-14deg); }
    45% { transform: rotate(6deg); }
}
.gg-bell-ring i { animation: gg-bell-shake 1.4s ease-in-out infinite; transform-origin: top center; }
.gg-notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--gg-red);
    color: #fff;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.gg-notif-item {
    display: block;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
}
.gg-notif-item:hover { background: var(--surface-2, #f7f8fa); }
.gg-notif-item.unread { background: rgba(42, 174, 155, 0.06); }
.gg-notif-item .t { font-size: 0.8rem; font-weight: 600; }
.gg-notif-item .m { font-size: 0.72rem; color: var(--fg-muted); }
.gg-notif-item .d { font-size: 0.65rem; color: var(--fg-muted); }

/* =====================================================================
   Audit Log
   ===================================================================== */
.gg-audit-table th {
    font-size: 0.72rem; font-weight: 700; text-transform: none; white-space: nowrap;
}
.gg-audit-table td { vertical-align: middle; padding: 0.5rem 0.625rem; }
.gg-audit-time { font-size: 0.75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* ชื่อ action ดิบ + IP — ตัวเล็ก monospace ให้กวาดตาข้ามได้ถ้าไม่ต้องใช้ */
.gg-audit-raw { font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; }
.gg-audit-json {
    background: #f7f8fa; border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 0.625rem 0.75rem; font-size: 0.72rem; line-height: 1.5;
    max-height: 260px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word;
}
:root[data-theme="dark"] .gg-audit-json,
[data-bs-theme="dark"] .gg-audit-json {
    background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.16); color: #e8edf4;
}

/* =====================================================================
   แถบเตือน "วันนี้ยังตั้งค่าไม่ครบ" — บนหัวทุกหน้า
   ===================================================================== */
.gg-setup-alert {
    display: flex; align-items: flex-start; gap: 0.75rem;
    border: 1px solid #f0a44a; border-left: 5px solid #e8590c; border-radius: 10px;
    background: #fff8ed; padding: 0.75rem 0.875rem; margin-bottom: 1rem;
}
.gg-setup-alert-icon { color: #e8590c; font-size: 1.05rem; line-height: 1.4; flex: none; }
.gg-setup-alert-body { flex: 1; min-width: 0; }
.gg-setup-alert-title { font-size: 0.875rem; font-weight: 800; color: #b45309; }
.gg-setup-alert-list {
    margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.8125rem; color: #4b5563;
}
.gg-setup-alert-list li + li { margin-top: 0.2rem; }
.gg-setup-alert-leave { color: #6b7280; }

.gg-setup-alert-actions { display: flex; align-items: center; gap: 0.375rem; flex: none; }
.gg-setup-alert-go {
    background: #e8590c; border: 1px solid #e8590c; color: #fff; white-space: nowrap;
}
.gg-setup-alert-go:hover { background: #c2410c; border-color: #c2410c; color: #fff; }
.gg-setup-alert-close {
    border: 0; background: transparent; color: #9ca3af; font-size: 0.8rem;
    padding: 0.25rem 0.375rem; border-radius: 6px; cursor: pointer;
}
.gg-setup-alert-close:hover { background: rgba(0, 0, 0, 0.06); color: #4b5563; }

@media (max-width: 700px) {
    .gg-setup-alert { flex-wrap: wrap; }
    .gg-setup-alert-actions { width: 100%; justify-content: flex-end; }
}

/* จุดแดงข้างเมนู "ตั้งค่าทั่วไป" */
.gg-nav-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
    margin-left: auto; flex: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22);
}

:root[data-theme="dark"] .gg-setup-alert,
[data-bs-theme="dark"] .gg-setup-alert { background: #2a2115; border-color: #b8781f; }
:root[data-theme="dark"] .gg-setup-alert-list,
[data-bs-theme="dark"] .gg-setup-alert-list { color: #d7dee8; }
:root[data-theme="dark"] .gg-setup-alert-leave,
[data-bs-theme="dark"] .gg-setup-alert-leave { color: #9ca3af; }

/* =====================================================================
   เวลาทำงาน & พักเที่ยง (หน้าตั้งค่าทั่วไป)
   ---------------------------------------------------------------------
   กรอบส้มโดยตั้งใจ ให้ต่างจากการ์ดอื่นในหน้า เพราะค่าตรงนี้เปลี่ยนวิธี
   คำนวณเป้าของทั้งระบบ ไม่ใช่ค่าตกแต่ง
   ===================================================================== */
.gg-workhours {
    border: 2px solid #f0a44a;
    border-radius: 12px;
    background: #fffaf2;
    padding: 0.875rem 1.125rem 1rem;
}
.gg-workhours-title { font-size: 0.95rem; font-weight: 800; color: #b45309; }
.gg-workhours-must { color: #dc2626; }
.gg-workhours-desc { font-size: 0.75rem; color: #6b7280; margin: 0.25rem 0 0.75rem; }

.gg-workhours-row {
    display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap;
}
.gg-workhours-label { font-size: 0.8125rem; font-weight: 600; color: #374151; margin: 0; }
.gg-workhours-select {
    width: auto; min-width: 170px; max-width: 100%;
    border: 2px solid #f0c040; background: #fffdf5; color: #1f2937;
    font-weight: 700; font-size: 0.875rem;
}
.gg-workhours-select:disabled { background: #f3f4f6; color: #6b7280; }

.gg-workhours-lunch-label {
    font-size: 0.8125rem; font-weight: 700; color: #b45309; margin: 0.875rem 0 0.5rem;
}
.gg-workhours-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.gg-workhours-chip {
    border: 1px solid #d1d5db; border-radius: 7px; background: #fff; color: #4b5563;
    padding: 0.3rem 0.7rem; font-size: 0.8125rem; font-variant-numeric: tabular-nums;
    cursor: pointer; transition: all 0.12s ease;
}
.gg-workhours-chip:hover:not(:disabled) { border-color: #f0a44a; color: #b45309; }
.gg-workhours-chip.is-lunch {
    background: #e5e7eb; border-color: #9ca3af; color: #1f2937; font-weight: 700;
}
/* รอบนอกเวลาทำงาน — จางไว้ให้เห็นว่ามีอยู่ แต่ติ๊กพักเที่ยงไม่มีความหมาย */
.gg-workhours-chip.is-outside { opacity: 0.4; cursor: not-allowed; }
.gg-workhours-chip:disabled { cursor: not-allowed; }

.gg-workhours-foot { font-size: 0.7rem; color: #6b7280; margin-top: 0.625rem; }
.gg-workhours-foot .warn { color: #dc2626; font-weight: 700; }

/* ธีมมืด: กล่องนี้คงพื้นสว่างไว้ แต่ปรับให้ไม่แสบตา */
:root[data-theme="dark"] .gg-workhours,
[data-bs-theme="dark"] .gg-workhours { background: #2a2115; border-color: #b8781f; }
:root[data-theme="dark"] .gg-workhours-label,
[data-bs-theme="dark"] .gg-workhours-label { color: #e8edf4; }
:root[data-theme="dark"] .gg-workhours-select,
[data-bs-theme="dark"] .gg-workhours-select { background: rgba(255, 255, 255, 0.08); color: #f5e7c8; }
:root[data-theme="dark"] .gg-workhours-chip,
[data-bs-theme="dark"] .gg-workhours-chip {
    background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.2); color: #d7dee8;
}
:root[data-theme="dark"] .gg-workhours-chip.is-lunch,
[data-bs-theme="dark"] .gg-workhours-chip.is-lunch { background: #4b5563; border-color: #9ca3af; color: #fff; }

/* =====================================================================
   รายงานยอดขายรายรอบ (คลาสสิก) — พื้นขาวเสมอ เพื่อ Export PNG สม่ำเสมอ
   ===================================================================== */
.gg-report {
    background: #fff;
    color: #1f2937;
    padding: 1.5rem 1.75rem;
    border-radius: var(--radius);
    border: 1px solid #e5e7eb;
    font-family: 'Inter', 'Sarabun', sans-serif;
}
.gg-report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.gg-report-brand { display: flex; align-items: center; gap: 0.875rem; }
.gg-report-logo { width: 58px; height: 58px; object-fit: contain; }
.gg-report-logo-mark {
    width: 58px; height: 58px; border-radius: 12px;
    background: linear-gradient(135deg, #2AAE9B, #164F73);
    color: #fff; font-weight: 800; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
}
.gg-report-title { font-size: 1.5rem; font-weight: 800; margin: 0; color: #164F73; }
.gg-report-company { font-size: 1.1rem; font-weight: 700; color: #2AAE9B; }

.gg-report-info { background: #1e3a5f; color: #fff; border-radius: 10px; padding: 0.5rem 0.75rem; min-width: 210px; }
.gg-report-date { text-align: center; font-size: 0.8rem; margin-bottom: 0.375rem; }
.gg-report-badge, .gg-report-badge2 {
    background: #fdf3c4; color: #1e3a5f; border-radius: 6px;
    padding: 0.25rem 0.625rem; font-weight: 700; font-size: 0.85rem;
    display: flex; justify-content: center; align-items: center; gap: 0.375rem; margin-bottom: 0.25rem;
}
.gg-report-badge2 { font-weight: 500; }
.gg-report-att { background: #f0d24a; border-radius: 4px; padding: 0 0.5rem; font-weight: 800; }

.gg-report-sub { color: #6b7280; font-size: 0.8125rem; margin: 0.75rem 0 1rem; }

/* ── ตาราง ── */
.gg-report-table-wrap { overflow-x: auto; }
.gg-report-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.gg-report-table th, .gg-report-table td {
    border: 1px solid #e5e7eb; padding: 0.5rem 0.625rem; text-align: center; vertical-align: middle;
}
.gg-report-table th { font-weight: 700; color: #374151; font-size: 0.78rem; }
.gg-report-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.gg-report-table td.c-team, .gg-report-table td.c-name { text-align: left; }

.gg-report-th-sub { font-size: 0.66rem; font-weight: 500; opacity: 0.85; }

/* สีหัวคอลัมน์ตามรายงานอ้างอิง */
.gg-report-table th.c-team   { background: #f6ded4; }
.gg-report-table th.c-name   { background: #f6ded4; }
.gg-report-table th.c-mtd    { background: #cdd6ec; }
.gg-report-table th.c-daily  { background: #f3ca4e; }
.gg-report-table th.c-target { background: #e35d5d; color: #fff; }
.gg-report-table th.c-sales  { background: #f5e199; }
.gg-report-table th.c-diff   { background: #e28b7c; color: #fff; }
.gg-report-table th.c-tg     { background: #f7d9c6; }
.gg-report-table th.c-call   { background: #aed6a6; }
.gg-report-table th.c-inc-sales { background: #fbf0c6; }
.gg-report-table th.c-inc    { background: #a9c9e3; }

/* สีพื้นเซลล์ */
.gg-report-table td.c-mtd    { background: #f2f4fa; }
.gg-report-table td.c-daily  { background: #fdf6df; }
.gg-report-table td.c-target { background: #fcefe6; }
.gg-report-table td.c-sales  { background: #fdf8e3; }

.gg-report-table .up   { color: #15803d; font-weight: 600; }
.gg-report-table .down { color: #dc2626; font-weight: 600; }

/* แถวหัวทีม */
.gg-report-team-head td {
    background: #1e3a5f; color: #fff; font-weight: 700; text-align: left; font-size: 0.8rem;
}
/* แถวสรุป */
.gg-report-sup td { background: #7fd0c4; font-weight: 700; }
.gg-report-all td { background: #eda45f; color: #fff; font-weight: 800; }

.gg-report-note { font-size: 0.72rem; color: #6b7280; margin-top: 0.5rem; }

/* ── ปุ่มสลับคอลัมน์ "เพิ่มจากชั่วโมงก่อน" ── */
.gg-report-toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.gg-report-toggle {
    border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #4b5563;
    padding: 0.3rem 0.75rem; font-size: 0.75rem; cursor: pointer;
}
.gg-report-toggle:hover { border-color: #2AAE9B; color: #2AAE9B; }
.gg-report-toggle[aria-pressed="true"] { background: #e6f6f3; border-color: #2AAE9B; color: #14776a; font-weight: 600; }

/* ── แผงล่าง: ข้ามวัน + สรุปรายรอบ ── */
.gg-report-panels {
    display: grid; grid-template-columns: minmax(300px, 460px) 1fr; gap: 1.25rem; margin-top: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) { .gg-report-panels { grid-template-columns: 1fr; } }

.gg-report-rounds { border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.75rem 0.875rem 0.875rem; }
.gg-report-rounds-head { font-size: 1rem; font-weight: 800; color: #164F73; }
.gg-report-rounds-sub { font-size: 0.7rem; color: #6b7280; margin: 0.125rem 0 0.625rem; }
.gg-report-rounds-table { font-size: 0.75rem; }
.gg-report-rounds-table td.c-team { font-weight: 600; white-space: nowrap; }
.gg-report-rounds-empty td { color: #9ca3af; padding: 1rem; }

/* ── การขายข้ามวัน ── */
.gg-report-crossday { max-width: 460px; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
.gg-report-crossday-head { background: #1e3a5f; color: #fff; font-weight: 700; padding: 0.5rem 0.75rem; font-size: 0.9rem; }
.gg-report-crossday-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.gg-report-crossday-table td { border: 1px solid #e5e7eb; padding: 0.5rem 0.75rem; }
.gg-report-crossday-table td:first-child { background: #fdf8e3; }
.gg-report-crossday-net td { background: #eda45f; color: #fff; font-weight: 800; font-size: 0.95rem; }
.gg-report-cd-input {
    width: 130px; text-align: right; border: 1px solid #f0c040; border-radius: 5px;
    padding: 0.2rem 0.5rem; background: #fffdf5;
}
.gg-report-crossday-note { font-size: 0.7rem; color: #6b7280; padding: 0.5rem 0.75rem; }

/* =====================================================================
   Activity Heatmap
   ===================================================================== */
.gg-heatmap { padding: 1.25rem 1.5rem; }
.gg-heat-filters {
    background: #f7f8fa; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 0.875rem 1rem; margin: 0.75rem 0 1rem;
}
:root[data-theme="dark"] .gg-heat-filters { background: #f7f8fa; }
.gg-heat-flabel { font-size: 0.8rem; font-weight: 600; color: #374151; margin-right: 0.5rem; }
.gg-heat-break.active {
    background: #6b7280 !important; border-color: #6b7280 !important; color: #fff !important;
}
.gg-heat-filters .gg-btn.active {
    background: var(--gg-teal); border-color: var(--gg-teal); color: #fff;
}

.gg-heat-table th, .gg-heat-table td {
    padding: 0.4rem 0.6rem; font-size: 0.8rem; white-space: nowrap;
}
.gg-heat-table td.num, .gg-heat-table td:not(.c-name) { text-align: right; font-variant-numeric: tabular-nums; }
.gg-heat-table th { background: #1e293b; color: #fff; text-align: right; }
.gg-heat-table th.c-name { text-align: left; }
.gg-heat-table th.c-total, .gg-heat-table td.c-total { border-left: 2px solid #cbd5e1; }
.gg-heat-table th.is-break { background: #64748b; }
.gg-heat-table td.is-break { background: #eef0f2 !important; }

/* แถวสรุปพนักงานเก่า/ใหม่ = เหลืองอ่อน */
.gg-heat-sub td { background: #f7e9a8 !important; font-weight: 600; color: #1a1a1a; }
.gg-heat-sub td.c-name { background: #f7e9a8 !important; }

.gg-report-note .hl-r { background: #ef5b63; color: #fff; padding: 0 .4rem; border-radius: 3px; }
.gg-report-note .hl-y { background: #f4c84a; color: #1a1a1a; padding: 0 .4rem; border-radius: 3px; }
.gg-report-note .hl-g { background: #2aae9b; color: #fff; padding: 0 .4rem; border-radius: 3px; }

/* =====================================================================
   สรุปจบวัน · End of Day / Range Summary
   ===================================================================== */
.gg-summary { padding: 1.25rem 1.5rem; }

.gg-sum-band {
    background: #1e3a5f; color: #fff; border-radius: 10px;
    padding: 0.625rem 1rem; font-weight: 700; font-size: 0.9rem; margin: 0.25rem 0 1.25rem;
}

/* KPI cards */
.gg-sum-kpis {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.875rem; margin-bottom: 1.5rem;
}
@media (max-width: 820px) { .gg-sum-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .gg-sum-kpis { grid-template-columns: 1fr; } }
.gg-sum-kpi {
    border: 1px solid #e5e7eb; border-radius: 12px; padding: 0.875rem 1rem;
    border-left: 5px solid #94a3b8; background: #fafbfc;
}
.gg-sum-kpi-label { font-size: 0.78rem; color: #64748b; font-weight: 600; }
.gg-sum-kpi-big { font-size: 1.6rem; font-weight: 800; color: #0f172a; margin: 0.25rem 0 0.125rem; line-height: 1.1; }
.gg-sum-kpi-sub { font-size: 0.76rem; color: #64748b; }
.gg-sum-kpi.k-sales  { border-left-color: #2AAE9B; }
.gg-sum-kpi.k-order  { border-left-color: #a9c9e3; }
.gg-sum-kpi.k-upsale { border-left-color: #9b8ce6; }
.gg-sum-kpi.k-call   { border-left-color: #eda45f; }
.gg-sum-kpi.k-conv   { border-left-color: #b07bd8; }
.gg-sum-kpi.k-tg.is-good, .gg-sum-kpi.k-pfm.is-good { border-left-color: #16a34a; background: #f0fdf4; }
.gg-sum-kpi.k-tg.is-warn, .gg-sum-kpi.k-pfm.is-warn { border-left-color: #f59e0b; background: #fffbeb; }
.gg-sum-kpi.k-tg.is-bad,  .gg-sum-kpi.k-pfm.is-bad  { border-left-color: #dc2626; background: #fef2f2; }
.gg-sum-kpi.k-tg.is-good .gg-sum-kpi-big, .gg-sum-kpi.k-pfm.is-good .gg-sum-kpi-big { color: #15803d; }
.gg-sum-kpi.k-tg.is-bad  .gg-sum-kpi-big, .gg-sum-kpi.k-pfm.is-bad  .gg-sum-kpi-big { color: #dc2626; }

/* แผงกรอกยอดจบวัน */
.gg-eod-entry {
    border: 1px solid var(--card-border, #e5e7eb); border-radius: 14px;
    background: var(--card, #fff); padding: 1rem 1.1rem 1.25rem; margin: 0 0 1.5rem;
    box-shadow: 0 6px 22px rgba(15, 23, 42, 0.06);
}
.gg-eod-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.gg-eod-note { font-size: 0.78rem; color: #64748b; margin-bottom: 0.75rem; }
.gg-eod-hint { font-size: 0.8rem; font-weight: 600; color: #16a34a; }
.gg-eod-grid th { background: #1e293b; color: #fff; white-space: nowrap; }
.gg-eod-grid td { padding: 0.35rem 0.4rem; }
.gg-eod-in {
    width: 100%; min-width: 74px; text-align: right; font-variant-numeric: tabular-nums;
    padding: 0.35rem 0.5rem; border: 1px solid #cbd5e1; border-radius: 7px;
    background: #fff; color: #0f172a; font-size: 0.9rem;
}
.gg-eod-in:focus { outline: none; border-color: #2AAE9B; box-shadow: 0 0 0 3px rgba(42, 174, 155, 0.18); }
.gg-eod-in.is-saving { border-color: #f59e0b; background: #fffbeb; }
.gg-eod-in.is-ok { border-color: #16a34a; background: #f0fdf4; }
.gg-eod-in.is-bad { border-color: #dc2626; background: #fef2f2; }

:root[data-theme="dark"] .gg-eod-entry,
[data-bs-theme="dark"] .gg-eod-entry { box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35); }
:root[data-theme="dark"] .gg-eod-in,
[data-bs-theme="dark"] .gg-eod-in {
    background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.2); color: #e8edf4;
}
:root[data-theme="dark"] .gg-eod-note,
[data-bs-theme="dark"] .gg-eod-note { color: #94a3b8; }
:root[data-theme="dark"] .gg-eod-in.is-saving,
[data-bs-theme="dark"] .gg-eod-in.is-saving { background: rgba(245, 158, 11, 0.16); }
:root[data-theme="dark"] .gg-eod-in.is-ok,
[data-bs-theme="dark"] .gg-eod-in.is-ok { background: rgba(22, 163, 74, 0.2); }
:root[data-theme="dark"] .gg-eod-in.is-bad,
[data-bs-theme="dark"] .gg-eod-in.is-bad { background: rgba(220, 38, 38, 0.2); }

/* ปุ่มล้างข้อมูล (แดง) */
.gg-btn-danger {
    background: #dc2626; border: 1px solid #dc2626; color: #fff;
}
.gg-btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

/* ปุ่ม × ล้างยอดรายคน */
.gg-eod-rowclear {
    width: 24px; height: 24px; line-height: 1; border-radius: 6px;
    border: 1px solid #f0c2c2; background: #fff; color: #dc2626;
    font-size: 1.05rem; font-weight: 700; cursor: pointer; padding: 0;
}
.gg-eod-rowclear:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
:root[data-theme="dark"] .gg-eod-rowclear,
[data-bs-theme="dark"] .gg-eod-rowclear {
    background: rgba(220, 38, 38, 0.14); border-color: rgba(220, 38, 38, 0.5); color: #f87171;
}
:root[data-theme="dark"] .gg-eod-rowclear:hover,
[data-bs-theme="dark"] .gg-eod-rowclear:hover { background: #dc2626; color: #fff; }

/* วางข้อมูล CRM */
.gg-eod-paste { margin-bottom: 0.85rem; }
.gg-eod-paste #eodPasteBox { margin-top: 0.6rem; }
.gg-eod-paste textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; white-space: pre;
}
.gg-eod-paste-actions { margin-top: 0.5rem; }
.gg-eod-presult {
    margin-top: 0.6rem; padding: 0.65rem 0.8rem; border-radius: 9px;
    background: #f8fafc; border: 1px solid #e5e7eb; font-size: 0.82rem; line-height: 1.7;
}
.gg-eod-presult-ok { color: #15803d; font-weight: 700; }
.gg-eod-map { color: #475569; }
.gg-eod-warn { color: #b45309; }
.gg-eod-in.is-pasted { border-color: #9b8ce6; background: #f5f3fe; }

:root[data-theme="dark"] .gg-eod-presult,
[data-bs-theme="dark"] .gg-eod-presult { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.14); }
:root[data-theme="dark"] .gg-eod-map,
[data-bs-theme="dark"] .gg-eod-map { color: #94a3b8; }
:root[data-theme="dark"] .gg-eod-warn,
[data-bs-theme="dark"] .gg-eod-warn { color: #fbbf24; }
:root[data-theme="dark"] .gg-eod-presult-ok,
[data-bs-theme="dark"] .gg-eod-presult-ok { color: #4ade80; }
:root[data-theme="dark"] .gg-eod-in.is-pasted,
[data-bs-theme="dark"] .gg-eod-in.is-pasted { border-color: #9b8ce6; background: rgba(155, 140, 230, 0.22); }

.gg-sum-h2 {
    font-size: 1rem; font-weight: 700; color: #164F73;
    margin: 1.5rem 0 0.625rem; padding-left: 0.5rem; border-left: 4px solid #2AAE9B;
}

/* Timeline */
.gg-sum-timeline th { background: #1e293b; color: #fff; }
.gg-sum-timeline th.c-total, .gg-sum-timeline td.c-total {
    background: #f5e199; color: #1e293b; font-weight: 700; border-left: 2px solid #cbd5e1;
}
.gg-sum-timeline th.c-total { background: #eda45f; color: #fff; }

/* ต่อพนักงาน */
.gg-sum-people th { background: #1e293b; color: #fff; white-space: nowrap; }
/* กลุ่มหัวตาราง 3 สี: น้ำเงิน=ข้อมูลดิบ · ชมพู=%PFM · เขียว=อันดับ */
.gg-sum-people th.h-b { background: #4472c4; color: #fff; }
.gg-sum-people th.h-p { background: #c98d88; color: #fff; }
.gg-sum-people th.h-g { background: #a9d18e; color: #1e293b; }
.gg-sum-people .gg-pos { color: #15803d; font-weight: 700; }
.gg-sum-people .gg-neg { color: #dc2626; font-weight: 700; }
.gg-sum-people .c-rank1 { color: #b7791f; font-weight: 800; }
.gg-sum-people .c-rank2 { color: #64748b; font-weight: 800; }
.gg-sum-people .c-rank3 { color: #b45309; font-weight: 800; }
.gg-sum-people tr.gg-sum-all td { background: #ffef9f; color: #1e293b; font-weight: 800; }
:root[data-theme="dark"] .gg-sum-people tr.gg-sum-all td,
[data-bs-theme="dark"] .gg-sum-people tr.gg-sum-all td { background: #6b5d1f; color: #fde68a; }
:root[data-theme="dark"] .gg-sum-people .c-rank1,
[data-bs-theme="dark"] .gg-sum-people .c-rank1 { color: #fbbf24; }
.gg-badge-ok {
    background: #16a34a; color: #fff; border-radius: 20px;
    padding: 0.125rem 0.625rem; font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}
.gg-badge-miss {
    background: #fee2e2; color: #b91c1c; border-radius: 20px;
    padding: 0.125rem 0.625rem; font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}

/* รายทีม */
.gg-sum-teams th { background: #1e293b; color: #fff; }
.gg-sum-teams .gg-pos { color: #15803d; font-weight: 700; }
.gg-sum-teams .gg-neg { color: #fecaca; font-weight: 700; }
.gg-sum-teams tr.gg-sum-all td { background: #eda45f; color: #fff; font-weight: 800; }
.gg-sum-teams tr.gg-sum-all .gg-pos { color: #dcfce7; }

.gg-sum-people .c-rankno,
.gg-sum-rank .c-rankno { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ── สรุปผลยอดเยี่ยม ── */
.gg-sum-best { max-width: 640px; }
.gg-sum-best td { padding: 0.6rem 0.9rem; font-size: 0.95rem; vertical-align: middle; }
.gg-sum-best .c-rankno { width: 2.2rem; color: #94a3b8; font-weight: 800; }
.gg-sum-best .c-bestval { color: #164F73; font-size: 1.05rem; }
.gg-sum-best tr { border-bottom: 1px solid #eef2f6; }
.gg-sum-best tr:nth-child(1) td { background: linear-gradient(90deg, #fff7e6, transparent); }

/* ── จัดอันดับ RANK ── */
.gg-sum-rank th { background: #1e293b; color: #fff; }
.gg-sum-rank .gg-pos { color: #15803d; font-weight: 700; }
.gg-sum-rank .gg-neg { color: #dc2626; font-weight: 700; }
.gg-sum-rank .c-rank1 { color: #b7791f; }
.gg-sum-rank .c-rank2 { color: #64748b; }
.gg-sum-rank .c-rank3 { color: #b45309; }

:root[data-theme="dark"] .gg-sum-best .c-bestval,
[data-bs-theme="dark"] .gg-sum-best .c-bestval { color: var(--text-accent, #F4C84A); }
:root[data-theme="dark"] .gg-sum-best tr,
[data-bs-theme="dark"] .gg-sum-best tr { border-color: rgba(255, 255, 255, 0.1); }
:root[data-theme="dark"] .gg-sum-best tr:nth-child(1) td,
[data-bs-theme="dark"] .gg-sum-best tr:nth-child(1) td { background: linear-gradient(90deg, rgba(244, 200, 74, 0.14), transparent); }
:root[data-theme="dark"] .gg-sum-rank .gg-neg,
[data-bs-theme="dark"] .gg-sum-rank .gg-neg { color: #fca5a5; }
:root[data-theme="dark"] .gg-sum-rank .c-rank1,
[data-bs-theme="dark"] .gg-sum-rank .c-rank1 { color: #fbbf24; }

/* ── ปุ่มลอย "อัพสแตท" (CRM) ── */
.gg-stat-fab {
    position: fixed; top: 74px; right: 22px; z-index: 1035;
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.6rem 1.05rem; border: none; border-radius: 999px;
    background: linear-gradient(135deg, #2AAE9B, #1c8f80); color: #fff;
    font-weight: 700; font-size: 0.9rem; cursor: pointer;
    box-shadow: 0 8px 22px rgba(42, 174, 155, 0.4);
    transition: transform .12s ease, box-shadow .12s ease;
}
.gg-stat-fab:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(42, 174, 155, 0.5); }
.gg-stat-fab:active { transform: translateY(0); }
.gg-stat-fab i { font-size: 1.05rem; }
@media (max-width: 640px) {
    .gg-stat-fab { top: auto; bottom: 20px; right: 16px; padding: 0.7rem 1rem; }
    .gg-stat-fab span { display: none; }
    .gg-stat-fab i { font-size: 1.25rem; }
}
.gg-stat-sec {
    font-weight: 700; font-size: 0.82rem; color: var(--text-accent, #164F73);
    margin: 0.5rem 0 0.15rem; padding-bottom: 0.15rem; border-bottom: 1px solid var(--border, #e5e7eb);
}
.gg-stat-in:read-only {
    background: #f1f5f9; color: #64748b; cursor: not-allowed; border-style: dashed;
}
:root[data-theme="dark"] .gg-stat-in:read-only,
[data-bs-theme="dark"] .gg-stat-in:read-only {
    background: rgba(255, 255, 255, 0.04); color: #94a3b8;
}

/* ── หัวรายงานสำหรับ Export PNG ── */
.gg-exp-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px; padding-bottom: 18px; margin-bottom: 14px;
    border-bottom: 2px solid #eef2f6;
}
.gg-exp-brand { display: flex; align-items: center; gap: 16px; }
.gg-exp-logo { width: 66px; height: 66px; object-fit: contain; border-radius: 50%; }
.gg-exp-title { font-size: 1.9rem; font-weight: 800; color: #1e2a4a; line-height: 1.1; }
.gg-exp-sub { font-size: 1.05rem; font-weight: 700; color: #2AAE9B; margin-top: 2px; }
.gg-exp-card {
    background: #1e2a4a; border-radius: 16px; padding: 14px 18px;
    display: flex; flex-direction: column; gap: 8px; min-width: 220px;
}
.gg-exp-date { color: #fff; text-align: center; font-weight: 700; font-size: 1.05rem; }
.gg-exp-pill {
    background: #fdf3c4; color: #1e2a4a; border-radius: 10px;
    padding: 6px 14px; text-align: center; font-weight: 700; white-space: nowrap;
}
.gg-exp-pill b { color: #7c5c12; background: #fbdf7e; padding: 0 7px; border-radius: 5px; margin: 0 2px; }

@media print {
    .gg-summary { border: none; padding: 0; }
    .d-print-none { display: none !important; }
}

/* ── รายงานย้อนหลัง Upsale ── */
.gg-ups-badge {
    display: inline-block; padding: 0.1rem 0.55rem; border-radius: 20px;
    font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}
.gg-ups-badge.r-ok      { background: #16a34a; color: #fff; }
.gg-ups-badge.r-no      { background: #fee2e2; color: #b91c1c; }
.gg-ups-badge.r-pending { background: #fef3c7; color: #92400e; }
.gg-ups-badge.r-closed  { background: #e0e7ff; color: #3730a3; }
.gg-ups-badge.r-open    { background: #f1f5f9; color: #475569; }
#upsCrm .gg-pos { color: #15803d; font-weight: 700; }
#upsCrm .gg-neg { color: #dc2626; font-weight: 700; }

/* ── ตารางสิทธิ์การเข้าถึง ── */
.gg-perm-table { width: 100%; }
.gg-perm-table th, .gg-perm-table td { text-align: center; vertical-align: middle; padding: 0.6rem 0.75rem; }
.gg-perm-table thead th { font-size: 0.8rem; color: var(--muted-fg); border-bottom: 2px solid var(--border); }
.gg-perm-table thead th.c-ceo, .gg-perm-table td.c-ceo { background: color-mix(in srgb, var(--gg-teal) 10%, transparent); }
.gg-perm-table td.c-ceo .bi { color: var(--gg-teal); font-size: 1.1rem; }
.gg-perm-page { font-weight: 600; }
.gg-perm-section td {
    background: var(--muted); color: var(--fg); font-weight: 700; text-align: left;
    font-size: 0.78rem; letter-spacing: 0.02em; text-transform: uppercase;
}
.gg-perm-table tbody tr[data-key]:hover td { background: color-mix(in srgb, var(--gg-teal) 5%, transparent); }
.gg-perm-table tbody tr[data-key]:hover td.c-ceo { background: color-mix(in srgb, var(--gg-teal) 14%, transparent); }

/* checkbox แบบสวิตช์เล็ก */
.gg-perm-check { display: inline-flex; cursor: pointer; margin: 0; }
.gg-perm-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.gg-perm-check span {
    width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1;
    position: relative; transition: background 0.15s; display: inline-block;
}
.gg-perm-check span::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.gg-perm-check input:checked + span { background: var(--gg-teal); }
.gg-perm-check input:checked + span::after { transform: translateX(18px); }
.gg-perm-check input:focus-visible + span { outline: 2px solid var(--gg-teal); outline-offset: 2px; }
[data-bs-theme="dark"] .gg-perm-check span { background: #475569; }

/* =====================================================================
   ยอดขายของฉัน (My Sales) — สไตล์ spreadsheet ใกล้ Sheet
   ===================================================================== */
.gg-ms-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .gg-ms-layout { grid-template-columns: 1fr; } }
.gg-ms-left, .gg-ms-right { min-width: 0; }
.gg-ms-right { display: flex; flex-direction: column; gap: 0.75rem; }

/* หัวเป้า */
.gg-ms-head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
    background: #f4e2a1; color: #5a4a10; border: 1px solid #e5cd7a;
    border-radius: 10px 10px 0 0; padding: 0.6rem 0.9rem;
}
.gg-ms-head-title { font-weight: 800; font-size: 1.05rem; }
.gg-ms-head-goals { display: flex; gap: 0.6rem; margin-left: auto; }
.gg-ms-goal {
    background: #fff; border: 1px solid #e5cd7a; border-radius: 8px; padding: 0.2rem 0.7rem;
    display: flex; align-items: baseline; gap: 0.4rem; font-size: 0.8rem; color: #6b5a1e;
}
.gg-ms-goal b { font-size: 1.05rem; color: #164F73; }
.gg-ms-goal-min b { color: #b45309; }
.gg-ms-who { font-size: 0.85rem; color: var(--fg); padding: 0.4rem 0.2rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.gg-ms-updated { color: var(--muted-fg); margin-left: auto; font-size: 0.75rem; }
.gg-ms-notarget { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; border-radius: 8px; padding: 0.5rem 0.8rem; font-size: 0.85rem; margin-bottom: 0.5rem; }

/* ตาราง */
.gg-ms-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; max-height: 70vh; }
.gg-ms-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gg-ms-table th, .gg-ms-table td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0.28rem 0.5rem; text-align: right; }
.gg-ms-table thead th {
    position: sticky; top: 0; z-index: 3; background: #1e293b; color: #fff;
    text-align: center; font-weight: 600; font-size: 0.72rem;
}
.gg-ms-table .c-day { position: sticky; left: 0; z-index: 2; text-align: center; background: var(--card); font-weight: 600; }
.gg-ms-table thead .c-day { z-index: 4; background: #1e293b; }
.gg-ms-table tbody tr:hover td { background: color-mix(in srgb, var(--gg-teal) 8%, transparent); }
.gg-ms-table tbody tr:hover .c-day { background: color-mix(in srgb, var(--gg-teal) 14%, var(--card)); }
.gg-ms-table tr.is-today td { background: #fff7d6; }
.gg-ms-table tr.is-today .c-day { background: #ffe9a6; }

/* สีคอลัมน์ตาม Sheet */
.gg-ms-table td.c-prod  { background: #fdf7dc; }
.gg-ms-table td.c-crm   { background: #e6f2e6; font-weight: 600; }
.gg-ms-table td.c-up    { background: #fbeeb5; }
.gg-ms-table td.c-total { background: #ece3f5; }
.gg-ms-table td.c-ret   { background: #fbe2e6; }
.gg-ms-table td.c-net   { background: #dcefe4; font-weight: 600; }
.gg-ms-table td.c-ord   { background: #eef1f4; text-align: center; }
.gg-ms-table td.c-real  { background: #eaf1fb; }
.gg-ms-table td.c-diff  { text-align: center; }
/* dark mode: ผสมสี accent เข้ากับพื้นการ์ด → สีสะอาด สว่าง ไม่ทึบมืด */
[data-bs-theme="dark"] .gg-ms-table td.c-prod  { background: color-mix(in srgb, #F4C84A 26%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-crm   { background: color-mix(in srgb, #2AAE9B 30%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-up    { background: color-mix(in srgb, #F4C84A 34%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-total { background: color-mix(in srgb, #9A86E6 32%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-ret   { background: color-mix(in srgb, #EF5B63 28%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-net   { background: color-mix(in srgb, #2AAE9B 32%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-ord   { background: color-mix(in srgb, #5AA9E6 26%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table td.c-real  { background: color-mix(in srgb, #5AA9E6 32%, var(--card)); }
/* แถววันนี้ (เดิมพื้นสว่างจนตัวหนังสือหาย) */
[data-bs-theme="dark"] .gg-ms-table tr.is-today td { background: color-mix(in srgb, #F4C84A 36%, var(--card)); }
[data-bs-theme="dark"] .gg-ms-table tr.is-today .c-day { background: color-mix(in srgb, #F4C84A 46%, var(--card)); color: #fff; }
/* ช่องกรอกใน dark: พื้นจาง ๆ + กรอบ ให้รู้ว่าพิมพ์ได้ · hover/focus สว่างชัด */
[data-bs-theme="dark"] .ms-cell { border-color: rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .05); }
[data-bs-theme="dark"] .ms-cell:hover { border-color: rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .12); }
[data-bs-theme="dark"] .ms-cell:focus, [data-bs-theme="dark"] .ms-cell.is-editing { background: color-mix(in srgb, var(--gg-teal) 28%, var(--card)); border-color: var(--gg-teal); }

/* แถวรวม */
.gg-ms-table tfoot .gg-ms-total td { position: sticky; bottom: 0; background: #eda45f; color: #3a1f06; font-weight: 800; z-index: 2; }
.gg-ms-table tfoot .gg-ms-total .c-day { background: #e0872f; color: #fff; z-index: 3; }

.gg-ms-diff { font-weight: 700; padding: 0.05rem 0.4rem; border-radius: 5px; font-size: 0.72rem; }
.gg-ms-diff.st-match { color: #15803d; }
.gg-ms-diff.st-short { background: #fee2e2; color: #b91c1c; }
.gg-ms-diff.st-over  { background: #ffedd5; color: #c2410c; }
.st-none { color: var(--muted-fg); }

/* กล่องสรุปล่างซ้าย */
.gg-ms-sumbox { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: stretch; }
.gg-ms-sumtable { border-collapse: collapse; font-size: 0.82rem; flex: 1; min-width: 320px; }
.gg-ms-sumtable th, .gg-ms-sumtable td { border: 1px solid var(--border); padding: 0.35rem 0.7rem; text-align: right; }
.gg-ms-sumtable th { background: var(--muted); text-align: center; font-size: 0.75rem; }
.gg-ms-sumtable td:first-child { text-align: left; font-weight: 600; }
.gg-ms-sumtable .gg-ms-ret { color: #dc2626; }
.gg-ms-net { background: #164F73; color: #fff; border-radius: 10px; padding: 0.5rem 1.1rem; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 150px; }
.gg-ms-net span { font-size: 0.78rem; opacity: 0.85; }
.gg-ms-net b { font-size: 1.5rem; }

/* แผงขวา */
.gg-ms-panel { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 0.9rem; }
.gg-ms-panel-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.4rem; }
.gg-ms-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding: 0.18rem 0; font-size: 0.85rem; }
.gg-ms-rows > div span { color: var(--muted-fg); }
.gg-ms-rows > div b { font-variant-numeric: tabular-nums; }
.gg-ms-sep { border-top: 1px dashed var(--border); margin: 0.25rem 0; height: 0; padding: 0 !important; }
.gg-pos { color: #15803d; } .gg-neg { color: #dc2626; }

.gg-ms-gear { margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted-fg); cursor: pointer; padding: 0.1rem 0.4rem; }
.gg-ms-gear:hover { color: var(--gg-teal); }

/* commission level table */
.gg-ms-lvtable { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.gg-ms-lvtable th, .gg-ms-lvtable td { border: 1px solid var(--border); padding: 0.22rem 0.4rem; text-align: right; }
.gg-ms-lvtable th { background: #4b7d54; color: #fff; text-align: center; font-size: 0.7rem; }
.gg-ms-lvtable td:first-child { text-align: center; font-weight: 700; }
.gg-ms-lvtable tr.is-current td { background: #d1fae5; color: #14532d; font-weight: 700; }
.gg-ms-lvtable tr.is-off { opacity: 0.45; }

/* commission boxes */
.gg-ms-commbox { background: #eef6ee; border: 1px solid #cfe3cf; border-radius: 10px; padding: 0.55rem 0.8rem; margin-bottom: 0.5rem; }
.gg-ms-commbox.is-hi { border-color: var(--gg-orange); box-shadow: 0 0 0 1px var(--gg-orange) inset; }
.gg-ms-commbox-t { font-weight: 700; font-size: 0.82rem; margin-bottom: 0.3rem; color: var(--text-accent); }
.gg-ms-commbox-r { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 0.08rem 0; }
.gg-ms-commbox-r span { color: var(--muted-fg); }
.gg-ms-commbox-r.total { border-top: 1px solid #cfe3cf; margin-top: 0.2rem; padding-top: 0.3rem; font-weight: 800; }
.gg-ms-commbox-r.total b { color: var(--gg-orange); }
.gg-ms-tonext { font-size: 0.78rem; color: #b45309; text-align: center; margin: -0.2rem 0 0.5rem; }
[data-bs-theme="dark"] .gg-ms-commbox { background: #16281a; border-color: #24402a; }

/* compare panel */
.gg-ms-compare-status { text-align: center; font-weight: 800; padding: 0.3rem; border-radius: 8px; margin-top: 0.4rem; }
.gg-ms-compare.st-match .gg-ms-compare-status { background: #d1fae5; color: #15803d; }
.gg-ms-compare.st-short .gg-ms-compare-status { background: #fee2e2; color: #b91c1c; }
.gg-ms-compare.st-over  .gg-ms-compare-status { background: #ffedd5; color: #c2410c; }
.gg-ms-compare.st-none  .gg-ms-compare-status { background: var(--muted); color: var(--muted-fg); }
.gg-ms-compare-note { font-size: 0.72rem; color: var(--muted-fg); text-align: center; margin-top: 0.3rem; }
.gg-ms-savestate { font-size: 0.78rem; color: var(--muted-fg); }
/* modal compare diff text */
td.st-match { color: #15803d; } td.st-short { color: #dc2626; } td.st-over { color: #c2410c; }

/* editable cells */
.ms-cell {
    width: 100%; min-width: 46px; border: 1px solid transparent; background: transparent;
    text-align: right; font: inherit; color: inherit; padding: 0.1rem 0.15rem; border-radius: 4px;
    font-variant-numeric: tabular-nums;
}
.ms-cell:hover { border-color: var(--border); }
.ms-cell:focus, .ms-cell.is-editing { outline: none; border-color: var(--gg-teal); background: color-mix(in srgb, var(--gg-teal) 12%, var(--card)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gg-teal) 25%, transparent); position: relative; z-index: 1; }
.ms-cell.saved-flash { animation: msSaved 0.7s ease; }
@keyframes msSaved { 0% { background: #bbf7d0; } 100% { background: transparent; } }
.ms-cell.is-error { border-color: var(--gg-red); background: color-mix(in srgb, var(--gg-red) 15%, transparent); }

.gg-ms-ro { color: var(--muted-fg); font-size: 0.78rem; font-weight: 400; }

/* save state indicator */
.ms-ss { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; }
.ms-ss-wait { color: #b45309; }
.ms-ss-saving { color: var(--gg-teal); }
.ms-ss-ok { color: #15803d; }
.ms-ss-err { color: var(--gg-red); }

/* =====================================================================
   Customer Leads (ข้อมูลรายชื่อ)
   ===================================================================== */
.lead-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; border-bottom: 2px solid var(--border, #e5e7eb); margin-bottom: 1rem; }
.lead-tab-btn { background: none; border: none; padding: 0.6rem 1rem; font-weight: 600; font-size: 0.9rem; color: var(--muted-fg, #64748b); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.lead-tab-btn:hover { color: var(--text-accent, #164F73); }
.lead-tab-btn.active { color: var(--text-accent, #164F73); border-bottom-color: #2AAE9B; }

/* KPI cards (clickable) */
.lead-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.lead-kpi { text-align: left; border: 1px solid var(--border, #e5e7eb); border-left: 4px solid #94a3b8; border-radius: 12px; padding: 0.7rem 0.9rem; background: var(--card, #fff); cursor: pointer; transition: transform .1s, box-shadow .1s; }
.lead-kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15,23,42,.08); }
.lead-kpi-val { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--text-accent, #164F73); }
.lead-kpi-label { font-size: 0.76rem; color: var(--muted-fg, #64748b); margin-top: 0.2rem; }
.lead-kpi.k-teal { border-left-color: #2AAE9B; } .lead-kpi.k-green { border-left-color: #16a34a; }
.lead-kpi.k-orange { border-left-color: #F37B2A; } .lead-kpi.k-red { border-left-color: #EF5B63; }
.lead-kpi.k-yellow { border-left-color: #F4C84A; } .lead-kpi.k-purple { border-left-color: #7E57C2; }
.lead-kpi.k-blue { border-left-color: #164F73; } .lead-kpi.k-gray { border-left-color: #8A94A6; }

.lead-overview-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .lead-overview-cols { grid-template-columns: 1fr; } }
.lead-camp-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0; border-top: 1px solid var(--border, #eef2f6); font-size: 0.86rem; }
.lead-camp-row:first-child { border-top: 0; }
.lead-camp-name { font-weight: 600; flex: 1; } .lead-camp-nums { color: var(--muted-fg, #64748b); font-size: 0.8rem; }
.lead-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; margin-right: 0.35rem; }
.lead-task { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0; border-top: 1px solid var(--border, #eef2f6); }
.lead-task:first-child { border-top: 0; }
.lead-task-time { font-weight: 800; color: var(--text-accent, #164F73); width: 3.2rem; }
.lead-task-main { flex: 1; min-width: 0; } .lead-task-name { font-weight: 600; } .lead-task-phone { font-size: 0.8rem; color: var(--muted-fg, #64748b); }

/* quick filter chips */
.lead-quickfilters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.lead-chip { border: 1px solid var(--border, #d7dee7); background: var(--card, #fff); border-radius: 999px; padding: 0.28rem 0.85rem; font-size: 0.82rem; font-weight: 600; color: var(--muted-fg, #64748b); cursor: pointer; }
.lead-chip:hover { border-color: #2AAE9B; }
.lead-chip.active { background: #2AAE9B; border-color: #2AAE9B; color: #fff; }
.lead-filterbar .lead-f { display: flex; flex-direction: column; }
.lead-filterbar .lead-f label { font-size: 0.7rem; color: var(--muted-fg, #64748b); margin-bottom: 2px; font-weight: 600; }
.lead-filterbar .lead-f input, .lead-filterbar .lead-f select { min-width: 130px; }

/* table */
.lead-table-wrap { overflow-x: auto; max-height: 68vh; overflow-y: auto; }
.lead-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
.lead-table thead th { position: sticky; top: 0; z-index: 3; background: #1e293b; color: #fff; text-align: left; padding: 0.6rem 0.7rem; white-space: nowrap; font-weight: 600; }
.lead-table th.sortable { cursor: pointer; } .lead-table th.sortable:hover { background: #273449; }
.lead-table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border, #eef2f6); vertical-align: middle; }
.lead-table tbody tr { cursor: pointer; } .lead-table tbody tr:hover td { background: rgba(42,174,155,.06); }
.lead-table .sticky-col { position: sticky; left: 0; z-index: 2; background: var(--card, #fff); box-shadow: 2px 0 4px rgba(0,0,0,.04); }
.lead-table thead .sticky-col { z-index: 4; background: #1e293b; }
.lead-table tbody tr:hover .sticky-col { background: #eef7f5; }
.lead-table tr.row-sold td { background: #eafaf1; } .lead-table tr.row-sold:hover td { background: #ddf5e8; }
.lead-table tr.row-sold .sticky-col { background: #eafaf1; }
.lead-table tr.row-overdue td.lt-flag { box-shadow: inset 3px 0 0 #EF5B63; }
/* เม็ดยา: เหลือง = ใกล้หมดภายใน 3 วัน · แดง = หมดแล้วยังไม่ ReOrder (ทับสีขายได้ เพราะต้องตาม ReOrder ก่อน) */
.lead-table tr.row-pill-soon td, .lead-table tr.row-pill-soon .sticky-col { background: #fff4c2; }
.lead-table tr.row-pill-soon:hover td, .lead-table tr.row-pill-soon:hover .sticky-col { background: #ffeb99; }
.lead-table tr.row-pill-out td, .lead-table tr.row-pill-out .sticky-col { background: #fde0e2; }
.lead-table tr.row-pill-out:hover td, .lead-table tr.row-pill-out:hover .sticky-col { background: #fbcdd1; }
.lt-pill { width: 1px; white-space: nowrap; }
.lead-pill-input { width: 72px; padding: .15rem .4rem; font-size: .8rem; text-align: right; display: inline-block; }
.lt-runout { white-space: nowrap; line-height: 1.2; }
.lt-name { min-width: 160px; } .lt-flag { width: 1px; white-space: nowrap; }
.lead-pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 20px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.lead-badge { display: inline-block; padding: 0.05rem 0.4rem; border-radius: 5px; font-size: 0.64rem; font-weight: 700; margin-right: 3px; }
.lead-badge.b-new { background: #2AAE9B; color: #fff; } .lead-badge.b-overdue { background: #EF5B63; color: #fff; } .lead-badge.b-pull { background: #F4C84A; color: #4a3a08; }
.lead-topic { display: inline-block; padding: 0.02rem 0.4rem; border-radius: 5px; font-size: 0.68rem; font-weight: 600; margin-left: 3px; }

/* drawer */
.lead-drawer-backdrop { position: fixed; inset: 0; background: rgba(10,15,25,.45); z-index: 1050; }
.lead-drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(460px, 94vw); background: var(--card, #fff); z-index: 1051; box-shadow: -8px 0 30px rgba(0,0,0,.25); transform: translateX(100%); transition: transform .25s ease; overflow-y: auto; }
.lead-drawer.open { transform: translateX(0); }
.lead-drawer-head { padding: 1.2rem 1.2rem 0.8rem; border-bottom: 1px solid var(--border, #eef2f6); position: relative; }
.lead-drawer-close { position: absolute; top: 0.9rem; right: 0.9rem; background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--muted-fg, #64748b); }
.lead-drawer-name { font-size: 1.25rem; font-weight: 800; } .lead-drawer-code { font-size: 0.78rem; }
.lead-drawer-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border, #eef2f6); }
.lead-drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 1rem; padding: 1rem 1.2rem; }
.lead-drawer-grid span { display: block; font-size: 0.72rem; color: var(--muted-fg, #64748b); } .lead-drawer-grid b { font-size: 0.9rem; }
.lead-drawer-note { padding: 0 1.2rem 0.8rem; font-size: 0.85rem; } .lead-drawer-note span { color: var(--muted-fg, #64748b); font-size: 0.72rem; display: block; }
.lead-drawer-sec { padding: 0.8rem 1.2rem; border-top: 1px solid var(--border, #eef2f6); }
.lead-drawer-sec h4 { font-size: 0.82rem; font-weight: 700; color: var(--text-accent, #164F73); margin-bottom: 0.6rem; letter-spacing: .5px; }
.lead-fu-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; padding: 0.4rem 0; font-size: 0.82rem; border-bottom: 1px dashed var(--border, #eef2f6); }
.lead-fu-row:last-of-type { border-bottom: 0; }
.lead-fu-main { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; min-width: 0; }
.lead-fu-when { font-weight: 600; } .lead-fu-status { font-size: 0.72rem; color: var(--muted-fg, #64748b); }
.lead-fu-note { flex-basis: 100%; font-size: 0.76rem; }
.lead-fu-acts { display: flex; gap: 0.3rem; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.lead-fu-row.lead-fu-completed, .lead-fu-row.lead-fu-cancelled, .lead-fu-row.lead-fu-rescheduled { opacity: .55; }
/* ตั้งนัดใหม่ (form) */
.lead-fu-form { margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--border, #eef2f6); }
.lead-fu-form-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.lead-fu-form-row > * { flex: 1 1 160px; min-width: 0; }
.lead-tl { position: relative; } .lead-tl-item { display: flex; gap: 0.6rem; padding: 0.35rem 0; }
.lead-tl-dot { width: 9px; height: 9px; border-radius: 50%; background: #2AAE9B; margin-top: 5px; flex: 0 0 auto; }
.lead-tl-act { font-size: 0.84rem; font-weight: 600; } .lead-tl-note { font-size: 0.8rem; color: #475569; } .lead-tl-meta { font-size: 0.72rem; color: var(--muted-fg, #94a3b8); }
.lead-drawer-hint { padding: 0.8rem 1.2rem 1.5rem; font-size: 0.78rem; }
.lead-pullout-banner { background: rgba(220,38,38,.08); color: #b91c1c; border: 1px solid rgba(220,38,38,.25); border-radius: .5rem; padding: .5rem .7rem; font-size: .82rem; }
:root[data-theme="dark"] .lead-pullout-banner, [data-bs-theme="dark"] .lead-pullout-banner { background: rgba(248,113,113,.14); color: #fca5a5; border-color: rgba(248,113,113,.3); }

/* Customer Leads — Import wizard (Phase 7) */
.lead-imp-steps { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.lead-imp-step { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted-fg, #64748b); padding: .35rem .7rem; border-radius: 999px; background: var(--card, #fff); border: 1px solid var(--border, #e2e8f0); }
.lead-imp-step span { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--border, #e2e8f0); color: #fff; font-size: .72rem; font-weight: 700; }
.lead-imp-step.active { border-color: #2AAE9B; color: #2AAE9B; font-weight: 600; }
.lead-imp-step.active span { background: #2AAE9B; }
.lead-imp-step.done span { background: #2AAE9B; }
.lead-upload { border: 2px dashed var(--border, #cbd5e1); border-radius: .8rem; padding: 2rem 1rem; text-align: center; color: var(--muted-fg, #64748b); transition: .15s; }
.lead-upload.drag { border-color: #2AAE9B; background: rgba(42,174,155,.06); }
.lead-map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.lead-map-row { display: flex; flex-direction: column; gap: .2rem; }
.lead-map-row label { font-size: .8rem; font-weight: 600; }
.lead-imp-stats { display: flex; gap: .6rem; flex-wrap: wrap; }
.lead-imp-stat { flex: 1 1 120px; border-radius: .6rem; padding: .7rem; text-align: center; border: 1px solid var(--border, #e2e8f0); }
.lead-imp-stat b { display: block; font-size: 1.5rem; line-height: 1; }
.lead-imp-stat span { font-size: .76rem; color: var(--muted-fg, #64748b); }
.lead-imp-stat.s-ok { background: rgba(42,174,155,.08); border-color: rgba(42,174,155,.3); }
.lead-imp-stat.s-warn { background: rgba(244,200,74,.1); border-color: rgba(244,200,74,.35); }
.lead-imp-stat.s-dup { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.3); }
.lead-imp-stat.s-err { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.3); }
.lead-imp-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; }
.lead-imp-tag { font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; }
.lead-imp-tag.t-ok { background: rgba(42,174,155,.15); color: #1c8f80; }
.lead-imp-tag.t-warn { background: rgba(244,200,74,.2); color: #8a6d1a; }
.lead-imp-tag.t-dup { background: rgba(59,130,246,.15); color: #2563eb; }
.lead-imp-tag.t-err { background: rgba(220,38,38,.15); color: #b91c1c; }
.lead-table tr.imp-row-error { opacity: .6; }

/* toggle + checkbox (Phase 9 notification settings) */
.gg-switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.gg-switch input { width: 42px; height: 24px; appearance: none; -webkit-appearance: none; background: var(--border, #cbd5e1); border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; flex: 0 0 auto; }
.gg-switch input::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .15s; }
.gg-switch input:checked { background: #2AAE9B; }
.gg-switch input:checked::after { left: 21px; }
.gg-check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; padding: .4rem .6rem; border: 1px solid var(--border, #e2e8f0); border-radius: .5rem; font-size: .88rem; }
.gg-check input { width: 16px; height: 16px; accent-color: #2AAE9B; }

/* click-to-copy phone (lead tables) */
.lead-copy { display: inline-flex; align-items: center; gap: .35rem; background: none; border: 0; padding: .1rem .25rem; margin: -.1rem -.25rem; border-radius: .35rem; cursor: pointer; color: inherit; font: inherit; font-variant-numeric: tabular-nums; }
.lead-copy i { font-size: .8em; opacity: .35; transition: opacity .12s; }
.lead-copy:hover { background: rgba(42,174,155,.1); color: #1c8f80; }
.lead-copy:hover i { opacity: .8; }
.lead-copy.copied { background: rgba(42,174,155,.18); color: #1c8f80; }
.lead-copy.copied i::before { content: "\F26B"; } /* bi-check-lg */

/* ไฮไลต์แถวที่เพิ่งอัปเดตในที่ (ไม่รีโหลดทั้งตาราง) */
@keyframes leadRowFlash { from { background: rgba(42,174,155,.28); } to { background: transparent; } }
.lead-table tr.row-flash td { animation: leadRowFlash 1.2s ease-out; }

/* inline edit (สถานะ/นัดหมาย ในแถว) */
.lead-inline-edit { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: .25rem; border-radius: .4rem; }
.lead-inline-status { padding: .1rem .3rem; margin: -.1rem -.3rem; }
.lead-inline-status i { font-size: .62rem; opacity: .4; }
.lead-inline-status:hover { background: rgba(42,174,155,.1); outline: 1px dashed rgba(42,174,155,.5); }
.lead-inline-appt { margin-left: .4rem; color: #2AAE9B; opacity: .55; }
.lead-inline-appt:hover { opacity: 1; }
.lead-popover { position: absolute; z-index: 1080; min-width: 200px; max-width: 260px; background: var(--card, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: .6rem; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: .5rem; }
.lead-pop-title { font-size: .72rem; font-weight: 700; color: var(--muted-fg, #64748b); letter-spacing: .3px; padding: .1rem .2rem .4rem; }
.lead-pop-list { display: flex; flex-direction: column; gap: .25rem; }
.lead-pop-item { text-align: left; background: var(--card, #fff); border: 1px solid var(--border, #eef2f6); border-radius: .4rem; padding: .4rem .55rem; font-size: .85rem; cursor: pointer; color: inherit; }
.lead-pop-item:hover { background: rgba(42,174,155,.08); border-color: #2AAE9B; }
.lead-pop-item.ok { border-left: 3px solid #2AAE9B; } .lead-pop-item.no { border-left: 3px solid #E5573F; }
:root[data-theme="dark"] .lead-popover, [data-bs-theme="dark"] .lead-popover { background: var(--card, #1c2530); }

:root[data-theme="dark"] .lead-table .sticky-col, [data-bs-theme="dark"] .lead-table .sticky-col { background: var(--card, #1c2530); }
:root[data-theme="dark"] .lead-table tr.row-sold td, [data-bs-theme="dark"] .lead-table tr.row-sold td { background: rgba(22,163,74,.14); }
:root[data-theme="dark"] .lead-table tr.row-sold .sticky-col, [data-bs-theme="dark"] .lead-table tr.row-sold .sticky-col { background: rgba(22,163,74,.14); }
:root[data-theme="dark"] .lead-table tr.row-pill-soon td, [data-bs-theme="dark"] .lead-table tr.row-pill-soon td,
:root[data-theme="dark"] .lead-table tr.row-pill-soon .sticky-col, [data-bs-theme="dark"] .lead-table tr.row-pill-soon .sticky-col { background: rgba(244,200,74,.22); }
:root[data-theme="dark"] .lead-table tr.row-pill-out td, [data-bs-theme="dark"] .lead-table tr.row-pill-out td,
:root[data-theme="dark"] .lead-table tr.row-pill-out .sticky-col, [data-bs-theme="dark"] .lead-table tr.row-pill-out .sticky-col { background: rgba(239,91,99,.22); }

/* Customer Leads — status change controls (Phase 4) */
.lead-status-sec .lead-st-btns { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lead-st-btn { background: var(--card, #fff); border: 1.5px solid #cbd5e1; border-radius: 8px; padding: 0.4rem 0.8rem; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.lead-st-btn:hover { filter: brightness(0.96); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.lead-sub-box, .lead-reason-box { margin-top: 0.7rem; padding: 0.7rem; background: rgba(0,0,0,.03); border-radius: 8px; }
.lead-sub-label { font-size: 0.78rem; color: var(--muted-fg, #64748b); margin-bottom: 0.4rem; }
.lead-sub-btns { display: flex; gap: 0.5rem; }
.lead-sub-btn { flex: 1; border: none; border-radius: 8px; padding: 0.55rem; font-weight: 700; font-size: 0.9rem; cursor: pointer; color: #fff; }
.lead-sub-btn.sub-sold { background: #2AAE9B; } .lead-sub-btn.sub-sold:hover { background: #1c8f80; }
.lead-sub-btn.sub-notsold { background: #F4C84A; color: #4a3a08; } .lead-sub-btn.sub-notsold:hover { background: #e8b93a; }
:root[data-theme="dark"] .lead-sub-box, [data-bs-theme="dark"] .lead-sub-box,
:root[data-theme="dark"] .lead-reason-box, [data-bs-theme="dark"] .lead-reason-box { background: rgba(255,255,255,.05); }

/* ── สรุปยอดรายคนของทีม (ด้านบนหน้า My Sales) ── */
.gg-ms-team-table { min-width: 940px; font-variant-numeric: tabular-nums; }
.gg-ms-team-table th { font-size: .72rem; color: var(--muted-fg); font-weight: 600; white-space: nowrap; }
.gg-ms-team-table td { font-size: .8rem; vertical-align: middle; white-space: nowrap; }
.gg-ms-team-table tfoot td { border-top: 2px solid var(--border-strong); font-size: .8rem; font-weight: 600; }
.gg-ms-grouphead th { font-size: .64rem; color: var(--muted-fg); font-weight: 700; letter-spacing: .02em;
    border-bottom: none; padding-bottom: 0; text-transform: none; }
.gg-ms-team-row { cursor: pointer; transition: background .12s; }
/* CRM ดูได้อย่างเดียว เปิดสมุดคนอื่นไม่ได้ → ไม่ต้องทำให้แถวดูกดได้ */
#msTeamSummary.is-static .gg-ms-team-row { cursor: default; }
#msTeamSummary.is-static .gg-ms-team-row:hover { background: transparent; }
#msTeamSummary.is-static .gg-ms-team-row.is-current:hover { background: var(--gg-teal-soft); }
.gg-ms-team-row:hover { background: var(--gg-teal-soft); }
.gg-ms-team-row.is-current { background: var(--gg-teal-soft); box-shadow: inset 3px 0 0 var(--gg-teal); }
.gg-ms-team-sub { font-size: .68rem; color: var(--muted-fg); font-weight: 400; }
.gg-ms-rank { font-size: .95rem; }
.gg-ms-name b { white-space: nowrap; }
/* คอลัมน์ยอดอัพ = ตัวเลขสีน้ำเงิน · กลุ่ม "วันนี้" = ไฮไลต์อ่อน */
.gg-ms-team-table .gg-ms-up { color: var(--gg-dark-blue); }
.gg-ms-team-table .gg-ms-today { background: color-mix(in srgb, var(--gg-teal) 8%, transparent); }
.gg-ms-bar { height: 6px; border-radius: 3px; background: var(--gg-teal-soft); overflow: hidden; }
.gg-ms-bar > div { height: 100%; border-radius: 3px; transition: width .3s ease; }
.gg-ms-pos { color: var(--gg-teal-dark); font-weight: 600; }
.gg-ms-neg { color: var(--gg-red); font-weight: 600; }
.gg-ms-team-total { font-size: .85rem; color: var(--muted-fg); }
.gg-ms-team-total b { color: var(--gg-teal-dark); font-size: 1rem; }
:root[data-theme="dark"] .gg-ms-team-table .gg-ms-up { color: var(--gg-light-teal); }

/* ── น้องนุ่น: สัตว์เลี้ยงประจำตัวบนหน้าแรก (เห็นเฉพาะ CRM เจ้าของเอง) ── */
.gg-pet-card {
    display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1rem;
    padding: 0.4rem 1rem 0.35rem; align-items: end;
    background: linear-gradient(120deg, color-mix(in srgb, var(--gg-yellow) 10%, var(--card)), var(--card) 62%);
}
.gg-pet-figure { position: relative; height: 288px; }
.gg-pet-figure img,
.gg-pet-figure video {
    position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
    height: 100%; width: auto; transition: opacity .3s ease;
}
/* ร่างที่มีคลิป = จิ้มได้ · เด้งเล็กน้อยตอนจิ้มเพื่อให้รู้ว่ากดโดน */
.gg-pet-figure.has-clip { cursor: pointer; }
.gg-pet-figure.is-poke { animation: gg-pet-poke .45s ease; }
@keyframes gg-pet-poke {
    0%   { transform: translateY(0) scale(1); }
    35%  { transform: translateY(2px) scale(.97); }
    100% { transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .gg-pet-figure.is-poke { animation: none; } }
.gg-pet-body { display: flex; flex-direction: column; gap: .4rem; padding-bottom: .15rem; align-self: center; }
.gg-pet-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.gg-pet-name { font-weight: 800; font-size: 1rem; color: var(--fg-strong); }
.gg-pet-rename {
    border: none; background: none; padding: 0 .1rem; line-height: 1; cursor: pointer;
    color: var(--muted-fg); font-size: .8rem; opacity: .55; transition: opacity .15s, color .15s;
}
.gg-pet-rename:hover { opacity: 1; color: var(--gg-teal-dark); }
.gg-pet-rename:focus-visible { outline: 2px solid var(--gg-teal); outline-offset: 2px; border-radius: 4px; }
.gg-pet-tier { font-size: .78rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px;
    border: 1px solid currentColor; color: var(--muted-fg); }
.gg-pet-card[data-tone="danger"]  .gg-pet-tier { color: var(--gg-red); }
.gg-pet-card[data-tone="warning"] .gg-pet-tier { color: var(--gg-orange); }
.gg-pet-card[data-tone="success"] .gg-pet-tier { color: var(--gg-teal-dark); }
.gg-pet-card[data-tone="gold"]    .gg-pet-tier { color: #b8860f; }
.gg-pet-score { margin-left: auto; font-size: .78rem; color: var(--muted-fg); font-variant-numeric: tabular-nums; }
.gg-pet-msg { margin: 0; font-size: .82rem; color: var(--fg); }
.gg-pet-bars { display: flex; flex-direction: column; gap: .28rem; }
.gg-pet-bar { display: grid; grid-template-columns: 74px 1fr auto; gap: .5rem; align-items: center;
    font-size: .7rem; color: var(--muted-fg); }
.gg-pet-bar-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.gg-pet-bar-fill { display: block; height: 100%; border-radius: 3px; transition: width .35s ease; }
.gg-pet-bar-fill.is-good { background: var(--gg-teal); }
.gg-pet-bar-fill.is-ok   { background: var(--gg-yellow); }
.gg-pet-bar-fill.is-warn { background: var(--gg-orange); }
.gg-pet-bar-fill.is-low  { background: var(--gg-red); }
.gg-pet-bar-val { font-variant-numeric: tabular-nums; }
/* เป้าเต็มวัน — ตัวรองข้างเลขจังหวะ ไม่ให้แย่งสายตาจากเลขที่ต้องทำตอนนี้ */
.gg-pet-bar-day { font-size: .92em; opacity: .6; margin-left: .15rem; }
.gg-pet-foot { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.gg-pet-cta { font-size: .76rem; font-weight: 700; color: var(--gg-teal-dark); text-decoration: none; }
.gg-pet-cta:hover { text-decoration: underline; }
.gg-pet-note { font-size: .68rem; color: var(--muted-fg); margin-left: auto; }
/* วันลา/วันหยุด — หรี่สีแล้วติดป้าย zZz แทนที่จะต้องมีภาพท่านอนอีกชุด */
.gg-pet-card.is-asleep .gg-pet-figure img { filter: grayscale(.5) brightness(.85); }
.gg-pet-card.is-asleep .gg-pet-figure::before {
    content: "z Z z"; position: absolute; top: 2px; right: -2px; z-index: 1;
    font-size: .8rem; font-weight: 700; letter-spacing: .08em; color: var(--muted-fg);
    transform: rotate(-12deg);
}
:root[data-theme="dark"] .gg-pet-card[data-tone="gold"] .gg-pet-tier { color: #f0bd45; }
@media (max-width: 575.98px) {
    .gg-pet-card { grid-template-columns: 132px minmax(0, 1fr); gap: .75rem; }
    .gg-pet-figure { height: 176px; }
    .gg-pet-score { margin-left: 0; width: 100%; }
}

/* ---------------------------------------------------------------------
   21) หน้า Login (การ์ดสองฝั่ง โทนเข้ม)
   ---------------------------------------------------------------------
   หน้านี้ตั้งสีเองทั้งหมด ไม่ใช้ token ของ theme เพราะตอนยังไม่ล็อกอิน
   เรายังไม่รู้ว่าผู้ใช้ตั้ง light/dark ไว้ ปล่อยให้เป็นโทนเข้มเสมอ
   --------------------------------------------------------------------- */
body.gg-login-body {
    background: #0B120F;
    color-scheme: dark;
}

.gg-login {
    --lg-bg:        #0B120F;
    --lg-panel:     #12211C;
    --lg-brand-a:   #1D3A32;
    --lg-brand-b:   #16302A;
    --lg-line:      #2A463D;
    --lg-line-soft: #223A33;
    --lg-fg:        #FFFFFF;
    --lg-muted:     #A6BEB5;
    --lg-teal:      #5FC1AA;
    --lg-teal-dim:  rgba(95, 193, 170, .28);

    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background:
        radial-gradient(760px 420px at 22% 12%, rgba(42, 174, 155, .10), transparent 70%),
        var(--lg-bg);
    font-family: 'Sarabun', 'Inter', system-ui, sans-serif;
}

.gg-login-card {
    width: 100%;
    max-width: 1120px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid var(--lg-line-soft);
    box-shadow: 0 32px 80px rgba(0, 0, 0, .45);
}

/* ---- ฝั่งซ้าย: แบรนด์ ---- */
.gg-login-brand {
    background: linear-gradient(155deg, var(--lg-brand-a) 0%, var(--lg-brand-b) 100%);
    padding: 3.5rem 3rem;
    display: flex;
    flex-direction: column;
    min-height: 540px;
}

/* กระเบื้องโลโก้พื้นเข้ม — โลโก้ใหม่มีพื้นดำกับแสงเรืองในตัว
   ถ้าใส่พื้นขาวเหมือนเดิมจะเห็นเป็นสี่เหลี่ยมดำแปะกลางกรอบขาว */
.gg-login-logo {
    width: 128px;
    height: 128px;
    border-radius: 26px;
    background: #0A0B0A;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .38), 0 0 0 1px rgba(212, 175, 78, .28);
    flex-shrink: 0;
}

.gg-login-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gg-login-slides {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    margin: 2.5rem 0 1.5rem;
}

.gg-login-slide {
    position: absolute;
    inset: auto 0 auto 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .45s var(--ease), transform .45s var(--ease);
    pointer-events: none;
}

.gg-login-slide.is-active {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.gg-login-headline {
    font-size: clamp(1.75rem, 2.6vw, 2.4rem);
    font-weight: 700;
    color: var(--lg-fg);
    line-height: 1.25;
    margin: 0 0 1.25rem;
}

.gg-login-tagline {
    font-size: 1.0625rem;
    line-height: 1.8;
    color: var(--lg-muted);
    margin: 0;
}

.gg-login-dots {
    display: flex;
    gap: .5rem;
    margin-top: auto;
}

.gg-login-dot {
    width: 34px;
    height: 5px;
    border: 0;
    padding: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    cursor: pointer;
    transition: background .25s var(--ease), width .25s var(--ease);
}

.gg-login-dot.is-active {
    width: 58px;
    background: var(--lg-teal);
}

/* ---- ฝั่งขวา: ฟอร์ม ---- */
.gg-login-panel {
    background: var(--lg-panel);
    padding: 3.5rem 3rem;
    display: flex;
    align-items: center;
}

.gg-login-form {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.gg-login-title {
    font-size: clamp(1.5rem, 2.2vw, 2rem);
    font-weight: 700;
    color: var(--lg-fg);
    margin: 0 0 .5rem;
}

.gg-login-subtitle {
    font-size: .9375rem;
    color: var(--lg-muted);
    margin: 0 0 2rem;
}

.gg-login-alert {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .8125rem;
    line-height: 1.6;
    padding: .75rem .875rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.gg-login-alert.is-error {
    background: rgba(239, 91, 99, .12);
    border-color: rgba(239, 91, 99, .35);
    color: #FF9BA0;
}

.gg-login-alert.is-success {
    background: rgba(95, 193, 170, .12);
    border-color: rgba(95, 193, 170, .35);
    color: var(--lg-teal);
}

.gg-login-field { margin-bottom: 1.25rem; }

.gg-login-field label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: #DDE9E4;
    margin-bottom: .5rem;
}

.gg-login-input {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--lg-line);
    border-radius: 14px;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.gg-login-input:focus-within {
    border-color: var(--lg-teal);
    box-shadow: 0 0 0 3px var(--lg-teal-dim);
}

.gg-login-input > i {
    flex-shrink: 0;
    width: 3rem;
    text-align: center;
    font-size: 1.0625rem;
    color: #8FA9A0;
}

.gg-login-input input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--lg-fg);
    font-size: 1rem;
    padding: .9375rem 1rem .9375rem 0;
    font-family: inherit;
}

.gg-login-input input::placeholder { color: #7C948B; }

/* กัน autofill ของ Chrome ทาพื้นขาวทับช่องกรอก */
.gg-login-input input:-webkit-autofill,
.gg-login-input input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--lg-fg);
    caret-color: var(--lg-fg);
    transition: background-color 9999s ease-out;
}

.gg-login-eye {
    flex-shrink: 0;
    background: none;
    border: 0;
    padding: 0 1rem;
    font-size: 1.0625rem;
    color: #8FA9A0;
    cursor: pointer;
    transition: color .2s var(--ease);
}

.gg-login-eye:hover { color: var(--lg-fg); }

.gg-login-submit {
    width: 100%;
    margin-top: .75rem;
    padding: 1rem 1.25rem;
    border: 0;
    border-radius: 14px;
    background: var(--lg-teal);
    color: #08211B;
    font-family: inherit;
    font-size: 1.0625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .625rem;
    cursor: pointer;
    transition: background .2s var(--ease), transform .12s var(--ease);
}

.gg-login-submit:hover:not(:disabled) { background: #6FCFB8; }
.gg-login-submit:active:not(:disabled) { transform: translateY(1px); }
.gg-login-submit:disabled { opacity: .7; cursor: not-allowed; }

.gg-login-foot {
    margin-top: 2.5rem;
    text-align: center;
    font-size: .8125rem;
    color: #7C948B;
}

/* ---- จอเล็ก: พับเหลือคอลัมน์เดียว ฝั่งแบรนด์ย่อเป็นหัวการ์ด ---- */
@media (max-width: 991.98px) {
    .gg-login { padding: 1.25rem; }

    .gg-login-card {
        grid-template-columns: 1fr;
        max-width: 480px;
        border-radius: 22px;
    }

    .gg-login-brand {
        min-height: 0;
        padding: 2.25rem 1.75rem 1.75rem;
    }

    .gg-login-logo { width: 92px; height: 92px; border-radius: 20px; }

    .gg-login-slides { margin: 1.5rem 0 1.25rem; min-height: 132px; }

    .gg-login-slide { position: absolute; }

    .gg-login-panel { padding: 2rem 1.75rem 2.25rem; }

    .gg-login-subtitle { margin-bottom: 1.5rem; }

    .gg-login-foot { margin-top: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
    .gg-login-slide { transition: none; }
}

/* =======================================================================
   เกมทีม (/game) — โปรโมชั่นประจำสัปดาห์
   ใช้โทนสถานะ 3 ระดับเดียวกับหน้า "ยอดขายของฉัน":
     teal (ถึงเป้า/ปลดล็อกแล้ว) · dark-blue (ใกล้แล้ว) · orange (ยังห่าง)
   ======================================================================= */
.gg-game-banner {
    display: flex;
    align-items: center;
    gap: .875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.gg-game-banner-title { font-size: 1.0625rem; font-weight: 700; color: var(--fg-strong); }
.gg-game-banner-sub   { font-size: .8125rem; color: var(--muted-fg); margin-top: .125rem; }
.gg-game-banner-note  { font-size: .75rem; color: var(--muted-fg); margin-top: .25rem; }

.gg-game-status {
    margin-left: auto;
    flex-shrink: 0;
    text-align: right;
}

.gg-game-card-head {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.gg-game-headline {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.02em;
    color: var(--fg-strong);
}

.gg-game-headline .unit {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted-fg);
    margin-left: .25rem;
}

.gg-game-headline-sub { font-size: .8125rem; color: var(--muted-fg); margin-top: .125rem; }

/* หลอดหลักของทีม — หนากว่า gg-kpi-bar ทั่วไปเพราะเป็นพระเอกของการ์ด */
.gg-game-bar-wrap { position: relative; margin: .875rem 0 .25rem; }

.gg-game-bar {
    height: 14px;
    background: var(--muted);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.gg-game-bar span {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--gg-orange);
    transition: width .6s var(--ease);
}

.gg-game-bar span.tier-ok   { background: var(--gg-dark-blue); }
.gg-game-bar span.tier-good { background: var(--gg-teal); }

/* เส้นบอกเกณฑ์ปลดล็อก (เฉพาะทีมประเภทความขยัน) — ปักหมุดตำแหน่ง threshold_pct */
.gg-game-bar-marker {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--fg-strong);
    opacity: .35;
}

.gg-game-bar-marker-label {
    position: absolute;
    top: -1.125rem;
    transform: translateX(-50%);
    font-size: .625rem;
    color: var(--muted-fg);
    white-space: nowrap;
}

.gg-game-members { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.gg-game-member-row {
    display: flex;
    align-items: center;
    gap: .625rem;
}

/* คอลัมน์ชื่อ + รายละเอียดตัวเลขจริง (2 บรรทัด) — กว้างกว่าตอนมีแค่ชื่ออย่างเดียว
   ปล่อยให้ตัดขึ้นบรรทัดใหม่ได้ (ไม่ ellipsis) เพราะตัวเลขที่ "ขาดอีกเท่าไหร่" เป็นเนื้อหาหลัก
   ที่ผู้ใช้ต้องอ่านได้ครบ ไม่ใช่แค่ทศนิยมประดับ */
.gg-game-member-info {
    width: 220px;
    flex-shrink: 0;
}

.gg-game-member-name {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--fg-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gg-game-member-detail {
    font-size: .625rem;
    line-height: 1.35;
    color: var(--muted-fg);
    font-variant-numeric: tabular-nums;
    white-space: normal;
}

.gg-game-member-bar {
    flex: 1;
    height: 6px;
    background: var(--muted);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.gg-game-member-bar span {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--gg-orange);
    transition: width .5s var(--ease);
}

.gg-game-member-bar span.tier-ok   { background: var(--gg-dark-blue); }
.gg-game-member-bar span.tier-good { background: var(--gg-teal); }

.gg-game-member-value {
    font-size: .75rem;
    font-weight: 600;
    color: var(--muted-fg);
    width: 58px;
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

:root[data-theme="dark"] .gg-game-bar-marker,
[data-bs-theme="dark"] .gg-game-bar-marker { opacity: .5; }

/* ตารางย่อยเป้ารวมทีม (ทำได้ / เป้า / ขาดอีก) — ต่อแกน */
.gg-game-target-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    row-gap: .3125rem;
    column-gap: .75rem;
    margin-top: .875rem;
    padding: .75rem .875rem;
    background: var(--muted);
    border-radius: var(--radius-sm);
    font-size: .75rem;
}

.gg-game-target-grid .label { color: var(--muted-fg); font-weight: 500; }
.gg-game-target-grid .amount {
    color: var(--fg-strong);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.gg-game-target-grid .remain {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
.gg-game-target-grid .remain.done { color: var(--gg-teal); font-weight: 600; }
.gg-game-target-grid .remain.pending { color: var(--gg-orange); }

/* =======================================================================
   ประกาศข่าวสาร (Announcements) — ป็อปอัพผู้รับ + หน้าแอดมิน
   ======================================================================= */

/* checkbox แบบชิป (เลือกทีม/ตำแหน่งเป้าหมาย) */
.gg-chip-check {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .3125rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: .8125rem;
    cursor: pointer;
    user-select: none;
    transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.gg-chip-check:hover { border-color: var(--border-strong); }
.gg-chip-check:has(input:checked) {
    background: var(--gg-teal-soft);
    border-color: var(--gg-teal);
    color: var(--gg-teal-dark);
    font-weight: 600;
}
.gg-chip-check input { margin: 0; accent-color: var(--gg-teal); }

/* กริดรูปแนบในฟอร์มแอดมิน (ทั้งรูปที่มีอยู่แล้ว + รูปที่เพิ่งเลือกยังไม่อัปโหลด) */
.gg-ann-image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 0;
}
.gg-ann-thumb {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.gg-ann-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gg-ann-thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.gg-ann-thumb-remove:hover { background: var(--gg-red); }

/* ป็อปอัพผู้รับ — รูปแนบ (เรียงเต็มความกว้าง อ่านง่ายกว่ากริดเล็ก ๆ) */
.gg-ann-images {
    display: flex;
    flex-direction: column;
    gap: .625rem;
    margin-bottom: 1rem;
}
.gg-ann-images img {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--muted);
    display: block;
    cursor: zoom-in;
}
.gg-ann-content {
    font-size: .9375rem;
    line-height: 1.65;
    color: var(--fg);
}

/* ดูรูปแนบขยายใหญ่ (คลิกรูปในป็อปอัพผู้รับ) */
.gg-ann-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(7, 6, 15, .88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    cursor: zoom-out;
}
.gg-ann-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    cursor: default;
    box-shadow: var(--shadow-lg);
}
.gg-ann-lightbox-close {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
}
.gg-ann-lightbox-close:hover { background: rgba(255, 255, 255, .22); }

/* หน้า "ประกาศ" ของพนักงาน — รายการย้อนหลัง */
.gg-ann-history-item {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.gg-ann-history-item:last-child { border-bottom: none; }
.gg-ann-history-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    flex-wrap: wrap;
}
.gg-ann-history-sender {
    font-weight: 700;
    font-size: .9375rem;
    color: var(--fg-strong);
    display: flex;
    align-items: center;
    gap: .4rem;
}
.gg-ann-history-sender i { color: var(--gg-orange); }
.gg-ann-history-item .gg-ann-thumb img { cursor: zoom-in; }

/* =====================================================================
   เกมน้องนุ่น: Token + ร้านค้าแต่งตัว
   =====================================================================
   ของแต่งตัวทุกชิ้นเป็นเลเยอร์รอบตัวน้อง (กรอบ/ฉาก/อนุภาค/คู่หู)
   ไม่แตะคลิปตัวการ์ตูน — เพิ่มไอเทมใหม่ = เพิ่ม class ตาม render ในตาราง pet_items */

/* ---- ชิปเหรียญ + ปุ่มร้านค้าบนหัวการ์ด ---- */
.gg-pet-tokens {
    margin-left: auto; border: 1px solid #f0c94255; background: #fff7de;
    color: #8a6d1a; border-radius: 999px; padding: .15rem .6rem;
    font-size: .75rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.gg-pet-tokens:hover { background: #ffefb8; }

/* ---- กรอบการ์ด (slot: frame) ---- */
.pet-frame-mint { border: 3px solid #2AAE9B !important; box-shadow: 0 0 0 3px #2AAE9B22, 0 6px 18px #2AAE9B33; }
.pet-frame-gold { border: 3px solid #d4af37 !important; box-shadow: 0 0 0 3px #d4af3722, 0 6px 20px #d4af3755; }
.pet-frame-neon {
    border: 3px solid #7c4dff !important;
    animation: pet-neon 3s linear infinite;
}
@keyframes pet-neon {
    0%   { box-shadow: 0 0 14px #7c4dffaa; border-color: #7c4dff !important; }
    33%  { box-shadow: 0 0 14px #00e5ffaa; border-color: #00e5ff !important; }
    66%  { box-shadow: 0 0 14px #ff4d8daa; border-color: #ff4d8d !important; }
    100% { box-shadow: 0 0 14px #7c4dffaa; border-color: #7c4dff !important; }
}
.pet-frame-diamond {
    border: 3px solid #b9f2ff !important;
    animation: pet-diamond 2.2s ease-in-out infinite;
}
@keyframes pet-diamond {
    0%, 100% { box-shadow: 0 0 8px #b9f2ff88, 0 0 22px #ffffffcc; }
    50%      { box-shadow: 0 0 18px #b9f2ffee, 0 0 34px #ffffff; }
}

/* ---- ฉากหลัง (slot: background) — ใส่ที่ .gg-pet-figure ---- */
.gg-pet-figure.has-pet-bg { border-radius: 14px; overflow: hidden; }
.gg-pet-figure.has-pet-bg img, .gg-pet-figure.has-pet-bg video { position: relative; z-index: 2; }
.gg-pet-figure.has-pet-bg::before {
    position: absolute; inset: auto .35rem .25rem auto; z-index: 3;
    font-size: 1.1rem; opacity: .9;
}
.pet-bg-sunset { background: linear-gradient(180deg, #ff9a56 0%, #ffd56b 70%, #ffedb8 100%); }
.pet-bg-sunset::before { content: '🌅'; }
.pet-bg-beach { background: linear-gradient(180deg, #7ed6f2 0%, #bdeaf7 62%, #f7e2b4 62%, #ffedc9 100%); }
.pet-bg-beach::before { content: '🏖️'; }
.pet-bg-sakura { background: linear-gradient(180deg, #ffd6e8 0%, #fff0f6 100%); }
.pet-bg-sakura::before { content: '🌸'; }
.pet-bg-space {
    background:
        radial-gradient(1.5px 1.5px at 18% 22%, #fff 60%, transparent 61%),
        radial-gradient(1.5px 1.5px at 72% 14%, #fff 60%, transparent 61%),
        radial-gradient(2px 2px at 84% 58%, #ffeaa7 60%, transparent 61%),
        radial-gradient(1.5px 1.5px at 34% 74%, #fff 60%, transparent 61%),
        linear-gradient(180deg, #0e1638 0%, #26235c 100%);
}
.pet-bg-space::before { content: '🪐'; }
.pet-bg-stage {
    background:
        radial-gradient(70% 90% at 50% 0%, #fff7cf66 0%, transparent 60%),
        linear-gradient(180deg, #1d1533 0%, #3a2160 100%);
}
.pet-bg-stage::before { content: '🎤'; }

/* ---- เอฟเฟกต์อนุภาคลอย (slot: effect) ---- */
.gg-pet-fx { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.gg-pet-fx span {
    position: absolute; bottom: -6%; font-size: 1rem; opacity: 0;
    animation: pet-float 3.6s ease-in infinite;
}
.gg-pet-fx span:nth-child(1) { left: 8%;  animation-delay: 0s; }
.gg-pet-fx span:nth-child(2) { left: 78%; animation-delay: .7s; }
.gg-pet-fx span:nth-child(3) { left: 30%; animation-delay: 1.3s; font-size: .8rem; }
.gg-pet-fx span:nth-child(4) { left: 60%; animation-delay: 1.9s; }
.gg-pet-fx span:nth-child(5) { left: 16%; animation-delay: 2.5s; font-size: .8rem; }
.gg-pet-fx span:nth-child(6) { left: 88%; animation-delay: 3.1s; }
@keyframes pet-float {
    0%   { transform: translateY(0) rotate(-8deg); opacity: 0; }
    12%  { opacity: .95; }
    100% { transform: translateY(-240px) rotate(10deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .gg-pet-fx span, .pet-frame-neon, .pet-frame-diamond { animation: none; }
}

/* ---- เพื่อนคู่หู (slot: companion) ---- */
.gg-pet-buddy {
    position: absolute; right: 6%; bottom: 4%; z-index: 4; font-size: 1.7rem;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.25));
    animation: pet-bob 2.4s ease-in-out infinite; pointer-events: none;
}
@keyframes pet-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* ---- ป้ายฉายา (slot: title) ---- */
.gg-pet-title-badge {
    background: linear-gradient(90deg, #f6d365, #fda085); color: #6b3f00;
    border-radius: 999px; font-size: .65rem; font-weight: 700;
    padding: .1rem .5rem; margin-left: .3rem; white-space: nowrap;
}

/* ---- ร้านค้า (modal) ---- */
.pet-shop-overlay {
    position: fixed; inset: 0; z-index: 1080; background: rgba(15, 25, 40, .55);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.pet-shop {
    background: var(--gg-card-bg, #fff); border-radius: 16px; width: min(680px, 100%);
    max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 18px 50px rgba(0,0,0,.3);
}
.pet-shop-head {
    display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem;
    border-bottom: 1px solid rgba(128,128,128,.15);
}
.pet-shop-title { font-weight: 700; }
.pet-shop-balance {
    margin-left: auto; background: #fff7de; color: #8a6d1a; font-weight: 700;
    border-radius: 999px; padding: .2rem .7rem; font-size: .85rem;
}
.pet-shop-close { border: none; background: none; cursor: pointer; font-size: 1rem; padding: .2rem .4rem; }
.pet-shop-tabs { display: flex; gap: .4rem; padding: .6rem 1rem 0; flex-wrap: wrap; }
.pet-shop-tab {
    border: 1px solid rgba(128,128,128,.25); background: none; border-radius: 999px;
    padding: .2rem .8rem; font-size: .8rem; cursor: pointer;
}
.pet-shop-tab.active { background: #2AAE9B; border-color: #2AAE9B; color: #fff; font-weight: 600; }
.pet-shop-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .7rem; padding: 1rem; overflow-y: auto;
}
.pet-shop-item {
    border: 1px solid rgba(128,128,128,.18); border-radius: 12px; padding: .6rem;
    display: flex; flex-direction: column; gap: .35rem; align-items: stretch; text-align: center;
}
.pet-shop-item.is-on { border-color: #2AAE9B; box-shadow: 0 0 0 2px #2AAE9B33; }
.pet-prev {
    height: 74px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; background: rgba(128,128,128,.08); position: relative; overflow: hidden;
    border-width: 2px !important;
}
.pet-prev-big { font-size: 2.2rem; }
.ps-name { font-size: .78rem; font-weight: 600; line-height: 1.25; }
.ps-meta { display: flex; justify-content: center; gap: .35rem; font-size: .65rem; }
.ps-rarity { border-radius: 999px; padding: .05rem .45rem; font-weight: 600; }
.ps-rarity.r-common { background: rgba(128,128,128,.15); }
.ps-rarity.r-rare { background: #e3f2fd; color: #1565c0; }
.ps-rarity.r-legend { background: linear-gradient(90deg, #f6d365, #fda085); color: #6b3f00; }
.ps-on { color: #2AAE9B; font-weight: 700; }
.pet-shop-earn { font-size: .7rem; padding: 0 1rem .5rem; line-height: 1.5; }
.pet-shop-history { border-top: 1px solid rgba(128,128,128,.15); max-height: 130px; overflow-y: auto; padding: .4rem 1rem .7rem; }
.pet-shop-h-row { display: flex; gap: .6rem; font-size: .72rem; padding: .12rem 0; }
.pet-shop-h-row span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
