/* ระบบงานพัสดุโรงเรียน - ส่วนแสดงผลหน้าจอ */
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --app-navy: #17324d;
  --app-navy-2: #21466b;
  --app-gold: #c9952b;
  --app-bg: #f3f5f8;
  --app-card: #ffffff;
  --app-line: #e3e8ef;
  --bs-body-font-family: 'Sarabun', 'Leelawadee UI', 'Tahoma', sans-serif;
  --bs-primary: #21466b;
  --bs-primary-rgb: 33, 70, 107;
  --bs-link-color: #21466b;
  --bs-link-color-rgb: 33, 70, 107;
  --bs-link-hover-color: #17324d;
}
body { background: var(--app-bg); font-size: 15.5px; color: #1f2a37; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
.btn-primary { --bs-btn-bg: var(--app-navy-2); --bs-btn-border-color: var(--app-navy-2); --bs-btn-hover-bg: var(--app-navy); --bs-btn-hover-border-color: var(--app-navy); --bs-btn-active-bg: var(--app-navy); }
.btn-outline-primary { --bs-btn-color: var(--app-navy-2); --bs-btn-border-color: var(--app-navy-2); --bs-btn-hover-bg: var(--app-navy-2); --bs-btn-hover-border-color: var(--app-navy-2); }
.text-primary { color: var(--app-navy-2) !important; }
.bg-primary { background-color: var(--app-navy-2) !important; }

/* Navbar */
.app-nav { background: linear-gradient(90deg, var(--app-navy), var(--app-navy-2)); box-shadow: 0 2px 10px rgba(16, 37, 61, .18); }
.app-nav .nav-link { color: rgba(255,255,255,.82); border-radius: .5rem; padding: .45rem .75rem !important; }
.app-nav .nav-link:hover, .app-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--app-gold); color: #fff; font-size: 1.15rem; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; }
.brand-title { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.brand-sub { color: rgba(255,255,255,.7); font-size: .78rem; }
.dropdown-item i { width: 1.25rem; display: inline-block; }

.app-footer { color: #6b7785; padding: 1rem 0 1.4rem; border-top: 1px solid var(--app-line); background: #fff; }

/* Cards */
.card { border: 1px solid var(--app-line); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--app-line); border-radius: 14px 14px 0 0 !important; font-weight: 600; padding: .8rem 1.1rem; }
.card-header .bi { color: var(--app-gold); }
.section-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--app-navy-2); color: #fff; font-size: .8rem; margin-right: .4rem; }

.stat { border-radius: 14px; padding: 1rem 1.1rem; background: #fff; border: 1px solid var(--app-line); height: 100%; position: relative; overflow: hidden; }
.stat .stat-icon { position: absolute; right: .9rem; top: .9rem; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; }
.stat .stat-label { color: #6b7785; font-size: .88rem; }
.stat .stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; }
.stat .stat-sub { font-size: .8rem; color: #8a96a3; }

.quick-btn { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; border-radius: 14px; background: #fff; border: 1px solid var(--app-line); text-decoration: none; color: inherit; transition: .15s; height: 100%; }
.quick-btn:hover { border-color: var(--app-navy-2); box-shadow: 0 4px 14px rgba(33,70,107,.12); transform: translateY(-1px); color: inherit; }
.quick-btn .qi { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: none; }

/* Tables */
.table { --bs-table-bg: transparent; }
.table-app thead th { background: #f6f8fb; color: #4b5867; font-weight: 600; font-size: .88rem; white-space: nowrap; border-bottom: 1px solid var(--app-line); }
.table-app td { vertical-align: middle; }
.table-app tbody tr:hover { background: #fafcff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge-status { font-weight: 500; font-size: .78rem; }
.type-badge { font-weight: 500; font-size: .78rem; }
.text-wrap-anywhere { overflow-wrap: anywhere; }

/* Forms */
.form-label { font-weight: 500; font-size: .92rem; margin-bottom: .3rem; color: #344150; }
.form-control, .form-select { border-radius: .55rem; }
.req::after { content: ' *'; color: #dc3545; }
.thdate .thdate-native { position: absolute; opacity: 0; width: 1px; height: 1px; right: 0; bottom: 0; pointer-events: none; }
.thdate-hint { min-height: 1.1em; color: var(--app-navy-2); font-size: .8rem; margin-top: .15rem; }
.form-control.is-computed, .form-control[readonly] { background: #f6f8fb; }

.items-table input { min-width: 70px; }
.items-table td { padding: .35rem; }
.items-table textarea { min-height: 38px; resize: vertical; }
.items-table .row-no { width: 36px; color: #8a96a3; text-align: center; }

.sticky-summary { position: sticky; top: 84px; }
.summary-line { display: flex; justify-content: space-between; padding: .3rem 0; border-bottom: 1px dashed var(--app-line); }
.summary-line:last-child { border-bottom: 0; }
.summary-total { font-size: 1.35rem; font-weight: 700; color: var(--app-navy); }
.baht-text { color: #6b7785; font-size: .88rem; }

.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { padding: .45rem .6rem; border-radius: .5rem; margin-bottom: .35rem; font-size: .88rem; display: flex; gap: .45rem; }
.check-list .lv-danger { background: #fdecec; color: #8a1f1f; }
.check-list .lv-warning { background: #fff6e0; color: #7a5300; }
.check-list .lv-info { background: #e8f2fd; color: #164b7e; }
.check-list .lv-ok { background: #e7f6ec; color: #17633a; }

/* Workflow stepper */
.stepper { display: flex; gap: 0; overflow-x: auto; padding-bottom: .25rem; }
.stepper .step { flex: 1 1 0; min-width: 120px; text-align: center; position: relative; }
.stepper .step::before { content: ''; position: absolute; top: 17px; left: -50%; width: 100%; height: 3px; background: var(--app-line); z-index: 0; }
.stepper .step:first-child::before { display: none; }
.stepper .dot { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; background: #fff; border: 3px solid var(--app-line); color: #9aa5b1; position: relative; z-index: 1; }
.stepper .step.done .dot { background: #198754; border-color: #198754; color: #fff; }
.stepper .step.done::before { background: #198754; }
.stepper .step.current .dot { border-color: var(--app-gold); color: var(--app-gold); }
.stepper .lbl { font-size: .82rem; margin-top: .35rem; color: #4b5867; }
.stepper .dt { font-size: .76rem; color: #8a96a3; }

.doc-btn { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border: 1px solid var(--app-line); border-radius: 10px; background: #fff; color: inherit; text-decoration: none; font-size: .9rem; height: 100%; }
.doc-btn:hover { border-color: var(--app-navy-2); background: #f7faff; color: inherit; }
.doc-btn i { font-size: 1.1rem; color: var(--app-navy-2); }
.doc-btn .form-check-input { margin: 0; }

.dl-grid { display: grid; grid-template-columns: 170px 1fr; gap: .35rem .8rem; font-size: .93rem; }
.dl-grid dt { color: #6b7785; font-weight: 500; }
.dl-grid dd { margin: 0; }
@media (max-width: 575px) { .dl-grid { grid-template-columns: 1fr; } .dl-grid dt { margin-top: .35rem; } }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--app-line); margin-left: .4rem; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--app-navy-2); }
.timeline li:last-child { padding-bottom: 0; }

.diff-table td, .diff-table th { font-size: .88rem; }
.diff-old { background: #fff3f3; }
.diff-new { background: #f0fbf3; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; align-content: center; background: radial-gradient(1200px 600px at 10% 0%, #2a5683 0%, transparent 60%), linear-gradient(160deg, #17324d, #0e2236); padding: 1rem; }
.login-card { width: 100%; max-width: 410px; border-radius: 18px; border: 0; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-badge { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto .75rem; background: var(--app-gold); color: #fff; font-size: 1.9rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: #8a96a3; }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: .5rem; color: #c3ccd6; }

@media (max-width: 991px) { .sticky-summary { position: static; } }
@media print { .app-nav, .app-footer, .no-print { display: none !important; } body { background: #fff; } }
.stat .stat-label, .stat .stat-value { padding-right: 44px; }
@media (max-width: 575px) {
  .stat .stat-icon { width: 32px; height: 32px; font-size: 1rem; right: .6rem; top: .6rem; }
  .stat .stat-value { font-size: 1.2rem; padding-right: 0; }
  .stat .stat-label { font-size: .8rem; padding-right: 34px; }
  .quick-btn { padding: .7rem; gap: .5rem; font-size: .9rem; }
  .quick-btn .qi { width: 36px; height: 36px; font-size: 1.1rem; }
  .quick-btn small { display: none; }
}

/* v2: หลายโรงเรียน */
.impersonate-bar { background: #fff3cd; color: #664d03; border-bottom: 1px solid #ffe08a; font-size: .9rem; padding: .45rem 0; }
.app-nav.platform { background: linear-gradient(90deg, #2b2f3a, #3c4354); }
.fy-switch { background: rgba(255,255,255,.12); border-radius: .5rem; }
.register-wrap { min-height: 100vh; background: radial-gradient(1200px 600px at 10% 0%, #2a5683 0%, transparent 60%), linear-gradient(160deg, #17324d, #0e2236); padding: 2rem 1rem; }
.register-card { max-width: 860px; margin: 0 auto; border-radius: 18px; border: 0; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.fy-card { border-left: 4px solid var(--app-line); }
.fy-card.current { border-left-color: var(--app-gold); }
.fy-card.closed { background: #f8f9fa; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* เครดิตผู้พัฒนา */
.dev-credit { font-size: .8rem; color: #6b7785; }
.dev-credit a { color: inherit; text-decoration: none; }
.dev-credit a:hover { text-decoration: underline; }
.dev-credit .sep { opacity: .6; }
.dev-credit.on-dark { color: rgba(255,255,255,.72); text-align: center; margin-top: 1rem; }
.register-wrap .dev-credit.on-dark { max-width: 860px; margin: 1rem auto 0; }
