/* ============================================================
   DragonBoard Activation — monochrome (black / white / off-white)
   ============================================================ */
:root{
  --bg:#f4f6f8;          /* cool off-white page     */
  --surface:#ffffff;     /* cards                   */
  --surface-2:#f7f8fa;   /* subtle fills            */
  --ink:#11161c;         /* near-black text         */
  --ink-2:#3a4350;       /* secondary text          */
  --muted:#6b7682;       /* tertiary / labels       */
  --line:#ecedf1;        /* hairline borders        */
  --line-2:#dcdfe5;      /* stronger borders        */
  --black:#0c0f14;       /* solid black accents     */
  --soft:#eef1f4;        /* soft chip fill          */
  --radius:16px;
  --radius-sm:10px;
  --control-h:40px;       /* ความสูงมาตรฐาน input/button */
  --control-h-sm:34px;
  --shadow:0 1px 2px rgba(17,22,28,.05), 0 1px 3px rgba(17,22,28,.05);
  --shadow-md:0 4px 14px -3px rgba(17,22,28,.10), 0 2px 6px -3px rgba(17,22,28,.07);
  --shadow-lg:0 14px 38px -14px rgba(17,22,28,.24);
  --focus:0 0 0 3px rgba(17,22,28,.10);
}
*{box-sizing:border-box}
/* ซ่อน scrollbar แต่ยังเลื่อนได้ */
*{scrollbar-width:none;-ms-overflow-style:none}
*::-webkit-scrollbar{width:0;height:0;display:none}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  font-family:"Inter","Segoe UI",Roboto,Arial,"Noto Sans Thai",sans-serif;
  background:var(--bg);color:var(--ink);
  font-size:14.5px;line-height:1.55;
  -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;
}
a{color:var(--ink);text-decoration:none}
a:hover{text-decoration:underline;text-underline-offset:3px}
h1{font-size:23px;font-weight:700;letter-spacing:-.015em;margin:0 0 4px}
h2{font-size:16px;font-weight:650;letter-spacing:-.01em;margin:22px 0 12px}
.muted{color:var(--muted)}
.small{font-size:12.5px}

/* icons --------------------------------------------------- */
.icon{width:1.05em;height:1.05em;display:inline-block;vertical-align:-.16em;flex:none}
.btn .icon,.copy-btn .icon{vertical-align:-.18em}

/* ============ SaaS admin shell (light sidebar) ============ */
:root{--sidebar-w:256px;--header-h:64px;--chrome-line:#e6e8ec}

.app{min-height:100vh}

/* sidebar ------------------------------------------------- */
.sidebar{
  position:fixed;top:0;left:0;bottom:0;width:var(--sidebar-w);z-index:40;
  background:var(--surface);box-shadow:6px 0 20px -16px rgba(17,22,28,.22);
  display:flex;flex-direction:column;
}
.sidebar-close{
  display:none;position:absolute;top:13px;right:14px;z-index:2;
  width:38px;height:38px;align-items:center;justify-content:center;
  border:1px solid var(--chrome-line);background:var(--surface);border-radius:9px;
  cursor:pointer;color:var(--ink-2);
}
.sidebar-close .icon{width:19px;height:19px}
.sidebar-close:hover{background:var(--soft);color:var(--ink)}
.sidebar .brand{
  display:flex;align-items:center;gap:11px;height:var(--header-h);flex:none;
  padding:0 18px;color:var(--ink);line-height:1.1;
}
.sidebar .brand:hover{text-decoration:none}
.sidebar .brand .brand-mark{
  width:34px;height:34px;flex:none;border-radius:10px;
  background:var(--ink);display:flex;align-items:center;justify-content:center;color:#fff;
}
.sidebar .brand .brand-mark .icon{width:19px;height:19px}
.sidebar .brand .brand-name{font-weight:750;font-size:15.5px;letter-spacing:-.01em}
.sidebar .brand .brand-name small{display:block;font-weight:500;font-size:11px;
  letter-spacing:.04em;color:var(--muted)}

.sidebar .nav{display:flex;flex-direction:column;gap:2px;padding:14px 12px;overflow-y:auto;flex:1}
.sidebar .nav-label{font-size:10px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;
  color:var(--muted);padding:16px 12px 7px}
.sidebar .nav a{
  position:relative;display:flex;align-items:center;gap:12px;
  padding:10px 12px;border-radius:9px;font-size:13.5px;font-weight:550;
  color:var(--ink-2);line-height:1.2;transition:background .14s,color .14s;
}
.sidebar .nav a .icon{width:18px;height:18px;flex:none;color:var(--muted);transition:color .14s}
.sidebar .nav a:hover{background:var(--soft);color:var(--ink);text-decoration:none}
.sidebar .nav a:hover .icon{color:var(--ink-2)}
.sidebar .nav a.active{background:var(--ink);color:#fff;font-weight:650;box-shadow:var(--shadow)}
.sidebar .nav a.active .icon{color:#fff}
.sidebar .nav a.active:hover{background:var(--black);color:#fff}
.sidebar .nav a.active:hover .icon{color:#fff}
.sidebar-foot{flex:none;border-top:1px solid var(--chrome-line);padding:12px;
  display:flex;align-items:center;gap:6px}
.sidebar-foot .user-link{
  flex:1;min-width:0;display:flex;align-items:center;gap:11px;padding:8px 9px;border-radius:10px;
  color:var(--ink);font-size:13px;
}
.foot-btn{
  display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex:none;
  border:1px solid var(--chrome-line);background:var(--surface);border-radius:10px;cursor:pointer;
  color:var(--ink-2);transition:background .13s,border-color .13s,color .13s;
}
.foot-btn:hover{background:var(--soft);color:var(--ink);border-color:var(--line-2)}
.foot-btn .icon{width:17px;height:17px}
.sidebar-foot .user-link:hover{background:var(--soft);text-decoration:none}
.sidebar-foot .user-link .avatar{
  width:34px;height:34px;flex:none;border-radius:50%;background:var(--ink);color:#fff;
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:14px;text-transform:uppercase;
}
.sidebar-foot .user-link .meta{min-width:0;line-height:1.3;flex:1}
.sidebar-foot .user-link .meta .nm{font-weight:600;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sidebar-foot .user-link .meta .rl{font-size:11.5px;color:var(--muted)}
.sidebar-foot .user-link > .icon{width:16px;height:16px;flex:none;color:var(--muted)}

/* main column -------------------------------------------- */
.main{margin-left:var(--sidebar-w);min-height:100vh;display:flex;flex-direction:column;background:var(--bg)}

/* mobile top bar (hamburger) — shown only on small screens */
.mobile-bar{display:none}
.mobile-bar .spacer{flex:1}
.hamburger{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;flex:none;
  border:1px solid var(--chrome-line);background:var(--surface);border-radius:10px;cursor:pointer;color:var(--ink-2);
  transition:background .13s,color .13s}
.hamburger:hover{background:var(--soft);color:var(--ink)}
.hamburger .icon{width:20px;height:20px}
.mobile-brand{display:inline-flex;align-items:center;gap:10px;font-weight:750;font-size:15.5px;
  letter-spacing:-.01em;color:var(--ink)}
.mobile-brand .brand-mark{width:30px;height:30px;flex:none;border-radius:8px;background:var(--ink);
  display:flex;align-items:center;justify-content:center;color:#fff}
.mobile-brand .brand-mark .icon{width:17px;height:17px}
.nav-overlay{display:none;position:fixed;inset:0;background:rgba(12,15,20,.45);z-index:35}

/* bottom navigation (mobile only) ------------------------- */
.bottom-nav{display:none}

.container{width:100%;margin:0;padding:26px 28px}

/* cards --------------------------------------------------- */
.card{
  background:var(--surface);border-radius:var(--radius);
  padding:22px 24px;margin-bottom:20px;box-shadow:var(--shadow);
}
.card h2:first-child{margin-top:0}
.card h2 .icon{width:17px;height:17px;color:var(--muted)}
.row{display:flex;gap:20px;flex-wrap:wrap}
.row > .card{flex:1}

/* page header (title + actions) --------------------------- */
.page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:14px;
  flex-wrap:wrap;margin-bottom:20px}

/* stats (balanced 6-up grid) ------------------------------ */
.stats{display:grid;grid-template-columns:repeat(6,1fr);gap:16px;margin-bottom:20px}
.stat{
  display:flex;align-items:center;gap:13px;
  background:var(--surface);border-radius:var(--radius-sm);
  padding:16px 16px;box-shadow:var(--shadow);transition:box-shadow .16s,transform .16s;
}
.stat:hover{box-shadow:var(--shadow-md);transform:translateY(-1px)}
.stat .stat-ic{
  width:42px;height:42px;flex:none;border-radius:11px;
  background:var(--soft);color:var(--ink);
  display:flex;align-items:center;justify-content:center;
}
.stat .stat-ic .icon{width:20px;height:20px}
.stat .n{font-size:24px;font-weight:750;letter-spacing:-.03em;line-height:1.1}
.stat .l{color:var(--muted);font-size:12px;margin-top:1px}

/* breakdown bars ------------------------------------------ */
.breakdown{display:flex;flex-direction:column;gap:13px}
.breakdown .b-head{display:flex;align-items:center;justify-content:space-between;
  font-size:13px;margin-bottom:5px}
.breakdown .b-head b{font-weight:700}
.bar{height:7px;background:var(--soft);border-radius:99px;overflow:hidden}
.bar i{display:block;height:100%;border-radius:99px;background:var(--ink);min-width:2px;
  transition:width .3s ease}
.bar.t-green i{background:#1ea672}
.bar.t-amber i{background:#e0922f}
.bar.t-red i{background:#d6455d}
.bar.t-blue i{background:#3f6fc0}
.bar.t-gray i{background:#aab0b6}

/* table --------------------------------------------------- */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse;background:transparent}
th,td{text-align:left;padding:11px 13px;border-bottom:1px solid var(--line);vertical-align:middle}
thead th{
  font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;
  color:var(--muted);background:var(--surface-2);white-space:nowrap;
}
tbody tr{transition:background .12s}
tbody tr:hover{background:var(--surface-2)}
tr:last-child td{border-bottom:none}
code{
  background:var(--soft);padding:2px 7px;border-radius:6px;font-size:12.5px;color:var(--ink-2);
  font-family:"Cascadia Code",Consolas,ui-monospace,monospace;
}
.claim{font-size:15px;font-weight:650;letter-spacing:.05em;font-family:"Cascadia Code",Consolas,monospace}

/* badges (monochrome, icon-led) --------------------------- */
.badge{
  display:inline-flex;align-items:center;gap:5px;
  padding:3px 10px 3px 8px;border-radius:999px;
  font-size:12px;font-weight:600;line-height:1.4;white-space:nowrap;
}
.badge .badge-ic{width:13px;height:13px}
.badge--green{background:#e7f6ee;color:#15784a}
.badge--amber{background:#fbeedd;color:#985b0c}
.badge--red{background:#fce9eb;color:#b62a39}
.badge--blue{background:#e9effb;color:#2a548f}
.badge--gray{background:var(--soft);color:var(--ink-2)}

/* forms --------------------------------------------------- */
label{display:block;font-size:12.5px;font-weight:550;color:var(--ink-2);margin:11px 0 5px}
input,select,textarea{
  width:100%;min-height:var(--control-h);padding:0 12px;
  border:1px solid var(--line-2);border-radius:9px;
  font-size:14px;font-family:inherit;line-height:1.4;background:#fff;color:var(--ink);
  transition:border-color .12s,box-shadow .12s;
}
textarea{min-height:72px;padding:9px 12px;resize:vertical}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--ink);box-shadow:var(--focus)}
::placeholder{color:#aeb1b6}

/* buttons ------------------------------------------------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  min-height:var(--control-h);padding:0 16px;
  background:var(--ink);color:#fff;border:1px solid var(--ink);cursor:pointer;
  border-radius:9px;font-size:14px;font-weight:600;line-height:1.4;white-space:nowrap;
  transition:background .14s,border-color .14s,color .14s,box-shadow .14s,transform .04s;
}
.btn:hover{background:#000;border-color:#000;text-decoration:none;box-shadow:var(--shadow-md)}
.btn:active{transform:translateY(1px)}
.btn .icon{width:15px;height:15px}
.btn.sm{min-height:var(--control-h-sm);padding:0 12px;font-size:13px;border-radius:8px}
.btn.sm .icon{width:14px;height:14px}
.btn.ghost{background:#fff;color:var(--ink);border-color:var(--line-2)}
.btn.ghost:hover{background:var(--surface-2);border-color:var(--ink);box-shadow:none}
.btn.grey{background:#fff;color:var(--ink-2);border-color:var(--line-2)}
.btn.grey:hover{background:var(--soft);color:var(--ink);box-shadow:none}
.btn.amber{background:#fff;color:var(--ink);border:1px dashed var(--line-2)}
.btn.amber:hover{background:var(--surface-2);border-style:solid;border-color:var(--ink);box-shadow:none}
.btn.red{background:var(--black);color:#fff;border-color:var(--black)}
.btn.red:hover{background:#000}
.btn[disabled],.btn.is-disabled{opacity:.4;pointer-events:none}
.inline{display:inline}
.actions{display:flex;gap:9px;flex-wrap:wrap;align-items:center}

/* modal --------------------------------------------------- */
.modal{position:fixed;inset:0;z-index:60;display:none;align-items:center;justify-content:center;padding:20px}
.modal.open{display:flex}
.modal-backdrop{position:absolute;inset:0;background:rgba(12,15,20,.45)}
.modal-card{
  position:relative;background:var(--surface);border-radius:16px;box-shadow:var(--shadow-lg);
  width:392px;max-width:100%;padding:26px 24px;text-align:center;
  animation:modal-in .16s ease;
}
@keyframes modal-in{from{opacity:0;transform:translateY(8px) scale(.985)}to{opacity:1;transform:none}}
.modal-ic{width:50px;height:50px;border-radius:50%;background:var(--soft);color:var(--ink);
  display:flex;align-items:center;justify-content:center;margin:0 auto 14px}
.modal-ic .icon{width:23px;height:23px}
.modal-card h3{font-size:17px;font-weight:700;letter-spacing:-.01em;margin:0 0 5px}
.modal-card p{margin:0 0 22px;font-size:13.5px}
.modal-actions{display:flex;gap:10px}
.modal-actions > *{flex:1}
.modal-actions .btn{width:100%}

/* checklist (multi-select) -------------------------------- */
.checklist{display:flex;flex-direction:column;gap:1px;border:1px solid var(--line-2);
  border-radius:9px;padding:6px;max-height:260px;overflow:auto}
.check-row{display:flex;align-items:flex-start;gap:10px;margin:0;padding:8px 10px;
  border-radius:7px;font-size:13.5px;font-weight:400;color:var(--ink);cursor:pointer}
.check-row:hover{background:var(--surface-2)}
.check-row input[type=checkbox]{width:16px;height:16px;min-height:0;flex:none;margin-top:2px;
  accent-color:var(--ink);cursor:pointer}

.copy-btn{
  display:inline-flex;align-items:center;gap:5px;cursor:pointer;
  border:1px solid var(--line-2);background:#fff;border-radius:7px;
  padding:3px 9px;font-size:12px;color:var(--ink-2);transition:background .12s,border-color .12s;
}
.copy-btn:hover{background:var(--surface-2);border-color:var(--ink);color:var(--ink)}
.copy-btn .icon{width:13px;height:13px}

/* flash --------------------------------------------------- */
.flash{
  display:flex;align-items:flex-start;gap:9px;
  padding:12px 15px;border-radius:11px;margin-bottom:18px;font-weight:500;font-size:13.5px;
  background:var(--surface);border:1px solid var(--line);box-shadow:var(--shadow);
}
.flash.ok{border-left:3px solid var(--ink)}
.flash.err{border-left:3px solid var(--ink);background:#fff}
.err-list{margin:0;padding-left:18px}

/* login --------------------------------------------------- */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}
.login-card{width:380px;max-width:100%;box-shadow:var(--shadow-lg)}
.login-brand{display:flex;align-items:center;justify-content:center;gap:9px;
  font-size:20px;font-weight:750;letter-spacing:-.02em}
.login-brand .icon{width:24px;height:24px}

/* responsive ---------------------------------------------- */
@media (max-width:1100px){
  .stats{grid-template-columns:repeat(3,1fr)}
}
/* tablet/mobile: hide sidebar, use top brand bar + bottom nav */
@media (max-width:900px){
  .sidebar{display:none}
  .main{margin-left:0}
  .mobile-bar{display:flex;align-items:center;gap:12px;height:60px;padding:0 14px 0 16px;
    position:sticky;top:0;z-index:30;background:var(--surface);border-bottom:1px solid var(--chrome-line)}
  .container{padding:20px 16px calc(92px + env(safe-area-inset-bottom, 0px))}
  .bottom-nav{
    display:flex;align-items:center;gap:2px;position:fixed;left:0;right:0;bottom:0;z-index:35;
    background:var(--surface);border-top:1px solid var(--chrome-line);
    padding:8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .bottom-nav a,.bottom-nav .more-tab{
    flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:5px;
    padding:2px;color:var(--muted);font-size:10.5px;font-weight:600;line-height:1;text-decoration:none;
    background:none;border:none;font-family:inherit;cursor:pointer;
  }
  .bottom-nav a span,.bottom-nav .more-tab span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:font-size .18s ease}
  .bottom-nav a .icon,.bottom-nav .more-tab .icon{
    width:22px;height:22px;box-sizing:content-box;padding:6px;border-radius:50%;
    color:var(--muted);transition:all .18s ease;
  }
  .bottom-nav a:hover,.bottom-nav .more-tab:hover{text-decoration:none}
  .bottom-nav a:hover .icon,.bottom-nav .more-tab:hover .icon{background:var(--soft);color:var(--ink-2)}
  /* แท็บ active = วงกลมดำลอยโผล่พ้นขอบบนไปครึ่งวง */
  .bottom-nav a.active,.bottom-nav .more-tab.active{color:var(--ink);font-weight:700}
  .bottom-nav a.active .icon,.bottom-nav .more-tab.active .icon{
    width:26px;height:26px;padding:11px;background:var(--ink);color:#fff;
    border:4px solid var(--bg);box-shadow:var(--shadow-lg);
    margin-top:-30px;
  }
  .bottom-nav a.active span,.bottom-nav .more-tab.active span{font-size:11.5px}
}

/* bottom sheet "เพิ่มเติม" (mobile only) ------------------- */
.sheet{position:fixed;inset:0;z-index:55;display:none}
.sheet.open{display:block}
.sheet-backdrop{position:absolute;inset:0;background:rgba(12,15,20,.45)}
.sheet-card{
  position:absolute;left:0;right:0;bottom:0;
  background:var(--surface);border-radius:18px 18px 0 0;box-shadow:var(--shadow-lg);
  padding:8px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  animation:sheet-in .2s ease;
}
@keyframes sheet-in{from{transform:translateY(100%)}to{transform:none}}
.sheet-handle{width:40px;height:4px;border-radius:99px;background:var(--line-2);margin:8px auto 12px}
.sheet-profile{
  display:flex;align-items:center;gap:13px;
  padding:14px;margin-bottom:8px;border-radius:13px;
  background:var(--soft);color:var(--ink);
}
.sheet-profile .avatar{
  width:46px;height:46px;flex:none;border-radius:12px;background:var(--ink);color:#fff;
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:19px;text-transform:uppercase;
}
.sheet-profile .meta{min-width:0;flex:1;line-height:1.3}
.sheet-profile .meta .nm{font-weight:700;font-size:15.5px;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sheet-profile .meta .rl{font-size:12.5px;color:var(--muted)}
.sheet-list{display:flex;flex-direction:column;gap:2px}
.sheet-item{
  display:flex;align-items:center;gap:13px;width:100%;
  padding:13px 14px;border-radius:11px;text-align:left;
  background:none;border:none;font-family:inherit;font-size:15px;font-weight:600;
  color:var(--ink);cursor:pointer;text-decoration:none;transition:background .12s;
}
.sheet-item:hover{background:var(--soft);text-decoration:none}
.sheet-item .icon{width:20px;height:20px;flex:none;color:var(--muted)}
.sheet-item.active{background:var(--ink);color:#fff}
.sheet-item.active .icon{color:#fff}
.sheet-item.danger{color:#b62a39}
.sheet-item.danger .icon{color:#b62a39}
@media (max-width:620px){
  .row{flex-direction:column;gap:14px}
  .row > .card{min-width:0 !important;width:100% !important;flex:1 1 auto !important}
  .card{padding:16px 16px}
  .stats{grid-template-columns:repeat(2,1fr)}
  .container{padding:18px 14px calc(92px + env(safe-area-inset-bottom, 0px))}
  h1{font-size:20px}
}
@media (max-width:400px){
  .stats{grid-template-columns:1fr}
}
