/* facescan v2 - ธีมหลัก */
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 300; font-display: swap; src: url(vendor/fonts/sarabun-thai-300-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 400; font-display: swap; src: url(vendor/fonts/sarabun-thai-400-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 500; font-display: swap; src: url(vendor/fonts/sarabun-thai-500-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 600; font-display: swap; src: url(vendor/fonts/sarabun-thai-600-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 700; font-display: swap; src: url(vendor/fonts/sarabun-thai-700-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 300; font-display: swap; src: url(vendor/fonts/sarabun-latin-300-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 400; font-display: swap; src: url(vendor/fonts/sarabun-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 500; font-display: swap; src: url(vendor/fonts/sarabun-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+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 600; font-display: swap; src: url(vendor/fonts/sarabun-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+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 700; font-display: swap; src: url(vendor/fonts/sarabun-latin-700-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --app-primary: #1d3a8a;
  --app-primary-2: #2b54c4;
  --app-accent: #d9468f;
  --app-bg: #f3f5fa;
  --app-ink: #1c2540;
  --app-muted: #66708a;
  --app-line: #e3e7f0;
  --bs-primary: #1d3a8a;
  --bs-primary-rgb: 29, 58, 138;
  --bs-link-color: #2747a8;
  --bs-link-color-rgb: 39, 71, 168;
  --bs-body-font-family: 'Sarabun', 'Leelawadee UI', 'Tahoma', sans-serif;
  --bs-body-color: #1c2540;
}
body { background: var(--app-bg); font-family: var(--bs-body-font-family); font-size: 1rem; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
.btn-primary { --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: #17306f; --bs-btn-hover-border-color: #17306f; --bs-btn-active-bg: #142a61; }
.btn-outline-primary { --bs-btn-color: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary); }
.text-primary { color: var(--app-primary) !important; }
.bg-primary { background-color: var(--app-primary) !important; }

/* Navbar */
.app-nav { background: linear-gradient(120deg, #172f73 0%, var(--app-primary) 55%, #2c4fb5 100%); box-shadow: 0 2px 12px rgba(18, 35, 90, .25); }
.app-nav .nav-link { color: rgba(255,255,255,.86); border-radius: 8px; padding: .45rem .75rem; }
.app-nav .nav-link:hover, .app-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.14); }
.brand-logo { background: #fff; border-radius: 50%; padding: 2px; object-fit: contain; }
.brand-sys { font-weight: 600; font-size: 1.02rem; line-height: 1.15; }
.brand-school { font-size: .78rem; opacity: .82; line-height: 1.2; }
@media (max-width: 575.98px) { .brand-sys { font-size: .9rem; } .brand-school { font-size: .7rem; } }
.dropdown-item i { width: 1.4em; display: inline-block; }

/* Card */
.card { border: 1px solid var(--app-line); border-radius: 14px; box-shadow: 0 1px 2px rgba(20, 30, 60, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--app-line); border-radius: 14px 14px 0 0 !important; font-weight: 600; }
.page-head h1 { color: var(--app-ink); }

/* KPI */
.kpi { border-radius: 14px; padding: 14px 16px; background: #fff; border: 1px solid var(--app-line); height: 100%; position: relative; overflow: hidden; }
.kpi .kpi-label { color: var(--app-muted); font-size: .86rem; }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.kpi .kpi-sub { font-size: .8rem; color: var(--app-muted); }
.kpi .kpi-icon { position: absolute; right: 12px; top: 10px; font-size: 1.6rem; opacity: .22; }
.kpi.k-blue { border-left: 5px solid #2b54c4; } .kpi.k-blue .kpi-value { color: #2b54c4; }
.kpi.k-green { border-left: 5px solid #1f9d63; } .kpi.k-green .kpi-value { color: #168152; }
.kpi.k-amber { border-left: 5px solid #e59a0b; } .kpi.k-amber .kpi-value { color: #b87800; }
.kpi.k-red { border-left: 5px solid #d64545; } .kpi.k-red .kpi-value { color: #c03535; }
.kpi.k-cyan { border-left: 5px solid #1595b3; } .kpi.k-cyan .kpi-value { color: #127c95; }
.kpi.k-pink { border-left: 5px solid var(--app-accent); } .kpi.k-pink .kpi-value { color: #b8306f; }

/* Hero */
.hero { background: #fff; border: 1px solid var(--app-line); border-radius: 16px; padding: 16px 18px; }
.live-clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.6rem; color: var(--app-primary); line-height: 1; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #1f9d63; display: inline-block; box-shadow: 0 0 0 0 rgba(31,157,99,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,157,99,.55);} 70% { box-shadow: 0 0 0 8px rgba(31,157,99,0);} 100% { box-shadow: 0 0 0 0 rgba(31,157,99,0);} }

/* Tables */
.table-app { margin: 0; }
.table-app thead th { background: #eef2fb; color: #334063; font-weight: 600; font-size: .88rem; white-space: nowrap; border-bottom: 1px solid var(--app-line); }
.table-app td { vertical-align: middle; }
.table-app tbody tr:hover { background: #f8faff; }
.table-app .t-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.tr-late td { color: #b42318; }
.scroll-y { max-height: 560px; overflow-y: auto; }
.scroll-y thead th { position: sticky; top: 0; z-index: 1; }

.badge-soft-success { background: #e3f6ec; color: #136c43; }
.badge-soft-warning { background: #fff2d6; color: #8a5a00; }
.badge-soft-danger { background: #fde7e7; color: #a42525; }
.badge-soft-info { background: #e1f3f8; color: #0f6178; }
.badge-soft-secondary { background: #eceff4; color: #4a5470; }
.badge-soft-light { background: #f4f5f8; color: #8a91a5; }
.badge-st { font-weight: 600; font-size: .78rem; padding: .35em .6em; border-radius: 6px; }

.progress { height: 8px; background: #e9edf5; border-radius: 6px; }

/* Tiles */
.tile { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 14px; background: #fff; border: 1px solid var(--app-line); color: var(--app-ink); text-decoration: none; height: 100%; transition: transform .12s ease, box-shadow .12s ease, border-color .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(25, 45, 110, .1); border-color: #c9d3ee; color: var(--app-ink); }
.tile .tile-ic { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; }
.tile .tile-t { font-weight: 600; }
.tile .tile-d { font-size: .82rem; color: var(--app-muted); }
.ic-blue { background: #2b54c4; } .ic-green { background: #1f9d63; } .ic-amber { background: #e59a0b; } .ic-red { background: #d64545; }
.ic-cyan { background: #1595b3; } .ic-pink { background: #d9468f; } .ic-violet { background: #6b4fd1; } .ic-slate { background: #4a5470; }

/* report type chooser */
.rtype input { display: none; }
.rtype label { display: block; cursor: pointer; padding: 12px 14px; border: 1.5px solid var(--app-line); border-radius: 12px; background: #fff; height: 100%; }
.rtype label .rt-t { font-weight: 600; }
.rtype label .rt-d { font-size: .8rem; color: var(--app-muted); }
.rtype input:checked + label { border-color: var(--app-primary-2); background: #f1f5ff; box-shadow: 0 0 0 3px rgba(43, 84, 196, .12); }

.form-label { font-weight: 600; font-size: .9rem; }
.app-footer { color: var(--app-muted); padding: 18px 0 22px; }

.login-wrap { max-width: 420px; margin: 4vh auto; }

/* ---------- Report paper ---------- */
.report-toolbar { position: sticky; top: 0; z-index: 10; background: rgba(243,245,250,.95); backdrop-filter: blur(4px); padding: 10px 0; }
.paper { background: #fff; margin: 0 auto 24px; padding: 14mm 12mm; box-shadow: 0 4px 24px rgba(20, 30, 70, .12); color: #000; font-family: 'Sarabun', 'TH SarabunPSK', Tahoma, sans-serif; font-size: 14px; }
.paper.portrait { width: 210mm; max-width: 100%; }
.paper.landscape { width: 297mm; max-width: 100%; }
.paper .r-title { text-align: center; font-weight: 700; font-size: 18px; line-height: 1.5; }
.paper .r-sub { text-align: center; font-size: 15px; line-height: 1.5; }
.paper .r-meta { font-size: 12.5px; color: #333; text-align: center; margin-top: 2px; }
.paper .r-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin: 10px 0 4px; font-size: 14px; }
.paper .r-summary b { font-weight: 700; }
.paper h3.r-sec { font-size: 15.5px; font-weight: 700; margin: 14px 0 6px; }
.paper table.r-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.paper table.r-table th, .paper table.r-table td { border: 1px solid #333; padding: 3px 5px; line-height: 1.35; }
.paper table.r-table th { background: #e9edf6; font-weight: 700; text-align: center; }
.paper table.r-table tr { page-break-inside: avoid; break-inside: avoid; }
.paper table.r-table thead { display: table-header-group; }
.paper .r-late td { color: #c00000; }
.paper .r-bold td { font-weight: 700; background: #f5f6fa; }
.paper .c { text-align: center; } .paper .r { text-align: right; }
.paper .r-sign { margin-top: 26px; display: flex; justify-content: flex-end; page-break-inside: avoid; break-inside: avoid; }
.paper .r-sign .box { text-align: center; min-width: 300px; font-size: 15px; line-height: 1.6; }
.paper .r-sign img { height: 56px; display: block; margin: 0 auto -6px; }
.paper .r-empty { text-align: center; color: #555; padding: 10px; }
@media (max-width: 991.98px) {
  .paper { padding: 16px 12px; font-size: 13px; }
  .paper-wrap { overflow-x: auto; }
}

@media print {
  @page { size: A4; margin: 10mm 8mm; }
  body { background: #fff !important; }
  .no-print, .app-nav, .app-footer, .report-toolbar { display: none !important; }
  main { padding: 0 !important; }
  main > .container, main > .container-fluid { max-width: none !important; padding: 0 !important; }
  .paper { box-shadow: none !important; margin: 0 !important; padding: 0 !important; width: auto !important; }
  .paper-wrap { overflow: visible !important; }
}
body.print-landscape { }

/* Mobile tweaks */
@media (max-width: 575.98px) {
  .kpi .kpi-value { font-size: 1.5rem; }
  .table-app { font-size: .9rem; }
  .hide-xs { display: none !important; }
  main { padding-top: .75rem !important; }
}
@media (max-width: 767.98px) { .hide-sm { display: none !important; } }
.paper.pdf-mode { box-shadow: none !important; margin: 0 !important; padding: 0 !important; max-width: none !important; }

/* หน้าหลัก: หัวตารางเวลาเข้า = เขียว, เวลาออก = แดง */
.card-in .card-header { background: #1f9d63; color: #fff; border-bottom: 0; }
.card-out .card-header { background: #d64545; color: #fff; border-bottom: 0; }
.card-in .card-header i, .card-out .card-header i { color: #fff !important; }
.card-in .card-header .badge, .card-out .card-header .badge { background: rgba(255,255,255,.22) !important; color: #fff !important; }
.card-in .card-header input, .card-out .card-header input { border: 0; }
.card-in .table-app thead th { background: #e3f6ec; color: #136c43; }
.card-out .table-app thead th { background: #fde7e7; color: #a42525; }

/* ช่องค้นหาบุคลากร */
.mp-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 1050; max-height: 320px; overflow-y: auto; display: none; margin-top: 2px; border-radius: 10px; }
.mp-list.show { display: block; }
.mp-list .list-group-item { cursor: pointer; padding: .5rem .75rem; }
.mp-list .list-group-item.active { background: #eef2fb; color: var(--app-ink); border-color: var(--app-line); }
.mp-list .mp-g { font-size: .78rem; color: var(--app-muted); }
.mp-list mark { padding: 0; background: #fff2b3; }
