/* สไตล์ร่วมของหน้าสมาชิก (login / verify / reset / account / admin) — โทนเดียวกับแดชบอร์ด */
:root {
  --bg: #0b0e14; --panel: #131722; --panel-2: #0d1017; --raise: #1a1e29;
  --line: #1e222d; --line-2: #262b38; --line-3: #3a4050;
  --text: #d1d4dc; --text-hi: #eaecef; --muted: #8b93a7; --faint: #5a5f6b;
  --gold: #ffb800; --gold-hi: #ffc633; --on-gold: #14110a;
  --green: #26a69a; --red: #ef5350; --red-soft: #ef8a88; --blue: #5b9bd5;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh;
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", "Leelawadee UI", sans-serif; font-size: 14px; line-height: 1.5;
}
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code, .mono { font-family: Consolas, Menlo, "Courier New", monospace; }

/* ---------- auth card (login / verify / reset) ---------- */
.auth-body {
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255,184,0,.08), transparent 70%);
}
.card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px 24px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 40px; height: 40px; }
.brand h1 { font-size: 19px; font-weight: 600; color: var(--text-hi); }
.brand span { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.card h2 { font-size: 18px; color: var(--text-hi); margin-bottom: 6px; }
.lead { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.lead b { color: var(--text-hi); word-break: break-all; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; margin-bottom: 20px; }
.tabs button { background: transparent; border: 0; color: var(--muted); padding: 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.tabs button.active { background: #1e2530; color: var(--gold); font-weight: 600; }
.foot { text-align: center; font-size: 11px; color: var(--faint); margin-top: 18px; line-height: 1.6; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12.5px; padding: 0; }
.linkish:hover { color: var(--text); }
.center { text-align: center; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-size: 12px; color: #9aa1b2; margin: 0 0 6px; }
.input, .field input[type=email], .field input[type=password], .field input[type=text], .field textarea, .field select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line-2); color: #e6e9f0; border-radius: 8px;
  padding: 10px 12px; font-size: 15px; outline: none;
}
.field textarea { min-height: 70px; resize: vertical; font-size: 13.5px; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,184,0,.12); }
.input[readonly] { color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 58px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: var(--muted); font-size: 12px; padding: 6px 8px; cursor: pointer; }
.hint { font-size: 11.5px; color: #6b7080; margin-top: 5px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #9aa1b2; cursor: pointer; }
.code-input { text-align: center; font-family: Consolas, Menlo, monospace; font-size: 26px !important; letter-spacing: 10px; padding: 12px 8px !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.strength { height: 4px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.strength > i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s, background .2s; }
.strength-label { font-size: 11px; color: var(--muted); margin-top: 4px; min-height: 15px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--raise); border: 1px solid var(--line-2); color: var(--text); padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--line-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: var(--on-gold); border-color: var(--gold); font-weight: 700; }
.btn-primary:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn-danger { color: var(--red-soft); border-color: rgba(239,83,80,.35); }
.btn-danger:hover { background: rgba(239,83,80,.08); border-color: rgba(239,83,80,.6); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- messages ---------- */
.msg { display: none; font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; line-height: 1.55; }
.msg.error { display: block; background: rgba(239,83,80,.1); color: var(--red-soft); border: 1px solid rgba(239,83,80,.25); }
.msg.info { display: block; background: rgba(91,155,213,.1); color: #8fb8e0; border: 1px solid rgba(91,155,213,.25); }
.msg.ok { display: block; background: rgba(38,166,154,.1); color: #5fcfc4; border: 1px solid rgba(38,166,154,.3); }
.toast-wrap { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #1e2530; border: 1px solid var(--line-2); color: var(--text-hi); padding: 11px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toast-in .2s ease-out; }
.toast.error { border-color: rgba(239,83,80,.5); }
.toast.ok { border-color: rgba(38,166,154,.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.b-green { background: rgba(38,166,154,.12); color: #4fc3b6; border-color: rgba(38,166,154,.25); }
.b-red { background: rgba(239,83,80,.1); color: var(--red-soft); border-color: rgba(239,83,80,.25); }
.b-gold { background: rgba(255,184,0,.12); color: var(--gold); border-color: rgba(255,184,0,.25); }
.b-blue { background: rgba(91,155,213,.12); color: #8fb8e0; border-color: rgba(91,155,213,.25); }
.b-grey { background: rgba(139,147,167,.1); color: var(--muted); border-color: rgba(139,147,167,.25); }

/* ---------- app pages (account / admin) ---------- */
.app-top { position: sticky; top: 0; z-index: 50; background: rgba(11,14,20,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.app-top-inner { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 12px; }
.app-top .back { color: var(--muted); text-decoration: none; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; border-radius: 8px; }
.app-top .back:hover { background: var(--raise); color: var(--text); }
.app-top h1 { font-size: 16px; font-weight: 600; color: var(--text-hi); display: flex; align-items: center; gap: 10px; }
.app-top h1 img { width: 24px; height: 24px; }
.app-top .spacer { flex: 1; }
.app-main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.app-main.narrow { max-width: 760px; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-bottom: 16px; }
.section > h2 { font-size: 15px; color: var(--text-hi); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section > .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; text-align: left; }
.stat:hover { border-color: var(--line-2); }
.stat.active { border-color: var(--gold); }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; color: var(--text-hi); margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v.warn { color: var(--gold); }
.stat .v.bad { color: var(--red-soft); }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { position: relative; flex: 1; min-width: 200px; }
.search input { width: 100%; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px 9px 34px; font-size: 14px; outline: none; color: #e6e9f0; }
.search input:focus { border-color: var(--gold); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.sys-status { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12px; color: var(--muted); align-items: center; }

/* table */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.users { width: 100%; border-collapse: collapse; }
table.users th { text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
table.users td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
table.users tbody tr { cursor: pointer; }
table.users tbody tr:hover { background: #161a25; }
table.users tbody tr:last-child td { border-bottom: 0; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2a2f3d; color: var(--text-hi); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; text-transform: uppercase; }
.avatar.admin { background: var(--gold); color: var(--on-gold); }
.who .n { color: var(--text-hi); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .e { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who > div { min-width: 0; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--panel); border-left: 1px solid var(--line-2); z-index: 101; transform: translateX(100%); transition: transform .22s ease-out; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.drawer-head .who { flex: 1; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 10px; font-weight: 600; }
.drawer h3:first-child { margin-top: 0; }
.x-btn { background: transparent; border: 0; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.x-btn:hover { background: var(--raise); color: var(--text); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .t { font-size: 13.5px; color: var(--text-hi); }
.toggle-row .d { font-size: 11.5px; color: var(--muted); }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2a2f3d; border-radius: 22px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:disabled + span { opacity: .45; cursor: not-allowed; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { color: var(--text); word-break: break-all; }

/* activity list */
.events { list-style: none; }
.events li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.events li:last-child { border-bottom: 0; }
.events .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--muted); }
.events .dot.ok { background: var(--green); }
.events .dot.bad { background: var(--red); }
.events .dot.warn { background: var(--gold); }
.events .ev { color: var(--text-hi); }
.events .meta { color: var(--faint); font-size: 11.5px; word-break: break-all; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; padding: 20px 22px; }
.modal h2 { font-size: 16px; color: var(--text-hi); margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }

/* 2FA */
.qr-box { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin: 6px 0 16px; }
.qr { background: #fff; border-radius: 10px; padding: 6px; width: 180px; height: 180px; flex-shrink: 0; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { font-family: Consolas, Menlo, monospace; background: var(--panel-2); border: 1px dashed var(--line-3); border-radius: 8px; padding: 8px 10px; font-size: 13px; letter-spacing: 1px; word-break: break-all; color: var(--text-hi); }
.steps { padding-left: 18px; color: var(--text); font-size: 13px; }
.steps li { margin-bottom: 6px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; margin: 10px 0 14px; }
.codes code { font-size: 15px; color: var(--text-hi); text-align: center; padding: 4px; letter-spacing: 1px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .app-top-inner { padding: 10px 14px; gap: 8px; }
  .app-top .lbl { display: none; }
  .app-top h1 { font-size: 15px; white-space: nowrap; }
  .app-main { padding: 16px 14px 60px; }
  .section { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat .v { font-size: 19px; }
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; width: 100%; }
  table.users tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.users tbody tr:last-child { border-bottom: 0; }
  table.users td { padding: 0; border: 0; }
  table.users td + td { margin-top: 8px; }
  table.users td[data-label]::before { content: attr(data-label) " · "; color: var(--faint); font-size: 11.5px; }
  table.users td.hide-sm { display: none; }
  .kv { grid-template-columns: 105px 1fr; }
  .card { padding: 24px 18px 20px; }
}

/* Google sign-in */
.or-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted, #8a93a6); font-size: 12.5px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--border, rgba(255,255,255,.12)); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; text-decoration: none; }
.btn-google:hover { background: #f5f7fa; color: #1f1f1f; }
.g-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: rgba(66,133,244,.15); color: #8ab4f8; border: 1px solid rgba(66,133,244,.35); }
