/* ฟอนต์ไทย Sarabun (OFL) เก็บไว้ในเว็บเอง ไม่ต้องโหลดจากภายนอก */
@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

:root {
    --brand: #0f6cbd;
    --text: #1f2933;
    --muted: #6b7785;
    --line: #dde3ea;
    --bg: #f7f9fb;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Sarabun", Tahoma, sans-serif;
    font-size: 17px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* แถบบน */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.5rem; font-weight: 700; color: var(--brand); text-decoration: none; }
.tagline { color: var(--muted); }
/* ช่องเปิดประวัติของแพทย์ในแถบบน: กินพื้นที่ว่างระหว่างชื่อคลินิกกับเมนู */
/* ปุ่มแว่นขยายวางทับมุมขวาในช่อง (position: absolute เทียบกับฟอร์มที่เป็น relative) */
/* ช่องค้นหาแบบ Google: ทรงแคปซูล แว่นขยายสีเทาด้านขวา ชี้เมาส์/คลิกแล้วมีเงาแทนกรอบ */
.topbar-search { flex: 0 1 340px; display: flex; margin: 0 0 0 8px; position: relative; }
.topbar-search input { font: inherit; font-size: 0.95rem; padding: 7px 44px 7px 16px; border: 1px solid #dfe1e5;
                       border-radius: 24px; flex: 1; min-width: 160px; background: #fff; transition: box-shadow .15s; }
.topbar-search input:hover,
.topbar-search input:focus { outline: none; border-color: transparent; box-shadow: 0 1px 6px rgba(32, 33, 36, .28); }
/* ปุ่มแว่นขยาย: วงกลม ชี้เมาส์แล้วมีพื้นวงกลมสีเทาอ่อน (แบบปุ่มในช่องค้นหาของ Google) */
.search-icon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0;
               color: #5f6368; cursor: pointer; width: 32px; height: 32px; padding: 0; border-radius: 50%;
               display: flex; align-items: center; justify-content: center; transition: background .15s; }
.search-icon:hover, .search-icon:focus-visible { background: #f1f3f4; color: #202124; outline: none; }


/* ผลค้นหา: ตารางในการ์ดขาว หัวคอลัมน์เล็กสีเทา แถวโปร่ง เส้นคั่นบาง ชี้แล้วพื้นฟ้าอ่อน
   ตัวอักษรในแถวเป็นสีเข้มปกติ (อ่านง่าย) ใช้สีเทาเฉพาะหัวคอลัมน์ */
/* หน้าผลค้นหาใช้ความกว้างเต็มจอ (:has = ถ้าในเนื้อหามีตารางผลค้นหา ให้เลิกจำกัดความกว้าง 1100px) */
.content:has(.result-card) { max-width: none; padding: 16px 24px; }
.result-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 0; }
.result-head { padding: 12px 20px; color: var(--muted); font-size: 0.9rem; border-bottom: 1px solid var(--line); }
.result-table { width: 100%; border-collapse: collapse; }
.result-table th { text-align: left; font-weight: 400; font-size: 0.85rem; color: var(--muted);
                   padding: 10px 20px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* ทุกช่องไม่ตัดขึ้นบรรทัดใหม่ (เบอร์โทร/ชื่อจะไม่ตก) ยกเว้นข้อควรระวังที่ตัดเป็น … แทน */
.result-table td { padding: 12px 20px; border-bottom: 1px solid #eef1f4; vertical-align: middle; white-space: nowrap; }
.result-table tbody tr:last-child td { border-bottom: 0; }
.result-table tbody tr:hover { background: #f5f9fd; }
.result-table .col-hn, .result-table .col-doc { font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-table .col-hn { color: var(--muted); }
.result-name { color: var(--text); font-weight: 700; text-decoration: none; }
.result-name:hover { color: var(--brand); text-decoration: underline; }
.type-tag { margin-left: 8px; font-size: 0.75rem; color: var(--muted); background: #f1f3f4; border-radius: 10px; padding: 1px 8px; }
.result-table .col-caution { width: 30%; max-width: 360px; }
.caution-mini { display: inline-block; max-width: 340px; vertical-align: middle; color: #b42318; background: #fdecea;
                border-radius: 6px; padding: 2px 8px; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-table .col-actions { text-align: right; white-space: nowrap; }
.result-table .col-actions form { margin-right: 12px; }
.link-quiet { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.link-quiet:hover { color: var(--brand); }

/* หัวหน้าแบบแถบเครื่องมือ: ชื่อหน้า (ซ้าย) ช่องค้นหา + ปุ่ม (ขวา) */
.page-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-toolbar h1 { margin: 0 auto 0 0; }
.page-search { position: relative; display: flex; width: 280px; margin: 0; }
.page-search input { flex: 1; font: inherit; font-size: 0.95rem; padding: 7px 44px 7px 16px; border: 1px solid #dfe1e5;
                     border-radius: 24px; background: #fff; transition: box-shadow .15s; }
.page-search input:hover, .page-search input:focus { outline: none; border-color: transparent; box-shadow: 0 1px 6px rgba(32, 33, 36, .28); }
/* ปุ่มบนหัวหน้า (เช่น + เพิ่มผู้ใช้) ขนาดเล็ก สูงเท่าช่องค้นหาข้าง ๆ */
.page-toolbar .btn { align-self: auto; padding: 6px 14px; font-size: 0.92rem; }
/* ช่องติ๊กบทบาทในฟอร์มผู้ใช้: บรรทัดเดียว = ชื่อบทบาท + ตัวอย่างสั้นสีเทา */
.form label.check.role { gap: 8px; }
.form label.check.role input { flex: none; }
.role-hint { color: var(--muted); font-size: 0.85rem; margin-left: 4px; }
.role-tag { display: inline-block; font-size: 0.82rem; background: #eef4fb; color: #1d4f86; border-radius: 10px;
            padding: 1px 10px; margin: 2px 6px 2px 0; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-dot.on { background: #1a7f37; }
.status-dot.off { background: #b0b8c1; }
.result-table tr.inactive td { color: var(--muted); }

/* ข้อความว่าง/ค้นไม่เจอ: กลางจอ เรียบ ๆ ตัวหนังสือบาง ปุ่มสองปุ่มอยู่ใต้ข้อความ */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
               text-align: center; min-height: 60vh; gap: 4px; }
.empty-state h2 { margin: 0; font-size: 1.6rem; font-weight: 400; }
.empty-state p { margin: 8px 0 0; color: var(--muted); max-width: 520px; line-height: 1.6; }
.empty-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; justify-content: center; }
.empty-actions .btn { align-self: auto; border-radius: 8px; padding: 8px 22px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }

/* ปุ่มเมนูแบบแถบเครื่องมือของ Outlook (.rb = ribbon button): ไอคอนสีฟ้า + ข้อความสีเข้ม ไม่มีกรอบ
   ชี้เมาส์ = พื้นเทาอ่อน, หน้าที่เปิดอยู่ (.active จาก NavLink) = ตัวหนา + เส้นสีฟ้าใต้ข้อความ */
.rb { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
      border: 0; border-radius: 4px; background: none; font: inherit; font-size: .95rem; color: #242424;
      text-decoration: none; white-space: nowrap; cursor: pointer; transition: background .1s; }
.rb .icon { flex: none; color: var(--brand); }
.rb:hover, .rb:focus-visible { background: #f0f0f0; outline: none; }
.rb:active { background: #e0e0e0; }
.rb.active { font-weight: 700; }
.rb.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 1px; height: 3px;
                    border-radius: 2px; background: var(--brand); }
/* ข้อความเฉย ๆ (ชื่อผู้ใช้) หน้าตาเหมือนปุ่มแต่กดไม่ได้ */
.rb-static, .rb-static:hover { cursor: default; background: none; color: var(--muted); }
.rb-static .icon { color: var(--muted); }
/* ปุ่มหลักสีฟ้าเต็ม แบบปุ่ม "จดหมายใหม่" */
.rb-primary { background: var(--brand); color: #fff; padding: 0 14px; font-weight: 700; flex: none; }
.rb-primary .icon { color: #fff; }
.rb-primary:hover, .rb-primary:focus-visible { background: #115ea3; }
.rb-primary:active { background: #0f548c; }
/* เส้นคั่นแนวตั้งระหว่างกลุ่มเมนู */
.rb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }

/* ปุ่มสลับภาษา */
.lang { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.lang a { padding: 4px 10px; color: var(--muted); text-decoration: none; }
.lang a.active { background: var(--brand); color: #fff; }

/* เนื้อหา */
.content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px; }
h1 { margin-top: 0; }
.lead { font-size: 1.15rem; }
.muted { color: var(--muted); }
.steps li { margin: 6px 0; }

/* ฟอร์ม (หน้าสมัครใช้งาน และหน้าอื่น ๆ ต่อไป) */
.form { max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; background: #fff;
                 display: flex; flex-direction: column; gap: 12px; }
.form legend { font-weight: 700; padding: 0 6px; }
.form label { display: flex; flex-direction: column; gap: 4px; }
.form input, .form textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; }
.form label.check input { width: 18px; height: 18px; }
.field-error { color: #b42318; font-size: 0.9rem; }
.btn { font: inherit; padding: 10px 20px; border: 0; border-radius: 6px; background: var(--brand); color: #fff;
       cursor: pointer; align-self: flex-start; }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: #b42318; }
.btn.small { padding: 4px 10px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.4; cursor: default; }
a.btn { text-decoration: none; display: inline-block; }
.link-btn { font: inherit; background: none; border: 0; color: var(--brand); cursor: pointer; padding: 2px 4px; }
.link-btn.active { font-weight: 700; background: #e8f1fb; border-radius: 4px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.id-count.done { color: #1a7f37; font-weight: 700; }
.id-count.bad { color: #b42318; font-weight: 700; }
[hidden] { display: none !important; }   /* ให้ hidden ชนะ display:flex ของ label */.form.wide { max-width: none; }
.form select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline { display: inline; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ตาราง */
.grid { width: 100%; border-collapse: collapse; background: #fff; margin: 12px 0; }
.grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.grid tr.inactive td { color: var(--muted); }

/* ค้นหา */
.search { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.search input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; flex: 1; min-width: 240px; }

/* พิมพ์ */
.pdf-frame { width: 100%; height: 75vh; border: 1px solid var(--line); background: #fff; }

/* หน้าดูประวัติ */
.patient-head { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; background: #fff;
                border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; margin-bottom: 12px; }
.patient-head h1 { margin: 0; font-size: 1.5rem; }
.allergy { color: #b42318; font-weight: 700; }
/* หน้าประวัติแบบ Outlook: ใช้ความกว้างเต็มจอ (:has = ถ้าในเนื้อหามี .mail ให้เลิกจำกัดความกว้าง) */
/* เต็มความสูงจอ: body สูงพอดีจอ, เนื้อหายืดเต็มที่เหลือใต้แถบบน, แต่ละช่องเลื่อนของตัวเอง */
body:has(.mail) { height: 100vh; }
.content:has(.mail) { max-width: none; padding: 8px; min-height: 0; display: flex; flex-direction: column; }
.patient-head .muted { font-size: 0.95rem; }
.mail { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px 1fr; gap: 0; background: #fff;
        border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mail-list { border-right: 1px solid var(--line); overflow-y: auto; background: #fbfcfd; }
.mail-list-title { font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fbfcfd; }
.mail-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; text-align: left; font: inherit;
             background: none; border: 0; border-bottom: 1px solid var(--line); border-left: 4px solid transparent;
             padding: 10px 12px; cursor: pointer; color: var(--text); }
.mail-item:hover { background: #f0f5fb; }
.mail-item.active { background: #e8f1fb; border-left-color: var(--brand); }
.mail-date { font-weight: 700; }
.mail-ago { color: var(--muted); font-size: 0.85rem; text-align: right; }
.mail-meta { grid-column: 1 / -1; display: flex; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.badge-wait { background: #fff4e5; color: #9a5b00; border-radius: 4px; padding: 0 6px; }
.mail-read { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.mail-head { border-bottom: 1px solid var(--line); padding: 10px 16px 0; }
.mail-head .patient-head { border: 0; padding: 0 0 8px; margin: 0; background: none; flex-wrap: nowrap; align-items: flex-start; }
/* ข้อมูลผู้ป่วยอยู่บรรทัดเดียว: ทุกอย่างคงขนาด ยกเว้นป้ายแพ้ยาที่หดตามพื้นที่ที่เหลือแล้วตัดเป็น … เอง */
.ph-info { flex: 1; min-width: 0; display: flex; flex-wrap: nowrap; gap: 16px; align-items: baseline; }
.ph-info > * { flex: none; white-space: nowrap; }
.ph-info .allergy-chip { flex: 0 1 auto; min-width: 80px; }
.ph-actions { flex: none; display: flex; gap: 12px; align-items: center; }
.mail-head .toolbar { border-top: 1px solid var(--line); padding: 8px 0; margin: 0; }
.mail-pages { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.mail-empty { padding: 16px; }
.sheet { margin: 0 0 20px; text-align: center; }
.sheet figcaption { text-align: left; font-weight: 700; margin-bottom: 6px; display: flex; gap: 12px; align-items: center; }
.sheet img { max-width: none; border: 1px solid var(--line); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.danger-text { color: #b42318; font-weight: 400; }

/* แพ้ยาในหัวช่องขวา: ย่อเหลือบรรทัดเดียว ยาวเกินแสดง … กดเพื่อเปิดหน้าต่าง */
.allergy-chip { font: inherit; color: #b42318; font-weight: 700; background: #fdecea; border: 1px solid #f5c2bd;
                border-radius: 6px; padding: 2px 10px; cursor: pointer;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.allergy-chip:hover { background: #fbd9d5; }
.allergy-chip.none { color: var(--muted); font-weight: 400; background: #f3f5f7; border-color: var(--line); }

/* หน้าต่าง Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex;
                  align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.25); width: min(720px, 100%);
         max-height: 90vh; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 1.25rem; color: #b42318; }
.modal h3 { margin: 4px 0 0; font-size: 1.05rem; }
.modal-field textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.allergy-full { white-space: pre-wrap; font-weight: 700; color: #b42318; margin: 0; }
.modal-log { max-height: 260px; overflow: auto; }

/* Modal ที่มีฟอร์ม (ลงทะเบียนใหม่): ตัวอักษรเล็กลงให้สมส่วนกับหน้าต่าง ไม่มีกรอบซ้อนกรอบ */
.modal-form { width: min(560px, 100%); font-size: 15px; gap: 8px; }
.modal-form .modal-head { position: sticky; top: -16px; background: #fff; padding: 6px 0; z-index: 1;
                          border-bottom: 1px solid var(--line); }
.modal-form .modal-head h2 { color: var(--text); font-size: 1.15rem; }
.modal-form .form { max-width: none; gap: 12px; }
.modal-form .form fieldset { border: 0; padding: 0; gap: 10px; }
.modal-form .form input, .modal-form .form select { padding: 6px 10px; }
.modal-form .lead { font-size: 1.05rem; }

/* กลุ่มช่องกรอกที่ไม่ได้ใช้ label ครอบ (เช่น ช่องเลขบัตร) ให้หน้าตาเหมือน label ของฟอร์ม */
.form .field { display: flex; flex-direction: column; gap: 4px; }
.form .field > input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.modal-form .form .field > input { padding: 6px 10px; }
.hint-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.form label.check.small { font-size: 0.8rem; color: var(--muted); gap: 4px; flex: none; }
.form label.check.small input { width: 14px; height: 14px; }

/* ไอคอน ? ที่ชี้เมาส์แล้วแสดงคำอธิบาย (ข้อความอยู่ใน data-tip) */
.help-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
            border-radius: 50%; background: #e8f1fb; color: var(--brand); font-size: 0.75rem; font-weight: 700;
            cursor: help; vertical-align: middle; margin-left: 4px; }
.help-tip:hover::after, .help-tip:focus::after {
    content: attr(data-tip); position: absolute; left: 0; top: 24px; z-index: 5; width: max-content; max-width: 320px;
    background: #1f2933; color: #fff; font-weight: 400; font-size: 0.8rem; line-height: 1.4;
    padding: 6px 10px; border-radius: 6px; white-space: normal; }
.modal-close { text-decoration: none; font-size: 1.2rem; }

/* ปุ่มในทุก Modal อยู่มุมล่างขวา (แบบ Outlook): เส้นคั่นด้านบน ปุ่มหลักก่อน ตามด้วยยกเลิก
   ใช้กับทุกหน้าต่าง เพราะทุก Modal วางปุ่มไว้ใน <div class="actions"> เหมือนกัน */
.modal .actions { justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.modal .actions .btn { min-width: 110px; text-align: center; }
/* ฟอร์มยาวที่ต้องเลื่อน: แถบปุ่มค้างอยู่ขอบล่างของหน้าต่างเสมอ */
.modal form > .actions { position: sticky; bottom: -16px; background: #fff; padding-bottom: 12px; z-index: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.image-box { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 80vh; text-align: center; }
.image-box img { max-width: none; }
.delete-box { margin-top: 8px; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.delete-box input { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; }

/* อัปโหลด */
.dropzone { border: 2px dashed var(--brand); border-radius: 10px; padding: 40px 16px; text-align: center;
            background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.summary { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }

/* รอจับคู่ */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.thumb { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-decoration: none;
         color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.thumb img { width: 100%; height: 140px; object-fit: cover; object-position: top; }
.pending-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
.pending-layout .image-box img { width: 100%; }

/* หน้าแรกของแพทย์ */
.today-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 12px 0; }

/* ผู้ดูแลระบบกลาง / ตั้งค่าคลินิก */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px;
        display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 1.8rem; color: var(--brand); }
.logo-preview { max-height: 80px; border: 1px solid var(--line); background: #fff; padding: 4px; }

@media (max-width: 800px) {
    .pending-layout { grid-template-columns: 1fr; }
    body:has(.mail) { height: auto; }
    .mail { grid-template-columns: 1fr; }
    .mail-list { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
    .form .row2 { grid-template-columns: 1fr; }
}

.clinic-code { font-size: 2.5rem; font-weight: 700; letter-spacing: 0.2em; color: var(--brand); margin: 8px 0; }


/* แถบแจ้งข้อผิดพลาดของ Blazor (ซ่อนไว้ จนกว่า Blazor จะเปิดเอง) */
#blazor-error-ui {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    padding: 10px 24px;
    background: #fff4ce;
    border-top: 1px solid #e0c060;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* หน้าเข้าสู่ระบบ / สมัครใช้งาน (AuthFrame) — หน้า / ตอนยังไม่เข้าสู่ระบบ, /login, /register
   แบบ: รูปโต๊ะทำงานสีขาวเป็นพื้นหลังเต็มจอ (wwwroot/img/login-bg.jpg) ฟอร์มลอยฝั่งซ้าย ไม่มีการ์ด
   ซ่อนแถบบนและให้เนื้อหาเต็มจอ เฉพาะหน้าที่มี .login-screen อยู่ */
body:has(.login-screen) .topbar { display: none; }
.content:has(.login-screen) { max-width: none; padding: 0; display: flex; }
.login-screen { flex: 1; min-height: 100vh; position: relative; overflow: hidden; display: grid;
                grid-template-columns: minmax(0, max(46%, calc(100% - 80vh))) 1fr;
                background: #f6f6f6 url("img/login-bg.jpg") right center / auto 100vh no-repeat fixed; }
/* รูปพื้นหลัง (1920x1024) สูงเท่าจอ ชิดขวา และค้างกับจอ (fixed) หน้ายาวเลื่อนแล้วรูปไม่ขยาย/ไม่เลื่อนตาม
   ของบนโต๊ะกินพื้นที่ขวาราว 0.8 เท่าของความสูงจอ คอลัมน์ฟอร์มจึงกว้าง = จอ - 80vh (อย่างน้อย 46%)
   ฝั่งซ้ายของรูปเป็นพื้นสีเรียบ #f6f6f6
   จึงต่อกับสีพื้นหน้าได้เนียน ถ้าจอกว้างกว่ารูป ส่วนที่เกินทางซ้ายเป็นสีเดียวกัน */
body:has(.login-screen) { background: #f6f6f6; }
.login-lang { position: absolute; top: 16px; right: 24px; z-index: 2; background: #fff; }


/* คอลัมน์ฟอร์ม: จัดกลางในฝั่งซ้าย */
.login-main { position: relative; z-index: 1; grid-column: 1; display: flex; flex-direction: column;
              align-items: center; justify-content: center; padding: 64px 24px 32px; text-align: center; }
.login-logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: #3a4252;
              font-size: 3rem; font-weight: 700; letter-spacing: -.01em; line-height: 1; }
.login-logo svg { width: 44px; height: 44px; fill: #2f6fd6; }
.login-logo b { color: #2f80ed; }
.login-tagline { margin: 10px 0 0; color: var(--muted); font-size: .95rem; max-width: 520px; text-wrap: balance; }

.login-card { width: 100%; max-width: 440px; margin-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 2.6rem; margin: 0; color: #3a4252; }
.login-card .subtitle { margin: 0 0 10px; color: #5d6676; }
.login-card .subtitle a, .login-register a { color: #2f80ed; font-weight: 700; text-decoration: none; margin-left: 6px; }
.login-card .form { max-width: none; gap: 18px; text-align: left; }

/* ช่องกรอกทรงแคปซูล ไม่มีเส้นขอบ ใช้เงานุ่ม ๆ แทน */
.login-card .form input, .login-card .form textarea {
    width: 100%; border: 0; border-radius: 999px; padding: 15px 22px; background: #fff;
    box-shadow: 0 10px 26px rgba(40, 70, 130, .13); }
.login-card .form textarea { border-radius: 22px; resize: vertical; }
.login-card .form input:focus, .login-card .form textarea:focus { outline: none;
    box-shadow: 0 10px 26px rgba(40, 70, 130, .13), 0 0 0 3px rgba(47, 128, 237, .35); }
.login-field { position: relative; display: block !important; }
.login-field > svg { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px;
                     fill: #5d6676; pointer-events: none; }
.login-card .form .login-field input { padding-left: 54px; padding-right: 54px; }
.login-eye { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); border: 0; background: none;
             padding: 6px; cursor: pointer; line-height: 0; border-radius: 50%; }
.login-eye svg { width: 22px; height: 22px; fill: #8a93a2; }
.login-eye.on svg { fill: #2f80ed; }
.login-forgot { margin: -4px 8px 0 0; text-align: right; font-size: .85rem; color: #5d6676; }

/* ปุ่มทรงแคปซูลไล่สีฟ้า + เงาสีฟ้า */
.login-card .form .btn { width: 100%; border-radius: 999px; padding: 14px; font-size: 1.15rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    background: linear-gradient(90deg, #1f6fff, #3d9bff); box-shadow: 0 12px 26px rgba(31, 111, 255, .35); }
.login-card .form .btn:hover { filter: brightness(1.05); }
.login-submit svg { width: 22px; height: 22px; fill: #fff; }
.login-card > .btn { align-self: center; border-radius: 999px; padding: 12px 36px; }

.login-register { margin: 8px 0 0; color: #5d6676; }
.login-footer { margin-top: 40px; font-size: .85rem; color: #7a8392; }

/* หน้าสมัคร: ช่องเยอะ ใช้ชื่อช่องเหนือช่องกรอก (ไม่มีไอคอน) และฟอร์มกว้างขึ้น */
.login-card.wide { max-width: 560px; }
.login-card .form fieldset { border: 0; padding: 0; margin: 0; background: none; display: flex;
                             flex-direction: column; gap: 14px; }
.login-card .form legend { padding: 0; margin-bottom: 6px; font-weight: 700; color: #2f80ed; }
.login-card .form label.check input { box-shadow: none; width: 18px; margin: 0; }
.login-card .clinic-code { text-align: center; }

/* จอแคบ: ฟอร์มเต็มความกว้าง รูปถูกฟอร์มทับ จึงลดความเข้มของรูปด้วยชั้นสีขาวโปร่ง */
@media (max-width: 1000px) {
    .login-screen { grid-template-columns: 1fr;
        background: linear-gradient(rgba(246, 246, 246, .82), rgba(246, 246, 246, .82)),
                    #f6f6f6 url("img/login-bg.jpg") right top / auto 100vh no-repeat fixed; }
    .login-main { padding: 72px 16px 24px; }
    .login-logo { font-size: 2.4rem; }
    .login-card h1 { font-size: 2rem; }
}

/* เมนูผู้ใช้มุมขวาบน (UserMenu) แบบ Outlook: วงกลมอักษรย่อ กดแล้วมีแผงลอยใต้วงกลม */
.usermenu { position: relative; margin-left: 8px; }
.usermenu > summary { list-style: none; cursor: pointer; }
.usermenu > summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
          background: #cfe4fa; color: #0b4a8b; font-weight: 700; font-size: .9rem; user-select: none; flex: none; }
.usermenu > summary.avatar:hover, .usermenu > summary.avatar:focus-visible { outline: 2px solid #c7c7c7; outline-offset: 2px; }
.usermenu[open] > summary.avatar { outline: 2px solid var(--brand); outline-offset: 2px; }
.avatar-lg { width: 88px; height: 88px; font-size: 2rem; }

.usermenu-panel { position: absolute; right: 0; top: calc(100% + 10px); z-index: 50; width: 370px; max-width: calc(100vw - 24px); background: #fff;
                  border-radius: 8px; box-shadow: 0 8px 28px rgba(0, 0, 0, .18), 0 0 2px rgba(0, 0, 0, .12); overflow: hidden; }
.usermenu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.usermenu-head form { margin: 0; }
.usermenu-org { font-size: .9rem; color: #424242; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ปุ่มออกจากระบบแบบลิงก์ของ Outlook: ชี้เมาส์แล้วมีพื้นเทาและเส้นใต้ */
.usermenu-signout { font: inherit; font-size: .9rem; background: none; border: 0; padding: 6px 10px; border-radius: 4px;
                    color: #242424; cursor: pointer; white-space: nowrap; }
.usermenu-signout:hover, .usermenu-signout:focus-visible { background: #f0f0f0; text-decoration: underline; outline: none; }
.usermenu-body { display: flex; align-items: center; gap: 16px; padding: 12px 20px 22px; }
.usermenu-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.usermenu-info strong { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-info .muted { font-size: .9rem; }
.usermenu-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
                 background: #f5f5f5; border-top: 1px solid #ebebeb; font-size: .9rem; color: #424242; }
.usermenu-foot .lang { background: #fff; }

/* ---------- หน้าตั้งค่าหน่วยงาน: การ์ดขาวแบบเดียวกับหน้าผู้ใช้งาน ---------- */
.code-chip { font-size: 0.95rem; color: var(--muted); background: #fff; border: 1px solid var(--line);
             border-radius: 999px; padding: 6px 14px; }
.code-chip strong { color: var(--text, #1f2328); margin-left: 4px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.settings-card .form { max-width: none; }
.card-actions { justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 14px; }
/* ปุ่มเลือกแบบการ์ด (ขนาดกระดาษ) */
.choice-row { display: flex; gap: 10px; }
.form label.choice { flex-direction: row; align-items: center; gap: 8px; padding: 8px 18px; border: 1px solid var(--line);
                     border-radius: 8px; cursor: pointer; background: #fff; font-weight: 600; }
.form label.choice:hover { border-color: #9ec5f0; }
.form label.choice:has(input:checked) { border-color: var(--brand); background: #e8f1fb; color: var(--brand); }
.form label.choice input { width: 16px; height: 16px; margin: 0; }
/* กรอบโลโก้ */
.logo-box { height: 120px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center;
            justify-content: center; background: #fafbfc; }
.logo-box img { max-height: 96px; max-width: 90%; }
.logo-remove { margin: -6px 0 0; text-align: right; }
.danger-text { color: #b42318; font-size: 0.9rem; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

/* [Blazor] FocusOnNavigate (ใน Routes.razor) ย้าย focus ไปที่ <h1> ทุกครั้งที่เปิดหน้า
   เพื่อให้โปรแกรมอ่านหน้าจออ่านชื่อหน้าก่อน — เบราว์เซอร์จึงวาดกรอบ focus รอบหัวข้อ ซ่อนกรอบนั้น */
h1:focus { outline: none; }

/* หน้าต่างแจ้งผล (MessageDialog.razor): กล่องเล็กกลางจอ ไอคอนถูกสีเขียว ข้อความ ปุ่ม OK ตรงกลาง */
.message-dialog { width: min(380px, 100%); align-items: center; text-align: center; gap: 6px; padding-top: 24px; }
.message-dialog svg { color: #1a7f37; }
.message-dialog p { margin: 4px 0 8px; font-size: 1.1rem; font-weight: 600; }
.message-dialog .actions { align-self: stretch; justify-content: center; }   /* ปุ่มเดียว = วางกลาง */

/* ---------- หน้าจับคู่เอกสาร (PendingItem.razor) ---------- */
.back-row { margin: 0 0 4px; }
.back-row a { text-decoration: none; font-size: 0.95rem; }
.pending-image { max-height: calc(100vh - 230px); overflow: auto; background: #fafbfc; }
.pending-image img { display: block; width: 100%; }
.pending-side { display: flex; flex-direction: column; gap: 16px; }
.page-search.full { width: 100%; }
.pending-tip { margin: 0; text-align: center; padding: 12px 0; }
/* รายชื่อให้เลือก: การ์ดกดได้ทั้งแถว เลือกแล้วกรอบสีฟ้า */
.pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.form label.pick { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line);
                   border-radius: 8px; cursor: pointer; background: #fff; }
.form label.pick:hover { border-color: #9ec5f0; }
.form label.pick:has(input:checked) { border-color: var(--brand); background: #e8f1fb; }
.form label.pick input { width: 16px; height: 16px; margin: 0; flex: none; }
.pick-hn { font-weight: 700; min-width: 60px; }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* กล่องลบ: พับไว้ หัวข้อสีแดงเล็ก ๆ */
.danger-zone summary { padding: 12px 20px; cursor: pointer; color: #b42318; font-size: 0.95rem; }
.danger-zone[open] summary { border-bottom: 1px solid var(--line); }

/* หน้าต่างยืนยันจับคู่ / ย้ายเอกสาร: กล่องสรุปว่าเอกสารจะไปอยู่กับใคร */
.confirm-who { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; background: #f8fafc;
               display: flex; flex-direction: column; gap: 4px; }
.confirm-name { font-size: 1.2rem; font-weight: 700; }
.move-summary { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.move-summary .confirm-who:not(.from) { border-color: var(--brand); background: #e8f1fb; }
.move-summary .from { opacity: .75; }
.move-arrow { font-size: 1.5rem; color: var(--muted); text-align: center; }
.notice-inline { color: #1a7f37; font-size: 0.9rem; font-weight: 600; }
@media (max-width: 600px) { .move-summary { grid-template-columns: 1fr; } .move-arrow { transform: rotate(90deg); } }

/* ผลการอัปโหลด (Upload.razor): แถบสรุป + การ์ดตัวเลข + รายการทุกหน้าพร้อมภาพย่อ
   สี: s-ok = เขียว (เข้าประวัติแล้ว), s-warn = ส้ม (รอจับคู่ ต้องทำต่อ), s-bad = แดง (ไม่ได้เก็บ) */
.up-banner { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: 10px; margin-bottom: 16px;
             border: 1px solid; }
.up-banner.ok { background: #eaf7ee; border-color: #b7e1c3; }
.up-banner.warn { background: #fff6e8; border-color: #f3d39b; }
.up-banner-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
                  font-size: 1.4rem; font-weight: 700; color: #fff; flex: none; }
.up-banner.ok .up-banner-icon { background: #1f8a4c; }
.up-banner.warn .up-banner-icon { background: #d97a00; }
.up-banner-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.up-banner-text strong { font-size: 1.2rem; }
.up-banner-text span { color: #4b5563; font-size: .92rem; }
.up-banner-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.up-banner .rb:not(.rb-primary) { background: #fff; border: 1px solid var(--line); }
.up-banner .rb:not(.rb-primary):hover { background: #f5f5f5; }

.up-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.up-stat { background: #fff; border: 1px solid var(--line); border-left: 4px solid; border-radius: 8px; padding: 10px 14px;
           display: flex; flex-direction: column; gap: 2px; }
.up-stat strong { font-size: 1.9rem; line-height: 1.1; }
.up-stat span { font-size: .9rem; color: #4b5563; }
.up-stat.s-ok { border-left-color: #1f8a4c; } .up-stat.s-ok strong { color: #1f8a4c; }
.up-stat.s-warn { border-left-color: #d97a00; } .up-stat.s-warn strong { color: #b86800; }
.up-stat.s-bad { border-left-color: #c62828; } .up-stat.s-bad strong { color: #c62828; }

.up-title { font-size: 1.15rem; margin: 0; }
.up-subtitle { margin: 2px 0 12px; font-size: .92rem; }
.up-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.up-item { display: grid; grid-template-columns: 72px 1fr auto; gap: 16px; align-items: center; background: #fff;
           border: 1px solid var(--line); border-left: 4px solid; border-radius: 8px; padding: 8px 16px 8px 8px; }
.up-item.s-ok { border-left-color: #1f8a4c; }
.up-item.s-warn { border-left-color: #d97a00; }
.up-item.s-bad { border-left-color: #c62828; }
/* ภาพย่อแนวตั้งสัดส่วนกระดาษ ชี้แล้วมีเงา */
.up-thumb { width: 72px; height: 96px; border-radius: 4px; border: 1px solid var(--line); background: #f3f4f6; overflow: hidden;
            display: flex; align-items: center; justify-content: center; color: var(--muted); transition: box-shadow .15s; }
.up-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
a.up-thumb:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.up-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.up-who strong { font-size: 1.05rem; }
.up-who .muted { font-size: .92rem; }
.up-file { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; max-width: 420px;
             font-size: .9rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.badge.s-ok { background: #e3f4e8; color: #17703c; }
.badge.s-warn { background: #fff1db; color: #9a5b00; }
.badge.s-bad { background: #fde7e7; color: #b42318; }

@media (max-width: 700px) {
    .up-banner { flex-wrap: wrap; }
    .up-item { grid-template-columns: 56px 1fr; }
    .up-thumb { width: 56px; height: 75px; }
    .up-status { grid-column: 1 / -1; align-items: flex-start; text-align: left; max-width: none; }
}

/* แถบความคืบหน้าการอัปโหลด (upload.js) */
.up-progress { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; max-width: 720px;
               display: flex; flex-direction: column; gap: 10px; }
.up-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.up-progress-label { font-size: 1.1rem; }
.up-progress-pct { font-size: 1.6rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.up-progress-track { height: 12px; border-radius: 999px; background: #e8edf3; overflow: hidden; }
.up-progress-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #0f6cbd, #3d9bff);
                   transition: width .3s ease; }
/* ไม่รู้ % (กำลังสรุปผล): แถบลายวิ่ง ให้เห็นว่ายังทำงานอยู่ */
.up-progress-bar.busy { background: repeating-linear-gradient(45deg, #0f6cbd 0 14px, #3d9bff 14px 28px);
                        background-size: 40px 40px; animation: up-busy 1s linear infinite; }
@keyframes up-busy { to { background-position: 40px 0; } }
@media (prefers-reduced-motion: reduce) { .up-progress-bar.busy { animation: none; } }
.up-progress-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .9rem; color: #4b5563; }
.up-progress-steps { display: flex; gap: 16px; }
.up-step { color: #9aa3ae; }
.up-step.current { color: var(--brand); font-weight: 700; }
.up-step.done { color: #1f8a4c; }
.up-step.done::before { content: "✓ "; }
.up-progress-time { font-variant-numeric: tabular-nums; }
.up-progress-note { margin: 0; font-size: .88rem; }

/* หน้ารอจับคู่: ติ๊กเลือกหลายหน้าแล้วลบ (Pending.razor + pending.js) */
.pending-toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 8px 12px;
                   margin-bottom: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.pending-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.pending-all input, .thumb-check input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.pending-toolbar .rb-danger { margin-left: auto; }
/* ปุ่มลบแบบเมนู: ไอคอน/ตัวอักษรสีแดง กดไม่ได้ = จาง */
.rb-danger { color: #b42318; }
.rb-danger .icon { color: #b42318; }
.rb-danger:hover:not(:disabled) { background: #fdecea; }
.rb:disabled { opacity: .4; cursor: default; background: none; }

.thumb.selectable { position: relative; padding: 0; }
.thumb.selectable > a { display: flex; flex-direction: column; gap: 4px; padding: 8px; color: var(--text); text-decoration: none;
                        border-radius: 8px; }
.thumb.selectable > a:hover { background: #f7f9fb; }
/* ช่องติ๊กลอยมุมซ้ายบนของรูป พื้นขาวให้เห็นชัดบนรูปทุกแบบ */
.thumb-check { position: absolute; top: 12px; left: 12px; z-index: 1; width: 32px; height: 32px; border-radius: 6px;
               background: rgba(255, 255, 255, .92); box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
               display: flex; align-items: center; justify-content: center; cursor: pointer; }
.thumb.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

/* หน้าต่างยืนยันแบบ <dialog>: .modal ใช้ display:flex จึงต้องซ่อนเองตอนยังไม่เปิด */
dialog.modal { border: 0; width: min(520px, calc(100% - 32px)); color: var(--text); }
dialog.modal:not([open]) { display: none; }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
.confirm-dialog .modal-head h2 { color: #b42318; }
.confirm-dialog p { margin: 0; }
.confirm-dialog .modal-field { display: flex; flex-direction: column; gap: 4px; }
.confirm-dialog .actions { display: flex; gap: 8px; }

/* ยกเลิกใบที่พิมพ์ผิด (CancelSheetButton, Print.razor, TodayPanel) */
.rb.small { height: 28px; padding: 0 8px; font-size: .88rem; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; white-space: nowrap; }.cancelled-note { display: flex; gap: 14px; align-items: flex-start; background: #fdecea; border: 1px solid #f5c2bd;
                  border-radius: 10px; padding: 16px 20px; margin: 16px 0; max-width: 760px; }
.cancelled-note > .icon { width: 32px; height: 32px; color: #b42318; flex: none; }
.cancelled-note > div { display: flex; flex-direction: column; gap: 4px; }
.cancelled-note strong { font-size: 1.2rem; color: #b42318; }
.confirm-dialog form { display: flex; flex-direction: column; gap: 12px; }
/* หน้าต่างที่อยู่ในช่องตาราง (เช่น ปุ่มยกเลิกใบในตารางวันนี้) ไม่รับค่า "ห้ามตัดบรรทัด" ของช่องตาราง */
dialog.modal { white-space: normal; text-align: left; }

/* พื้นที่เก็บเอกสาร (StorageBar / StorageNotice / เมนูผู้ใช้ / หน้า Admin) — สี: เขียว < 80%, ส้ม 80–89%, แดง >= 90% */
.storage-bar { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.storage-bar-text { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; color: #4b5563; }
.storage-bar-track { height: 8px; border-radius: 999px; background: #e8edf3; overflow: hidden; }
.storage-bar-fill { height: 100%; border-radius: 999px; background: #1f8a4c; }
.storage-bar.lv-warn .storage-bar-fill { background: #d97a00; }
.storage-bar.lv-bad .storage-bar-fill { background: #c62828; }
.storage-bar.lv-bad .storage-bar-text span:last-child { color: #b42318; font-weight: 700; }
.storage-notice { display: flex; flex-direction: column; gap: 6px; border-radius: 10px; padding: 12px 16px; margin: 12px 0;
                  border: 1px solid; max-width: 720px; }
.storage-notice.warn { background: #fff6e8; border-color: #f3d39b; }
.storage-notice.full { background: #fdecea; border-color: #f5c2bd; }
.storage-notice.full strong { color: #b42318; }
.usermenu-storage { padding: 0 20px 18px; }
.admin-storage { min-width: 220px; }
/* จุดแดงที่วงกลมเมนูผู้ใช้ = พื้นที่ใกล้เต็ม */
.avatar.has-alert { position: relative; }
.avatar.has-alert::after { content: ""; position: absolute; top: -1px; right: -1px; width: 10px; height: 10px; border-radius: 50%;
                           background: #c62828; border: 2px solid #fff; }
/* หน้าต่างแจ้งเตือน AlertModal (เข้าสู่ระบบไม่สำเร็จ / หน่วยงานถูกระงับ) */
.alert-modal { width: min(480px, 100%); }
.alert-modal h2 { display: flex; align-items: center; gap: 8px; }
.alert-modal p { margin: 0; }
.alert-modal.success .modal-head h2 { color: #17703c; }
.login-suspended-phone a { color: var(--brand); font-weight: 700; text-decoration: none; }

/* ---------- หน้าเครื่องอัปโหลด /settings/devices (X03) ---------- */
.device-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.device-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
               background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.device-main { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.device-main > .icon { width: 28px; height: 28px; color: var(--brand); flex: none; margin-top: 2px; }
.device-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.device-main .muted { font-size: 0.92rem; }
.btn.danger-outline { color: #b42318; border-color: #e5a29b; display: inline-flex; align-items: center; gap: 6px; }
.btn.danger-outline .icon { width: 16px; height: 16px; }
.device-setup { margin-bottom: 24px; }
.setup-steps { margin: 0; padding: 16px 20px 16px 44px; display: flex; flex-direction: column; gap: 18px; }
.setup-steps li::marker { font-weight: 700; color: var(--brand); }
.step-title { font-weight: 700; margin-bottom: 8px; }
.setup-steps p { margin: 0; }
.download-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.download-row .btn { display: inline-flex; align-items: center; gap: 8px; }
.pair-info { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; align-items: center; }
.pair-info dt { color: var(--muted); }
.pair-info dd { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pair-info code { font-size: 1rem; background: #f1f4f7; border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px;
                  overflow-wrap: anywhere; }
.copy-btn { min-width: 96px; }
.device-revoked { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; }
.device-revoked summary { padding: 12px 18px; cursor: pointer; color: var(--muted); }
.device-revoked[open] summary { border-bottom: 1px solid var(--line); }
.device-revoked ul { margin: 0; padding: 12px 18px 12px 38px; display: flex; flex-direction: column; gap: 6px; }
.device-alt { margin-top: 8px; }
@media (max-width: 600px) {
    .pair-info { grid-template-columns: 1fr; gap: 4px; }
    .pair-info dd { margin-bottom: 8px; }
}
