*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f6fa; color: #1a1a2e; }

.navbar { background: #1a1a2e; color: #fff; padding: 0 2rem; height: 56px; display: flex; align-items: center; gap: 2rem; }
.navbar-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.5px; }
.navbar-links { display: flex; gap: 1.2rem; }
.navbar-link { color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.9rem; }
.navbar-link:hover { color: #fff; }

.container { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }

h1 { font-size: 1.6rem; margin-bottom: 1.5rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.page-header h1 { margin-bottom: 0; }
.page-desc { color: #888; font-size: 0.9rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.1rem; margin-bottom: 1rem; color: #444; }

.back-link { display: inline-block; margin-bottom: 1rem; color: #5c6bc0; text-decoration: none; font-size: 0.9rem; }
.back-link:hover { text-decoration: underline; }
.listing-city { font-size: 0.85em; color: #888; font-weight: 400; }

/* Cards */
.card { background: #fff; border-radius: 10px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,.07); }

/* Listings grid */
.listings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.listing-card { background: #fff; border-radius: 10px; overflow: hidden; text-decoration: none; color: inherit; box-shadow: 0 1px 4px rgba(0,0,0,.07); transition: box-shadow .15s; display: block; }
.listing-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.13); }
.listing-thumb { width: 100%; height: 150px; object-fit: cover; display: block; }
.listing-thumb--placeholder { background: #e0e0e0; }
.listing-card__body { padding: 0.9rem 1rem; }
.listing-card__name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.2rem; }
.listing-card__city { font-size: 0.8rem; color: #888; margin-bottom: 0.4rem; }
.listing-card__price { font-size: 0.85rem; color: #666; }

/* Forms */
.form-inline { display: flex; align-items: center; gap: 0.6rem; }
.form-inline input { width: 120px; padding: 0.45rem 0.6rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.95rem; }
.currency { font-size: 0.9rem; color: #666; }

/* Template */
select { padding: 0.45rem 0.6rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.9rem; min-width: 200px; }
.template-preview { display: flex; gap: 4px; margin-top: 1rem; flex-wrap: wrap; }
.template-month { background: #f5f5f5; border-radius: 6px; padding: 0.4rem 0.5rem; text-align: center; min-width: 60px; flex: 1; }
.template-month__name { font-size: 0.72rem; color: #888; }
.template-month__adj { font-size: 0.85rem; font-weight: 700; margin-top: 2px; }
.template-month.pos .template-month__adj { color: #2e7d32; }
.template-month.neg .template-month__adj { color: #c62828; }
.template-month.zero .template-month__adj { color: #999; }

/* Apply — day selection */
.calendar-day { cursor: pointer; user-select: none; }
.calendar-day--grayed { cursor: default; }
.calendar-day--selected { outline: 2px solid #5c6bc0; background: #e8eaf6 !important; }

/* Popover */
.day-popover { position: absolute; z-index: 100; background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 1rem; min-width: 220px; box-shadow: 0 4px 20px rgba(0,0,0,.15); }
.day-popover__date { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.6rem; color: #1a1a2e; }
.day-popover__row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.3rem; color: #555; }
.day-popover__delta { font-size: 0.82rem; font-weight: 600; margin: 0.4rem 0; }
.day-popover__apply { width: 100%; margin-top: 0.5rem; }
.day-popover__close { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.1rem 0.4rem; font-size: 0.75rem; }

/* Selection banner */
.selection-banner { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #1a1a2e; color: #fff; padding: 0.8rem 1.4rem; border-radius: 30px; display: flex; align-items: center; gap: 1rem; box-shadow: 0 4px 20px rgba(0,0,0,.3); z-index: 200; font-size: 0.9rem; }
.selection-banner .btn--ghost { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.3); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; padding: 2rem; max-width: 640px; width: 90%; max-height: 85vh; display: flex; flex-direction: column; gap: 1rem; }
.modal__title { font-size: 1.1rem; font-weight: 700; }
.modal__subtitle { font-size: 0.85rem; color: #666; margin-top: -0.5rem; }
.modal__table-wrap { overflow-y: auto; max-height: 300px; border: 1px solid #eee; border-radius: 6px; }
.modal__table { margin-bottom: 0; }
.modal__confirm-row { display: flex; align-items: center; gap: 0.6rem; }
.modal__checkbox-label { display: flex; align-items: center; gap: 0.6rem; font-size: 0.88rem; cursor: pointer; }
.modal__checkbox-label input { width: 16px; height: 16px; cursor: pointer; }
.modal__actions { display: flex; justify-content: flex-end; gap: 0.8rem; padding-top: 0.5rem; border-top: 1px solid #eee; }
.modal__result { padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.88rem; font-weight: 600; }
.modal__result--success { background: #e8f5e9; color: #2e7d32; }
.modal__result--error { background: #fdecea; color: #c62828; }

/* Templates page */
.template-card { margin-bottom: 1.5rem; }
.template-card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.template-card__name { font-size: 1rem; font-weight: 700; margin: 0; color: #1a1a2e; }
.template-card__actions { display: flex; align-items: center; gap: 0.6rem; }
.month-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.month-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.month-label { font-size: 0.72rem; color: #888; font-weight: 600; }
.month-input-wrap { display: flex; align-items: center; gap: 2px; }
.month-input { width: 52px; padding: 0.35rem 0.3rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.85rem; font-weight: 600; text-align: center; }
.month-input.pos { border-color: #a5d6a7; background: #f1f8f1; color: #2e7d32; }
.month-input.neg { border-color: #ef9a9a; background: #fdf1f1; color: #c62828; }
.month-input.zero { color: #999; }
.month-pct { font-size: 0.75rem; color: #aaa; }
.badge--saved { background: #e8f5e9; color: #2e7d32; }
.template-status { font-size: 0.85rem; }
.template-status--ok { color: #2e7d32; font-weight: 600; }
.template-status--err { color: #c62828; font-weight: 600; }
.badge--tpl { background: #e8eaf6; color: #3949ab; font-size: 0.68rem; }
.rule--from-template td { color: #666; }
.assign-section { margin-top: 1rem; border-top: 1px solid #eee; padding-top: 0.8rem; }
.assign-summary { cursor: pointer; font-size: 0.88rem; color: #555; font-weight: 600; user-select: none; }
.assign-summary:hover { color: #1a1a2e; }
.assign-body { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; }
.assign-listing-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; cursor: pointer; }
.assign-listing-label input[type="checkbox"] { accent-color: #4e6ef2; width: 15px; height: 15px; }
.assign-status { font-size: 0.85rem; font-weight: 600; }

.form-baseprice { display: flex; flex-direction: column; gap: 0.6rem; }
.baseprice-row { display: flex; align-items: center; gap: 0.7rem; }
.baseprice-row label { width: 160px; font-size: 0.9rem; color: #555; flex-shrink: 0; }
.baseprice-row label small { color: #aaa; }
.baseprice-row input { width: 110px; padding: 0.45rem 0.6rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.95rem; }

.form-rule { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; align-items: center; }
.form-rule input[name="label"] { flex: 1; min-width: 130px; }
.form-rule input[type="date"] { width: 145px; }
.form-rule__adj { display: flex; align-items: center; gap: 0.3rem; }
.form-rule__adj input { width: 70px; }
.form-rule input { padding: 0.45rem 0.6rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.9rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; padding: 0.45rem 1rem; border-radius: 6px; border: none; cursor: pointer; font-size: 0.9rem; font-weight: 500; transition: background .15s; }
.btn--primary { background: #1a1a2e; color: #fff; }
.btn--primary:hover { background: #2d2d5e; }
.btn--secondary { background: #5c6bc0; color: #fff; }
.btn--secondary:hover { background: #3f51b5; }
.btn--danger { background: #ef5350; color: #fff; }
.btn--danger:hover { background: #c62828; }
.btn--ghost { background: transparent; border: 1px solid #ddd; color: #444; padding: 0.35rem 0.7rem; }
.btn--ghost:hover { background: #f0f0f0; }
.btn--sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 0.5rem; }
.table th { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 2px solid #eee; color: #888; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
.table td { padding: 0.55rem 0.8rem; border-bottom: 1px solid #f0f0f0; }
.table .pos { color: #2e7d32; font-weight: 600; }
.table .neg { color: #c62828; font-weight: 600; }
.empty { color: #aaa; text-align: center; padding: 1rem; }

/* Badge */
.badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge--warn { background: #fff3e0; color: #e65100; }

/* Calendar */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }
.calendar-header h2 { margin-bottom: 0; }
.calendar-month { margin-bottom: 2rem; }
.calendar-month:last-child { margin-bottom: 0; }
.calendar-month__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.calendar-month__title { font-size: 1rem; font-weight: 700; color: #1a1a2e; margin: 0; }
.calendar-nav-bottom { display: flex; justify-content: space-between; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid #eee; }
.calendar-nav { display: flex; align-items: center; gap: 0.8rem; font-weight: 600; font-size: 0.95rem; }

.legend { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.legend-item { font-size: 0.78rem; display: flex; align-items: center; gap: 0.3rem; }
.legend-item::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend-item--available::before { background: #f9f9f9; border: 1px solid #ddd; }
.legend-item--reserved::before { background: #fff3e0; border: 1px solid #ffcc80; }
.legend-item--blocked::before { background: #f5f5f5; border: 1px solid #ccc; }
.legend-item--hostaway::before { background: #90a4ae; }
.legend-item--recommended::before { background: #5c6bc0; }
.legend-item--diff-up::before { background: #e53935; }
.legend-item--diff-down::before { background: #2e7d32; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day-header { text-align: center; font-size: 0.75rem; color: #999; padding: 0.3rem 0; font-weight: 600; text-transform: uppercase; }
.calendar-day { background: #f9f9f9; border-radius: 6px; padding: 0.5rem 0.4rem; min-height: 80px; font-size: 0.78rem; }
.calendar-day--empty { background: transparent; }
.calendar-day--grayed { background: #f0f0f0; opacity: 0.45; }
.calendar-day--grayed .calendar-day__date { color: #aaa; }
.calendar-day--today { border: 2px solid #5c6bc0; }
.calendar-day--available { background: #f9f9f9; }
.calendar-day--reserved { background: #fff3e0; }
.calendar-day--blocked { background: #f5f5f5; opacity: 0.7; }
.calendar-day__status { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }
.calendar-day__status--reserved { color: #e65100; }
.calendar-day__status--blocked { color: #9e9e9e; }
.calendar-day__date { font-weight: 700; font-size: 0.8rem; color: #333; margin-bottom: 0.3rem; }
.calendar-day__today .calendar-day__date { color: #5c6bc0; }
.calendar-day__hostaway { color: #607d8b; }
.calendar-day__recommended { color: #3949ab; font-weight: 600; }
.calendar-day__delta { font-size: 0.72rem; margin-top: 0.2rem; }
.calendar-day__delta--up { color: #e53935; }
.calendar-day__delta--down { color: #2e7d32; }
.calendar-day__no-base { color: #bbb; font-style: italic; font-size: 0.72rem; }
.calendar-loading { grid-column: 1/-1; text-align: center; padding: 2rem; color: #999; }
.calendar-error { grid-column: 1/-1; text-align: center; padding: 2rem; color: #c62828; font-size: 0.9rem; }
