/* PSS Hub brand — ตรงกับหน้า landing (accent #2540E8) */
:root {
  /* dark = navy panel เหมือน section เข้มของ landing */
  --bg: #0B1B3A; --bg2: #12233f; --bg3: #1c2e4d;
  --border: #26375a; --border2: #1a2c4d;
  --text: #EAF0FB; --muted: #AEB9D4; --muted2: #8593b0;
  --accent: #5B78FF; --green: #16C173; --red: #FF6B5E; --yellow: #F0A24E;
  --purple: #a78bfa; --teal: #2dd4bf;
  --brand-ink: #0B1B3A; --brand-surface: #F6F7FB;
  --radius: 8px;
}
:root[data-theme="light"] {
  --bg: #F6F7FB; --bg2: #ffffff; --bg3: #EEF1F7;
  --border: #E7EAF2; --border2: #EEF1F7;
  --text: #0B1B3A; --muted: #5A6780; --muted2: #8A96AC;
  --accent: #2540E8; --green: #0B9E5B; --red: #E0483B; --yellow: #E86A2B;
  --purple: #7C3AED; --teal: #0d9488;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(circle at top left, rgba(37,64,232,.10), transparent 28rem),
    var(--bg);
  color: var(--text);
  font: 14px/1.6 'Anuphan', -apple-system, "Segoe UI", system-ui, "Noto Sans Thai", sans-serif;
}
/* หัวข้อ + ตัวเลขเด่น = Space Grotesk (เหมือน landing) */
h1, h2, h3, .statcard .n { font-family: 'Space Grotesk', 'Anuphan', sans-serif; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
textarea { resize: vertical; min-height: 70px; font-family: inherit; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--bg2); }
code, .mono { font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace; font-size: 12.5px; }

/* buttons */
.btn { background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 14px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--bg2); border-color: var(--muted); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: #168f7e; }
.btn.blue { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* layout — sidebar ซ้าย + content ขวา */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--bg2); background: color-mix(in srgb, var(--bg2) 94%, var(--accent)); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); min-height: 68px; }
/* แบรนด์มาร์ค PSS Hub — chip ไล่สี + สี่เหลี่ยมหมุน (ตรงกับหน้า landing) */
.brand::before, .brand::after, .login-brand::before, .login-brand::after { content: none; }
.brandmark { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #2540E8, #5B78FF);
  box-shadow: 0 6px 18px rgba(37,64,232,.35);
  display: flex; align-items: center; justify-content: center; }
.brandmark i { display: block; width: 14px; height: 14px; border: 2.5px solid #fff;
  border-radius: 4px; border-bottom-color: transparent; transform: rotate(-45deg); }
.brandname { font-family: 'Space Grotesk','Anuphan',sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--text); }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), var(--green));
  display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sidenav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidenav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 7px; color: var(--muted); font-weight: 600; }
.sidenav a:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.sidenav a.active { color: var(--text); background: var(--bg3); box-shadow: inset 3px 0 0 var(--teal); }
.sidenav .ico { width: 18px; text-align: center; font-size: 15px; }
.side-foot { padding: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main .container { flex: 1; }
.app-footer { display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.app-footer img { height: 14px; }
body, .sidebar, .panel, .btn, input, select, textarea { transition: background-color .15s, border-color .15s, color .15s; }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.container { width: 100%; margin: 0; padding: 26px 32px; }

@media (max-width: 760px) {
  .sidebar { width: 60px; }
  .brand { font-size: 0; padding: 16px 0; justify-content: center; }
  .brand::after { content: ""; display: none; }
  .sidenav a { justify-content: center; padding: 11px 0; font-size: 0; gap: 0; }
  .sidenav .ico { font-size: 17px; }
  .side-foot { display: none; }
  .container { padding: 18px 14px; }
}

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.statcard { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.statcard .n { font-size: 28px; font-weight: 700; }
.statcard .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.statcard.warn .n { color: var(--yellow); }
.statcard.danger .n { color: var(--red); }
.statcard.ok .n { color: var(--green); }

.panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; font-weight: 600; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }

/* pills / badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); background: var(--bg); font-weight: 600; }
.badge.green { color: var(--green); border-color: rgba(63,185,80,.4); background: rgba(63,185,80,.1); }
.badge.blue { color: var(--accent); border-color: rgba(47,129,247,.4); background: rgba(47,129,247,.1); }
.badge.red { color: var(--red); border-color: rgba(248,81,73,.4); background: rgba(248,81,73,.1); }
.badge.yellow { color: var(--yellow); border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.1); }
.badge.purple { color: var(--purple); border-color: rgba(163,113,247,.4); background: rgba(163,113,247,.1); }
.badge.gray { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .grid3 { grid-template-columns: 1fr; } }
.flex1 { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* repo cards */
.repo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.repo-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.repo-card h3 { margin: 0 0 4px; font-size: 16px; }
.repo-card .meta { color: var(--muted); font-size: 13px; margin: 8px 0; min-height: 20px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 9px 16px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--teal); }

/* release item */
.release { display: flex; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.release .side { width: 160px; flex-shrink: 0; }
.release .body { flex: 1; }
.release .note { white-space: pre-wrap; color: var(--text); margin: 8px 0; }
.asset { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; margin-top: 6px; background: var(--bg); }
.asset .fn { flex: 1; }

/* login */
.login-wrap { max-width: 360px; margin: 11vh auto; padding: 0 16px; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 30px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; display: flex; gap: 10px; align-items: center; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 14px; }
.login-brand::before, .login-brand::after { content: none; }
.login-brand .brandmark { width: 46px; height: 46px; border-radius: 11px; }
.login-brand .brandmark i { width: 18px; height: 18px; }
.login-brand .brandname { font-size: 25px; }
.login-brand img { display: none; }
.or-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 20px 0 14px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-footer { text-align: center; margin-top: 20px; color: var(--muted); font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.login-footer img { height: 14px; }
/* sidebar brand logo — เต็มความกว้างเมนู */
.brand-img { display: none; }
.brand span { font-weight: 800; letter-spacing: .5px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(1,4,9,.7); display: flex; align-items: flex-start;
  justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 560px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; display: flex; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg3); border: 1px solid var(--border); border-left: 3px solid var(--green);
  padding: 12px 16px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.perm-table th, .perm-table td { text-align: center; }
.perm-table input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; }
.perm-table tbody tr:hover td { background: var(--bg2); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; }

/* api docs */
.panel-body h3 { font-size: 14px; margin: 20px 0 8px; }
.panel-body h3:first-child { margin-top: 0; }
.codewrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: 6px 0 14px; background: var(--bg); }
.codebar { display: flex; align-items: center; padding: 5px 10px; background: var(--bg3); border-bottom: 1px solid var(--border); font-size: 11px; }
.codebar .muted { flex: 1; text-transform: uppercase; letter-spacing: .05em; }
.copybtn { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 5px; padding: 2px 9px; font-size: 11px; }
.copybtn:hover { color: var(--text); border-color: var(--muted); }
.codeblock { margin: 0; padding: 12px 14px; overflow-x: auto; font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12.5px; line-height: 1.5; color: var(--text); white-space: pre; }
.method { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 5px; min-width: 48px; text-align: center; }
.method.get { background: rgba(63,185,80,.15); color: var(--green); }
.method.post { background: rgba(47,129,247,.15); color: var(--accent); }
.method.put { background: rgba(210,153,34,.15); color: var(--yellow); }
.method.delete { background: rgba(248,81,73,.15); color: var(--red); }
td .method { margin: 0; }
.panel-body > details { border-top: 1px solid var(--border); padding: 11px 2px; }
.panel-body > details > summary { font-weight: 700; color: var(--text); font-size: 14px; list-style: none; }
.panel-body > details > summary::before { content: '▸ '; color: var(--muted); }
.panel-body > details[open] > summary::before { content: '▾ '; }
.panel-body > details[open] > summary { margin-bottom: 4px; }

/* rating (ดาว) */
.rating-sum { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.rev-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.rev { border-left: 2px solid var(--border); padding: 2px 0 2px 10px; }

/* spinner ในปุ่ม (สถานะ loading) */
.spin { display: inline-block; width: 13px; height: 13px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: .75; cursor: progress; }
