/* ═══════════════════════════════════════════════════════
   Nebrix Hub (หน้าลูกค้า) — โครงร่วม + Dashboard · 0.14.0
   ใช้ตัวแปรธีมของ nebrix-admin.css (--bg --surface --tx --s2 --b1 --b2) · ธีมมืดเป็นค่าเริ่มต้น · html.light = สว่าง
═══════════════════════════════════════════════════════ */
:root {
    --nh-accent: #534AB7;
    --nh-accent-hover: #463EA0;
    --nh-accent-soft: rgba(139,131,230,.16);
    --nh-accent-tx: #B4AEF5;
    --nh-muted: #A1A7B3;
    --nh-line: rgba(255,255,255,.10);
    --nh-chip: rgba(255,255,255,.06);
    --nh-warn-bg: rgba(245,158,11,.10);
    --nh-warn-line: rgba(245,158,11,.32);
    --nh-warn-icon: rgba(245,158,11,.18);
    --nh-warn-tx: #FBBF24;
    --nh-ok-tx: #34D399;
    --nh-ok-bg: rgba(16,185,129,.12);
    --nh-danger: #F87171;
    --nh-shadow: 0 10px 30px rgba(0,0,0,.35);
}
html.light {
    --nh-accent-soft: rgba(83,74,183,.10);
    --nh-accent-tx: #3F3797;
    --nh-muted: #5B6475;
    --nh-line: #E4E7EE;
    --nh-chip: #F1F3F7;
    --nh-warn-bg: #FFF8EB;
    --nh-warn-line: #FCD9A0;
    --nh-warn-icon: #FDEBC8;
    --nh-warn-tx: #9A4A06;
    --nh-ok-tx: #047857;
    --nh-ok-bg: #E7F7EF;
    --nh-danger: #C2410C;
    --nh-shadow: 0 12px 32px rgba(17,24,39,.14);
}

.nh-page { min-height: 100vh; background: var(--bg); color: var(--tx); font-family: var(--font); font-size: 15px; line-height: 1.55; }
/* 0.29.1 — หน้า Hub เลื่อนด้วยหน้าต่าง (nebrix-admin.css ล็อกเฉพาะ .app-shell ของ Admin)
   scroll-padding เว้นที่ให้แถบบน sticky (64px · + แถบแดง "ดูในมุมมองลูกค้า" 44px) เมื่อกระโดดไปยัง #anchor / โฟกัสด้วยคีย์บอร์ด */
html:has(.nh-page) { scroll-padding-top: 80px; }
html:has(.nh-page):has(.nh-imp) { scroll-padding-top: 124px; }
.nh-page a { color: var(--nh-accent-tx); }
.nh-page :focus-visible { outline: 2px solid var(--nh-accent); outline-offset: 2px; }
.nh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── แถบบน ─────────────────────────────────────────────── */
.nh-top { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--nh-line); }
.nh-top-in { max-width: 1320px; margin: 0 auto; padding: 0 32px; height: 64px; display: flex; align-items: center; gap: 28px; }
.nh-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--tx) !important; flex-shrink: 0; }
.nh-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--nh-accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.nh-brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.nh-brand-name { font-weight: 700; font-size: 15px; }
.nh-brand-org { font-size: 12px; color: var(--nh-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nh-nav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.nh-nav a { padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--nh-muted); white-space: nowrap; }
.nh-nav a:hover { color: var(--tx); background: var(--nh-chip); }
.nh-nav a.active { color: var(--nh-accent-tx); background: var(--nh-accent-soft); font-weight: 600; }

.nh-user { position: relative; margin-left: auto; }
.nh-user > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; min-height: 44px; border: 1px solid var(--nh-line); border-radius: 999px; background: var(--surface); cursor: pointer; color: var(--tx); }
.nh-user > summary::-webkit-details-marker { display: none; }
.nh-user > summary:hover { background: var(--nh-chip); }
.nh-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--nh-accent-soft); color: var(--nh-accent-tx); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.nh-user-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.nh-user-name { font-size: 14px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nh-user-role { font-size: 12px; color: var(--nh-muted); }
.nh-chev { transition: transform .15s; }
.nh-user[open] .nh-chev { transform: rotate(180deg); }
.nh-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 270px; background: var(--surface); border: 1px solid var(--nh-line); border-radius: 12px; box-shadow: var(--nh-shadow); padding: 6px; z-index: 40; }
.nh-menu-head { padding: 10px 12px; border-bottom: 1px solid var(--nh-line); margin-bottom: 6px; }
.nh-menu-head b { display: block; font-size: 14px; }
.nh-menu-head span { font-size: 13px; color: var(--nh-muted); word-break: break-all; }
.nh-menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--tx) !important; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; text-align: left; }
.nh-menu-item:hover { background: var(--nh-chip); }
.nh-menu-item.danger { color: var(--nh-danger) !important; }
.nh-menu-sep { height: 1px; background: var(--nh-line); margin: 6px 0; }
.nh-menu-mobile { display: none; }
.nh-theme-dark, html.light .nh-theme-light { display: none; }
html.light .nh-theme-dark { display: inline; }

@media (max-width: 900px) {
    .nh-top-in { padding: 0 16px; gap: 12px; height: 60px; }
    .nh-nav, .nh-user-txt { display: none; }
    .nh-menu-mobile { display: block; }
    .nh-brand-org { max-width: 160px; }
}

/* ── เนื้อหา ───────────────────────────────────────────── */
.nh-main { max-width: 1320px; margin: 0 auto; padding: 36px 32px 56px; display: flex; flex-direction: column; gap: 28px; }
.nh-main.narrow { max-width: 1040px; }
@media (max-width: 900px) { .nh-main { padding: 20px 16px 40px; gap: 20px; } }

.nh-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.nh-h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.2px; }
.nh-sub { margin: 4px 0 0; color: var(--nh-muted); font-size: 15px; }
.nh-h2 { margin: 0; font-size: 20px; font-weight: 700; }
@media (max-width: 900px) { .nh-h1 { font-size: 24px; } }

.nh-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.nh-btn-primary { background: var(--nh-accent); color: #fff !important; }
.nh-btn-primary:hover { background: var(--nh-accent-hover); }
.nh-btn-ghost { background: var(--surface); color: var(--tx) !important; border-color: var(--nh-line); font-weight: 500; }
.nh-btn-ghost:hover { background: var(--nh-chip); }
.nh-btn-icon { width: 44px; padding: 0; background: transparent; color: var(--nh-muted); border: 0; }
.nh-btn-icon:hover { background: var(--nh-chip); }

.nh-alert { border-radius: 10px; font-size: 14px; padding: 12px 16px; line-height: 1.5; }
.nh-alert.err { background: rgba(239,68,68,.10); border: 1px solid rgba(239,68,68,.28); color: var(--nh-danger); }
.nh-alert.ok { background: var(--nh-ok-bg); border: 1px solid rgba(16,185,129,.28); color: var(--nh-ok-tx); }

.nh-nudge { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 12px; background: var(--nh-warn-bg); border: 1px solid var(--nh-warn-line); }
.nh-nudge-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--nh-warn-icon); color: var(--nh-warn-tx); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nh-nudge-txt { flex: 1; min-width: 240px; }
.nh-nudge-txt b { display: block; color: var(--nh-warn-tx); }
.nh-nudge-txt span { font-size: 14px; color: var(--nh-muted); }

.nh-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.nh-stat { background: var(--surface); border: 1px solid var(--nh-line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; min-height: 118px; }
.nh-stat-label { font-size: 13px; color: var(--nh-muted); font-weight: 500; }
.nh-stat-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.nh-stat-value.sm { font-size: 18px; margin-top: 8px; }
.nh-stat-value.warn { color: var(--nh-warn-tx); }
.nh-stat-value.ok { color: var(--nh-ok-tx); }
.nh-stat-foot { font-size: 13px; color: var(--nh-muted); margin-top: auto; }
.nh-stat-foot a { text-decoration: none; font-weight: 500; }
.nh-skel { display: inline-block; width: 90px; height: 28px; border-radius: 6px; background: var(--nh-chip); }
@media (max-width: 900px) { .nh-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .nh-stat { padding: 14px; min-height: 0; } .nh-stat-value { font-size: 24px; } }

.nh-sec-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.nh-sec-sub { font-size: 14px; color: var(--nh-muted); }
.nh-search { display: flex; align-items: center; gap: 8px; width: 300px; max-width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--nh-line); border-radius: 10px; background: var(--surface); color: var(--nh-muted); }
.nh-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--tx); font: inherit; font-size: 14px; }

.nh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.nh-card { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--nh-line); border-radius: 14px; padding: 20px; min-height: 212px; transition: border-color .15s, box-shadow .15s; }
.nh-card:hover { border-color: rgba(83,74,183,.45); box-shadow: var(--nh-shadow); }
.nh-card-head { display: flex; align-items: center; gap: 12px; }
.nh-mark { width: 44px; height: 44px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; letter-spacing: .3px; flex-shrink: 0;
           color: var(--mk); background: color-mix(in srgb, var(--mk) 12%, transparent); }
html:not(.light) .nh-mark { color: color-mix(in srgb, var(--mk) 45%, white); background: color-mix(in srgb, var(--mk) 22%, transparent); }
.nh-card-name { margin: 0; font-size: 17px; font-weight: 700; }
.nh-chips { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.nh-chip { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--nh-chip); color: var(--nh-muted); }
.nh-chip.accent { background: var(--nh-accent-soft); color: var(--nh-accent-tx); }
.nh-card-desc { margin: 0; font-size: 14px; color: var(--nh-muted); line-height: 1.55; flex: 1; }
.nh-card-credit { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--nh-chip); font-size: 13px; }
.nh-card-credit span { color: var(--nh-muted); }
.nh-card-credit b { font-variant-numeric: tabular-nums; }
.nh-card.locked { min-height: 0; opacity: .75; }
.nh-card.locked:hover { box-shadow: none; border-color: var(--nh-line); }
.nh-empty { padding: 36px; text-align: center; color: var(--nh-muted); border: 1px dashed var(--nh-line); border-radius: 14px; }

.nh-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 20px; border-top: 1px solid var(--nh-line); font-size: 13px; color: var(--nh-muted); }
.nh-foot a { text-decoration: none; }

@media (max-width: 900px) { .team-main, .sec-main, .au-main { padding: 20px 16px 40px !important; } }

/* ── S6 (0.21.0): แถบ "ดูในมุมมองลูกค้า" (ผู้ดูแลแพลตฟอร์ม · อ่านอย่างเดียว) — แสดงบนสุดทุกหน้า Hub ─────────── */
.nh-imp { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; gap: 10px;
    height: 44px; box-sizing: border-box; padding: 0 16px; background: #B91C1C; color: #fff; font-family: var(--font);
    font-size: 14px; line-height: 1.4; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
body:has(.nh-imp) .nh-top { top: 44px; }   /* แถบบนของ Hub ต่อใต้แถบแดง */
.nh-imp-ic { flex-shrink: 0; }
.nh-imp-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nh-imp-txt b { font-weight: 700; }
.nh-imp-left { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nh-imp-exit { flex-shrink: 0; color: #B91C1C !important; background: #fff; border-radius: 8px; padding: 5px 12px;
    font-weight: 600; text-decoration: none; white-space: nowrap; }
.nh-imp-exit:hover { background: #FEE2E2; }
.nh-imp-exit:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 640px) {
    .nh-imp { position: static; height: auto; flex-wrap: wrap; padding: 8px 12px; }
    .nh-imp-txt { white-space: normal; }
    body:has(.nh-imp) .nh-top { top: 0; }
}
@media print { .nh-imp { display: none; } }
