/* KMM Auto Server — หน้าแอดมิน
   ธีม: กระจกฝ้า มุมโค้ง ไล่สีแบรนด์ #6d6cff → #ec4899 • สว่าง/มืด (data-theme บน <html>) • ฟอนต์ของระบบที่แสดงไทยได้ดี (ไม่โหลดฟอนต์จากภายนอก) */

:root {
  --font: 'Leelawadee UI', 'Noto Sans Thai', Tahoma, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --brand-a: #6d6cff;
  --brand-b: #ec4899;
  --grad: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  --radius: 18px;
  --radius-sm: 12px;

  --bg: #f3f4fb;
  --blob-1: rgba(109, 108, 255, 0.2);
  --blob-2: rgba(236, 72, 153, 0.15);
  --blob-3: rgba(56, 189, 248, 0.13);
  --surface: rgba(255, 255, 255, 0.8);
  --surface-glass: rgba(255, 255, 255, 0.66);
  --surface-solid: #ffffff;
  --surface-sub: rgba(23, 26, 46, 0.045);
  --line: rgba(23, 26, 46, 0.09);
  --line-strong: rgba(23, 26, 46, 0.16);
  --text: #171a2e;
  --muted: #555b75;
  --faint: #777d96;
  --brand-text: #5a55e6;
  --brand-bg: rgba(109, 108, 255, 0.12);
  --ok: #047857;
  --ok-bg: rgba(16, 185, 129, 0.15);
  --ok-dot: #10b981;
  --warn: #a8500a;
  --warn-bg: rgba(245, 158, 11, 0.2);
  --warn-line: rgba(245, 158, 11, 0.55);
  --err: #d42626;
  --err-bg: rgba(239, 68, 68, 0.12);
  --err-line: rgba(239, 68, 68, 0.45);
  --shadow: 0 1px 2px rgba(23, 26, 46, 0.05), 0 14px 34px -16px rgba(60, 50, 140, 0.25);
  --shadow-pop: 0 30px 70px -24px rgba(30, 20, 90, 0.45);
  --focus: 0 0 0 3px rgba(109, 108, 255, 0.35);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #090a16;
  --blob-1: rgba(109, 108, 255, 0.28);
  --blob-2: rgba(236, 72, 153, 0.17);
  --blob-3: rgba(56, 189, 248, 0.1);
  --surface: rgba(255, 255, 255, 0.06);
  --surface-glass: rgba(20, 21, 40, 0.62);
  --surface-solid: #181a30;
  --surface-sub: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #eef0fb;
  --muted: #aab0cb;
  --faint: #8187a5;
  --brand-text: #aeb0ff;
  --brand-bg: rgba(125, 124, 255, 0.2);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.15);
  --ok-dot: #34d399;
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.15);
  --warn-line: rgba(251, 191, 36, 0.45);
  --err: #fb7185;
  --err-bg: rgba(251, 113, 133, 0.16);
  --err-line: rgba(251, 113, 133, 0.5);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 44px -20px rgba(0, 0, 0, 0.8);
  --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, 0.85);
  --focus: 0 0 0 3px rgba(140, 139, 255, 0.45);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(52% 44% at 8% 0%, var(--blob-1), transparent 70%),
    radial-gradient(46% 40% at 100% 6%, var(--blob-2), transparent 70%),
    radial-gradient(50% 46% at 55% 108%, var(--blob-3), transparent 70%);
}

/* ---------- ไอคอน ---------- */

.i {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.plat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-sub);
}

.plat svg {
  width: 15px;
  height: 15px;
}

.plat.yt {
  color: #ff2d2d;
  background: rgba(255, 45, 45, 0.12);
}

.plat.fb {
  color: #2b7cff;
  background: rgba(43, 124, 255, 0.14);
}

/* ---------- พื้นผิว / ป้าย / ปุ่ม ---------- */

.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface-sub);
}

.pill .i {
  width: 13px;
  height: 13px;
  vertical-align: 0;
}

.pill-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.pill-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.pill-err {
  color: var(--err);
  background: var(--err-bg);
}

.pill-brand {
  color: var(--brand-text);
  background: var(--brand-bg);
}

.t-ok {
  color: var(--ok);
}

.t-warn {
  color: var(--warn);
}

.t-err {
  color: var(--err);
}

.t-mute {
  color: var(--faint);
}

.t-brand {
  color: var(--brand-text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.2;
  white-space: nowrap;
  transition:
    transform 0.12s,
    box-shadow 0.15s,
    background 0.15s,
    border-color 0.15s;
}

.btn:hover {
  border-color: var(--brand-a);
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.card:focus-visible,
.seg button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.btn-primary {
  border-color: transparent;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(109, 108, 255, 0.75);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

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

.btn-ghost:hover {
  background: var(--surface-sub);
  border-color: transparent;
  color: var(--text);
}

.btn-danger {
  color: var(--err);
  border-color: var(--err-line);
  background: var(--err-bg);
}

.btn-danger:hover {
  border-color: var(--err);
}

.btn-warn {
  color: var(--warn);
  border-color: var(--warn-line);
  background: var(--warn-bg);
}

.btn-warn:hover {
  border-color: var(--warn);
}

.btn-solid-danger {
  border-color: transparent;
  background: #dc2626;
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  transition:
    background 0.15s,
    color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-sub);
  color: var(--text);
}

.input,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  border-color: var(--brand-a);
  box-shadow: var(--focus);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

.hint {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--faint);
}

.hint a {
  color: var(--brand-text);
  font-weight: 600;
  text-decoration: underline;
}

.pw {
  position: relative;
}

.pw .input {
  padding-right: 46px;
}

.pw .icon-btn {
  position: absolute;
  top: 1px;
  right: 2px;
}

.msg {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
}

.msg-err {
  color: var(--err);
  background: var(--err-bg);
}

.msg-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.msg-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

/* ---------- โครงหน้า ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-glass);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
}

.top-in {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1320px;
  height: 62px;
  margin: 0 auto;
  padding: 0 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  margin-right: auto;
  border-radius: 12px;
}

.logo img {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  box-shadow: 0 8px 18px -8px rgba(109, 108, 255, 0.8);
}

.logo b {
  display: block;
  font-size: 16px;
  line-height: 1.25;
  white-space: nowrap;
}

.logo span {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  color: var(--faint);
  white-space: nowrap;
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-sub);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.sync .led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok-dot);
}

.sync.bad {
  color: var(--err);
  background: var(--err-bg);
}

.sync.bad .led {
  background: var(--err);
}

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 64px;
}

.splash,
.noscript {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 70vh;
  color: var(--muted);
}

.splash img {
  border-radius: 16px;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.page-title h1 {
  font-size: 21px;
  line-height: 1.3;
}

/* ---------- ภาพรวม: ตัวเลขสรุป ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.tile-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font-size: 21px;
  box-shadow: 0 10px 20px -10px rgba(109, 108, 255, 0.8);
}

.tile-ic.ok {
  background: linear-gradient(135deg, #10b981, #22d3ee);
  box-shadow: 0 10px 20px -10px rgba(16, 185, 129, 0.8);
}

.tile-ic.err {
  background: linear-gradient(135deg, #f43f5e, #f97316);
  box-shadow: 0 10px 20px -10px rgba(244, 63, 94, 0.8);
}

.tile-ic.warn {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 10px 20px -10px rgba(245, 158, 11, 0.8);
}

.tile-txt {
  min-width: 0;
}

.tile-num {
  display: block;
  font-size: 29px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.tile-num small {
  font-size: 16px;
  font-weight: 600;
  color: var(--faint);
}

.tile-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.4;
}

.tile-sub {
  display: block;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--faint);
}

/* ---------- ภาพรวม: ค้นหา + ตัวกรอง ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 420px;
}

.search .i {
  position: absolute;
  top: 50%;
  left: 13px;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 16px;
  pointer-events: none;
}

.search .input {
  padding-left: 40px;
  background: var(--surface);
}

.seg {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.seg button b {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-sub);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.seg button.on {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 16px -10px rgba(109, 108, 255, 0.9);
}

.seg button.on b {
  background: rgba(255, 255, 255, 0.24);
}

/* ---------- ภาพรวม: การ์ดเครื่อง ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
  padding: 16px 18px 13px;
  overflow: hidden;
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
}

.card[data-sev='error'] {
  border-color: var(--err-line);
}

.card[data-sev='error']::before {
  background: linear-gradient(90deg, #f43f5e, #f97316);
}

.card[data-sev='warn'] {
  border-color: var(--warn-line);
}

.card[data-sev='warn']::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.card[data-sev='blocked'] {
  border-style: dashed;
  border-color: var(--line-strong);
}

.card[data-sev='blocked'] .c-body,
.card[data-sev='blocked'] .c-probs {
  opacity: 0.55;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    border-color: var(--brand-a);
    box-shadow:
      var(--shadow),
      0 18px 36px -22px rgba(109, 108, 255, 0.6);
  }
}

.c-top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.dot {
  position: relative;
  flex: none;
  width: 11px;
  height: 11px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.dot-on {
  background: var(--ok-dot);
}

.dot-on::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ok-dot);
  opacity: 0;
  animation: ping 2.2s ease-out infinite;
}

.dot-off {
  background: var(--err);
}

@keyframes ping {
  0% {
    transform: scale(0.6);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.c-title {
  flex: 1 1 0;
  min-width: 0;
}

.c-title h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.4;
}

.c-title p {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-badges {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  max-width: 48%;
  padding-top: 1px;
}

.c-conn {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  font-size: 13.5px;
  color: var(--muted);
}

.c-conn b {
  font-weight: 600;
}

.c-body {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.c-body.stale {
  opacity: 0.62;
}

.c-sched {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface-sub);
  font-size: 13.5px;
  line-height: 1.5;
}

.c-sched > .i {
  margin-top: 2px;
  font-size: 17px;
}

.c-sched b {
  font-weight: 600;
}

.c-sched p {
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.c-sched .bar {
  margin-top: 6px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  padding: 8px 4px 7px;
  border-radius: 12px;
  background: var(--surface-sub);
  text-align: center;
}

.stat i {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-style: normal;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
}

.stat i .i {
  width: 12px;
  height: 12px;
  vertical-align: 0;
}

.stat b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.stat small {
  display: block;
  font-size: 11px;
  line-height: 1.35;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c-none {
  padding: 14px 12px;
  border-radius: 12px;
  background: var(--surface-sub);
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
}

.c-probs {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.c-probs li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.c-probs li .i {
  margin-top: 3px;
  font-size: 14px;
}

.c-probs li span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.c-probs .more {
  padding-left: 22px;
  color: var(--faint);
  font-size: 12.5px;
}

.c-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--faint);
}

.c-foot .go {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  color: var(--brand-text);
  font-weight: 600;
}

/* ---------- ว่าง / ผิดพลาด ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 620px;
  margin: 26px auto;
  padding: 34px 26px;
  text-align: center;
}

.empty-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin-bottom: 6px;
  border-radius: 20px;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-size: 28px;
}

.empty-ic.err {
  background: var(--err-bg);
  color: var(--err);
}

.empty h2 {
  font-size: 18px;
}

.empty p {
  color: var(--muted);
}

.empty ol {
  margin: 8px 0 0;
  padding-left: 22px;
  text-align: left;
  color: var(--muted);
}

.empty .btn {
  margin-top: 10px;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: var(--surface-sub);
  text-align: left;
}

.copy-row code {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-text);
}

/* ---------- รายละเอียดเครื่อง ---------- */

.d-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.d-head .back {
  padding: 0 12px 0 8px;
}

.d-title {
  flex: 1 1 auto;
  min-width: 0;
}

.d-title h1 {
  font-size: 22px;
  line-height: 1.35;
}

.d-title p {
  font-size: 13px;
  color: var(--faint);
}

.d-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 14px;
}

.banner .i {
  margin-top: 3px;
  font-size: 17px;
}

.banner-err {
  color: var(--err);
  border-color: var(--err-line);
  background: var(--err-bg);
}

.banner-mute {
  color: var(--muted);
  border-style: dashed;
  border-color: var(--line-strong);
  background: var(--surface-sub);
}

.d-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.d-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 16px 18px 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 13px;
}

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.4;
}

.panel-head h2 .i {
  color: var(--brand-text);
  font-size: 17px;
}

.panel-head .sum {
  margin-left: auto;
  font-size: 13px;
  color: var(--faint);
}

.sub-title {
  margin: 16px 0 9px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
}

.none {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-sub);
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
}

.none.good {
  color: var(--ok);
  background: var(--ok-bg);
}

.st-main {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 14px;
}

.st-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--surface-sub);
  color: var(--muted);
  font-size: 24px;
}

.st-ic.is-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.st-ic.is-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.st-ic.is-brand {
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 20px -10px rgba(109, 108, 255, 0.8);
}

.st-main b {
  display: block;
  font-size: 17px;
  line-height: 1.4;
}

.st-main p {
  font-size: 13.5px;
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.fact {
  min-width: 0;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--surface-sub);
}

.fact i {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--faint);
}

.fact b {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
}

.fact small {
  display: block;
  font-size: 12px;
  color: var(--faint);
}

.st-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--muted);
}

.st-msg .i {
  margin-top: 3px;
  color: var(--faint);
}

.run {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.run + .run {
  margin-top: 8px;
}

.run-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.run-top b {
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.run-sub {
  margin: 4px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.run-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--faint);
}

.bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-sub);
  overflow: hidden;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--grad);
  transition: width 0.4s;
}

.plist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plist li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.55;
}

.plist li .i {
  margin-top: 3px;
  font-size: 17px;
}

.plist li small {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.plist .p-err {
  color: var(--err);
  background: var(--err-bg);
}

.plist .p-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.plist li p {
  color: var(--text);
}

.rows {
  display: flex;
  flex-direction: column;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.row:first-child {
  padding-top: 2px;
  border-top: 0;
}

.row:last-child {
  padding-bottom: 0;
}

.row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-main b {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
}

.row-main small {
  display: block;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--faint);
}

.row-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 92px;
  gap: 6px;
}

.cell {
  min-width: 0;
  text-align: right;
}

.cell i {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--faint);
}

.cell b {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.cell small {
  display: block;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.more-btn {
  margin-top: 12px;
}

.acc {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.acc:first-child {
  padding-top: 2px;
  border-top: 0;
}

.acc:last-child {
  padding-bottom: 0;
}

.acc-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.acc-head b {
  margin-right: auto;
  font-size: 14.5px;
  font-weight: 600;
}

.acc-login {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.chips i {
  font-style: normal;
  font-size: 12.5px;
  color: var(--faint);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.6;
}

.chip small {
  color: var(--faint);
  font-size: 11.5px;
}

.hist {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.hist:first-child {
  padding-top: 2px;
  border-top: 0;
}

.hist:last-child {
  padding-bottom: 0;
}

.hist-st {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 9px;
  background: var(--surface-sub);
  color: var(--faint);
  font-size: 15px;
}

.hist-st.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.hist-st.err {
  color: var(--err);
  background: var(--err-bg);
}

.hist-main {
  flex: 1 1 auto;
  min-width: 0;
}

.hist-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
}

.hist-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 7px;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.hist-meta .when {
  color: var(--faint);
  white-space: nowrap;
}

.hist-meta .plat {
  width: 18px;
  height: 18px;
  border-radius: 6px;
}

.hist-meta .plat svg {
  width: 12px;
  height: 12px;
}

.hist-err {
  margin-top: 5px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 13px;
  line-height: 1.5;
}

.hist-err.soft {
  background: var(--surface-sub);
  color: var(--muted);
}

.hist-note {
  margin-top: 3px;
  font-size: 12.5px;
}

.hist-link {
  flex: none;
  align-self: center;
}

.kv {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 14px;
}

.kv dt {
  color: var(--faint);
  font-size: 13.5px;
}

.kv dd small {
  display: block;
  font-size: 12.5px;
  color: var(--faint);
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.set-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.set-row b {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
}

.set-row span {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.act {
  margin-top: 10px;
}

/* ---------- ตั้งค่า ---------- */

.s-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.s-grid .panel p {
  color: var(--muted);
  font-size: 14px;
}

.s-grid .panel p + p {
  margin-top: 8px;
}

.s-grid .panel p.hint,
.empty p.hint {
  font-size: 13px;
  color: var(--faint);
}

.s-grid ul.addr {
  margin-top: 10px;
}

.s-grid ul.addr li {
  padding: 3px 0;
  font-size: 13.5px;
  color: var(--muted);
}

.inline {
  display: flex;
  gap: 8px;
}

.inline .input {
  flex: 1 1 auto;
  min-width: 0;
}

.callout {
  margin: 12px 0;
  padding: 11px 14px;
  border-radius: 13px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13.5px;
  line-height: 1.6;
}

.callout b {
  font-weight: 700;
}

.callout ol {
  margin: 6px 0 0;
  padding-left: 20px;
}

.seg.full {
  display: flex;
}

.seg.full button {
  flex: 1 1 0;
}

/* ---------- เข้าสู่ระบบ ---------- */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 30px 28px 26px;
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: var(--shadow-pop);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 22px;
  text-align: center;
}

.login-brand img {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border-radius: 19px;
  box-shadow: 0 16px 30px -12px rgba(109, 108, 255, 0.85);
}

.login-brand h1 {
  font-size: 22px;
  line-height: 1.3;
}

.login-brand p {
  color: var(--muted);
  font-size: 14px;
}

.login-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--faint);
}

/* ---------- หน้าต่างยืนยัน / ข้อความแจ้ง ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(8, 9, 24, 0.55);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: fade 0.15s ease-out;
}

.modal {
  width: 100%;
  max-width: 440px;
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-pop);
  animation: pop 0.18s ease-out;
}

.modal h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 17.5px;
  line-height: 1.4;
}

.modal p {
  color: var(--muted);
  font-size: 14.5px;
}

.modal p + p {
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

#toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 520px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  font-weight: 600;
  animation: pop 0.2s ease-out;
}

.toast.ok .i {
  color: var(--ok);
}

.toast.err {
  color: var(--err);
}

.toast.out {
  opacity: 0;
  transition: opacity 0.3s;
}

/* ---------- จอแคบ ---------- */

@media (max-width: 1040px) {
  .d-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* คอลัมน์เดียว: รวมสองคอลัมน์แล้วเรียงตามความสำคัญ (class o1…o10 ของแต่ละกล่อง) */
  .d-col {
    display: contents;
  }

  .o1 {
    order: 1;
  }

  .o2 {
    order: 2;
  }

  .o3 {
    order: 3;
  }

  .o4 {
    order: 4;
  }

  .o5 {
    order: 5;
  }

  .o6 {
    order: 6;
  }

  .o7 {
    order: 7;
  }

  .o8 {
    order: 8;
  }

  .o9 {
    order: 9;
  }

  .o10 {
    order: 10;
  }

  .s-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    max-width: none;
  }

  .seg {
    display: flex;
  }

  .seg button {
    flex: 1 1 0;
    padding: 0 8px;
  }
}

@media (max-width: 640px) {
  .top-in {
    height: 56px;
    padding: 0 12px;
    gap: 4px;
  }

  .logo span {
    display: none;
  }

  .logo img {
    width: 32px;
    height: 32px;
  }

  .logo div {
    min-width: 0;
  }

  .logo b {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top .icon-btn {
    width: 36px;
    height: 36px;
  }

  .sync {
    padding: 0 9px;
  }

  .sync .sync-txt {
    display: none;
  }

  .wrap {
    padding: 14px 12px 56px;
  }

  .tiles {
    gap: 10px;
    margin-bottom: 14px;
  }

  .tile {
    gap: 11px;
    padding: 12px;
  }

  .tile-ic {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 18px;
  }

  .tile-num {
    font-size: 24px;
  }

  .tile-label {
    font-size: 12.5px;
  }

  .tile-sub {
    font-size: 11.5px;
  }

  .input,
  .textarea {
    font-size: 16px; /* iOS ซูมหน้าเองถ้าตัวอักษรในช่องกรอกเล็กกว่า 16px */
  }

  .seg button {
    font-size: 13px;
    gap: 5px;
  }

  .card {
    padding: 14px 14px 12px;
  }

  /* จอแคบ: ป้ายปัญหาลงไปอยู่บรรทัดของตัวเอง ชื่อเครื่องจะได้ไม่ถูกตัด */
  .c-top {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .c-badges {
    flex: 1 1 100%;
    justify-content: flex-start;
    max-width: none;
    padding: 0 0 0 22px;
  }

  .panel {
    padding: 14px 14px 16px;
  }

  /* ปุ่มย้อนกลับ (เหลือแค่ลูกศร) อยู่แถวเดียวกับหัวข้อ */
  .d-head {
    align-items: flex-start;
    gap: 8px 10px;
  }

  .d-title {
    flex: 1 1 0;
  }

  .d-head .back span {
    display: none;
  }

  .d-head .back {
    padding: 0 10px;
  }

  .d-title h1 {
    font-size: 19px;
  }

  .d-state {
    width: 100%;
    justify-content: flex-start;
  }

  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .row-cells {
    grid-auto-columns: minmax(0, 1fr);
    padding: 7px 4px;
    border-radius: 11px;
    background: var(--surface-sub);
  }

  .cell {
    text-align: center;
  }

  .kv {
    grid-template-columns: 108px minmax(0, 1fr);
  }

  .hist {
    flex-wrap: wrap;
  }

  .hist-main {
    flex-basis: calc(100% - 40px);
  }

  .hist-link {
    margin-left: 39px;
  }

  .inline {
    flex-direction: column;
  }

  .login-card {
    padding: 26px 20px 22px;
  }

  .modal-actions .btn {
    flex: 1 1 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   แดชบอร์ดของเครื่อง: เมนูด้านซ้าย + เนื้อหาทีละเมนู
   ============================================================ */

.dash {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.side {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 100px);
  padding: 12px;
  overflow-y: auto;
}

.side-back {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 7px;
  padding: 6px 10px 6px 8px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

.side-back:hover {
  background: var(--surface-sub);
  color: var(--text);
}

.side-id {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 2px 6px 0;
}

.side-id > div {
  min-width: 0;
}

.side-id b {
  display: block;
  font-size: 16.5px;
  line-height: 1.4;
}

.side-id small {
  display: block;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--faint);
}

.side-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 6px;
  margin-top: 6px;
  padding: 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.side-state b {
  font-weight: 600;
}

.side-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  padding: 0 6px;
}

.side-switch {
  display: block;
  padding: 10px 6px 2px;
  border-top: 1px solid var(--line);
}

.side-switch > span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--faint);
}

.side-switch select {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 14px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.nav a > .i {
  font-size: 17px;
}

.nav a > span {
  flex: 1 1 auto;
  min-width: 0;
}

.nav a:hover {
  background: var(--surface-sub);
  color: var(--text);
}

.nav a.on {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 20px -12px rgba(109, 108, 255, 0.95);
}

.nav-badge {
  flex: none;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-sub);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.75;
  text-align: center;
}

.nav-badge.err {
  background: var(--err-bg);
  color: var(--err);
}

.nav-badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.nav-badge.brand {
  background: var(--brand-bg);
  color: var(--brand-text);
}

.nav a.on .nav-badge {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
}

.page,
#pg,
.narrow {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.narrow {
  max-width: 1000px;
  margin: 0 auto;
}

.page .banner,
.page .d-head,
.narrow .d-head,
.narrow .banner {
  margin-bottom: 0;
}

/* กล่องที่ยังไม่มีเนื้อหาไม่กินช่องว่างระหว่างส่วน */
#send-note:empty,
#pg-head:empty {
  display: none;
}

/* เปลี่ยนเมนูขณะเลื่อนจออยู่: หัวข้อของหน้าต้องไม่ถูกแถบด้านบนบัง */
.page {
  scroll-margin-top: 82px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.page-head h1 {
  font-size: 23px;
  line-height: 1.3;
}

.page-head p {
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--faint);
}

.page-state {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 4px;
}

.pg-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.keys {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.keys-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* 6 ช่องในแถวเดียว (จอกว้าง): ช่องแคบ จึงเรียงแนวตั้ง — ไอคอนบน ตัวเลข ป้าย */
@media (min-width: 1181px) {
  .keys:not(.keys-3) .key {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }

  .keys:not(.keys-3) .key-txt {
    width: 100%;
  }
}

.key {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition:
    border-color 0.15s,
    transform 0.15s;
}

a.key:hover {
  border-color: var(--brand-a);
  transform: translateY(-1px);
}

.key-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-size: 17px;
}

.key-txt {
  min-width: 0;
}

.key-txt b {
  display: block;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.key-txt i {
  display: block;
  font-style: normal;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--muted);
}

.key-txt small {
  display: block;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link {
  color: var(--brand-text);
  font-weight: 600;
}

.link:hover {
  text-decoration: underline;
}

.center {
  text-align: center;
}

.chip.more {
  border-style: dashed;
  color: var(--faint);
}

.is-stale {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s;
}

.seg-wrap {
  align-self: flex-start;
  flex-wrap: wrap;
}

.toolbar-send {
  margin-left: auto;
}

/* ---------- ตัวเปลี่ยนหน้าของรายการ ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pager-info {
  font-size: 13.5px;
  text-align: center;
}

.pager-info b {
  font-weight: 600;
}

.pager-info small {
  display: block;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- ส่งของให้เครื่อง ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-sub);
}

.tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tabs button.on {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 16px -10px rgba(109, 108, 255, 0.9);
}

.tabs button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

select.input {
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 26px 16px;
  border: 2px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--surface-sub);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.drop:hover,
.drop.over {
  border-color: var(--brand-a);
  background: var(--brand-bg);
}

.drop b {
  font-size: 15px;
  font-weight: 600;
}

.drop small {
  font-size: 12.5px;
  color: var(--faint);
}

.drop-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 15px;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-size: 23px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.file-list li > .i {
  color: var(--brand-text);
  font-size: 17px;
}

.file-list li.bad {
  border-color: var(--err-line);
  background: var(--err-bg);
}

.file-list li.bad > .i {
  color: var(--err);
}

.file-list li > div {
  flex: 1 1 auto;
  min-width: 0;
}

.file-list b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.file-list small {
  display: block;
  font-size: 12.5px;
  color: var(--faint);
}

.send-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 14px;
}

.cap-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cap-box {
  position: relative;
  padding: 10px 10px 6px 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-sub);
}

.cap-no {
  position: absolute;
  top: 12px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-size: 13px;
  font-weight: 700;
}

.cap-box .textarea {
  min-height: 74px;
}

.cap-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--faint);
}

.cap-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 12px 0;
}

.cap-actions .hint,
.send-actions .hint {
  margin-top: 0;
}

.bulk {
  margin-bottom: 4px;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}

.bulk summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.bulk summary::-webkit-details-marker {
  display: none;
}

.bulk[open] summary {
  margin-bottom: 6px;
}

.bulk .textarea {
  margin-top: 8px;
}

.up-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.up-row:first-child {
  padding-top: 2px;
  border-top: 0;
}

.up-row:last-child {
  padding-bottom: 0;
}

.up-main {
  flex: 1 1 auto;
  min-width: 0;
}

.up-main b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-main small {
  display: block;
  font-size: 12.5px;
  color: var(--faint);
}

.up-main .bar {
  margin-top: 6px;
}

.up-btns {
  display: flex;
  flex: none;
  gap: 6px;
}

.hist-main > .bar {
  margin-top: 6px;
}

.tray {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(370px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-pop);
}

.tray > .i {
  font-size: 22px;
}

.pick-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pick-tools .search {
  flex: 1 1 200px;
  max-width: 300px;
}

.pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 8px;
  max-height: 300px;
  padding: 2px;
  overflow-y: auto;
}

.pick {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.pick:hover {
  border-color: var(--brand-a);
}

.pick:has(input:checked) {
  border-color: var(--brand-a);
  background: var(--brand-bg);
}

.pick input {
  flex: none;
  width: 18px;
  height: 18px;
  accent-color: var(--brand-a);
}

.pick .dot {
  margin-top: 0;
}

.pick-name {
  min-width: 0;
}

.pick-name b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-name small {
  display: block;
  font-size: 12px;
  color: var(--faint);
}

.pick-list > .none,
.pick-list > .empty {
  grid-column: 1 / -1;
  margin: 0;
}

/* ---------- ชุดวิดีโอ: หน้าวิดีโอของเครื่อง (กล่องละชุด) + ช่องเลือกชุดปลายทางตอนส่งวิดีโอ ---------- */

.vset.is-warn {
  border-color: var(--warn-line);
}

.vset-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 10px;
}

.vset-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 4px 11px 4px 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.vset-mode > span:last-child {
  min-width: 0;
}

.vset-mode b {
  font-weight: 600;
  color: var(--text);
}

.vset-mode > .i {
  width: 22px;
  height: 15px;
  color: var(--brand-text);
}

.vset .rows {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ตัวเปลี่ยนหน้าของรายการกล่อง (อยู่นอกกล่อง): ไม่ต้องมีเส้นคั่นด้านบน */
#pg > .pager {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

#vid-set-note {
  margin: -4px 0 10px;
}

#vid-set-note:empty {
  display: none;
}

#vid-set-note .hint,
#vid-set-note .msg {
  margin: 0;
}

#vid-set-note p + p {
  margin-top: 6px;
}

/* ---------- แดชบอร์ดบนจอแคบ: เมนูกลายเป็นแถบเลื่อนแนวนอนติดด้านบน ---------- */

@media (max-width: 1180px) {
  .keys {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .dash {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  /* กล่องเมนูหายไป: ชิ้นส่วนข้างในเรียงเป็นแถวของตัวเอง แถบเมนูติดอยู่ใต้หัวหน้าเว็บขณะเลื่อน */
  .side {
    display: contents;
  }

  /* ทางกลับไปหน้าทุกเครื่อง: แถวเล็ก ๆ เหนือการ์ดชื่อเครื่อง */
  .side-back {
    justify-self: start;
    margin: -2px 0 -4px;
    padding: 4px 10px 4px 6px;
  }

  #side-id {
    padding: 12px 12px 12px 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  #side-switch:empty {
    display: none;
  }

  .side-switch {
    padding: 0;
    border-top: 0;
  }

  .side-switch > span {
    display: none;
  }

  .side-switch select {
    min-height: 42px;
    background: var(--surface);
  }

  .nav {
    position: sticky;
    top: 62px;
    z-index: 15;
    flex-direction: row;
    gap: 6px;
    margin: 0 -24px;
    padding: 8px 24px;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    backdrop-filter: blur(18px) saturate(1.6);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    flex: none;
    gap: 7px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13.5px;
  }

  .nav a.on {
    border-color: transparent;
  }

  .nav a > .i {
    font-size: 15px;
  }

  .nav a > span {
    flex: none;
  }

  /* เนื้อหาสูงอย่างน้อยเท่าจอ: เปลี่ยนเมนูขณะเลื่อนจออยู่แล้วเมนูใหม่สั้น/กำลังโหลด จอก็ยังเลื่อนให้หัวข้ออยู่ใต้แถบเมนูได้ (ไม่เด้งกลับไปบนสุด) */
  .page {
    min-height: calc(100vh - 128px);
    min-height: calc(100dvh - 128px);
    scroll-margin-top: 128px;
  }
}

@media (max-width: 900px) {
  .pg-cols {
    grid-template-columns: minmax(0, 1fr);
  }

  .toolbar-send {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  /* แถบสรุปบนมือถือ: 3 ช่อง × 2 แถว แบบตั้ง (ไอคอนบน ตัวเลข ป้าย) */
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .tile {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px;
  }

  .tile-ic {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: 15px;
  }

  .tile-num {
    font-size: 22px;
  }

  .tile-label {
    font-size: 12px;
    line-height: 1.35;
  }

  .tile-sub {
    display: none;
  }

  .nav {
    top: 56px;
    margin: 0 -12px;
    padding: 8px 12px;
  }

  .page {
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
    scroll-margin-top: 120px;
  }

  .page-head h1 {
    font-size: 20px;
  }

  .page-state {
    justify-content: flex-start;
  }

  .keys,
  .keys-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .key {
    padding: 10px;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .pager {
    gap: 6px;
  }

  .pager .btn {
    padding: 0 9px;
  }

  .tabs button {
    padding: 0 8px;
    font-size: 13.5px;
  }

  .up-row {
    flex-wrap: wrap;
  }

  .up-main {
    flex-basis: calc(100% - 40px);
  }

  .up-btns {
    margin-left: 39px;
  }

  .cap-box {
    padding-left: 10px;
    padding-top: 42px;
  }

  .cap-no {
    top: 9px;
  }

  .tray {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
  }
}
