@charset "UTF-8";
/* ==========================================================================
   ระบบบันทึกการใช้ห้องพยาบาล โรงเรียนคงคาราม
   Stylesheet : ธีมสีเขียวมิ้นท์-เทาอ่อน เน้นอ่านง่าย รองรับมือถือ
   ========================================================================== */

/* หากมีไฟล์ฟอนต์ TH Sarabun New วางไว้ที่ assets/fonts/ ระบบจะใช้ไฟล์นั้นก่อน
   ถ้าไม่มี จะใช้ฟอนต์ที่ติดตั้งในเครื่อง หรือฟอนต์ Sarabun จาก Google Fonts */
@font-face {
    font-family: 'TH Sarabun New';
    src: local('TH Sarabun New'), local('TH SarabunPSK'),
         url('../fonts/THSarabunNew.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TH Sarabun New';
    src: local('TH Sarabun New Bold'), local('TH SarabunPSK Bold'),
         url('../fonts/THSarabunNew-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #14b8a6;
    --primary-soft: #ccfbf1;
    --accent: #f59e0b;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --info: #2563eb;
    --info-soft: #dbeafe;
    --purple: #7c3aed;

    --text: #0f172a;
    --text-muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, .14);
    /* ใช้หน่วย rem เพื่อให้แถบเมนูขยายตามขนาดตัวอักษรที่ผู้ใช้เลือก */
    --sidebar-w: 13.6rem;
    --font: 'TH Sarabun New', 'TH SarabunPSK', 'Sarabun', 'Segoe UI', Tahoma, sans-serif;

    /* ฟอนต์ตระกูล TH Sarabun มีตัวอักษรเล็กกว่าฟอนต์ทั่วไปที่ขนาด px เท่ากัน
       จึงตั้งขนาดอ้างอิงไว้ที่ 21px และให้ผู้ใช้ปรับได้ด้วย --fs-scale */
    --fs-base: 21px;
    --fs-scale: 1;
}

* { box-sizing: border-box; }

/* กำหนดขนาดที่ราก เพื่อให้ทุกขนาดที่ใช้หน่วย rem ปรับตามไปด้วย */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: calc(var(--fs-base) * var(--fs-scale));
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4, h5 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-nowrap { white-space: nowrap; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: .92rem; }
.fs-lg { font-size: 1.15rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.w-100 { width: 100%; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* ==========================================================================
   โครงหน้า
   ========================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, #0f766e 0%, #0d5f57 55%, #134e4a 100%);
    color: #e2f8f4;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 60;
    box-shadow: 4px 0 24px rgba(15, 23, 42, .12);
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .13);
}
.sidebar-brand .logo {
    width: 2.15rem; height: 2.15rem;
    flex: 0 0 2.15rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .16);
    display: grid; place-items: center;
    font-size: 1.5rem;
}
.sidebar-brand .brand-text { line-height: 1.25; }
.sidebar-brand .brand-text strong { display: block; font-size: 1rem; color: #fff; }
.sidebar-brand .brand-text span { font-size: .85rem; color: #a7f3ec; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .7rem .6rem 1.4rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 3px; }

.nav-section {
    font-size: .8rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #7fd8ce;
    padding: 1rem .65rem .35rem;
    font-weight: 700;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .48rem .7rem;
    border-radius: 11px;
    color: #d7f5f0;
    margin-bottom: .15rem;
    font-size: .98rem;
    transition: background .15s, color .15s, transform .15s;
}
.nav-link i { font-size: 1.1rem; width: 1.35rem; text-align: center; }
.nav-link:hover { background: rgba(255, 255, 255, .12); color: #fff; transform: translateX(2px); }
.nav-link.active { background: #fff; color: var(--primary-dark); font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .16); }
.nav-link .badge-count {
    margin-left: auto;
    background: var(--accent);
    color: #422006;
    font-size: .78rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0 .45rem;
    min-width: 1.35rem;
    text-align: center;
}
.sidebar-footer {
    padding: .7rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .13);
    font-size: .85rem;
    color: #9fe4db;
    line-height: 1.45;
}
.sidebar-footer .sidebar-dev {
    margin-top: .25rem;
    font-size: .8rem;
    color: #fff;
    font-weight: 700;
}

.site-footer {
    margin-top: auto;
    padding: .85rem 1.1rem 1.1rem;
    text-align: center;
    font-size: .9rem;
    color: var(--text-muted);
    border-top: 1px solid var(--line);
}
.site-footer span {
    font-weight: 700;
    color: #1e3a8a;
}

.content { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding: .5rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .page-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.topbar .page-sub { font-size: .85rem; color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.topbar-clock { font-size: .9rem; color: var(--text-muted); white-space: nowrap; }

/* ปุ่มปรับขนาดตัวอักษร */
.font-control { display: flex; align-items: center; gap: .15rem; background: #fff;
    border: 1px solid var(--line); border-radius: 999px; padding: .12rem; }
.font-control button {
    border: 0; background: none; cursor: pointer;
    font-family: var(--font); color: #475569;
    width: 1.75rem; height: 1.75rem; border-radius: 50%;
    display: grid; place-items: center; line-height: 1;
}
.font-control button:hover { background: var(--primary-soft); color: var(--primary-dark); }
.font-control button.reset { font-size: .9rem; font-weight: 700; }
.font-control button.step { font-size: 1.05rem; font-weight: 700; }

.sidebar-toggle {
    display: none;
    background: var(--primary-soft);
    color: var(--primary-dark);
    border: 0;
    width: 1.9rem; height: 1.9rem;
    border-radius: 11px;
    font-size: 1.15rem;
    cursor: pointer;
}

.user-chip {
    display: flex; align-items: center; gap: .6rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .25rem .8rem .25rem .3rem;
    cursor: pointer;
    position: relative;
}
.user-chip .avatar {
    width: 1.6rem; height: 1.6rem; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .95rem;
}
.user-chip .u-name { font-size: .92rem; font-weight: 700; line-height: 1.1; }
.user-chip .u-role { font-size: .78rem; color: var(--text-muted); }

.user-menu {
    position: absolute;
    right: 0; top: calc(100% + .5rem);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 210px;
    padding: .4rem;
    display: none;
    z-index: 70;
}
.user-menu.show { display: block; }
.user-menu a {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .7rem; border-radius: 8px; color: var(--text); font-size: .98rem;
}
.user-menu a:hover { background: var(--bg); }
.user-menu a.danger { color: var(--danger); }
.user-menu hr { border: 0; border-top: 1px solid var(--line); margin: .35rem 0; }

.page { padding: 1.1rem; flex: 1; }
.page-inner { max-width: 1440px; margin: 0 auto; }

.breadcrumb { font-size: .88rem; color: var(--text-muted); margin-bottom: .8rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span + span::before { content: "›"; margin: 0 .4rem; }

/* ==========================================================================
   การ์ด
   ========================================================================== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-head {
    padding: .7rem .95rem;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    background: linear-gradient(180deg, #fbfefd, #f8fafc);
}
.card-head h3, .card-head h2 { margin: 0; font-size: 1.05rem; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: .95rem; }
.card-body.tight { padding: 0; }
.card-foot { padding: .7rem .95rem; border-top: 1px solid var(--line); background: #fafbfc; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

/* การ์ดสถิติ */
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem 1rem;
    display: flex; align-items: center; gap: .85rem;
    position: relative; overflow: hidden;
}
.stat::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 5px;
    background: var(--primary);
}
.stat.is-info::after { background: var(--info); }
.stat.is-warning::after { background: var(--warning); }
.stat.is-danger::after { background: var(--danger); }
.stat.is-success::after { background: var(--success); }
.stat.is-purple::after { background: var(--purple); }
.stat .icon {
    width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem;
    border-radius: 14px; display: grid; place-items: center;
    font-size: 1.25rem; background: var(--primary-soft); color: var(--primary-dark);
}
.stat.is-info .icon { background: var(--info-soft); color: var(--info); }
.stat.is-warning .icon { background: var(--warning-soft); color: var(--warning); }
.stat.is-danger .icon { background: var(--danger-soft); color: var(--danger); }
.stat.is-success .icon { background: var(--success-soft); color: var(--success); }
.stat.is-purple .icon { background: #ede9fe; color: var(--purple); }
.stat .value { font-size: 1.55rem; font-weight: 700; line-height: 1.15; }
.stat .label { font-size: .92rem; color: var(--text-muted); }
.stat .sub { font-size: .82rem; color: var(--text-muted); }

/* ==========================================================================
   ฟอร์ม
   ========================================================================== */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .8rem .85rem; }
.col-1 { grid-column: span 1; } .col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; }
.col-10 { grid-column: span 10; } .col-12 { grid-column: span 12; }

label.form-label, .form-label {
    display: block; font-weight: 700; font-size: .92rem; margin-bottom: .25rem; color: #334155;
}
.form-label .req { color: var(--danger); }

.form-control, .form-select, textarea.form-control {
    width: 100%;
    font-family: var(--font);
    font-size: 1rem;
    padding: .4rem .7rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    outline: 0;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, .18);
}
.form-control[readonly], .form-control:disabled, .form-select:disabled {
    background: #f1f5f9; color: #475569;
}
textarea.form-control { min-height: 4rem; resize: vertical; }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M8 11 3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .6rem center;
    background-size: 15px;
    padding-right: 2rem;
}
.form-hint { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); background: #fff7f7; }

.check-inline { display: flex; flex-wrap: wrap; gap: .5rem .9rem; }
.check {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .28rem .65rem; border: 1px solid #cbd5e1; border-radius: 999px;
    cursor: pointer; background: #fff; font-size: .94rem;
}
.check input { accent-color: var(--primary); }
.check:hover { border-color: var(--primary-light); }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

fieldset.section {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem 1.15rem;
    margin: 0 0 1.2rem;
}
fieldset.section > legend {
    font-weight: 700; font-size: 1.02rem; color: var(--primary-dark);
    padding: 0 .5rem; display: flex; align-items: center; gap: .4rem;
}

/* ==========================================================================
   ปุ่ม
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    font-family: var(--font); font-size: .98rem; font-weight: 700;
    padding: .42rem .9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff; color: var(--text);
    transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
    white-space: nowrap;
    line-height: 1.5;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary)); color: #fff; box-shadow: 0 4px 14px rgba(13, 148, 136, .3); }
.btn-primary:hover { color: #fff; box-shadow: 0 6px 18px rgba(13, 148, 136, .38); }
.btn-secondary { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-secondary:hover { border-color: var(--primary-light); color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-warning { background: var(--accent); color: #422006; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { color: #fff; background: #1d4ed8; }
.btn-light { background: var(--bg); border-color: var(--line); color: #334155; }
.btn-sm { padding: .22rem .6rem; font-size: .88rem; border-radius: 8px; }
.btn-lg { padding: .6rem 1.35rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .3rem .5rem; font-size: 1rem; }
.btn[disabled] { opacity: .6; cursor: not-allowed; transform: none; }

.btn-group { display: inline-flex; gap: .35rem; }

/* ==========================================================================
   ตาราง
   ========================================================================== */
.table-wrap { overflow-x: auto; }
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}
table.table th, table.table td {
    padding: .48rem .7rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
table.table thead th {
    background: #f8fafc;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
    border-bottom: 2px solid var(--line);
}
table.table tbody tr:hover { background: #f6fefc; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table td.actions { white-space: nowrap; text-align: right; }
table.table.table-sm th, table.table.table-sm td { padding: .4rem .6rem; font-size: .95rem; }
table.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.empty-state { padding: 2.6rem 1rem; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: .5rem; color: #cbd5e1; }

/* ==========================================================================
   ป้ายสถานะ
   ========================================================================== */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .86rem; font-weight: 700;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--bg); color: #475569;
    white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge-success { background: var(--success-soft); color: #15803d; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-info { background: var(--info-soft); color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-dark { background: #334155; color: #fff; }

.alert {
    display: flex; gap: .7rem; align-items: flex-start;
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: 1rem;
    font-size: .98rem;
}
.alert i { font-size: 1.2rem; line-height: 1.4; }
.alert-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #166534; }

/* ==========================================================================
   แถบตัวกรอง / เครื่องมือ
   ========================================================================== */
.toolbar {
    display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end;
}
.toolbar .field { min-width: 150px; }
.toolbar .field.grow { flex: 1 1 240px; }

.tabs {
    display: flex; gap: .35rem; flex-wrap: wrap;
    border-bottom: 2px solid var(--line);
    margin-bottom: 1rem;
}
.tabs a {
    padding: .5rem 1rem;
    border-radius: 10px 10px 0 0;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: -2px;
    border-bottom: 3px solid transparent;
}
.tabs a:hover { color: var(--primary); background: #f8fafc; }
.tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); background: #fff; }

/* แบ่งหน้า */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .7rem;
    padding: .7rem .95rem;
    border-top: 1px solid var(--line);
    font-size: .92rem;
}
.pagination-info { color: var(--text-muted); }
.pagination-links { display: flex; gap: .3rem; flex-wrap: wrap; }
.pagination-links a {
    min-width: 2.1rem; text-align: center;
    padding: .25rem .55rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #334155;
}
.pagination-links a:hover { border-color: var(--primary-light); color: var(--primary-dark); }
.pagination-links a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-links .dots { padding: .25rem; color: var(--text-muted); }

/* รายการข้อมูล (แสดงรายละเอียด) */
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; font-size: 1rem; }
.info-list dt { color: var(--text-muted); }
.info-list dd { margin: 0; font-weight: 600; }

.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before {
    content: ""; position: absolute; left: .45rem; top: .3rem; bottom: .3rem;
    width: 2px; background: var(--line);
}
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item::before {
    content: ""; position: absolute; left: -1.32rem; top: .45rem;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--primary-light); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary-soft);
}
.timeline-item .t-date { font-size: .88rem; color: var(--text-muted); }

/* กล่องค้นหาแบบแนะนำผลลัพธ์ */
.autocomplete { position: relative; }
/* การ์ดตัดส่วนที่ยื่นออกนอกขอบ (overflow:hidden) ทำให้เห็นผลค้นหาแค่บรรทัดแรก
   จึงยกเว้นให้การ์ดที่มีช่องค้นหาแสดงผลได้เต็ม (.card-flow ไว้รองรับเบราว์เซอร์ที่ไม่มี :has) */
.card.card-flow,
.card:has(.autocomplete) { overflow: visible; }
.autocomplete-list {
    position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 3px);
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item { padding: .5rem .8rem; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--primary-soft); }
.autocomplete-item .ac-name { font-weight: 700; }
.autocomplete-item .ac-meta { font-size: .88rem; color: var(--text-muted); }

/* ==========================================================================
   หน้าเข้าสู่ระบบ
   ========================================================================== */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(20, 184, 166, .35), transparent 60%),
        radial-gradient(900px 500px at 110% 10%, rgba(37, 99, 235, .22), transparent 55%),
        linear-gradient(160deg, #0f766e 0%, #115e59 45%, #0f172a 100%);
}
.login-card {
    width: min(1040px, 100%);
    background: rgba(255, 255, 255, .97);
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(2, 6, 23, .45);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}
.login-hero {
    background: linear-gradient(160deg, #0d9488, #0f766e 55%, #134e4a);
    color: #fff;
    padding: 2.1rem 1.9rem;
    display: flex; flex-direction: column; justify-content: center; gap: .6rem;
}
.login-hero .hero-logo {
    width: 3.3rem; height: 3.3rem; border-radius: 22px;
    background: rgba(255, 255, 255, .18);
    display: grid; place-items: center; font-size: 2.3rem; margin-bottom: .6rem;
}
.login-hero h1 { font-size: 1.6rem; margin: 0; }
.login-hero .sub { color: #b7f0e8; font-size: 1rem; }
.login-hero ul { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; gap: .45rem; }
.login-hero ul li { display: flex; gap: .55rem; align-items: center; color: #e0fbf6; font-size: 1rem; }
.login-hero ul li i { color: #99f6e4; }
.login-form { padding: 2.1rem 1.9rem; display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { margin-bottom: .25rem; }
.login-form .lead { color: var(--text-muted); margin-bottom: 1.4rem; }
.pw-wrap { position: relative; }
.pw-wrap .toggle-pw {
    position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
    background: none; border: 0; cursor: pointer; color: var(--text-muted);
    font-size: 1.05rem; padding: .35rem .5rem;
}
.login-meta { margin-top: 1.3rem; font-size: .9rem; color: var(--text-muted); text-align: center; }
.login-meta .login-dev {
    margin-top: .35rem;
    font-weight: 700;
    color: #1e3a8a;
}
.demo-box {
    margin-top: 1rem; padding: .7rem .9rem;
    background: var(--bg); border: 1px dashed #cbd5e1; border-radius: var(--radius-sm);
    font-size: .92rem; color: #475569;
}

/* ==========================================================================
   กราฟ
   ========================================================================== */
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 380px; }
.chart-box.short { height: 260px; }

/* ==========================================================================
   กล่องแจ้งเตือน SweetAlert2 ให้ใช้ฟอนต์และขนาดเดียวกับระบบ
   ========================================================================== */
.swal2-popup { font-family: var(--font) !important; font-size: 1rem !important; }
.swal2-title { font-size: 1.3rem !important; }
.swal2-html-container { font-size: 1rem !important; }
.swal2-styled { font-family: var(--font) !important; font-size: 1rem !important; font-weight: 700; }

/* ==========================================================================
   ตอบสนองหน้าจอ
   ========================================================================== */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open::after {
        content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 55;
    }
    .content { margin-left: 0; }
    .sidebar-toggle { display: grid; place-items: center; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .login-card { grid-template-columns: 1fr; }
    .login-hero { padding: 1.8rem; }
    .login-hero ul { display: none; }
}
@media (max-width: 768px) {
    :root { --fs-base: 20px; }
    .page { padding: .8rem; }
    .grid-4 { grid-template-columns: 1fr; }
    .form-grid > [class^="col-"] { grid-column: span 12; }
    .topbar { padding: .5rem .8rem; }
    .topbar .page-sub, .topbar-clock, .user-chip .u-role { display: none; }
    .info-list { grid-template-columns: 1fr; gap: .1rem .5rem; }
    .info-list dt { margin-top: .5rem; }
}

/* ==========================================================================
   พิมพ์เอกสาร
   ========================================================================== */
@media print {
    @page { size: A4; margin: 12mm; }
    html { font-size: 19px; }
    body { background: #fff; }
    .sidebar, .topbar, .no-print, .pagination, .tabs, .breadcrumb { display: none !important; }
    .content { margin-left: 0; }
    .page { padding: 0; }
    .card { box-shadow: none; border: 1px solid #cbd5e1; break-inside: avoid; }
    .print-header { display: block !important; text-align: center; margin-bottom: 1rem; }
    a { color: #000; }
}
.print-header { display: none; }
