/* =========================================================================
   Christmas Budget Planner — scoped styles (loaded only on the planner page)
   Reuses the theme's CSS custom properties (--hmtc-*).
   ========================================================================= */

.hmtc-budget { padding: 8px 0 24px; }
.hmtcb-section { margin: 26px auto; }
.hmtcb-section__title { font-size: clamp(1.3rem, 3vw, 1.8rem); color: var(--hmtc-deep-blue); margin-bottom: .4rem; }
.hmtcb-section__intro { color: var(--hmtc-muted); margin: 0 0 1rem; }

/* ---- Header ---- */
.hmtcb-header { text-align: center; position: relative; padding-top: 24px; }
.hmtcb-header__deco { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hmtcb-coin { position: absolute; font-size: 1.5rem; opacity: .55; animation: hmtcb-float 6s ease-in-out infinite; }
.hmtcb-coin--1 { left: 8%; top: 10px; animation-delay: .2s; }
.hmtcb-coin--2 { right: 10%; top: 4px; animation-delay: 1.4s; }
.hmtcb-coin--3 { left: 22%; top: 40px; animation-delay: 2.6s; }
@keyframes hmtcb-float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.hmtcb-title { font-size: clamp(1.8rem, 5vw, 2.8rem); color: var(--hmtc-deep-blue); margin: 0 0 .3rem; }
.hmtcb-intro { max-width: 680px; margin: 0 auto 1rem; color: var(--hmtc-ink); }
.hmtcb-privacy { max-width: 680px; margin: 0 auto 1rem; background: #eef7ef; border: 1px solid #cfe6d3; color: #1c4c2f; border-radius: 12px; padding: 10px 14px; font-size: .9rem; }
.hmtcb-privacy__icon { margin-right: 4px; }
.hmtcb-toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; margin-top: 12px; }

/* Getting-started guide */
.hmtcb-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 0; margin: 14px auto 8px; max-width: 820px; }
.hmtcb-steps li { display: flex; align-items: center; gap: 8px; background: #f2f6fc; border: 1px solid #e2e9f4; border-radius: 999px; padding: 8px 15px; font-size: .9rem; font-weight: 600; color: var(--hmtc-deep-blue); }
.hmtcb-steps__num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--hmtc-red); color: #fff; font-weight: 800; font-size: .85rem; flex: none; }
.hmtcb-starter { text-align: center; color: var(--hmtc-muted); font-size: .92rem; margin: 0 auto 6px; max-width: 640px; }
.hmtcb-step-badge { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--hmtc-red); color: #fff; font-weight: 800; font-size: 1rem; margin-right: 8px; vertical-align: middle; }
.hmtcb-noscript { background: #fff3cd; border: 1px solid #ffe08a; padding: 10px 14px; border-radius: 10px; margin-top: 12px; }

/* ---- Save status ---- */
.hmtcb-save-status { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--hmtc-muted); }
.hmtcb-save-status__dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa7bd; }
.hmtcb-save-status[data-state="saving"] .hmtcb-save-status__dot { background: var(--hmtc-gold); }
.hmtcb-save-status[data-state="saved"] .hmtcb-save-status__dot { background: #2e9e5b; }
.hmtcb-save-status[data-state="error"] .hmtcb-save-status__dot { background: var(--hmtc-red); }

/* ---- Buttons ---- */
.hmtcb-btn { font: inherit; font-weight: 700; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; line-height: 1.1; transition: background .15s ease, transform .12s ease, box-shadow .15s ease; }
.hmtcb-btn:hover { transform: translateY(-1px); }
.hmtcb-btn--primary { background: var(--hmtc-red); color: #fff; }
.hmtcb-btn--primary:hover { background: #a81f1f; }
.hmtcb-btn--ghost { background: #eef2f9; color: var(--hmtc-deep-blue); }
.hmtcb-btn--ghost:hover { background: #e0e8f5; }
.hmtcb-btn--danger { background: #fdecec; color: #a81f1f; }
.hmtcb-btn--danger:hover { background: #f8d7d7; }
.hmtcb-btn--tiny { padding: 6px 10px; font-size: .82rem; }

/* ---- Cards / sections shell ---- */
.hmtcb-setup, .hmtcb-summary, .hmtcb-categories, .hmtcb-expense-form-wrap,
.hmtcb-expenses, .hmtcb-gifts, .hmtcb-insights, .hmtcb-export {
	background: #fff; border: 1px solid rgba(11,30,63,.07); border-radius: var(--hmtc-radius);
	box-shadow: var(--hmtc-shadow-sm); padding: 22px;
}

/* ---- Fields ---- */
.hmtcb-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.hmtcb-field label { font-weight: 600; font-size: .9rem; color: var(--hmtc-deep-blue); }
.hmtcb-field input, .hmtcb-field select, .hmtcb-field textarea {
	font: inherit; padding: 10px 12px; border: 1.5px solid #d3dcea; border-radius: 10px; background: #fff; color: var(--hmtc-ink); width: 100%;
}
.hmtcb-field input:focus, .hmtcb-field select:focus, .hmtcb-field textarea:focus { outline: 3px solid var(--hmtc-gold); outline-offset: 1px; border-color: var(--hmtc-deep-blue); }
.hmtcb-field--full { grid-column: 1 / -1; }
.hmtcb-req { color: var(--hmtc-red); }
.hmtcb-field__error { color: #b1160f; font-size: .82rem; font-weight: 600; }
.hmtcb-field input[aria-invalid="true"], .hmtcb-field select[aria-invalid="true"] { border-color: #b1160f; }

.hmtcb-setup__form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 18px; }
.hmtcb-setup__extras { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.hmtcb-subcard { background: #f7faff; border: 1px solid #e2e9f4; border-radius: 14px; padding: 16px; }
.hmtcb-subcard__title { margin: 0 0 4px; color: var(--hmtc-deep-blue); font-size: 1.05rem; }
.hmtcb-subcard__hint { margin: 0 0 10px; color: var(--hmtc-muted); font-size: .85rem; }
.hmtcb-buffer-readout, .hmtcb-savings-readout { font-size: .9rem; color: var(--hmtc-ink); }
.hmtcb-savings-readout dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0; }
.hmtcb-savings-readout dt { color: var(--hmtc-muted); }
.hmtcb-savings-readout dd { margin: 0; font-weight: 700; text-align: right; }

/* ---- Status banner ---- */
.hmtcb-status { display: flex; align-items: center; gap: 12px; border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; border: 2px solid; }
.hmtcb-status__icon { font-size: 1.6rem; }
.hmtcb-status__title { display: block; font-size: 1.05rem; }
.hmtcb-status[data-state="healthy"] { background: #eef7ef; border-color: #7bc99a; }
.hmtcb-status[data-state="warn"] { background: #fff6e6; border-color: #f0c14b; }
.hmtcb-status[data-state="over"] { background: #fdecec; border-color: #e58a8a; }

/* ---- Summary cards ---- */
.hmtcb-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.hmtcb-card { background: linear-gradient(180deg, #fbfdff, #eef4fc); border: 1px solid #e2e9f4; border-radius: 14px; padding: 14px; text-align: center; }
.hmtcb-card--mini { background: #fff8ec; border-color: #f2e2c2; }
.hmtcb-card__value { display: block; font-size: 1.5rem; font-weight: 900; color: var(--hmtc-deep-blue); font-variant-numeric: tabular-nums; }
.hmtcb-card__label { font-size: .78rem; color: var(--hmtc-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

/* ---- Progress bars ---- */
.hmtcb-progress-group { margin-top: 18px; display: grid; gap: 14px; }
.hmtcb-progress-block__head { display: flex; justify-content: space-between; font-size: .88rem; font-weight: 600; color: var(--hmtc-deep-blue); margin-bottom: 4px; }
.hmtcb-bar { position: relative; height: 18px; background: #e7edf6; border-radius: 999px; overflow: hidden; }
.hmtcb-bar__fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--hmtc-green), #2e9e5b); transition: width .5s ease; }
.hmtcb-bar__fill--planned { background: linear-gradient(90deg, var(--hmtc-gold), var(--hmtc-amber)); }
.hmtcb-bar__fill--paid { background: linear-gradient(90deg, #3a83d6, #6bb0f5); }
.hmtcb-bar.is-over .hmtcb-bar__fill { background: linear-gradient(90deg, var(--hmtc-red), #e04b4b); }

/* ---- Alerts ---- */
.hmtcb-alerts { margin-top: 16px; display: grid; gap: 8px; }
.hmtcb-alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: .9rem; border-left: 4px solid; }
.hmtcb-alert--info { background: #eef4fc; border-color: #3a83d6; }
.hmtcb-alert--warn { background: #fff6e6; border-color: var(--hmtc-gold); }
.hmtcb-alert--danger { background: #fdecec; border-color: var(--hmtc-red); }
.hmtcb-alert__icon { flex: none; }

/* ---- Allocator / add category ---- */
.hmtcb-allocator, .hmtcb-add-category { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.hmtcb-field--inline { margin-bottom: 0; min-width: 180px; }
.hmtcb-allocator__hint { flex-basis: 100%; margin: 4px 0 0; color: var(--hmtc-muted); font-size: .82rem; }

/* ---- Category rows ---- */
.hmtcb-cat-list { display: grid; gap: 10px; }
.hmtcb-cat { background: #f7faff; border: 1px solid #e2e9f4; border-radius: 12px; padding: 12px 14px; }
.hmtcb-cat__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hmtcb-cat__name { font-weight: 700; color: var(--hmtc-deep-blue); border: 0; background: transparent; font-size: 1rem; padding: 4px 6px; border-radius: 8px; flex: 1 1 140px; min-width: 120px; }
.hmtcb-cat__name:focus { background: #fff; outline: 2px solid var(--hmtc-gold); }
.hmtcb-cat__budget { width: 130px; display: block; }
.hmtcb-cat__budget-input { width: 100%; font: inherit; padding: 8px 10px; border: 1.5px solid #d3dcea; border-radius: 8px; background: #fff; color: var(--hmtc-ink); }
.hmtcb-cat__budget-input:focus { outline: 3px solid var(--hmtc-gold); outline-offset: 1px; }
.hmtcb-cat__stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: .84rem; color: var(--hmtc-muted); }
.hmtcb-cat__stats b { color: var(--hmtc-ink); font-variant-numeric: tabular-nums; }
.hmtcb-cat__bar { height: 8px; background: #e7edf6; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.hmtcb-cat__bar span { display: block; height: 100%; background: var(--hmtc-green); }
.hmtcb-cat__bar.is-over span { background: var(--hmtc-red); }
.hmtcb-cat__actions { display: flex; gap: 4px; }
.hmtcb-iconbtn { border: 0; background: #eef2f9; color: var(--hmtc-deep-blue); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 1rem; line-height: 1; }
.hmtcb-iconbtn:hover { background: #e0e8f5; }
.hmtcb-iconbtn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Expense form grid ---- */
.hmtcb-expense-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.hmtcb-form-actions { display: flex; gap: 10px; }

/* ---- Filters ---- */
.hmtcb-filters { margin-bottom: 14px; }
.hmtcb-filter-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; margin-top: 12px; }
.hmtcb-filters__toggle { display: none; }

/* ---- Table ---- */
.hmtcb-table-wrap { overflow-x: auto; }
.hmtcb-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.hmtcb-table th, .hmtcb-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #e7edf6; vertical-align: top; }
.hmtcb-table thead th { position: sticky; top: 0; background: #f2f6fc; color: var(--hmtc-deep-blue); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.hmtcb-num { text-align: right; font-variant-numeric: tabular-nums; }
.hmtcb-table .hmtcb-num { text-align: right; }
.hmtcb-diff--under { color: #2e7d46; }
.hmtcb-diff--over { color: #b1160f; }
.hmtcb-diff--muted { color: var(--hmtc-muted); }
.hmtcb-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.hmtcb-pill--paid { background: #e3f4e9; color: #216b3b; }
.hmtcb-pill--partial { background: #fff2d6; color: #8a5a00; }
.hmtcb-pill--not_purchased, .hmtcb-pill--planned, .hmtcb-pill--ordered { background: #eef2f9; color: #3a4a63; }
.hmtcb-pill--returned, .hmtcb-pill--cancelled { background: #f0e6ea; color: #7a4a5a; text-decoration: line-through; }
.hmtcb-row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.hmtcb-row--inactive td { opacity: .6; }

/* ---- Expense cards (mobile) ---- */
.hmtcb-expense-cards { display: none; flex-direction: column; gap: 12px; }
.hmtcb-ecard { background: #f7faff; border: 1px solid #e2e9f4; border-radius: 12px; padding: 14px; }
.hmtcb-ecard__top { display: flex; justify-content: space-between; gap: 10px; }
.hmtcb-ecard__name { font-weight: 700; color: var(--hmtc-deep-blue); }
.hmtcb-ecard__meta { color: var(--hmtc-muted); font-size: .82rem; }
.hmtcb-ecard__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 8px 0; font-size: .86rem; }
.hmtcb-ecard__grid span:nth-child(odd) { color: var(--hmtc-muted); }
.hmtcb-ecard__grid span:nth-child(even) { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.hmtcb-empty { text-align: center; color: var(--hmtc-muted); padding: 24px; background: #f7faff; border-radius: 12px; }

/* ---- Recipients / gifts ---- */
.hmtcb-recipient-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.hmtcb-recipient-list { display: grid; gap: 12px; }
.hmtcb-recipient { border: 1px solid #e2e9f4; border-radius: 14px; overflow: hidden; }
.hmtcb-recipient__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #f2f6fc; padding: 12px 14px; }
.hmtcb-recipient__name { font-weight: 800; color: var(--hmtc-deep-blue); }
.hmtcb-recipient__rel { font-size: .78rem; color: var(--hmtc-muted); background: #fff; border-radius: 999px; padding: 2px 8px; }
.hmtcb-recipient__totals { margin-left: auto; font-size: .84rem; color: var(--hmtc-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.hmtcb-recipient__totals b { color: var(--hmtc-ink); }
.hmtcb-recipient__body { padding: 12px 14px; }
.hmtcb-gift-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed #e2e9f4; }
.hmtcb-gift-row__name { flex: 1 1 140px; font-weight: 600; }
.hmtcb-gift-flags { display: flex; gap: 10px; flex-wrap: wrap; font-size: .82rem; }
.hmtcb-gift-flags label { display: inline-flex; gap: 4px; align-items: center; color: var(--hmtc-muted); }
.hmtcb-addgift { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 10px; }
.hmtcb-addgift .hmtcb-field { margin-bottom: 0; }

/* ---- Insights + suggestions ---- */
.hmtcb-insight-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.hmtcb-insight { background: #f7faff; border: 1px solid #e2e9f4; border-left: 4px solid var(--hmtc-gold); border-radius: 10px; padding: 12px 14px; font-size: .92rem; }
.hmtcb-suggestions { margin-top: 16px; background: #eef7ef; border: 1px solid #cfe6d3; border-radius: 12px; padding: 14px; }
.hmtcb-suggestions__title { margin: 0 0 10px; font-size: 1rem; color: #1c4c2f; }
.hmtcb-suggestions__buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Export ---- */
.hmtcb-export__buttons { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- Dialogs ---- */
.hmtcb-dialog { border: 0; border-radius: 16px; padding: 0; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(11,30,63,.3); }
.hmtcb-dialog::backdrop { background: rgba(11,30,63,.45); }
.hmtcb-dialog__form { padding: 22px; }
.hmtcb-dialog__title { margin: 0 0 10px; color: var(--hmtc-deep-blue); }
.hmtcb-dialog__options { border: 1px solid #e2e9f4; border-radius: 10px; padding: 10px 12px; margin: 12px 0; display: grid; gap: 6px; }
.hmtcb-dialog__options legend { font-weight: 700; font-size: .9rem; padding: 0 6px; }
.hmtcb-dialog__warn { font-size: .84rem; color: #8a5a00; }
.hmtcb-dialog__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.hmtcb-dialog__summary-list { margin: 0; padding-left: 18px; font-size: .9rem; }

/* ---- Toast ---- */
.hmtcb-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--hmtc-deep-blue); color: #fff; border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--hmtc-shadow); z-index: 100; max-width: calc(100% - 24px); }
.hmtcb-toast__undo { background: var(--hmtc-gold); color: var(--hmtc-deep-blue); border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 800; cursor: pointer; }

/* ---- SEO content ---- */
.hmtcb-seo { padding: 20px; }
.hmtcb-seo__block { margin-bottom: 28px; }
.hmtcb-seo__block h2 { color: var(--hmtc-deep-blue); }
.hmtcb-seo__cols { columns: 2; }
@media (max-width: 560px) { .hmtcb-seo__cols { columns: 1; } }

/* ---- Responsive ---- */
@media (max-width: 860px) {
	.hmtcb-setup__extras { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
	.hmtcb-filters__toggle { display: inline-block; }
	.hmtcb-filter-panel { display: none; }
	.hmtcb-filter-panel.is-open { display: grid; }
	/* switch table to cards */
	.hmtcb-table-wrap { display: none; }
	.hmtcb-expense-cards { display: flex; }
}
@media (max-width: 420px) {
	.hmtcb-setup, .hmtcb-summary, .hmtcb-categories, .hmtcb-expense-form-wrap,
	.hmtcb-expenses, .hmtcb-gifts, .hmtcb-insights, .hmtcb-export { padding: 16px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
	.hmtcb-coin, .hmtcb-bar__fill, .hmtcb-btn { animation: none !important; transition: none !important; }
}

/* ---- Print ---- */
@media print {
	.hmtc-header, .hmtc-footer, .hmtcb-toolbar, .hmtcb-allocator, .hmtcb-add-category,
	.hmtcb-expense-form-wrap, .hmtcb-filters, .hmtcb-export, .hmtcb-header__deco,
	.hmtcb-row-actions, .hmtcb-cat__actions, .hmtcb-recipient__body .hmtcb-addgift,
	.hmtcb-suggestions, .hmtc-scene, .hmtcb-toast, .skip-link, .hmtcb-btn { display: none !important; }
	.hmtc-budget, .hmtcb-section, .hmtcb-seo { box-shadow: none !important; border: none !important; }
	body { background: #fff !important; color: #000 !important; }
	.hmtcb-expense-cards { display: none !important; }
	.hmtcb-table-wrap { display: block !important; overflow: visible !important; }
	.hmtcb-print-meta { display: block !important; margin-bottom: 12px; }
	.hmtcb-section { break-inside: avoid; }
	.hmtcb-cards { display: grid !important; }
}
.hmtcb-print-meta { display: none; }
