/* รายจ่าย /expenses (2026-11-08, Phase 4). On minimal.css's tokens (frosted
   cards, --pill for what's picked); loaded before soft/space/minimal so the
   page cards get their soft look, with the page's own pieces here. */
.ex-page { max-width: 720px; }
.ex-page [hidden], .ex-sheet[hidden], .ex-sheet [hidden] { display: none !important; }

/* notes (guest, import) */
.ex-note { margin: 0 0 12px; padding: 12px 14px; border-radius: 16px; background: var(--t5, #fff1c6); color: var(--text); font-size: 14px; line-height: 1.55; }
.ex-import { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.ex-link { font-weight: 800; color: inherit; text-decoration: underline; text-underline-offset: 3px; position: relative; }
.ex-link::after { content: ""; position: absolute; inset: -12px -8px; } /* a 44px tap box without stretching the line */
.ex-small { min-height: 44px; padding: 0 16px; font-size: 14px; }

/* the month card */
.ex-month { padding: 10px 14px 16px; }
.ex-mbar { display: flex; align-items: center; gap: 4px; }
.ex-mbar h2 { flex: 1; margin: 0; text-align: center; font-size: 17px; font-weight: 800; line-height: 1.4; }
.ex-icon-btn { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 14px; background: transparent; color: var(--text); font: 800 24px/1 inherit; cursor: pointer; padding: 0; }
.ex-icon-btn:hover { background: var(--fill); }
.ex-icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.ex-icon-btn img { width: 28px; height: 28px; }
.ex-gear { margin-left: 2px; }
.ex-total { margin: 8px 0 12px; text-align: center; line-height: 1.2; }
.ex-total-n { display: block; font-family: "Chakra Petch", Inter, sans-serif; font-size: clamp(34px, 10vw, 46px); font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ex-total-c { display: block; margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.ex-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--fill); gap: 2px; }
.ex-bar i { display: block; min-width: 4px; height: 100%; }
.ex-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 18px; }
.ex-legend li { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13.5px; line-height: 1.5; }
.ex-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.ex-lg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-legend b { font-weight: 700; font-variant-numeric: tabular-nums; }
.ex-legend small { color: var(--muted); min-width: 32px; text-align: right; }

/* days */
.ex-state { text-align: center; color: var(--muted); margin: 18px 0; }
.ex-day { margin-top: 18px; }
.ex-day h3 { display: flex; justify-content: space-between; align-items: baseline; margin: 0 6px 8px; font-size: 14px; font-weight: 800; color: var(--muted); line-height: 1.5; }
.ex-day h3 b { font-variant-numeric: tabular-nums; }
.ex-list { list-style: none; margin: 0; padding: 0; border-radius: var(--card-r, 22px); overflow: hidden; background: var(--card-bg, var(--surface)); box-shadow: var(--hard-sm); border: 1px solid var(--edge); }
.ex-item { position: relative; touch-action: pan-y; }
.ex-item + .ex-item { border-top: 1px solid var(--line); }
.ex-swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 22px; background: #e5484d; color: #fff; font-weight: 800; font-size: 14px; }
.ex-item-main { position: relative; width: 100%; min-height: 60px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 0; background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer; transition: transform .2s ease; }
.ex-item.dragging .ex-item-main { transition: none; }
.ex-item-main:focus-visible { outline: 2px solid var(--accent, #ff4b2b); outline-offset: -3px; }
.ex-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ex-item-t { font-weight: 700; font-size: 15px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-item-m { font-size: 12.5px; color: var(--muted); line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-item-a { flex: none; font-weight: 800; font-size: 15.5px; font-variant-numeric: tabular-nums; }

/* a category's sticker on its colour */
.ex-tile { flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 22%, transparent); }
.ex-tile img { width: 30px; height: 30px; display: block; }
.ex-tile.sm { width: 36px; height: 36px; border-radius: 12px; }
.ex-tile.sm img { width: 26px; height: 26px; }
html[data-theme="dark"] .ex-tile { background: color-mix(in srgb, var(--c) 30%, #f3eee3 8%); }

/* empty */
.ex-empty { text-align: center; padding: 22px 12px 8px; }
.ex-empty img:first-child { width: 150px; height: 150px; object-fit: contain; }
.ex-empty p { margin: 8px 0 14px; font-weight: 700; font-size: 16px; line-height: 1.5; }
.ex-empty .fd-btn img, .ex-catedit .fd-btn img, #exCatAdd img { width: 22px; height: 22px; }

/* + log spending (the tab bar's Quick + opens the same sheet from anywhere) */
.ex-add { width: 100%; min-height: 50px; margin: 0 0 14px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px; background: #ff4b2b; color: #fff; font: 800 16px/1.4 inherit; cursor: pointer; box-shadow: 0 8px 20px -10px rgba(255, 75, 43, .7); }
.ex-add img { width: 26px; height: 26px; }
.ex-add:active { transform: scale(.98); }
.ex-page { padding-bottom: 40px; }

/* sheets */
html.ex-lock, html.ex-lock body { overflow: hidden; }
.ex-sheet { position: fixed; inset: 0; z-index: 1400; }
.ex-scrim { position: absolute; inset: 0; background: rgba(20, 12, 8, .42); opacity: 0; transition: opacity .2s ease; }
.ex-panel { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--text); border-radius: 24px 24px 0 0; padding: 6px 16px calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, .35);
  transform: translateY(100%); transition: transform .22s ease; }
.ex-sheet.open .ex-scrim { opacity: 1; }
.ex-sheet.open .ex-panel { transform: none; }
@media (min-width: 760px) { .ex-panel { bottom: 50%; border-radius: 24px; transform: translateY(calc(50% + 40px)); opacity: 0; transition: transform .22s ease, opacity .2s ease; } .ex-sheet.open .ex-panel { transform: translateY(50%); opacity: 1; } }
.ex-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 6px; }
.ex-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ex-panel-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 800; line-height: 1.4; }
.ex-amount { display: flex; align-items: center; gap: 6px; margin: 4px 0 12px; padding: 6px 16px; border-radius: 18px; background: var(--fill); }
.ex-baht { font-family: "Chakra Petch", Inter, sans-serif; font-size: 32px; font-weight: 700; color: var(--muted); }
.ex-panel .ex-amount input { flex: 1; min-width: 0; border: 0; border-radius: 0; box-shadow: none; -webkit-appearance: none; appearance: none; height: auto; background: transparent; color: var(--text); font-family: "Chakra Petch", Inter, sans-serif; font-size: 40px; font-weight: 700; line-height: 1.3; padding: 4px 0; outline: none; font-variant-numeric: tabular-nums; }
.ex-amount:focus-within { box-shadow: 0 0 0 2px var(--accent, #ff4b2b) inset; }
/* the shared field look (minimal/space/soft, !important) belongs to the wrapper here; an id beats their :is() lists */
:root body #exAmount, :root body #exAmount:focus { background-color: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0; }
/* the name box (2026-11-08, the user: "same size as price"): the amount box's twin, Thai-sized text */
.ex-amount { box-sizing: border-box; min-height: 72px; }
.ex-amount + .ex-name { margin-top: -4px; }
.ex-name-ic { width: 28px; height: 28px; flex: none; opacity: .55; }
.ex-panel .ex-name input { font-family: inherit; font-size: 24px; line-height: 1.5; font-variant-numeric: normal; padding: 6px 0; }
.ex-panel .ex-name input::placeholder { color: var(--muted); opacity: .8; font-weight: 600; }
:root body #exTitle, :root body #exTitle:focus { background-color: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0; }
.ex-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ex-cat { min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 2px; border: 0; border-radius: 16px; background: transparent; color: var(--text); font: 600 12.5px/1.45 inherit; cursor: pointer; }
.ex-cat span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.ex-cat.on { background: var(--pill); color: var(--pill-text); }
.ex-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.ex-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font: 600 14px/1.4 inherit; cursor: pointer; }
.ex-chip img { width: 22px; height: 22px; }
.ex-date input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; }
.ex-del { margin-left: auto; color: #d9363e; border-color: rgba(217, 54, 62, .35); }
.ex-note-wrap { margin-top: 10px; }
.ex-note-wrap input, .ex-field input { width: 100%; box-sizing: border-box; min-height: 46px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: 15px/1.5 inherit; }
.ex-msg { min-height: 1.5em; margin: 8px 2px 0; font-size: 13.5px; color: #d9363e; line-height: 1.5; }
.ex-msg-info { color: var(--muted); }
.ex-save { width: 100%; min-height: 54px; margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 18px; background: #ff4b2b; color: #fff; font: 800 17px/1.4 inherit; cursor: pointer; }
.ex-save img { width: 26px; height: 26px; filter: brightness(0) invert(1); }
.ex-save:disabled { background: var(--fill); color: var(--muted); cursor: default; }
.ex-save:disabled img { filter: none; opacity: .5; }

/* categories */
.ex-catlist { list-style: none; margin: 4px 0 12px; padding: 0; }
.ex-catrow { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 4px 4px; border-radius: 14px; background: var(--surface); }
.ex-catrow + .ex-catrow { border-top: 1px solid var(--line); }
.ex-catrow.sorting { box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .35); position: relative; z-index: 1; }
.ex-catname { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-handle { flex: none; width: 44px; height: 44px; border: 0; background: transparent; cursor: grab; touch-action: none; display: grid; place-items: center; border-radius: 12px; padding: 0; }
.ex-handle span { width: 18px; height: 12px; background: linear-gradient(var(--muted) 0 2px, transparent 2px 5px, var(--muted) 5px 7px, transparent 7px 10px, var(--muted) 10px 12px); border-radius: 1px; }
.ex-handle:focus-visible { outline: 2px solid var(--accent, #ff4b2b); }
.ex-lockic { width: 20px; height: 20px; opacity: .7; }
#exCatAdd { width: 100%; justify-content: center; min-height: 48px; }
.ex-archived { margin-top: 14px; }
.ex-archived summary { cursor: pointer; font-weight: 700; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.ex-catedit { margin-top: 4px; }
.ex-field { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
.ex-field input:disabled { opacity: .6; }
.ex-sub { margin: 14px 0 6px; font-weight: 700; font-size: 14px; }
.ex-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px; }
.ex-ic { height: 48px; border: 0; border-radius: 12px; background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.ex-ic img { width: 32px; height: 32px; }
.ex-ic.on { background: var(--pill); }
.ex-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.ex-col { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.ex-col::before { content: ""; width: 30px; height: 30px; border-radius: 50%; background: var(--c); }
.ex-col.on { box-shadow: 0 0 0 2.5px var(--pill) inset; }
.ex-danger { color: #d9363e; }

/* toast */
.ex-toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1450; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
html.has-bottomnav .ex-toast-wrap { bottom: calc(var(--bn-top, 80px) + 12px); }
.ex-toast { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 16px; min-height: 52px; box-sizing: border-box; border-radius: 999px; background: #111111; color: #f3eee3; font-weight: 700; font-size: 14px; line-height: 1.4; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); pointer-events: auto; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.ex-toast:not(:has(button)) { padding-right: 16px; }
.ex-toast.show { opacity: 1; transform: none; }
.ex-toast button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: #ff4b2b; color: #fff; font: 800 14px/1 inherit; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .ex-panel, .ex-scrim, .ex-toast, .ex-item-main { transition: none; } }

/* ---- สุขภาพ B2: "บันทึกเป็นมื้ออาหารด้วยไหม?" after a food expense, and the ค่าอาหาร switch */
.ex-mealask { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); z-index: 1440; width: min(420px, calc(100vw - 32px)); box-sizing: border-box;
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 22px; background: var(--surface, #fff); color: var(--ink, #111111);
  border: 1px solid var(--edge, rgba(17, 17, 17, .12)); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); opacity: 0; transition: opacity .2s, transform .2s; }
html.has-bottomnav .ex-mealask { bottom: calc(var(--bn-top, 80px) + 12px); }
.ex-mealask.show { opacity: 1; transform: translate(-50%, 0); }
.ex-mealask > img { flex: none; width: 56px; height: 56px; object-fit: contain; }
.ex-mealask b { display: block; font-size: 16px; line-height: 1.4; }
.ex-mealask small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.5; color: var(--muted, #6b655c); }
.ex-mealask .ex-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ex-mealask .fd-btn { min-height: 44px; }
.ex-mealask .ex-link { display: inline-block; margin-top: 10px; padding: 0; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted, #6b655c); }
.ex-foodrow { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.ex-foodrow > span { flex: 1; min-width: 0; }
.ex-foodrow b { display: block; font-size: 15px; }
.ex-foodrow small { display: block; font-size: 13px; line-height: 1.5; color: var(--muted, #6b655c); }
.ex-sw { flex: none; position: relative; width: 56px; height: 44px; border: 0; padding: 0; background: transparent; cursor: pointer; }
.ex-sw::before { content: ""; position: absolute; left: 2px; right: 2px; top: 8px; height: 28px; border-radius: 999px; background: rgba(17, 17, 17, .18); transition: background .2s; }
.ex-sw::after { content: ""; position: absolute; top: 11px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.ex-sw[aria-checked="true"]::before { background: #111111; }
.ex-sw[aria-checked="true"]::after { transform: translateX(22px); }
.ex-sw:focus-visible { outline: 3px solid #ff4b2b; outline-offset: 2px; }
html[data-theme="dark"] .ex-sw::before { background: rgba(243, 238, 227, .22); }
html[data-theme="dark"] .ex-sw[aria-checked="true"]::before { background: #f3eee3; }
html[data-theme="dark"] .ex-sw::after { background: #151515; }
@media (prefers-reduced-motion: reduce) { .ex-mealask, .ex-sw::before, .ex-sw::after { transition: none; } }
