/* ระบบแจ้งซ่อม — ส่วนเสริมเฉพาะระบบ (ธีมหลักมาจาก styles.css + theme.css ของระบบยานพาหนะ ห้ามแก้สองไฟล์นั้น)
 * โหลดหลัง theme.css
 */

/* ───── สถานะใบแจ้งซ่อม ───── */
.pill.st-new { background: #FFE3D8; color: #A3300B; }
.pill.st-acc { background: var(--gold-50); color: #8A6100; }
.pill.st-work { background: var(--peach); color: var(--orange-dd); }
.pill.st-hold { background: #EEF0F6; color: #3F4A6B; }
.pill.st-done { background: var(--green-50); color: #237A4B; }
.pill.st-closed { background: #D9F1E3; color: #1B5E3B; }
.pill.st-fail { background: var(--smoke-50); color: var(--smoke-d); }
.pill.p-ฉุกเฉิน { background: #B91C1C; color: #fff; animation: pulse 1.6s infinite; }
.pill.p-ด่วน { background: #FFE3D8; color: #A3300B; }
.pill.p-ปกติ { background: var(--green-50); color: #237A4B; }
.pill.p-ไม่เร่ง { background: var(--smoke-50); color: var(--smoke-d); }
.pill.repeat { background: #F3E8FF; color: #6B21A8; }

/* ───── ฟอร์มแจ้งซ่อม ───── */
.report-card { max-width: 860px; margin: 0 auto; }
.step { display: flex; align-items: center; gap: 8px; font: 600 15px 'Prompt'; color: var(--orange-d); margin: 4px 0 -4px; }
.step i { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-style: normal; color: #fff; background: linear-gradient(135deg, var(--orange-2), var(--orange)); font-size: 13.5px; flex: none; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.cat-opt { position: relative; cursor: pointer; }
.cat-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cat-opt span {
  display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff;
  font: 500 13.5px/1.3 'Prompt'; text-align: center; color: var(--ink); transition: .15s;
}
.cat-opt span b { font-size: 28px; line-height: 1.1; font-weight: 400; }
.cat-opt:hover span { background: var(--peach-50); }
.cat-opt input:checked + span { border-color: var(--orange); background: linear-gradient(135deg, #fff, var(--peach)); box-shadow: 0 6px 14px -8px rgba(242, 101, 34, .8); transform: translateY(-2px); }
.cat-opt input:focus-visible + span { outline: 3px solid rgba(242, 101, 34, .35); }
.prio-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.prio-opt { cursor: pointer; position: relative; }
.prio-opt input { position: absolute; opacity: 0; pointer-events: none; }
.prio-opt span { display: grid; gap: 1px; padding: 9px 10px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font: 500 14px 'Prompt'; transition: .15s; height: 100%; }
.prio-opt small { font: 400 12px/1.3 'Sarabun'; color: var(--smoke); }
.prio-opt input:checked + span { border-color: var(--orange); background: var(--peach-50); box-shadow: 0 0 0 3px rgba(242, 101, 34, .15); }
.prio-opt.em input:checked + span { border-color: #B91C1C; background: #FFF1F0; box-shadow: 0 0 0 3px rgba(185, 28, 28, .18); }
.dup-warn { border-radius: 14px; padding: 10px 12px; background: var(--gold-50); border: 1px dashed var(--gold); font-size: 14.5px; }
.dup-warn:empty { display: none; }
.dup-warn a { color: var(--orange-d); font-weight: 600; cursor: pointer; }
.em-note { display: none; padding: 10px 12px; border-radius: 12px; background: #FFF1F0; border-left: 5px solid #B91C1C; font-size: 14.5px; }
form:has([name=priority][value=ฉุกเฉิน]:checked) .em-note { display: block; }
.photo-prev { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-prev img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

/* ───── ป๊อปอัพแจ้งสำเร็จ ───── */
.success { text-align: center; padding: 6px 0 4px; }
.success .big-id { display: inline-block; margin: 6px 0 4px; padding: 8px 18px; border-radius: 14px; font: 700 clamp(22px, 5vw, 30px) 'Prompt'; letter-spacing: .5px;
  color: var(--orange-dd); background: linear-gradient(135deg, #fff, var(--peach)); border: 2px dashed var(--orange); }
.success .confetti { font-size: 46px; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }

/* ───── รายการ/การ์ดใบแจ้ง ───── */
.tlist { display: grid; gap: 8px; }
.titem {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; cursor: pointer;
  padding: 10px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--gold); transition: .15s;
}
.titem:hover { background: var(--peach-50); transform: translateX(2px); }
.titem.overdue { border-left-color: #C2410C; background: #FFF7F2; }
.titem.ok { border-left-color: var(--green); }
.titem.done { border-left-color: var(--smoke); opacity: .9; }
.titem .e { font-size: 28px; text-align: center; }
.titem b { font: 500 15px 'Prompt'; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.titem small { display: block; color: var(--smoke); font-size: 13px; }
.titem .side { display: grid; justify-items: end; gap: 4px; }
.tid { font: 600 12.5px 'Prompt'; color: var(--orange-d); letter-spacing: .3px; }
.sla { font: 500 12px 'Prompt'; white-space: nowrap; }
.sla.overdue { color: #B91C1C; } .sla.soon { color: #B45309; } .sla.ok { color: #237A4B; } .sla.done { color: var(--smoke); }

/* ───── รายละเอียด + ไทม์ไลน์ ───── */
.t-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.t-title { font: 600 18px/1.35 'Prompt'; margin: 0 0 4px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photos a { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 10px; background: var(--peach-50); border: 1px solid var(--line); color: var(--orange-d); text-decoration: none; font-size: 14px; }
.photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.progress { display: flex; gap: 0; margin: 12px 0 14px; }
.progress div { flex: 1; text-align: center; font: 500 11.5px/1.2 'Prompt'; color: var(--smoke); position: relative; padding-top: 26px; }
.progress div::before { content: attr(data-i); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--smoke-50); border: 2px solid #E6E2DF; display: grid; place-items: center; font-size: 12px; z-index: 1; }
.progress div::after { content: ''; position: absolute; top: 10px; left: -50%; width: 100%; height: 3px; background: #E6E2DF; }
.progress div:first-child::after { display: none; }
.progress div.on { color: var(--orange-d); }
.progress div.on::before { background: linear-gradient(135deg, var(--orange-2), var(--orange)); border-color: #fff; color: #fff; content: '✓'; box-shadow: 0 0 0 2px var(--orange); }
.progress div.on::after { background: linear-gradient(90deg, var(--orange), var(--gold)); }
.progress div.cur::before { animation: pulse 1.6s infinite; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 14px 24px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--orange); }
.timeline li.c::before { border-color: var(--gold); }
.timeline b { font: 500 14.5px 'Prompt'; }
.timeline small { color: var(--smoke); display: block; font-size: 12.5px; }
.timeline p { margin: 3px 0 0; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.qbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.box { border: 1.5px dashed var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 12px; }
.box > h4 { margin: 0 0 8px; font: 600 15px 'Prompt'; color: var(--orange-d); }

/* ───── ดาวประเมิน ───── */
.stars { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.stars input { position: absolute; opacity: 0; pointer-events: none; }
.stars label { font-size: 34px; cursor: pointer; filter: grayscale(1) opacity(.35); transition: .15s; line-height: 1; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { filter: none; transform: scale(1.08); }
.star-txt { color: var(--gold-d); letter-spacing: 1px; }

/* ───── กระดานงาน ───── */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.col { background: rgba(255, 255, 255, .7); border: 1px solid var(--line); border-radius: 18px; padding: 10px; min-height: 120px; backdrop-filter: blur(8px); }
.col > h3 { margin: 2px 4px 10px; font: 600 15px 'Prompt'; display: flex; justify-content: space-between; align-items: center; color: var(--orange-dd); }
.col > h3 span { background: var(--peach); border-radius: 99px; padding: 0 9px; font-size: 13px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 11px; margin-bottom: 8px; cursor: pointer; display: grid; gap: 4px; box-shadow: 0 4px 10px -8px rgba(210, 80, 26, .5); transition: .15s; border-top: 4px solid var(--gold); }
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kcard.overdue { border-top-color: #C2410C; } .kcard.ok { border-top-color: var(--green); } .kcard.done { border-top-color: var(--smoke); }
.kcard b { font: 500 14.5px/1.35 'Prompt'; }
.kcard small { color: var(--smoke); font-size: 12.5px; }
.kcard .bar { height: 5px; }
.kcard .row { font-size: 12.5px; align-items: center; }

/* ───── อาคาร / ห้อง ───── */
.bcards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.bcard { cursor: pointer; display: grid; gap: 6px; transition: transform .2s; position: relative; overflow: hidden; }
.bcard:hover { transform: translateY(-3px); }
.bcard .ico { font-size: 40px; line-height: 1; }
.bcard b { font: 600 17px 'Prompt'; }
.bcard::after { content: ''; position: absolute; right: -26px; bottom: -26px; width: 90px; height: 90px; border-radius: 50%; background: var(--peach); opacity: .55; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.room { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 6px; text-align: center; font: 500 14px 'Prompt'; position: relative; cursor: pointer; }
.room:hover { background: var(--peach-50); }
.room.hot { border-color: var(--orange); background: #FFF7F2; }
.room i { position: absolute; top: -7px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--orange-dd); color: #fff; font: 600 11px/20px 'Prompt'; font-style: normal; }
.room small { display: block; font: 400 11.5px 'Sarabun'; color: var(--smoke); }
.qr-box { display: grid; justify-items: center; gap: 6px; padding: 12px; border: 2px dashed var(--orange); border-radius: 16px; background: #fff; max-width: 260px; margin: 0 auto; text-align: center; }
.qr-box canvas, .qr-box img { width: 180px !important; height: 180px !important; }

/* ───── รายงาน ───── */
.stats6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-bars .r { grid-template-columns: 150px 1fr 90px; }
.month-chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 170px; padding-top: 8px; }
.month-chart > div { display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; min-width: 0; font: 500 11px 'Prompt'; color: var(--smoke); }
.month-chart .bars { flex: 1; width: 100%; display: flex; gap: 2px; align-items: flex-end; justify-content: center; }
.month-chart i { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--orange-2), var(--orange)); min-height: 3px; position: relative; }
.month-chart i em { position: absolute; top: -17px; left: 0; right: 0; text-align: center; font: 600 11px 'Prompt'; color: var(--orange-dd); font-style: normal; }
.month-chart i.d { background: linear-gradient(180deg, #8FD3A8, var(--green)); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--smoke); margin-top: 6px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ───── อื่น ๆ ───── */
.demo-banner { max-width: 1240px; margin: 0 auto 10px; padding: 8px 14px; border-radius: 12px; background: var(--gold-50); border: 1px dashed var(--gold); color: #6a4300; font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.filters select, .filters input { width: auto; min-width: 150px; flex: 1; }
.filters .subtabs { margin: 0; }
.mini { font-size: 13px; }
.kv.tight { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.parts-table input { padding: 6px 8px; }

@media (max-width: 1024px) {
  .stats6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .prio-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .cat-opt span { font-size: 12px; padding: 8px 4px; }
  .cat-opt span b { font-size: 24px; }
  .board { grid-template-columns: repeat(5, 78vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .titem { grid-template-columns: 36px minmax(0, 1fr); }
  .titem .side { grid-column: 2; justify-items: start; grid-auto-flow: column; justify-content: start; gap: 6px; }
  .chart-bars .r { grid-template-columns: 100px 1fr 60px; }
  .month-chart { height: 140px; gap: 3px; }
  .progress div { font-size: 10px; }
}
@media print {
  .filters, .qbtns, .toolbar .btn, .demo-banner { display: none !important; }
  .hero { display: none; }
}
