/* หน้า บิล: การ์ดสรุป, รายการบิลแยกตามสถานะ, หน้าต่างตั้งบิล */
.bill-cards { grid-template-columns: repeat(3, 1fr); }
.bill-section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.bill-section + .bill-section { margin-top: 8px; }
.bill-section h4 { margin: 14px 4px 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
.bill-section.overdue h4 { color: var(--expense); }
.bill-section.soon h4 { color: var(--loan); }
.bill-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 16px; cursor: pointer; transition: box-shadow .15s; }
@media (hover: hover) { .bill-row:hover { box-shadow: var(--out-sm); } }
.bill-row .ico { width: 42px; height: 42px; flex: none; border-radius: 14px; display: grid; place-items: center; color: var(--primary); box-shadow: var(--in); }
.bill-row.overdue .ico { color: var(--expense); }
.bill-row.soon .ico { color: var(--loan); }
.bill-row.paid .ico { color: var(--income); }
.bill-row.skipped, .bill-row.ended { opacity: .6; }
.bill-row .info { flex: 1; min-width: 0; }
.bill-row .cat { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-row .note { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-row.overdue .note { color: var(--expense); }
.bill-row.soon .note { color: var(--loan); }
.bill-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill-row.paid .bill-amt { color: var(--income); }
.bill-row.skipped .bill-amt { text-decoration: line-through; }
.bill-unknown { font-size: 13px; font-weight: 500; color: var(--muted); }
.bill-acts { display: flex; align-items: center; gap: 8px; flex: none; }
.bill-acts .btn-sm.btn-icon { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; color: var(--muted); }
.bill-edit { display: grid; color: var(--faint); }

/* แถบเตือนบนหน้าภาพรวม */
.bill-banner .lb-ico { color: var(--expense); }
.bill-banner .lb-item:nth-of-type(2) b { color: var(--expense); }

/* ตัวเลขแจ้งเตือนบนเมนู */
[data-route] { position: relative; }
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center; margin-left: auto; font-size: 11px; font-style: normal; font-weight: 700; color: #fff; background: var(--expense); box-shadow: 0 0 0 2px var(--bg); }
.app.collapsed .side-nav .nav-badge, .tabbar .nav-badge { position: absolute; top: 4px; right: calc(50% - 22px); margin: 0; }

/* หน้าต่างตั้งบิล */
.bill-check { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.bill-freq { display: flex; }
.bill-freq button { flex: 1; }
.bill-hint { margin: -4px 4px 12px; font-size: 12.5px; color: var(--primary); }
.bill-hint:empty { display: none; }

@media (max-width: 760px) {
  .bill-cards .card:first-child { grid-column: span 2; }
  /* มือถือ: จำนวนเงินอยู่เหนือปุ่ม ให้ชื่อ/วันครบกำหนดมีที่มากขึ้น */
  .bill-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ico info amt" "ico info acts"; column-gap: 10px; row-gap: 6px; padding: 10px 6px; }
  .bill-row .ico { grid-area: ico; }
  .bill-row .info { grid-area: info; }
  .bill-amt { grid-area: amt; justify-self: end; }
  .bill-acts { grid-area: acts; justify-self: end; }
  .bill-acts:empty { display: none; }
  .bill-row:has(.bill-acts:empty) { grid-template-areas: "ico info amt" "ico info amt"; }
  .bill-row .note { white-space: normal; }
  .bill-row .ico { width: 36px; height: 36px; border-radius: 12px; }
  .bill-acts { gap: 6px; }
  .bill-acts .btn-sm.btn-icon { width: 30px; height: 30px; }
}

/* มุมมอง "บัตร" */
#bill-list:has(.cardx) { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cardx { min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 18px; box-shadow: var(--in); }
.cardx-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cardx-head.none { cursor: default; }
.cardx-chip { width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center; color: #fff; background: var(--faint); box-shadow: 2px 3px 8px rgba(0, 0, 0, .15); }
.cardx-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cardx-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cardx-name small { font-size: 12px; color: var(--muted); }
.cardx-head:hover .bill-edit { color: var(--primary); }
.cardx-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.cardx-stats span { display: flex; flex-direction: column; }
.cardx-stats small { font-size: 11.5px; color: var(--muted); }
.cardx-stats b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cardx-stats b.expense { color: var(--expense); }
.cardx-bills { display: grid; gap: 2px; border-top: 1px solid var(--line, rgba(128, 128, 160, .18)); padding-top: 8px; }
.cardx-bill { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; cursor: pointer; font-size: 14px; }
@media (hover: hover) { .cardx-bill:hover { box-shadow: var(--out-sm); } }
.cardx-bico { display: grid; color: var(--primary); }
.cardx-bname { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.cardx-bname small { font-size: 12px; color: var(--muted); }
.cardx-bill b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cardx-empty { font-size: 13px; color: var(--muted); padding: 4px; }
