/* IBM Plex Sans Thai (OFL, see fonts/OFL.txt), thai + latin subsets, self-hosted */
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/ibm-plex-sans-thai-thai-400-normal.woff2) format("woff2");
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(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+0304,U+0308,U+0329,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-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/ibm-plex-sans-thai-thai-500-normal.woff2) format("woff2");
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/ibm-plex-sans-thai-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,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-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/ibm-plex-sans-thai-thai-600-normal.woff2) format("woff2");
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/ibm-plex-sans-thai-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --cp-bg: #f6f7f9;
  --cp-surface: #ffffff;
  --cp-border: #e5e8ec;
  --cp-text: #1c2430;
  --cp-muted: #6b7584;
  --cp-accent: #0f766e;
  --cp-radius: 10px;
  --cp-ok-bg: #dcf5ee;
  --cp-ok-fg: #0f766e;
  --cp-off-bg: #eceff2;
  --cp-off-fg: #5f6b7a;
  --cp-wait-bg: #fdf1d3;
  --cp-wait-fg: #b45309;
  --cp-bad-bg: #fde4e4;
  --cp-bad-fg: #b91c1c;
  --cp-info-bg: #e3effc;
  --cp-info-fg: #1d4ed8;
  --cp-progress-track: #e8ecef;
  --cp-progress-wait: #d97706;
  --cp-nav-fg: #4b5563;
  --cp-nav-active-bg: #e6f4f1;
  --cp-nav-active-fg: #0f766e;
  --cp-shadow: 0 1px 2px rgba(16,24,40,.04);
  --cp-font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", "Leelawadee UI", "Noto Sans Thai", sans-serif;
  --cp-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Tabler overrides */
:root {
  --tblr-font-sans-serif: var(--cp-font);
  --tblr-font-monospace: var(--cp-mono);
  --tblr-body-bg: var(--cp-bg);
  --tblr-body-color: var(--cp-text);
  --tblr-body-font-size: .9375rem;
  --tblr-body-line-height: 1.6;
  --tblr-secondary: var(--cp-muted);
  --tblr-border-color: var(--cp-border);
  --tblr-border-radius: var(--cp-radius);
  --tblr-bg-surface: var(--cp-surface);
  --tblr-primary: var(--cp-accent);
  --tblr-primary-rgb: 15,118,110;
  --tblr-primary-lt: var(--cp-nav-active-bg);
  --tblr-link-color: var(--cp-accent);
  --tblr-link-color-rgb: 15,118,110;
  --tblr-link-hover-color: var(--cp-accent);
  --tblr-badge-line-height: 1.5;
  /* Status colours: Tabler's .bg-*-lt / .text-* / .alert-* read these, so remapping them here
     (solid -lt backgrounds instead of Tabler's 10% mix) recolours every chip with no template change. */
  --tblr-green: var(--cp-ok-fg);  --tblr-green-lt: var(--cp-ok-bg);
  --tblr-teal: var(--cp-ok-fg);   --tblr-teal-lt: var(--cp-ok-bg);
  --tblr-success: var(--cp-ok-fg); --tblr-success-lt: var(--cp-ok-bg);
  --tblr-yellow: var(--cp-wait-fg);  --tblr-yellow-lt: var(--cp-wait-bg);
  --tblr-orange: var(--cp-wait-fg);  --tblr-orange-lt: var(--cp-wait-bg);
  --tblr-warning: var(--cp-wait-fg); --tblr-warning-lt: var(--cp-wait-bg);
  --tblr-red: var(--cp-bad-fg);    --tblr-red-lt: var(--cp-bad-bg);
  --tblr-danger: var(--cp-bad-fg); --tblr-danger-lt: var(--cp-bad-bg);
  --tblr-secondary-lt: var(--cp-off-bg);
  --tblr-dark: var(--cp-off-fg);   --tblr-dark-lt: var(--cp-off-bg);
  --tblr-blue: var(--cp-off-fg);   --tblr-blue-lt: var(--cp-off-bg);
  --tblr-purple: var(--cp-off-fg); --tblr-purple-lt: var(--cp-off-bg);
}
/* Tabler takes the text colour of bg-secondary-lt from --tblr-secondary (set to muted above), so
   the off-chip text needs this one !important to stay --cp-off-fg. */
.bg-secondary-lt { color: var(--cp-off-fg) !important; }

/* online dot, progress, meter, alerts */
.status-green { --tblr-status-color: var(--cp-ok-fg); }
.status-yellow { --tblr-status-color: var(--cp-wait-fg); }
.progress { background: var(--cp-progress-track); }
.progress-bar { background: var(--cp-progress-wait); }
/* !important: Tabler's .bg-warning utility is !important and maps to wait-fg, not the progress amber */
.progress-bar.bg-warning { background: var(--cp-progress-wait) !important; }
.progress-bar.bg-primary { background: var(--cp-accent) !important; }
.progress-bar.bg-danger { background: var(--cp-bad-fg) !important; }
/* Tabler makes .alert a flex row, which turns inline <b> and text into columns; alerts here are text blocks (icon rows opt in with d-flex) */
.alert { display: block; }
/* the admin home banner is a link: keep the severity colour, not the link teal */
a.alert { color: var(--tblr-alert-color); }
.alert-success { --tblr-alert-bg: var(--cp-ok-bg); --tblr-alert-color: var(--cp-ok-fg); }
.alert-info { --tblr-alert-bg: var(--cp-off-bg); --tblr-alert-color: var(--cp-off-fg); }
.alert-warning { --tblr-alert-bg: var(--cp-wait-bg); --tblr-alert-color: var(--cp-wait-fg); }
.alert-danger { --tblr-alert-bg: var(--cp-bad-bg); --tblr-alert-color: var(--cp-bad-fg); }
.alert-secondary { --tblr-alert-bg: var(--cp-off-bg); --tblr-alert-color: var(--cp-off-fg); }

/* density, cards, tables (spacing steps: 4/8/12/16/24/32) */
.page-title { font-size: 22px; font-weight: 600; }
.page-header { margin-top: 24px; }
.page-body { margin-top: 16px; margin-bottom: 24px; }
.card { border: 1px solid var(--cp-border); box-shadow: var(--cp-shadow); border-radius: var(--cp-radius); }
.card-body { padding: 16px; }
.card-header { padding: 12px 16px; min-height: auto; }
.card-title { font-size: 17px; font-weight: 600; }
.card-footer { padding: 12px 16px; }
.table > :not(caption) > * > * { padding: 10px 12px; vertical-align: middle; }
.table th { font-weight: 500; }
.btn, .form-control, .form-select { border-radius: var(--cp-radius); }
.btn { font-weight: 500; }
.badge { border-radius: 999px; font-weight: 500; white-space: normal; }
/* a chip in a table cell stays on one line (the table scrolls inside its card) instead of wrapping to 3-4 lines */
.table .badge { white-space: nowrap; }
.row-cards { --tblr-gutter-y: 16px; --tblr-gutter-x: 16px; }
.pw-box { font-family: var(--cp-mono); font-size: 1.5rem; letter-spacing: .08em; }
code, .font-monospace { font-family: var(--cp-mono); }

/* sidebar (light) */
@media (min-width: 992px) {
  .navbar-vertical.navbar-expand-lg { width: 14rem; }
  .navbar-vertical.navbar-expand-lg ~ .page-wrapper { margin-left: 14rem; }
}
.navbar.sidebar {
  --tblr-navbar-bg: var(--cp-surface);
  --tblr-navbar-color: var(--cp-nav-fg);
  --tblr-navbar-border-color: var(--cp-border);
  background: var(--cp-surface);
  border-right: 1px solid var(--cp-border);
}
.sidebar .navbar-toggler { border-color: var(--cp-border); }
.sidebar .container-fluid { padding: 0 12px !important; }
.sidebar .sb-nav { margin: 0 !important; flex-grow: 0; }
.sidebar .navbar-collapse { align-items: stretch; }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 16px 4px 12px; color: var(--cp-text); text-decoration: none; }
.sb-brand:hover { color: var(--cp-text); text-decoration: none; }
.sb-logo { width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: var(--cp-radius); display: grid; place-items: center; background: var(--cp-accent); }
.sb-logo .icon { width: 1.25rem; height: 1.25rem; color: var(--cp-surface); margin: 0; }
.sb-brand b { display: block; font-size: 1rem; line-height: 1.2; }
.sb-brand small { display: block; color: var(--cp-muted); font-size: .75rem; font-weight: 400; }
.sb-section { color: var(--cp-muted); font-size: .75rem; font-weight: 600; letter-spacing: .06em; padding: 12px 12px 4px; }
.sidebar .sb-nav .nav-link { border-radius: var(--cp-radius); margin: 2px 0; padding: 8px 12px; color: var(--cp-nav-fg); }
.sidebar .sb-nav .nav-link::after { display: none; }
.sidebar .sb-nav .nav-link:hover { background: var(--cp-bg); color: var(--cp-nav-fg); }
.sidebar .sb-nav .nav-item.active .nav-link { background: var(--cp-nav-active-bg); color: var(--cp-nav-active-fg); font-weight: 500; }
.sidebar .sb-nav .nav-item.active .nav-link-icon { color: currentColor; }
.sb-footer { margin-top: auto; border-top: 1px solid var(--cp-border); padding: 12px 0; }
.sb-link { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--cp-radius); color: var(--cp-nav-fg); text-decoration: none; font-size: .875rem; }
.sb-link:hover { background: var(--cp-bg); color: var(--cp-nav-fg); text-decoration: none; }
.sb-link .icon { width: 1.1rem; height: 1.1rem; margin: 0; }
.sb-user { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px; border-radius: var(--cp-radius); background: var(--cp-bg); }
.sb-avatar { background: var(--cp-nav-active-bg); color: var(--cp-nav-active-fg); font-weight: 600; flex-shrink: 0; }
.sb-user-text { flex: 1; min-width: 0; line-height: 1.25; color: var(--cp-text); font-size: .875rem; overflow-wrap: anywhere; }
.sb-user-text small { display: block; color: var(--cp-muted); font-size: .75rem; overflow-wrap: anywhere; }
.sb-logout { border: 0; background: transparent; color: var(--cp-muted); padding: 4px; border-radius: var(--cp-radius); display: grid; place-items: center; }
.sb-logout:hover { background: var(--cp-bad-bg); color: var(--cp-bad-fg); }
.sb-logout .icon { width: 1.1rem; height: 1.1rem; margin: 0; }

/* charts: one series, recessive grid, 2px line, 10% area wash */
.chart { touch-action:none; }
.chart .grid { stroke:var(--cp-border); stroke-width:1; }
.chart .axis { fill:var(--cp-muted); font-size:11px; }
.chart .line { fill:none; stroke:var(--cp-accent); stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.chart .area { fill:var(--cp-accent); opacity:.1; }
.chart .hover-line { stroke:var(--cp-muted); stroke-width:1; }
.chart .hover-dot { fill:var(--cp-accent); stroke:var(--cp-surface); stroke-width:2; }
.chart-tip { position:absolute; top:-4px; white-space:nowrap; pointer-events:none; font-size:12px;
  background:var(--cp-surface); border:1px solid var(--cp-border); border-radius:4px; padding:2px 6px; box-shadow:var(--cp-shadow); }

/* non-admin shell: top bar and a narrow column (admins keep the sidebar) */
.cp-topbar { background: var(--cp-surface); border-bottom: 1px solid var(--cp-border); padding: 12px 0; }
.cp-topbar .container-xl { display: flex; justify-content: flex-start; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.cp-brand { font-weight: 600; color: var(--cp-text); }
.cp-nav { flex-direction: row; gap: 4px; }
.cp-nav .nav-link { color: var(--cp-nav-fg); border-radius: var(--cp-radius); padding: 6px 12px; }
.cp-nav .nav-item.active .nav-link { background: var(--cp-nav-active-bg); color: var(--cp-nav-active-fg); font-weight: 500; }
.cp-topbar-right { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; }
.cp-toplink { background: none; border: 0; padding: 0; color: var(--cp-muted); font-size: inherit; text-decoration: none; }
.cp-toplink:hover { color: var(--cp-accent); text-decoration: none; }
@media (max-width: 575px) { .cp-topbar-right { margin-left: 0; width: 100%; } }
.cp-shell-user .cp-narrow { flex: 0 0 100%; max-width: 100%; }
.cp-shell-user:has(.cp-narrow) :is(.page-header, .page-body) > .container-xl { max-width: 560px; }
.cp-shell-user .cp-narrow .card-body { padding: 24px; }
.cp-hello { font-size: 22px; font-weight: 600; margin: 0 0 12px; }
.cp-status { margin-bottom: 16px; }
.cp-sev-security { background: var(--cp-info-bg); color: var(--cp-info-fg); }

/* standalone cards (login, access link) */
.cp-auth .card { box-shadow: var(--cp-shadow); }
.cp-auth .h2 { color: var(--cp-text); font-weight: 600; }
.cp-auth .h2 .icon { color: var(--cp-accent); }

/* page the new tab shows while the machine is being prepared (written by layout.html's script) */
.cp-wait-page { display: grid; place-items: center; height: 90vh; margin: 0; font-family: var(--cp-font); color: var(--cp-text); background: var(--cp-bg); }
.cp-wait-page > div { text-align: center; }
.cp-spinner { width: 40px; height: 40px; margin: 0 auto 16px; border: 4px solid var(--cp-progress-track); border-top-color: var(--cp-accent); border-radius: 50%; animation: cp-spin 1s linear infinite; }
@keyframes cp-spin { to { transform: rotate(360deg); } }
.cp-wait-note { color: var(--cp-muted); font-size: 14px; margin-top: 6px; }

/* launch: registration code / username / password beside the copy buttons */
.datagrid code { font-family: var(--cp-mono); font-size: 17px; overflow-wrap: anywhere; }
/* mfa secret: 32 characters must fit a 390px screen */
.user-select-all { font-family: var(--cp-mono); font-size: 15px; overflow-wrap: anywhere; }

/* new employee form: hide the machine options when "no machine" is ticked */
form:has([name=no_machine]:checked) .machine-opts { display: none; }

/* admin guide (admin_home) */
.guide h3 { margin-top:1.75rem; scroll-margin-top:1rem; }
.guide h3:first-child { margin-top:0; }
.guide .behind { border-left:3px solid var(--cp-accent); background:var(--cp-nav-active-bg); padding:.6rem .9rem; border-radius:.35rem; margin:.75rem 0; }
.guide div.behind > b:first-child { display:block; margin-bottom:.15rem; }
.guide details.behind > summary { cursor:pointer; }
.guide details.behind[open] > summary { margin-bottom:.15rem; }
.guide .try { border-left:3px solid var(--cp-ok-fg); background:var(--cp-ok-bg); padding:.6rem .9rem; border-radius:.35rem; margin:.75rem 0; }
.guide .warn { border-left:3px solid var(--cp-wait-fg); background:var(--cp-wait-bg); padding:.6rem .9rem; border-radius:.35rem; margin:.75rem 0; }
.guide ol.flow { counter-reset:f; list-style:none; padding-left:0; }
.guide ol.flow > li { counter-increment:f; position:relative; padding:.35rem 0 .35rem 2.4rem; }
.guide ol.flow > li::before { content:counter(f); position:absolute; left:0; top:.3rem; width:1.7rem; height:1.7rem; border-radius:50%;
  background:var(--cp-accent); color:var(--cp-surface); display:grid; place-items:center; font-size:.8rem; font-weight:600; }
.guide .toc a { display:block; padding:.25rem 0; color:var(--cp-text); text-decoration:none; }
.guide .toc a:hover { color:var(--cp-accent); }
@media (min-width: 992px) { .guide .toc { position:sticky; top:1rem; } }
