/* hos-stock: สไตล์ทั้งหมดของ index.html */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

body {
  font-family: 'Sarabun', sans-serif;
  font-size: 17px;
  background: #f0f4f8;
  color: #2d3748;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== LOGIN (แบ่งจอ 2 ฝั่ง แบบเดียวกับระบบแผนเงินบำรุง plan70 — ชุดสีน้ำเงินของระบบคลังวัสดุ) ===== */
#loginOverlay {
  --lg-primary: #1a56db;
  --lg-primary-dark: #1e429f;
  --lg-primary-deep: #172b5c;
  --lg-ink-2: #0b1a3d;
  --lg-ink: #0f172a;
  --lg-gold: #e8c874;
  --lg-paper: #f6f7f9;
  --lg-muted: #5b6573;
  --lg-on-dark: #f3f6fb;
  --lg-on-dark-muted: #bcc6d6;
  --lg-border: #e2e6ec;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  overflow-y: auto;
  background: var(--lg-paper);
  color: var(--lg-ink);
}

#loginOverlay h1,
#loginOverlay h2 {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  margin: 0;
  text-wrap: balance;
}

.lg-screen {
  width: 100%;
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

/* ---------- ซ้าย: ข้อมูลระบบ ---------- */
.lg-left {
  position: relative;
  background:
    radial-gradient(ellipse 900px 600px at 12% -10%, rgba(200, 153, 47, 0.16), transparent 60%),
    linear-gradient(160deg, var(--lg-ink-2) 0%, var(--lg-primary-deep) 46%, var(--lg-ink) 100%);
  color: var(--lg-on-dark);
  padding: clamp(2rem, 4vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2.5rem;
  overflow: hidden;
}

.lg-left::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 100% 80% at 30% 20%, black 10%, transparent 70%);
  mask-image: radial-gradient(ellipse 100% 80% at 30% 20%, black 10%, transparent 70%);
  pointer-events: none;
}

.lg-left::after {
  content: "";
  position: absolute;
  right: -180px;
  bottom: -180px;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  border: 1px solid rgba(232, 200, 116, 0.14);
  pointer-events: none;
}

.lg-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.lg-crest {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}

.lg-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--lg-gold);
  font-weight: 600;
  text-transform: uppercase;
}

.lg-org {
  font-size: 0.95rem;
  color: var(--lg-on-dark-muted);
  margin-top: 0.1rem;
}

.lg-hero {
  position: relative;
  max-width: 34rem;
  margin-top: 2.75rem;
}

.lg-hero h1 {
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  font-weight: 700;
  line-height: 1.28;
}

.lg-hero .lg-accent {
  color: var(--lg-gold);
}

.lg-hero p {
  margin: 0.9rem 0 0;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--lg-on-dark-muted);
  max-width: 30rem;
}

.lg-modules {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.lg-module {
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.9rem 0.7rem;
  text-align: center;
}

.lg-module svg {
  color: var(--lg-gold);
}

.lg-module-title {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.lg-module-label {
  font-size: 0.75rem;
  color: var(--lg-on-dark-muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

.lg-steps {
  position: relative;
}

.lg-steps-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--lg-gold);
  margin-bottom: 0.9rem;
}

.lg-step {
  display: flex;
  gap: 0.85rem;
  padding-bottom: 1.1rem;
  position: relative;
}

.lg-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.16);
}

.lg-step-num {
  flex-shrink: 0;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  border: 1px solid rgba(232, 200, 116, 0.55);
  color: var(--lg-gold);
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
}

.lg-step-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--lg-on-dark);
}

.lg-step-desc {
  font-size: 0.83rem;
  color: var(--lg-on-dark-muted);
  margin-top: 0.15rem;
  line-height: 1.55;
}

/* ---------- ขวา: ฟอร์มเข้าสู่ระบบ ---------- */
.lg-right {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.75rem, 4vw, 3rem);
}

.lg-form {
  width: 100%;
  max-width: 400px;
}

.lg-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.lg-logos img {
  width: clamp(64px, 9vw, 92px);
  height: clamp(64px, 9vw, 92px);
  object-fit: contain;
}

.lg-logos .lg-divider {
  width: 1px;
  align-self: stretch;
  margin: 0.4rem 0;
  background: var(--lg-border);
}

.lg-head {
  margin-bottom: 2rem;
  text-align: center;
}

.lg-head h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--lg-ink);
  line-height: 1.35;
}

.lg-head p {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--lg-muted);
}

/* ข้อความผิดพลาด — js เปลี่ยนข้อความและสั่งแสดง/ซ่อนด้วย style.display (ไอคอนอยู่ใน ::before จึงไม่หายเมื่อเปลี่ยนข้อความ) */
.lg-alert {
  display: none;
  position: relative;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 10px;
  padding: 0.7rem 0.85rem 0.7rem 2.3rem;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  text-align: left;
}

.lg-alert::before {
  content: "";
  position: absolute;
  left: 0.8rem;
  top: 0.85rem;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v5M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v5M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

.lg-field {
  margin-bottom: 1.15rem;
}

.lg-field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--lg-ink);
  margin-bottom: 0.4rem;
}

.lg-field label svg {
  color: var(--lg-primary);
  flex-shrink: 0;
}

.lg-input {
  position: relative;
  display: flex;
  align-items: center;
}

.lg-input input {
  width: 100%;
  font-family: 'Sarabun', sans-serif;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--lg-border);
  border-radius: 10px;
  background: var(--lg-paper);
  color: var(--lg-ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lg-input input.lg-has-toggle {
  padding-right: 2.6rem;
}

.lg-input input::placeholder {
  color: #9aa3b0;
}

.lg-input input:focus {
  outline: none;
  border-color: var(--lg-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.14);
}

.lg-toggle {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--lg-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: 6px;
}

.lg-toggle:hover {
  color: var(--lg-primary);
}

.lg-toggle:focus-visible {
  outline: 2px solid var(--lg-primary);
}

.lg-submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.85rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--lg-primary) 0%, var(--lg-primary-dark) 100%);
  color: #fff;
  font-family: 'Sarabun', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 20px -8px rgba(30, 66, 159, 0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.lg-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -8px rgba(30, 66, 159, 0.55);
}

.lg-submit:active {
  transform: translateY(0);
}

.lg-submit:focus-visible {
  outline: 2px solid var(--lg-ink);
  outline-offset: 2px;
}

.lg-foot {
  margin-top: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--lg-muted);
  text-align: center;
}

.lg-foot svg {
  flex-shrink: 0;
  color: var(--lg-primary);
}

.lg-links {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.lg-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--lg-border);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--lg-primary-dark);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lg-links a:hover {
  background: var(--lg-paper);
  border-color: var(--lg-primary);
}

.lg-links a:focus-visible {
  outline: 2px solid var(--lg-primary);
  outline-offset: 2px;
}

.lg-credit {
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--lg-muted);
  padding-top: 1.25rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--lg-border);
}

.lg-credit strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--lg-ink);
}

@media (max-width: 1100px) and (min-width: 861px) {
  .lg-screen {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .lg-screen {
    grid-template-columns: 1fr;
    min-height: 0;
    align-content: start;
  }

  /* มือถือ/แท็บเล็ต: ฟอร์มขึ้นก่อน ข้อมูลระบบอยู่ด้านล่าง */
  .lg-right {
    order: -1;
    padding: 2.25rem 1.5rem 2.5rem;
  }

  .lg-left {
    padding: 2.25rem 1.75rem;
    gap: 1.75rem;
  }

  .lg-hero {
    max-width: none;
    margin-top: 1.75rem;
  }
}

@media (max-width: 600px) {
  .lg-left {
    padding: 1.85rem 1.25rem 2.1rem;
    gap: 1.5rem;
  }

  .lg-left::after {
    display: none;
  }

  .lg-hero h1 {
    font-size: 1.5rem;
  }

  .lg-hero p {
    font-size: 0.92rem;
  }

  .lg-modules {
    grid-template-columns: 1fr;
  }

  .lg-module {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-align: left;
    padding: 0.7rem 0.85rem;
  }

  .lg-module-title {
    margin-top: 0;
  }

  .lg-steps {
    display: none;
  }

  .lg-right {
    padding: 1.75rem 1.1rem 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lg-submit,
  .lg-input input {
    transition: none;
  }
}

/* ===== APP SHELL ===== */
#app {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

header {
  background: linear-gradient(135deg, #1a56db 0%, #1e429f 100%);
  color: #fff;
  padding: 0 28px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(26, 86, 219, .35);
  position: sticky;
  top: 0;
  z-index: 100
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px
}

.header-icon {
  display: flex;
  align-items: center;
}

.header-icon img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.header-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2
}

.header-sub {
  font-size: 13px;
  opacity: .85;
  font-weight: 300
}

.logout-btn {
  background: rgba(255, 255, 255, .2);
  border: 1px solid rgba(255, 255, 255, .4);
  color: #fff;
  padding: 8px 18px;
  border-radius: 10px;
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  cursor: pointer;
  transition: .2s
}

.logout-btn:hover {
  background: rgba(255, 255, 255, .3)
}

/* ===== NAV ===== */
nav {
  background: #fff;
  border-bottom: 2px solid #e2e8f0;
  padding: 0 28px;
  display: flex;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  overflow-x: auto;
}

.nav-btn {
  padding: 16px 20px;
  border: none;
  background: none;
  font-family: 'Sarabun', sans-serif;
  font-size: 17px;
  font-weight: 500;
  color: #718096;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: .2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.nav-btn:hover {
  color: #1a56db;
  background: #f7faff
}

.nav-btn.active {
  color: #1a56db;
  border-bottom-color: #1a56db;
  font-weight: 600
}

.nav-icon {
  font-size: 20px
}

/* ===== MAIN ===== */
main {
  padding: 28px;
  max-width: 1400px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 24px 20px;
  color: #718096;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #f0f4f8;
}

.app-footer img {
  height: 28px;
  width: auto;
  object-fit: contain;
  opacity: 0.8;
}

/* ===== SECTION ===== */
.section {
  display: none
}

.section.active {
  display: block
}

/* ===== SUB NAV ===== */
.sub-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap
}

.sub-btn {
  padding: 12px 24px;
  border: 2px solid #e2e8f0;
  background: #fff;
  border-radius: 12px;
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  cursor: pointer;
  transition: .2s;
  color: #4a5568;
  font-weight: 500
}

.sub-btn:hover {
  border-color: #1a56db;
  color: #1a56db;
  background: #f7faff
}

.sub-btn.active {
  background: #1a56db;
  color: #fff;
  border-color: #1a56db
}

/* ===== CARD ===== */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
  margin-bottom: 24px
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  color: #1e429f;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 2px solid #e8f0ff
}

/* ===== FORM ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px
}

.form-group label {
  font-size: 15px;
  font-weight: 600;
  color: #4a5568
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  outline: none;
  transition: .2s;
  background: #fff
}

.form-group input:focus,
.form-group select:focus {
  border-color: #1a56db;
  box-shadow: 0 0 0 3px rgba(26, 86, 219, .1)
}

.form-group input[readonly] {
  background: #f7faff;
  color: #718096
}

.form-group input[type=number] {
  -moz-appearance: textfield
}

.form-group input[type=number]::-webkit-outer-spin-button,
.form-group input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none
}

.input-with-list {
  position: relative
}

.input-with-list input {
  width: 100%
}

.datalist-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 2px solid #1a56db;
  border-radius: 10px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
  display: none;
  box-shadow: 0 8px 25px rgba(0, 0, 0, .12)
}

.datalist-dropdown div {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 16px;
  border-bottom: 1px solid #f0f4f8
}

.datalist-dropdown div:hover {
  background: #f0f7ff;
  color: #1a56db
}

.form-group .hint {
  font-size: 13px;
  color: #a0aec0
}

/* ===== BUTTONS ===== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
  display: inline-flex;
  align-items: center;
  gap: 8px
}

.btn-primary {
  background: linear-gradient(135deg, #1a56db, #1e429f);
  color: #fff
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(26, 86, 219, .35)
}

.btn-success {
  background: linear-gradient(135deg, #38a169, #276749);
  color: #fff
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56, 161, 105, .35)
}

.btn-danger {
  background: linear-gradient(135deg, #e53e3e, #c53030);
  color: #fff
}

.btn-danger:hover {
  transform: translateY(-1px)
}

.btn-warning {
  background: linear-gradient(135deg, #d69e2e, #b7791f);
  color: #fff
}

.btn-outline {
  background: #fff;
  border: 2px solid #e2e8f0;
  color: #4a5568
}

.btn-outline:hover {
  border-color: #1a56db;
  color: #1a56db
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px
}

.btn-xs {
  padding: 5px 12px;
  font-size: 13px
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e2e8f0
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px
}

thead {
  background: linear-gradient(135deg, #1a56db, #1e429f);
  color: #fff
}

thead th {
  padding: 14px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none
}

thead th:hover {
  background: rgba(255, 255, 255, .1)
}

thead th .sort-icon {
  font-size: 12px;
  opacity: .7;
  margin-left: 4px
}

tbody tr {
  border-bottom: 1px solid #f0f4f8;
  transition: .15s
}

tbody tr:hover {
  background: #f7faff
}

tbody tr.low-stock {
  background: #fffbeb
}

tbody tr.low-stock:hover {
  background: #fef5d3
}

tbody tr.out-stock {
  background: #fff5f5
}

tbody tr.out-stock:hover {
  background: #fed7d7
}

tbody td {
  padding: 12px;
  vertical-align: middle
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-office {
  background: #e0f2fe;
  color: #075985
}

.badge-household {
  background: #dcfce7;
  color: #166534
}

.badge-medical {
  background: #fce7f3;
  color: #831843
}

.badge-computer {
  background: #e0e7ff;
  color: #3730a3
}

.badge-electric {
  background: #ffedd5;
  color: #9a3412
}

.badge-dental {
  background: #f3e8ff;
  color: #6b21a8
}

/* ตารางตรวจไฟล์นำเข้า Excel: แถวที่ข้อมูลผิด */
#excel-preview-table tr.import-row-error td {
  background: #fef2f2;
}

#excel-preview-table .import-error-text {
  color: #b91c1c;
  font-size: 13px;
}

#excel-import-confirm:disabled {
  opacity: .45;
  cursor: not-allowed;
  filter: grayscale(.6);
}

/* ===== FILTERS ===== */
.filter-bar {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06)
}

.filter-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.filter-group label {
  font-size: 14px;
  font-weight: 600;
  color: #4a5568
}

.filter-group input,
.filter-group select {
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  outline: none;
  min-width: 160px
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: #1a56db
}

.search-box {
  flex: 1;
  min-width: 220px
}

.checkbox-filter {
  background: #f7faff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 200px
}

.checkbox-filter-title {
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 10px
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  cursor: pointer
}

.checkbox-list input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: #1a56db
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px
}

.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .07);
  cursor: pointer;
  transition: .2s;
  border: 3px solid transparent
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, .12)
}

.stat-card.active {
  border-color: #1a56db
}

.stat-card .stat-icon {
  font-size: 32px;
  margin-bottom: 8px
}

.stat-card .stat-num {
  font-size: 32px;
  font-weight: 700
}

.stat-card .stat-label {
  font-size: 14px;
  color: #718096;
  margin-top: 4px
}

.stat-office .stat-num {
  color: #1a56db
}

.stat-household .stat-num {
  color: #38a169
}

.stat-medical .stat-num {
  color: #d69e2e
}

.stat-computer .stat-num {
  color: #4f46e5
}

.stat-electric .stat-num {
  color: #ea580c
}

.stat-low .stat-num {
  color: #d97706
}

.stat-out .stat-num {
  color: #e53e3e
}

/* ===== ส่วนสรุปตาราง ===== */
.report-summary-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #f0f7ff;
  padding: 15px 20px;
  border-radius: 12px;
  border: 1px solid #bee3f8;
  margin-bottom: 15px;
}

.report-summary-box div {
  font-size: 16px;
  font-weight: 600;
  color: #1e429f;
}

.report-summary-box span {
  font-size: 18px;
}

/* ===== ตารางรายงานประจำเดือน ===== */
.monthly-table th {
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.monthly-table td {
  border: 1px solid #e2e8f0;
  text-align: right;
}

.monthly-table td:nth-child(1),
.monthly-table td:nth-child(2),
.monthly-table td:nth-child(3) {
  text-align: left;
}

.monthly-table .cat-row {
  background: #eef2ff;
  font-weight: 700;
  color: #3730a3;
}

.monthly-table .cat-row td {
  text-align: left;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px
}

.modal-overlay.open {
  display: flex
}

.modal {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .3)
}

.modal-header {
  padding: 24px 28px;
  border-bottom: 2px solid #e8f0ff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #1e429f
}

.modal-header h3 img {
  height: 25px;
  width: auto;
  object-fit: contain;
  margin-right: 8px;
  vertical-align: middle;
}

.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: #a0aec0;
  transition: .2s;
  background: none;
  border: none;
  font-family: 'Sarabun', sans-serif
}

.modal-close:hover {
  color: #e53e3e
}

.modal-body {
  padding: 28px
}

.modal-footer {
  padding: 20px 28px;
  border-top: 2px solid #f0f4f8;
  display: flex;
  gap: 12px;
  justify-content: flex-end
}

/* ===== CONFIRM DIALOG ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center
}

.confirm-overlay.open {
  display: flex
}

.confirm-box {
  background: #fff;
  border-radius: 18px;
  padding: 36px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .3)
}

.confirm-icon {
  font-size: 52px;
  margin-bottom: 14px
}

.confirm-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px
}

.confirm-msg {
  font-size: 16px;
  color: #718096;
  margin-bottom: 26px;
  line-height: 1.6
}

.confirm-btns {
  display: flex;
  gap: 12px;
  justify-content: center
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: .3s;
  max-width: 340px;
  white-space: pre-line
}

#toast.show {
  transform: translateY(0);
  opacity: 1
}

#toast.success {
  background: linear-gradient(135deg, #38a169, #276749)
}

#toast.error {
  background: linear-gradient(135deg, #e53e3e, #c53030)
}

#toast.info {
  background: linear-gradient(135deg, #1a56db, #1e429f)
}

.issue-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin-top: 10px
}

.issue-items-table th {
  background: #f0f4f8;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px
}

.issue-items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f4f8;
  vertical-align: middle
}

.item-info-box {
  background: #f7faff;
  border: 1px solid #bee3f8;
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  display: none
}

.item-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px
}

.item-info-row {
  font-size: 15px
}

.item-info-row span {
  font-weight: 600;
  color: #1e429f
}

@media(max-width:768px) {
  #app {
    flex-direction: column !important;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 5px;
  }

  .sidebar-logo {
    display: none;
  }

  .main-wrapper header .header-icon {
    display: block;
  }

  nav {
    flex-wrap: nowrap
  }

  .nav-btn {
    white-space: nowrap;
    padding: 14px 18px
  }

  main {
    padding: 16px
  }

  .form-grid {
    grid-template-columns: 1fr
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .report-summary-box {
    flex-direction: column;
    align-items: flex-start;
  }
}

.loading {
  text-align: center;
  padding: 40px;
  color: #a0aec0;
  font-size: 16px
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #1a56db;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 10px
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

.no-data {
  text-align: center;
  padding: 40px;
  color: #a0aec0;
  font-size: 16px
}

.export-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px
}

/* ===== LAYOUT OVERRIDES FOR FORMAL SIDEBAR ====== */
#app {
  display: none;
  min-height: 100vh;
  flex-direction: row;
}

.sidebar {
  width: 280px;
  background: #1a365d;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
  z-index: 150;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  padding: 15px;
  text-align: center;
  background: #152c4d;
  border-bottom: 2px solid #2a4365;
}

.sidebar-logo img {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: transparent;
  border-radius: 4px;
  padding: 0;
  margin-bottom: 10px;
  box-shadow: none;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: #e2e8f0;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 15px 0;
  gap: 5px;
  overflow-y: auto;
}

.sidebar-nav .nav-btn {
  background: transparent;
  color: #3c434b;
  border: none;
  border-left: 4px solid transparent;
  text-align: left;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.2s;
  white-space: normal;
}

.sidebar-nav .nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #5f5c5c;
}

.sidebar-nav .nav-btn.active {
  color: #562af5;
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #0c0aad;
  font-weight: 600;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f0f4f8;
}

nav.sidebar-nav {
  box-shadow: none;
  border-bottom: none;
}

.main-wrapper header {
  background: #ffffff;
  color: #2d3748;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  height: 70px;
  border-bottom: 1px solid #e2e8f0;
}

.main-wrapper header .header-title {
  color: #1a365d;
}

.main-wrapper header .header-sub {
  color: #718096;
}

.main-wrapper header .header-icon {
  display: none;
}

.main-wrapper header .logout-btn {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  color: #4a5568;
}

.main-wrapper header .logout-btn:hover {
  background: #edf2f7;
}

.btn-primary {
  background: linear-gradient(135deg, #2b6cb0, #2c5282) !important;
}

thead {
  background: linear-gradient(135deg, #2a4365, #1a365d) !important;
}

/* ===== ทะเบียนครุภัณฑ์ e_LAAS ===== */
.asset-section-label {
  font-size: 16px;
  font-weight: 700;
  color: #2a4365;
  margin: 6px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px
}

.asset-section-label small {
  font-weight: 400;
  color: #718096;
  font-size: 14px
}

.asset-import-info {
  background: #f7faff;
  border: 1px solid #bee3f8;
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: 15px;
  color: #2d3748;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px
}

.asset-import-info b {
  color: #1e429f
}

.asset-card {
  --kc: #1a56db;
  border-top: 4px solid var(--kc);
  text-align: left;
  padding: 16px 18px
}

.asset-card.active {
  border-color: var(--kc);
  border-top-width: 4px;
  background: #f7faff
}

.asset-card .stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px
}

.asset-card .stat-icon {
  font-size: 26px;
  margin: 0
}

.asset-card .stat-num {
  color: var(--kc);
  font-size: 30px;
  line-height: 1.1
}

.asset-card .stat-num small {
  font-size: 14px;
  font-weight: 500;
  color: #718096;
  margin-left: 4px
}

.asset-card .stat-label {
  color: #2d3748;
  font-weight: 600;
  font-size: 15px;
  margin-top: 6px;
  min-height: 2.6em
}

.asset-card .stat-value {
  font-size: 13px;
  color: #718096;
  margin-top: 4px;
  line-height: 1.5
}

.asset-kind-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr))
}

.asset-table td {
  font-size: 14px
}

.asset-table td.num,
.asset-table th.num {
  text-align: right;
  white-space: nowrap
}

.asset-table tbody tr {
  cursor: pointer
}

.asset-code {
  font-family: Consolas, monospace;
  font-size: 13px;
  white-space: nowrap
}

.asset-code-sub {
  display: block;
  font-size: 12px;
  color: #a0aec0;
  white-space: nowrap
}

.asset-check-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 18px;
  font-size: 15px
}

.asset-check-list .ok {
  color: #276749
}

.asset-check-list .warn {
  color: #b7791f
}

.asset-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  font-size: 15px
}

.asset-detail-grid .full {
  grid-column: 1 / -1
}

.asset-detail-grid .lbl {
  display: block;
  font-size: 13px;
  color: #718096
}

.asset-detail-grid .val {
  font-weight: 600;
  color: #2d3748;
  word-break: break-word
}

@media(max-width:768px) {
  .asset-detail-grid {
    grid-template-columns: 1fr
  }
}

/* ===== ประวัติการเบิกจ่าย: จัดกลุ่มตามวันที่ ===== */
.day-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  padding: 12px 16px;
  margin-bottom: 14px;
  background: #f7faff;
  border: 1px solid #dbe7ff;
  border-radius: 12px;
  color: #4a5568;
  font-size: 15px
}

.day-summary b {
  color: #1e429f
}

.day-summary-actions {
  margin-left: auto;
  display: flex;
  gap: 8px
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 10px
}

.day-row {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s
}

.day-row.open {
  border-color: #93b4f5;
  box-shadow: 0 4px 16px rgba(26, 86, 219, .10)
}

.day-head {
  width: 100%;
  display: grid;
  grid-template-columns: 18px minmax(150px, 190px) 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: none;
  background: #fff;
  text-align: left;
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  color: #2d3748;
  cursor: pointer;
  transition: background .15s
}

.day-head:hover {
  background: #f7faff
}

.day-row.open .day-head {
  background: linear-gradient(90deg, #eef4ff, #fff);
  border-bottom: 1px solid #e2e8f0
}

.day-chevron {
  color: #1a56db;
  font-size: 18px;
  transition: transform .2s
}

.day-row.open .day-chevron {
  transform: rotate(90deg)
}

.day-date {
  font-weight: 700;
  font-size: 17px;
  color: #1e429f;
  white-space: nowrap
}

.day-weekday {
  display: inline-block;
  min-width: 34px;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #e8f0ff;
  color: #1a56db;
  font-size: 13px;
  font-weight: 600;
  text-align: center
}

.day-meta {
  color: #4a5568;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.day-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap
}

.day-pill {
  padding: 3px 10px;
  border-radius: 20px;
  background: #edf2f7;
  color: #4a5568;
  font-size: 13px;
  font-weight: 600
}

.day-amount {
  min-width: 90px;
  text-align: right;
  font-weight: 700;
  color: #1a56db
}

.day-body {
  display: none;
  padding: 14px 18px 18px;
  background: #fafcff
}

.day-row.open .day-body {
  display: block
}

.day-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px
}

/* กล่องผู้เบิก 1 คน (ใช้ทั้งหน้าประวัติและหน้าพิมพ์) */
.req-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px
}

.req-block:last-child {
  margin-bottom: 0
}

.req-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 10px
}

.req-name {
  font-weight: 700;
  color: #1e429f;
  font-size: 16px
}

.req-pos {
  color: #718096;
  font-size: 14px
}

.req-sum {
  margin-left: auto;
  color: #4a5568;
  font-size: 14px;
  font-weight: 600
}

.req-table {
  font-size: 14px
}

.req-table thead th {
  padding: 9px 10px;
  cursor: default
}

.req-table thead th:hover {
  background: none
}

.req-table tbody td {
  padding: 8px 10px
}

.req-table .num {
  text-align: right;
  white-space: nowrap
}

.req-id {
  font-size: 12px;
  color: #a0aec0;
  font-weight: 400
}

/* ===== พิมพ์ใบเบิก: รายการวันที่ซ้าย + ตัวอย่างขวา ===== */
.print-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  align-items: start
}

.print-dates {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #f7faff;
  border: 1px solid #dbe7ff;
  border-radius: 14px;
  max-height: calc(100vh - 60px)
}

.print-dates-title {
  font-weight: 700;
  color: #1e429f;
  font-size: 16px
}

.print-dates-tools {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.print-dates-tools input,
.print-date-pick input {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  background: #fff;
  color: #2d3748
}

.print-dates-tools input:focus,
.print-date-pick input:focus {
  outline: none;
  border-color: #1a56db
}

.print-date-list {
  overflow-y: auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px
}

.print-month-label {
  margin: 8px 2px 2px;
  font-size: 13px;
  font-weight: 700;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: .3px
}

.print-month-label:first-child {
  margin-top: 0
}

.print-date-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: .15s
}

.print-date-btn:hover {
  border-color: #93b4f5;
  background: #f7faff
}

.print-date-btn.active {
  border-color: #1a56db;
  background: linear-gradient(135deg, #1a56db, #1e429f);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26, 86, 219, .3)
}

.pd-date {
  font-weight: 700;
  font-size: 15px;
  color: #1e429f;
  display: flex;
  align-items: center;
  gap: 6px
}

.pd-weekday {
  padding: 1px 7px;
  border-radius: 7px;
  background: #e8f0ff;
  color: #1a56db;
  font-size: 12px;
  font-weight: 600
}

.pd-meta,
.pd-stats {
  font-size: 13px;
  color: #4a5568;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.print-date-btn.active .pd-date,
.print-date-btn.active .pd-meta,
.print-date-btn.active .pd-stats {
  color: #fff
}

.print-date-btn.active .pd-weekday {
  background: rgba(255, 255, 255, .22);
  color: #fff
}

.print-date-pick {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 10px;
  border-top: 1px dashed #c9d8f5;
  font-size: 13px;
  color: #718096
}

.print-main {
  min-width: 0
}

.print-day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 14px 18px;
  border-radius: 12px;
  background: linear-gradient(90deg, #eef4ff, #fff);
  border: 1px solid #dbe7ff
}

.print-day-title {
  font-size: 17px;
  color: #2d3748
}

.print-day-title b {
  color: #1e429f
}

.print-day-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto
}

.print-actions {
  margin-top: 14px
}

.print-preview-label {
  font-size: 15px;
  font-weight: 600;
  color: #1e429f;
  margin: 18px 0 10px
}

.pdf-iframe {
  width: 100%;
  height: 720px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff
}

.print-summary {
  margin-top: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0 14px
}

.print-summary summary {
  padding: 12px 0;
  font-weight: 600;
  color: #1e429f;
  cursor: pointer;
  list-style: none
}

.print-summary summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform .2s
}

.print-summary[open] summary::before {
  transform: rotate(90deg)
}

.print-summary[open] summary {
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 12px
}

.print-summary .req-block:last-child {
  margin-bottom: 14px
}

.print-hint {
  margin-top: 8px;
  font-size: 14px
}

@media (max-width: 900px) {
  .print-layout {
    grid-template-columns: 1fr
  }

  .print-dates {
    position: static;
    max-height: none
  }

  .print-date-list {
    max-height: 320px
  }

  .pdf-iframe {
    height: 60vh
  }

  .day-head {
    grid-template-columns: 18px 1fr;
    gap: 8px 12px
  }

  .day-meta {
    grid-column: 2;
    white-space: normal
  }

  .day-stats {
    grid-column: 2;
    flex-wrap: wrap
  }

  .day-amount {
    min-width: 0
  }

  .day-summary-actions {
    margin-left: 0
  }
}

/* ===== คู่มือการใช้งาน (เมนูสุดท้าย): manual.html ในกรอบ ใช้ได้ทั้งสองธีม ===== */
.manual-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px
}

.manual-head .card-title {
  margin: 0;
  padding: 0;
  border: 0
}

.manual-head .btn {
  text-decoration: none
}

.manual-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 235px);
  min-height: 520px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff
}
