/* Shared light theme. Keep application-specific layout rules in styles.css. */
:root {
    color-scheme: light;
    --page: #f3f6f4;
    --surface: #fff;
    --ink: #24362e;
    --muted: #62736a;
    --green: #246449;
    --green-dark: #194d37;
    --green-soft: #edf5ef;
    --line: #dce5df;
    --space-detail: 2px;
    --space-item: 6px;
    --space-group: 12px;
    --space-section: 20px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page); }
body {
    margin: 0;
    padding: 0 10px 16px;
    color: var(--ink);
    background: var(--page);
    font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-wrap: anywhere;
}
a {
    color: var(--green);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
a:hover { color: var(--green-dark); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid #69a98b;
    outline-offset: 3px;
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; }
h1 { font-size: 1.3rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: var(--space-section) 0 4px; }
h3 { font-size: 1rem; margin: var(--space-group) 0 4px; }
h4 { font-size: .95rem; margin: var(--space-item) 0 var(--space-detail); }
p { margin: 4px 0; }
small { color: var(--muted); }
ul, ol { margin: .35rem 0; padding-left: 1.25rem; }
li { margin-bottom: var(--space-detail); }
hr { border: 0; height: 0; margin: var(--space-section) 0; }

.top_nav_bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 2px 12px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2px 0;
    text-align: right;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.35;
}
.top_nav_bar a { display: inline-block; padding: 5px 2px; font-weight: 600; }
body > .header {
    max-width: 1600px;
    margin: 0 auto 6px;
    padding: 5px 8px;
    border-radius: 7px;
    background: var(--green);
    color: white;
    font-size: 1.05rem;
    font-weight: 600;
}
.header h1, .header h2, .header h3 { color: inherit; }
.header h1 { font-size: 1.2rem; margin: 0; }
.header h2 { font-size: 1rem; font-weight: 400; margin: .25rem 0 0; }
.header .header { background: transparent; margin: 0; padding: 0; }
body > .main_content, body > .main-content {
    width: 100%;
    max-width: 1600px;
    min-width: 0;
    margin: 0 auto;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: 0 2px 8px rgb(25 55 38 / 3%);
}
.main_content .main_content { margin: 0; }
.main_content > :first-child, .main-content > :first-child { margin-top: 0; }
body.guest-page { padding-top: 10px; }
.guest-page > .header, .guest-page > .main-content { max-width: 760px; }
.guest-page > .header:has(h1:empty) { display: none; }

/* Data tables scroll within the content panel, rather than widening the page. */
table {
    display: block;
    max-width: 100%;
    width: fit-content;
    overflow-wrap: normal;
    overflow-x: auto;
    border-collapse: collapse;
    border-spacing: 0;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    font-size: 14px;
    line-height: 1.25;
}
th, td { padding: 2px 6px; vertical-align: top; border-block: 0; }
th { background: var(--green-soft); font-weight: 600; text-align: left; }
td:last-child { padding-right: 6px; }
thead { color: var(--muted); }
.admin-user-list thead { font-style: normal; }
table, thead, tbody, tfoot, tr, colgroup { border-block: 0; }
table a { display: inline-block; padding: 0; }
.calendar-table, .planning-calendar { width: fit-content; border-spacing: 0; }
.calendar-cleaner-row td, .calendar-date-row td {
    background: var(--green-soft);
    color: var(--green-dark);
    font-style: normal;
}
.calendar-date-row > td { font-size: 1.25rem; font-weight: 700; }
.calendar-cleaner-row > td { font-size: .9375rem; font-weight: 600; background: transparent; }
.calendar-comment-row { font-size: .85rem; color: var(--muted); }
/* Details belong to the preceding cleaning; only a new cleaning gets a gap. */
.calendar-table .calendar-cleaning-row > td,
.planning-calendar .calendar-cleaning-row > td { padding-bottom: 0; }
.calendar-table .calendar-comment-row > td,
.planning-calendar .calendar-comment-row > td { padding: 0 6px 1px 22px; }
.calendar-cleaning-row + .calendar-cleaning-row > td,
.calendar-comment-row + .calendar-cleaning-row > td { padding-top: 6px; }
.calendar-spacer-row { height: 4px; }
.calendar-spacer-row.calendar-cleaner-gap { height: var(--space-group); }
.calendar-spacer-row.calendar-day-gap { height: var(--space-section); }
.calendar-spacer-row td { padding: 0; border: 0; background: transparent; }
.planning-calendar td, .planning-calendar th,
.planning-table th, .planning-table td,
.hours-table td, .work-history-table td { border-block: 0; border-inline: 1px solid var(--line); padding: 2px 6px; }
.planning-calendar colgroup.black-border { border-block: 0; border-inline: 1px solid #b8cbbf; }

/* Inputs stay large enough to use without zooming on a phone. */
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
select, textarea {
    max-width: 100%;
    min-width: 0;
    min-height: 32px;
    padding: 4px 7px;
    border: 1px solid #a9bcb0;
    border-radius: 7px;
    background: white;
    color: var(--ink);
}
textarea { width: 100%; min-height: 64px; resize: vertical; }
input[type="checkbox"], input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 3px 5px 3px 0;
    accent-color: var(--green);
    vertical-align: middle;
    flex-shrink: 0;
}
td input[type="checkbox"] { vertical-align: middle; }
label { cursor: pointer; }
input[type="radio"] + label, input[type="checkbox"] + label {
    display: inline-block;
    padding: 3px 0;
}
button, input[type="submit"], input[type="button"], .btn {
    display: inline-block;
    min-height: 32px;
    max-width: 100%;
    padding: 5px 10px;
    border: 1px solid var(--green);
    border-radius: 7px;
    background: var(--green);
    color: white;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    white-space: normal;
    cursor: pointer;
}
button:hover, input[type="submit"]:hover, .btn:hover { background: var(--green-dark); color: white; }
input.primary { background: var(--green); color: white; }
input.secondary, input[name="cancel"], .btn-link, a.btn:not(.btn-primary) {
    background: #f3f6f4;
    color: var(--green-dark);
    border-color: var(--line);
}
button:disabled, input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
.form-group, .fs-div { max-width: 100%; margin: 0 0 7px; }
.form-group > label, .fs-div > label { display: block; margin-bottom: 3px; font-weight: 600; }
.form-group > input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
.form-group > select, .fs-div > input:not([type="submit"]):not([type="checkbox"]) { width: 100%; }
form { max-width: 100%; margin: 0 0 .5rem; }
fieldset { min-width: 0; margin: var(--space-section) 0 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 6px; font-weight: 600; }
.alert, .fs-error-msg, .error { border-radius: 6px; padding: 5px 8px; color: #8f2424; background: #fff1ef; }
[role="status"] { font-size: .9rem; color: var(--muted); }

/* Only layout tables stack; booking and calendar tables keep their columns. */
table.form-layout { display: table; width: 100%; max-width: 720px; overflow: visible; }
.form-layout td { border: 0; padding: 3px 8px 3px 0; vertical-align: middle; }
.form-layout td:first-child { width: 35%; }
.form-layout td[colspan] { width: auto; }
.form-layout td > input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
.form-layout td > select { width: 100%; }
.form-layout td > label { font-weight: 600; }
.form-layout h3 { margin: 0 0 4px; }

.day_card, .card { margin: 6px 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); box-shadow: none; }
.photo-container { gap: 8px; }
.photo-container img { max-width: 100%; height: auto; border-radius: 8px; }
input[type="file"] { width: 100%; }
input::file-selector-button { padding: 8px 10px; margin-right: 10px; border: 0; border-radius: 5px; background: var(--green-soft); color: var(--green-dark); cursor: pointer; }

/* Authentication pages share the same theme without needing the app navigation. */
body.auth-page {
    width: calc(100% - 32px);
    max-width: 540px;
    margin: 16px auto;
    padding: 16px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 7px;
}
.auth-page .fs-gap:empty { display: none; }
.auth-page h1 { margin-top: 0; }
.auth-page .form-layout td:first-child { width: 30%; }

#date-picker {
    width: min(400px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: 0 12px 44px rgb(25 55 38 / 20%);
    color: var(--ink);
    font-size: 16px;
}
#date-picker .calendar-header { font-size: 1.1rem; padding: 6px 0; }
#date-picker .date-button { min-width: 0; min-height: 44px; padding: 8px 0; background: var(--green-soft); color: var(--ink); border: 0; font-size: 14px; }
#date-picker .date-button.selected { background: var(--green); color: white; }
#date-picker .date-button.adjacent-month { color: var(--muted); }
#date-picker .date-button:hover:not(:disabled) { background: #d7eadd; }
#date-picker .date-button.selected:hover { background: var(--green-dark); }
#date-picker .navigation-buttons { gap: 8px; }
#date-picker .navigation-buttons button { background: var(--green-soft); color: var(--green-dark); }
#date-picker .cancel-button { min-height: 44px; padding: 10px; background: #f3f6f4; border-color: var(--line); color: var(--ink); }

/* Compact desktop forms retain label/input columns on small screens. */
.form-layout { table-layout: fixed; }
.form-layout td:has(> br:only-child) { padding: 0; height: 0; }
.form-layout td > br:only-child, .form-layout td > br:first-child { display: none; }
.form-layout td > input[type="submit"] { margin: 2px 0; }
.form-layout td:has(> input[type="submit"]) { white-space: normal; }

@media (max-width: 600px) {
    body { padding: 0 4px 10px; font-size: 15px; }
    .top_nav_bar { justify-content: flex-start; gap: 0 10px; font-size: .8rem; padding: 0; text-align: left; }
    body > .header { padding: 7px 9px; margin-bottom: 4px; border-radius: 5px; }
    body > .main_content, body > .main-content { padding: 8px; border-radius: 5px; }
    body.guest-page { padding-top: 4px; }
    body.auth-page { width: calc(100% - 8px); margin: 6px auto; padding: 10px; }
    .header h1 { font-size: 1.1rem; }
    th, td { padding: 3px 5px; }
    .form-layout td { padding: 3px 5px 3px 0; }
    .form-layout td:first-child { width: 38%; text-align: left; }
    .form-layout td[colspan] { width: auto; }
    .form-layout td > label { display: inline; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
        font-size: 16px;
        min-height: 38px;
    }
    button, input[type="submit"], input[type="button"], .btn { min-height: 40px; }
    input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
    .form-layout td > input[type="submit"] { padding-left: 7px; padding-right: 7px; }
}

@media (pointer: coarse) {
    a { display: inline; padding: 0; }
    .top_nav_bar a { display: inline-block; padding: 7px 2px; }
    table a { display: inline-block; padding: 4px 0; }
    input[type="radio"] + label, input[type="checkbox"] + label { padding: 8px 0; }
}

/* Keep the eight-day booking diagram scrollable at its original column widths. */
body.bar-calendar-page { max-width: 1160px; margin: 0 auto; padding-top: 12px; }
.bar-calendar-page .calendar {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 12px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.bar-calendar-page .calendar-row { background: var(--green-soft); }
.bar-calendar-page .listing-name a { display: inline-block; padding: 3px 0; }

/* Calendar directories are compact link lists, not report tables. */
.calendar-links-table td {
    padding: 3px 12px 3px 0;
    border: 0;
}
.calendar-links-table a {
    display: inline;
    min-height: 0;
    padding: 0;
}

/* Use desktop width for independent dashboard sections instead of stacking them. */
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-section); }
.dashboard-column, .dashboard-column section { min-width: 0; }
.dashboard-column section + section { margin-top: var(--space-section); }
.dashboard-column section > h2:first-child { margin-top: 0; }
.dashboard-column ul { margin-bottom: 0; }
@media (min-width: 1000px) {
    .dashboard-columns { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 24px; }
    .command-list { columns: 2; column-gap: 20px; }
    .command-list li { break-inside: avoid; }
}

/* Cleaner actions keep touch-sized controls; remove space between those controls. */
.cleaning-times { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: .35rem 0; }
.cleaning-times > div { display: flex; gap: 5px; }
.cleaning-times dt { font-weight: 600; }
.cleaning-times dd { margin: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.choice-option {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 40px;
    margin: 0;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    line-height: 1.2;
}
.choice-option input { margin: 0; }
.choice-option span { min-width: 0; }
.choice-option:has(input:checked) { background: var(--green-soft); border-color: var(--green); }
.choice-option:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 1px; }
.choice-option:has(input:disabled) { opacity: .65; cursor: wait; }
.cleaner-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: .4rem 0; }
.cleaner-actions a { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 10px; }
.cleaner-actions .secondary { color: var(--green-dark); background: var(--green-soft); border-color: var(--line); }
.cleaner-page .photo-container img { max-width: 100px; max-height: 80px; object-fit: cover; }
.cleaner-page .photo-container a { display: inline-block; padding: 4px 0; }
.cleaner-page .calendar-cleaning-row a {
    display: inline-flex;
    align-items: flex-end;
    vertical-align: bottom;
    min-height: 26px;
    padding: 0 2px;
}
.cleaner-page .calendar-cleaning-row td { vertical-align: bottom; }
/* Include the open link height when keeping the gap between cleanings small. */
.cleaner-page .calendar-cleaning-row + .calendar-cleaning-row > td,
.cleaner-page .calendar-comment-row + .calendar-cleaning-row > td { padding-top: 2px; }
.cleaner-page .image-wrapper { width: 100%; max-width: 100%; height: 55vh; max-height: none; }
[role="status"]:empty { margin: 0; }
.inline-time-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inline-time-form label { font-weight: 600; }
.inline-time-form input[type="time"] { flex: 1; width: 120px; }
@media (min-width: 601px) {
    .choice-grid { max-width: 600px; }
    .cleaner-page .main_content { max-width: 960px; }
}
@media (max-width: 360px) {
    .choice-option { font-size: 14px; }
}

.top_nav_bar .nav-admin { background: #fff0ad; color: #574311; border-radius: 4px; padding-left: 5px; padding-right: 5px; }
#guest-cleanliness-form .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#guest-cleanliness-form .choice-option { gap: 4px; padding: 4px; }
.cleaner-page table { font-size: 15px; }
.page-tools { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 0 0 6px; }
.page-tools h3, .page-tools p { margin: 0; }
pre { max-width: 100%; overflow: auto; font-size: .85rem; line-height: 1.3; }

/* A heading stays close to its contents; top-level sections get the largest gap. */
:is(.main_content, .main-content, .auth-page) > :is(h2, h3),
:is(.main_content, .main-content) > form > :is(h2, h3) { margin-top: var(--space-section); }
:is(.main_content, .main-content, .auth-page) > :is(h2, h3):first-child,
form > :is(h2, h3):first-child,
form > input[type="hidden"] + :is(h2, h3) { margin-top: 0; }
:is(h2, h3, h4) + :is(p, ul, ol, form, table) { margin-top: 0; }
li > :is(p, ul, ol) { margin-top: var(--space-detail); margin-bottom: 0; }
.form-layout + .form-layout:has(h3) { margin-top: var(--space-section); }
.form-layout .form-group-start > td { padding-top: var(--space-group); }
.form-layout tr:has(input[type="submit"]) > td { padding-top: var(--space-group); }
.form-actions { margin-top: var(--space-group); }

/* Repeated records keep their secondary text attached and indented. */
.record-list > li + li { margin-top: var(--space-item); }
.record-details { margin: var(--space-detail) 0 0 16px; }
.record-details > :first-child { margin-top: 0; }
.record-details > :last-child { margin-bottom: 0; }
.message-thread { margin-top: var(--space-section); }
.message-thread:first-child { margin-top: 0; }
.message-thread > h3 { margin: 0 0 4px; }
.message-record { padding: 4px 6px; }
.message-record + .message-record { margin-top: var(--space-group); }
.message-record > h4 { margin: 0 0 var(--space-detail); }
.message-record > p { margin: var(--space-detail) 0 0 16px; }
.message-record > .record-details { color: var(--muted); }

/* Reports separate weeks/days more strongly than the rows inside them. */
.completed-cleanings .day-heading th,
.work-history-table .week-heading td {
    padding: var(--space-section) 6px 4px;
    background: transparent;
}
.completed-cleanings .nights { text-align: center; }
.completed-cleanings .day-heading:first-child th,
.work-history-table tbody > .week-heading:first-child td { padding-top: 0; }
.completed-cleanings .day-heading h3,
.work-history-table .week-heading h3 { margin: 0; }
.work-history-table .work-day-heading > td { padding-top: var(--space-group); font-weight: 600; }
.work-history-table .week-heading + .work-day-heading > td { padding-top: var(--space-detail); }
.work-history-table .work-detail > td { padding-top: 0; padding-bottom: 1px; font-size: .85rem; color: var(--muted); }
.work-history-table .work-total > td { padding-top: var(--space-item); }
.report-section { margin-top: var(--space-section); }
table.report-section:not(:has(tr)) { margin-top: 0; }

.booking-table .booking-row > td { padding-bottom: 0; }
.booking-table .calendar-comment-row > td { padding: 0 6px 1px 22px; }
.booking-table .booking-row + .booking-row > td,
.booking-table .calendar-comment-row + .booking-row > td { padding-top: var(--space-item); }

/* Print dark text on plain paper, including inline calendar colors. */
@media print {
    *, *::before, *::after, input::file-selector-button {
        color: #000 !important;
        background: transparent !important;
        border-color: #000 !important;
        outline-color: #000 !important;
        accent-color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    html, body { background: #fff !important; }
}
