:root {
    --primary: #336633;
    --primary-dark: #255425;
    --primary-soft: #e8f3e8;
    --text: #2f3530;
    --text-soft: #66706a;
    --border: #dbe3db;
    --surface: #ffffff;
    --surface-soft: #f6f8f6;
    --danger: #b91c1c;
    --shadow: 0 10px 24px rgba(27, 39, 27, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    scrollbar-gutter: stable;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: #ffffff !important;
}

body {
    min-height: 100vh;
}

.planning-admin-page {
    zoom: 0.85;
}

.planning-admin-page .planning-shell {
    max-width: none;
    padding: 14px 20px;
}

.planning-shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px;
    background: #ffffff;
}

.planning-embed-shell {
    max-width: none;
    padding: 0;
}

.planning-admin-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin-bottom: 14px;
}

.planning-admin-header h1 {
    margin: 0;
    font-size: 1.35rem;
}

.planning-admin-header .header-actions {
    margin-left: auto;
    align-items: center;
}

.planning-admin-header .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.planning-admin-header p,
.section-heading p,
.helper-text {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
}

.planning-checker-card,
.planning-admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.planning-admin-card {
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 14px rgba(27, 39, 27, 0.05);
}

.planning-admin-workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Entries, year, editor beside each other, so a day, what is on it and the form
   that changes it are all in view at once. The narrow layout keeps the DOM order
   (calendar first), which is the one that makes sense on a phone. */
@media (min-width: 1100px) {
    .planning-admin-workspace {
        display: grid;
        grid-template-columns: 300px minmax(0, 1fr) 320px;
        gap: 14px;
        align-items: start;
    }

    /* The row has to be spelled out: the list comes last in the HTML, and
       auto-placement never walks back to a column it has already passed. */
    .admin-entries {
        grid-column: 1;
        grid-row: 1;
    }

    #adminCalendarCard {
        grid-column: 2;
        grid-row: 1;
    }

    .admin-editor {
        grid-column: 3;
        grid-row: 1;
        position: sticky;
        top: 12px;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .admin-entries .section-heading {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    /* flex-basis is the height in a column, which turned the search box into a
       150px tall square. */
    .admin-entries .planning-search-input {
        flex: none;
        width: 100%;
    }

    /* The rows scroll on their own, so the three columns stay side by side
       instead of the list stretching the page to three screens. */
    .admin-entries .event-log {
        max-height: calc(100vh - 230px);
        overflow-y: auto;
    }
}

.admin-editor .stack {
    gap: 10px;
}

.admin-editor textarea {
    min-height: 68px;
}

.admin-editor .field-group input,
.admin-editor .field-group select,
.admin-editor .field-group textarea {
    padding: 8px 10px;
    border-radius: 9px;
}

.admin-editor .field-group {
    min-width: 0;
}

.admin-editor .field-group label {
    font-size: 0.82rem;
}

.admin-editor .btn {
    padding: 9px 14px;
}

/* ---------- toolbar: year navigation, counters, call to action ---------- */

.planning-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.planning-year-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
}

.cal-nav {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}

.cal-nav:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.planning-stats {
    flex: 1 1 220px;
    min-width: 0;
    font-size: 0.9rem;
    color: var(--text-soft);
}

.planning-stats strong {
    font-size: 1.05rem;
    color: var(--text);
}

.planning-stat-sep {
    padding: 0 4px;
    opacity: 0.5;
}

.planning-reserve-button {
    margin-left: auto;
    white-space: nowrap;
}

/* ---------- year calendar ---------- */

.planning-year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
    gap: 20px 16px;
}

.cal-month-label {
    margin-bottom: 7px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cal-weekday {
    padding-bottom: 3px;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.cal-day {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cal-day.is-empty {
    border-color: transparent;
    background: none;
    cursor: default;
}

.cal-day.is-weekend {
    background: var(--surface-soft);
}

@media (hover: hover) {
    .cal-day:not(.is-empty):hover {
        transform: scale(1.15);
        box-shadow: 0 5px 12px rgba(27, 39, 27, 0.2);
        position: relative;
        z-index: 1;
    }

    .event-row:hover {
        background: var(--surface-soft);
    }
}

/* The fill itself is set per day: one colour per hardware set, split
   diagonally when the two sets differ. Only the ink is decided here. */
.cal-day.has-light-ink {
    color: #fff;
    border-color: transparent;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.cal-day.has-dark-ink {
    color: var(--text);
    border-color: rgba(27, 39, 27, 0.08);
}

/* A note leaves the day available and only adds a remark. */
.cal-day.has-note::before {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    bottom: 2px;
    height: 2px;
    border-radius: 2px;
    background: var(--type-note);
}

.cal-day.has-note {
    position: relative;
}

.cal-day.is-today {
    outline: 2px dashed var(--primary);
    outline-offset: -3px;
    font-weight: 900;
}

.cal-day.is-selected {
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

.planning-calendar-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 18px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.planning-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-soft);
}

.planning-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.planning-legend-swatch {
    width: 14px;
    height: 14px;
    border: 1px solid var(--border);
    border-radius: 5px;
}

.planning-legend-swatch.is-free {
    background: #fff;
}

.planning-legend-swatch.is-note {
    background: #fff !important;
    box-shadow: inset 0 -4px 0 var(--type-note);
}

.planning-legend-note {
    font-weight: 500;
    font-style: italic;
}

/* ---------- availability answer ---------- */

.availability-result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 700;
    border: 1px solid transparent;
}

.availability-hidden {
    display: none;
}

.availability-date {
    font-weight: 800;
}

.availability-text {
    flex: 1;
    font-weight: 600;
}

.availability-remark {
    flex-basis: 100%;
    font-weight: 600;
}

.availability-remark.is-note {
    color: var(--type-note);
}

.availability-remark.is-instruction {
    color: var(--type-instruction);
}

.availability-cta {
    margin-left: auto;
    padding: 9px 14px;
    font-size: 0.85rem;
}

.availability-available {
    background: #f3f8f3;
    border-color: #d8e8da;
    color: #275738;
}

.availability-unavailable {
    background: #fcf2f2;
    border-color: #edd3d3;
    color: #991b1b;
}

.availability-note {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-soft);
    line-height: 1.45;
}

/* ---------- event list: one line per event, no cards ---------- */

.planning-list-section {
    margin-top: 26px;
}

.planning-list-section .section-heading {
    align-items: baseline;
    flex-wrap: wrap;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.planning-search-input {
    flex: 1 1 150px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 7px 11px;
    font: inherit;
    font-size: 0.88rem;
    color: var(--text);
    background: #fff;
}

.planning-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 102, 51, 0.1);
}

.event-log {
    margin: 0;
    padding: 0;
    list-style: none;
}

.event-month {
    padding: 16px 0 5px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.event-month:first-child {
    padding-top: 4px;
}

.event-row {
    display: grid;
    grid-template-columns: 62px 10px minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 12px;
    padding: 7px 4px;
    border-bottom: 1px solid #eef1ee;
    font-size: 0.92rem;
}

.event-row.is-past {
    color: var(--text-soft);
}

.event-row.is-past .event-row-mark {
    opacity: 0.45;
}

.event-row.is-highlighted {
    background: var(--primary-soft);
    color: var(--text);
}

.event-row.is-clickable {
    cursor: pointer;
}

.event-row.is-clickable:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.event-row-date {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    white-space: nowrap;
    text-align: right;
    color: var(--text-soft);
}

.event-row.is-highlighted .event-row.is-clickable {
    cursor: pointer;
}

.event-row.is-clickable:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.event-row-date {
    color: var(--text);
}

.event-row-mark {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    align-self: center;
}

.event-row-title {
    min-width: 0;
    font-weight: 600;
}

.event-row-notes {
    display: block;
    font-weight: 400;
    font-size: 0.82rem;
    color: var(--text-soft);
}

.event-row-scope {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-soft);
    white-space: nowrap;
}

/* ---------- shared form bits (mostly admin) ---------- */

.field-inline,
.form-actions,
.header-actions,
.section-heading {
    display: flex;
    gap: 12px;
}

.form-actions,
.header-actions {
    align-items: end;
}

.section-heading {
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.section-heading h2 {
    margin: 0 0 4px;
    font-size: 1.15rem;
}

.field-inline {
    align-items: stretch;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.field-group label {
    font-size: 0.88rem;
    font-weight: 700;
}

.field-group input,
.field-group textarea,
.field-group select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

.field-group textarea {
    min-height: 100px;
    resize: vertical;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(51, 102, 51, 0.1);
}

.btn {
    appearance: none;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.btn-primary,
.btn-secondary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover,
.btn-secondary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
}

.btn-danger.is-confirming {
    background: var(--danger);
    color: #fff;
}

.status-banner {
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    display: none;
}

.status-banner.show {
    display: block;
}

.status-success {
    background: #dcfce7;
    color: #166534;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

.empty-state {
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--text-soft);
    text-align: center;
}

.planning-login-shell {
    max-width: 460px;
    margin: 8vh auto 0;
    padding: 24px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@media (min-width: 1040px) {
    #planningApp {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(290px, 350px);
        gap: 22px;
        align-items: start;
        max-width: 1400px;
    }

    #planningApp .planning-list-section {
        margin-top: 0;
    }
}

@media (max-width: 800px) {
    .planning-shell,
    .planning-login-shell {
        padding: 14px;
    }

    .planning-embed-shell {
        padding: 0;
    }

    .planning-checker-card,
    .planning-admin-card {
        padding: 16px;
    }

    .planning-year-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
        gap: 18px 12px;
    }

    .cal-day {
        font-size: 0.78rem;
    }

    .availability-cta {
        width: 100%;
        margin-left: 0;
    }

    .planning-reserve-button,
    .planning-search-input {
        width: 100%;
        margin-left: 0;
    }

    .planning-list-section .section-heading,
    .field-inline,
    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
