/* Portiova Admin — layout and components on top of Bootstrap 5.3 */
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-thai-400-normal.woff2") format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-thai-500-normal.woff2") format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-thai-600-normal.woff2") format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 700; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-thai-700-normal.woff2") format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 700; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-thai-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  --pa-primary: #4f46e5;
  --pa-accent: #7c3aed;
  --pa-canvas: #f6f7fb;
  --pa-ink: #0f172a;
  --pa-muted: #64748b;
  --pa-line: #e5e7f0;
  --pa-sidebar: #111827;
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-body-font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
  --bs-body-color: #0f172a;
  --bs-border-radius: 0.6rem;
}
body { background: var(--pa-canvas); font-size: 0.94rem; }
.btn-primary { --bs-btn-bg: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; --bs-btn-disabled-bg: #4f46e5; --bs-btn-disabled-border-color: #4f46e5; }
.btn-outline-primary { --bs-btn-color: #4f46e5; --bs-btn-border-color: #c7c4f6; --bs-btn-hover-bg: #4f46e5; --bs-btn-hover-border-color: #4f46e5; --bs-btn-active-bg: #4338ca; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 2000; background: #fff; padding: 8px 12px; }
.skip-link:focus { left: 8px; }

/* ---------- Auth ---------- */
.layout-auth { background: radial-gradient(60% 50% at 20% 0%, #e0e7ff 0, transparent 70%), radial-gradient(50% 50% at 100% 100%, #f3e8ff 0, transparent 70%), #f8fafc; }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 32px; box-shadow: 0 20px 60px #0f172a14; border: 1px solid var(--pa-line); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand div { display: flex; flex-direction: column; line-height: 1.2; }
.auth-brand span { color: var(--pa-muted); font-size: 0.85rem; }
.auth-foot { color: var(--pa-muted); font-size: 0.8rem; margin-top: 16px; }
.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border: 1px solid var(--pa-line); border-radius: 12px; }
.qr-box svg, .qr-box img { width: 200px; height: 200px; }
.secret-code { font-family: ui-monospace, monospace; letter-spacing: 0.12em; word-break: break-all; }

/* ---------- Shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 260px; flex: 0 0 260px; background: var(--pa-sidebar); color: #cbd5e1; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 4px 8px 16px; }
.sidebar-brand span { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand small { color: #94a3b8; font-size: 0.75rem; }
.sidebar-group { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; color: #64748b; margin: 16px 10px 6px; }
.admin-sidebar .nav-link { color: #cbd5e1; border-radius: 10px; padding: 8px 10px; display: flex; gap: 10px; align-items: center; }
.admin-sidebar .nav-link:hover { background: #1f2937; color: #fff; }
.admin-sidebar .nav-link.active { background: linear-gradient(90deg, #4f46e5, #7c3aed); color: #fff; }
.admin-sidebar .nav-link:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 4px; display: flex; flex-direction: column; gap: 8px; font-size: 0.8rem; }
.sidebar-foot a { color: #a5b4fc; text-decoration: none; }
.mode-pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-weight: 600; width: fit-content; }
.mode-live { background: #065f46; color: #d1fae5; }
.mode-test { background: #92400e; color: #fef3c7; }
.mode-disabled { background: #374151; color: #e5e7eb; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar { display: flex; align-items: center; gap: 12px; background: #fff; border-bottom: 1px solid var(--pa-line); padding: 10px 24px; position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #eef2ff; color: #4f46e5; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.admin-content { padding: 24px; max-width: 1400px; width: 100%; }
@media (max-width: 991.98px) {
  .admin-sidebar { position: fixed; left: 0; top: 0; z-index: 1040; transform: translateX(-100%); transition: transform 0.2s; }
  .admin-sidebar.open { transform: none; box-shadow: 0 0 0 100vmax #0f172a66; }
  .admin-content { padding: 16px; }
}

/* ---------- Page parts ---------- */
.page-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--pa-muted); margin: 4px 0 0; }
.card { border: 1px solid var(--pa-line); border-radius: 14px; box-shadow: 0 1px 2px #0f172a0a; }
.card-header { background: transparent; border-bottom: 0; padding: 16px 18px 0; font-weight: 600; }
.card-body { padding: 16px 18px; }
.kpi { display: flex; flex-direction: column; gap: 4px; height: 100%; }
.kpi-label { color: var(--pa-muted); font-size: 0.82rem; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.kpi-sub { font-size: 0.8rem; color: var(--pa-muted); }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: #eef2ff; color: #4f46e5; }
.trend-up { color: #059669; }
.trend-down { color: #dc2626; }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 0.6rem 0.65rem; }
.table thead th { color: var(--pa-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom-color: var(--pa-line); white-space: nowrap; }
.table td { vertical-align: middle; border-color: #f1f2f7; }
.table-hover tbody tr { cursor: default; }
.mono { font-family: ui-monospace, monospace; font-size: 0.82rem; }
.badge-soft { font-weight: 600; border-radius: 999px; padding: 0.3em 0.7em; }
.badge-soft.ok { background: #d1fae5; color: #065f46; }
.badge-soft.warn { background: #fef3c7; color: #92400e; }
.badge-soft.bad { background: #fee2e2; color: #991b1b; }
.badge-soft.info { background: #e0e7ff; color: #3730a3; }
.badge-soft.muted { background: #f1f5f9; color: #475569; }
.badge-soft.pro { background: linear-gradient(90deg, #4f46e5, #7c3aed); color: #fff; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }
.empty-state { text-align: center; color: var(--pa-muted); padding: 28px 12px; }
.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.alert-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #f8fafc; }
.alert-list li.warn { background: #fffbeb; }
.alert-list li.bad { background: #fef2f2; }
.alert-list li.ok { background: #ecfdf5; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 0.86rem; }
.funnel-bar { height: 12px; border-radius: 999px; background: #eef2ff; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4f46e5, #7c3aed); }
.dl-grid { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
.dl-grid dt { color: var(--pa-muted); font-weight: 500; }
.dl-grid dd { margin: 0; overflow-wrap: anywhere; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .bi-check-circle-fill { color: #059669; }
.matrix .bi-x-circle { color: #cbd5e1; }
.content-view { background: #f8fafc; border-radius: 12px; padding: 14px; max-height: 60vh; overflow: auto; }
.content-view h6 { margin-top: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 18px; }
.swatch-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; border: 1px solid #0001; }
.sr-status { position: absolute; left: -9999px; }
.badge-soft { white-space: nowrap; }
.alert-list.scroll { max-height: 330px; overflow-y: auto; }
.table .col-wide { min-width: 220px; }
.funnel-row small { color: var(--pa-muted); font-weight: 400; margin-left: 4px; }
