:root {
    --sage: #bacdc6;
    --powder: #c2dafc;
    --olive: #c2c59c;
    --cream: #e4dcc9;
    --terracotta: #be6343;
    --ink: #25231f;
    --muted: #6c6962;
    --surface: #fff;
    --background: #f7f5f0;
    --border: #ded9cf;
    font-family: "Poppins", system-ui, sans-serif;
    color: var(--ink);
    background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--background); }
a { color: inherit; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header {
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1rem clamp(1rem, 4vw, 3rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { position: relative; width: 46px; height: 45px; background: #d6a476; border-radius: 3px 3px 0 0; }
.brand-mark::before { content: ""; position: absolute; width: 28px; height: 18px; left: 9px; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0; }
.brand-mark span { position: absolute; width: 7px; height: 17px; bottom: 0; background: var(--surface); }
.brand-mark span:first-child { left: 3px; }
.brand-mark span:last-child { right: 3px; }

nav { display: flex; align-items: center; gap: 1.15rem; font-size: .86rem; }
nav a { text-decoration: none; }
nav form { margin: 0; }
.logout-button {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 38px;
    padding: .45rem .7rem;
    border: 1px solid #b9afa4;
    border-radius: 6px;
    color: #7d3823;
    background: #fffaf7;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.logout-button:hover { border-color: var(--terracotta); background: #f8e8e1; }
.logout-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--terracotta), transparent 65%); outline-offset: 2px; }
.logout-button svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2.5rem 0 5rem; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.compact-hero h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
.compact-hero { margin-bottom: 1.5rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .5rem; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; }
h2 { margin-bottom: 0; }
.hero p:not(.eyebrow), .calendar-card p { color: var(--muted); }
.eyebrow { margin-bottom: .5rem; color: #8b432a; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: .7rem 1.2rem;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: #93482f;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: .62rem 1rem;
    border: 1px solid #aaa397;
    border-radius: 6px;
    color: var(--ink);
    background: var(--surface);
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.button-group { display: flex; flex-wrap: wrap; gap: .6rem; }

.stats-grid, .calendar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.stats-grid { margin-bottom: 3rem; }
.stat-card, .calendar-card { padding: 1.3rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.stat-card span { display: block; color: var(--muted); font-size: .85rem; }
.stat-card strong { font-size: 2rem; }
.section-heading { display: flex; justify-content: space-between; margin: 2.5rem 0 1rem; }
.sync-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 3rem; padding: 1.3rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.sync-card h2 { margin-bottom: .35rem; }
.sync-card p:last-child { margin-bottom: 0; color: var(--muted); }
.sync-card .sync-error { color: #a32727; white-space: pre-line; }
.secondary-button:disabled { cursor: not-allowed; opacity: .5; }
.calendar-card { display: flex; align-items: start; gap: .9rem; border-top: 4px solid var(--calendar-color); }
.calendar-card h3 { margin-bottom: .25rem; }
.calendar-card p { margin-bottom: 0; font-size: .82rem; }
.color-dot { width: 12px; height: 12px; flex: 0 0 auto; margin-top: .4rem; border-radius: 50%; background: var(--calendar-color); border: 1px solid rgb(0 0 0 / 12%); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .9rem 1rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.actions-cell { text-align: right; }
.compact-stay { display: block; font-size: .78rem; }
.amount-pending { color: #9b341d; font-weight: 700; }
.status-badge { display: inline-block; padding: .2rem .5rem; border-radius: 999px; background: #e8e6e0; font-size: .72rem; font-weight: 600; }
.status-confirmed { background: #dcebdd; color: #275a2c; }
.status-pending, .status-draft { background: #f5e5be; color: #71500b; }
.status-cancelled { background: #eee; color: #666; }

.search-form { display: flex; gap: .65rem; margin-bottom: 1rem; }
.search-form input, .search-form select { min-height: 42px; padding: .55rem .7rem; border: 1px solid #aaa397; border-radius: 6px; background: #fff; font: inherit; }
.search-form input { flex: 1 1 320px; }
.filter-form { flex-wrap: wrap; }

.form-page-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1.5rem; }
.form-page-heading h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.data-form { display: grid; gap: 1.2rem; }
.data-form fieldset { margin: 0; padding: 1.35rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.data-form legend { padding: 0 .4rem; font-size: 1rem; font-weight: 700; }
.fieldset-heading { display: flex; justify-content: space-between; align-items: center; }
.fieldset-heading legend { float: left; }
.fieldset-help { color: var(--muted); font-size: .82rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.field.full-width, .full-width { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: .3rem; font-size: .78rem; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: .55rem .65rem; border: 1px solid #aaa397; border-radius: 5px; background: #fff; font: inherit; }
.field textarea { resize: vertical; }
.field small { display: block; margin-top: .25rem; color: var(--muted); }
.has-error input, .has-error select, .has-error textarea { border-color: #a32727; }
.field-error { margin: .25rem 0 0; color: #a32727; font-size: .76rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .7rem; }
.stay-form-list { display: grid; gap: 1rem; clear: both; padding-top: 1rem; }
.stay-form-card { padding: 1rem; border: 1px solid var(--border); border-left: 5px solid var(--sage); border-radius: 7px; background: #fbfaf7; }
.delete-field { grid-column: 1 / -1; color: #8c2c1b; font-size: .82rem; }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.detail-card, .notes-card { padding: 1.2rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.detail-card dl { margin: 0; }
.detail-card dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.detail-card dl div:last-child { border: 0; }
.detail-card dt { color: var(--muted); font-size: .8rem; }
.detail-card dd { margin: 0; text-align: right; }
.stay-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.stay-card { padding: 1rem; border: 1px solid var(--border); border-top: 5px solid var(--calendar-color); border-radius: 8px; background: var(--surface); }
.stay-card h3 { margin-bottom: .25rem; }
.stay-card p { margin-bottom: .35rem; }
.stay-dates { font-weight: 600; }
.notes-card { margin-top: 1.5rem; }

.planning-wrap { overflow-x: auto; padding-bottom: .5rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.planning { min-width: 1050px; }
.week-planning { min-width: 760px; }
.planning-grid { display: grid; grid-template-columns: var(--planning-columns); position: relative; }
.planning-header { position: sticky; top: 0; z-index: 4; border-bottom: 1px solid var(--border); background: #f4f1eb; }
.planning-row { min-height: 74px; border-bottom: 1px solid var(--border); }
.planning-row:last-child { border-bottom: 0; }
.resource-label { position: sticky; left: 0; z-index: 3; display: flex; align-items: center; gap: .55rem; padding: .7rem; border-right: 1px solid var(--border); background: #fff; font-size: .8rem; font-weight: 700; }
.planning-header .resource-label { background: #f4f1eb; }
.day-heading { padding: .35rem .15rem; border-right: 1px solid var(--border); text-align: center; font-size: .66rem; color: var(--muted); }
.day-heading span, .day-heading strong { display: block; }
.day-heading strong { color: var(--ink); font-size: .82rem; }
.day-cell { grid-row: 1; min-width: 42px; border-right: 1px solid #eeeae2; }
.weekend { background: #f7f3eb; }
.planning-event { grid-row: 1; z-index: 2; align-self: center; min-width: 20px; margin: .55rem 2px; padding: .45rem .55rem; overflow: hidden; border-left: 5px solid color-mix(in srgb, var(--calendar-color), #000 24%); border-radius: 6px; background: var(--calendar-color); color: #25231f; text-decoration: none; white-space: nowrap; box-shadow: 0 2px 7px rgb(0 0 0 / 10%); }
.planning-event strong, .planning-event span { display: block; overflow: hidden; text-overflow: ellipsis; }
.planning-event strong { font-size: .72rem; }
.planning-event span { font-size: .68rem; }
.planning-event.has-pending { box-shadow: inset 0 -4px 0 #a63820, 0 2px 7px rgb(0 0 0 / 10%); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .75rem; color: var(--muted); font-size: .75rem; }
.legend-swatch { display: inline-block; width: 18px; height: 9px; margin-right: .3rem; border-radius: 2px; background: var(--sage); }
.pending-swatch { border-bottom: 3px solid #a63820; }

.calendar-toolbar { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.view-switcher { display: inline-flex; padding: .2rem; border: 1px solid var(--border); border-radius: 8px; background: #ece8df; }
.view-switcher a { padding: .5rem .75rem; border-radius: 6px; font-size: .78rem; font-weight: 600; text-decoration: none; }
.view-switcher a.active { background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 12%); }
.calendar-filter { justify-self: center; }
.calendar-filter label { display: block; margin-bottom: .2rem; color: var(--muted); font-size: .68rem; font-weight: 600; text-transform: uppercase; }
.calendar-filter select { min-height: 40px; min-width: 230px; padding: .5rem .65rem; border: 1px solid #aaa397; border-radius: 6px; background: #fff; font: inherit; }
.today { box-shadow: inset 0 3px 0 #93482f; }

.month-calendar { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.month-weekdays, .month-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-weekdays { border-bottom: 1px solid var(--border); background: #f4f1eb; }
.month-weekdays span { padding: .55rem; border-right: 1px solid var(--border); color: var(--muted); font-size: .7rem; font-weight: 700; text-align: center; text-transform: uppercase; }
.month-weekdays span:last-child { border-right: 0; }
.month-week { border-bottom: 1px solid var(--border); }
.month-week:last-child { border-bottom: 0; }
.month-day { min-width: 0; min-height: 128px; padding: .45rem; border-right: 1px solid var(--border); background: #fff; }
.month-day:last-child { border-right: 0; }
.month-day > time { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; margin-bottom: .3rem; border-radius: 50%; font-size: .75rem; font-weight: 600; }
.month-day.outside-month { background: #f5f3ee; color: #aaa49a; }
.month-day.today > time { color: #fff; background: #93482f; }
.month-events { display: grid; gap: .25rem; }
.month-event { min-width: 0; padding: .28rem .35rem; overflow: hidden; border-left: 4px solid color-mix(in srgb, var(--calendar-color), #000 24%); border-radius: 4px; background: var(--calendar-color); color: var(--ink); text-decoration: none; }
.month-event strong, .month-event span { display: block; overflow: hidden; font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.month-event.has-pending { box-shadow: inset 0 -3px 0 #a63820; }

.login-card { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(2rem, 8vw, 7rem); align-items: center; min-height: calc(100vh - 190px); }
.login-card > div > p:last-child { max-width: 44ch; color: var(--muted); }
.stacked-form { padding: 2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 50px rgb(63 45 32 / 8%); }
.stacked-form label { display: block; margin: 1rem 0 .35rem; font-size: .82rem; font-weight: 600; }
.stacked-form input { width: 100%; min-height: 44px; padding: .65rem .75rem; border: 1px solid #bcb6ab; border-radius: 5px; font: inherit; }
.stacked-form .primary-button { width: 100%; margin-top: 1.25rem; }
.form-error, .messages { padding: .8rem 1rem; border-left: 4px solid #a32727; background: #fae9e7; }
.notice-card { margin-bottom: 1.2rem; padding: .9rem 1rem; border-left: 4px solid #8b7445; background: #f4eedf; color: #574b34; font-size: .86rem; }
.messages p { margin: 0; }

@media (max-width: 720px) {
    .site-header, .hero { align-items: flex-start; }
    .site-header { flex-direction: column; gap: .8rem; }
    nav { width: 100%; flex-wrap: wrap; gap: .6rem 1rem; }
    .logout-form { margin-left: auto; }
    .hero { flex-direction: column; }
    .login-card { grid-template-columns: 1fr; min-height: auto; }
    .form-grid, .form-grid-3, .detail-grid { grid-template-columns: 1fr; }
    .field.full-width, .full-width { grid-column: auto; }
    .form-page-heading, .calendar-heading { flex-direction: column; }
    .calendar-toolbar { grid-template-columns: 1fr; align-items: stretch; }
    .view-switcher { justify-self: start; }
    .calendar-filter { justify-self: stretch; }
    .calendar-filter select { width: 100%; }
    .period-navigation { justify-content: space-between; }
    .month-day { min-height: 95px; padding: .25rem; }
    .month-event span { display: none; }
}
