:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #0f172a;
    --ink-2: #475569;
    --muted: #94a3b8;
    --line: #e2e8f0;
    --primary: #0f766e;
    --primary-ink: #ffffff;
    --ok: #16a34a;
    --warn: #ea580c;
    --danger: #dc2626;
    --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 640px; margin: 0 auto; padding: 16px 14px 64px; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.lead { color: var(--ink-2); margin: 4px 4px 14px; font-size: .95rem; }

.topbar {
    display:flex; align-items:center; justify-content:space-between;
    padding: 14px 16px; background: var(--ink); color: #fff;
    position: sticky; top: 0; z-index: 10;
    padding-top: calc(env(safe-area-inset-top) + 14px);
}
.topbar .muted { color: #cbd5e1; margin-left: 8px; }
.topbar form { margin: 0; }
.topbar .link-btn { color: #fff; opacity: .85; }

.day {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 14px;
    margin: 0 0 14px;
}
.day.status-done { background: #f0fdf4; border-color: #bbf7d0; }
.day.status-cant_do { background: #fff7ed; border-color: #fed7aa; }
.day.status-no_cleaning { background: #f1f5f9; border-color: #cbd5e1; opacity: .85; }
.day.status-no_cleaning h2 { color: #475569; }

.day-head { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
.day h2 { font-size: 1.18rem; margin: 2px 0 2px; }
.rel {
    display:inline-block; padding: 2px 8px; border-radius: 999px;
    background: var(--primary); color: #fff; font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px;
}
.badge { display:inline-block; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #ffedd5; color: #9a3412; }
.badge.dim { background: #e2e8f0; color: #475569; }
.badge.guests { background: #fef3c7; color: #92400e; }

.res-admin-note {
    margin-top: 8px; padding: 8px 10px;
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
    font-size: .92rem; color: #78350f;
}
.res-edit { margin-top: 8px; }
.res-edit form { display:flex; flex-direction:column; gap: 8px; padding: 8px 0; }

/* Anchor scroll target — give a bit of breathing room under the sticky topbar */
.day { scroll-margin-top: 80px; }

.arrival { margin: 6px 0 0; font-size: .92rem; color: var(--ink-2); }

.reservations { margin-top: 10px; display:flex; flex-direction: column; gap: 6px; }
.res {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: .92rem;
}
.res.block { background: #f1f5f9; opacity: .85; }
.res-line { display:flex; flex-wrap:wrap; align-items:center; gap: 8px; }
.res-stay { color: var(--ink-2); }
.res-meta { margin-top: 4px; }
.res-meta a { color: var(--primary); }

.src {
    display:inline-block; padding: 1px 8px; border-radius: 6px;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em;
    text-transform: uppercase;
}
.src-airbnb  { background: #fee2e2; color: #b91c1c; }
.src-booking { background: #dbeafe; color: #1d4ed8; }

.notes { margin: 12px -2px 4px; }
.note {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 8px 0;
}
.note.cleaner { background: #f0fdfa; border-color: #99f6e4; }
.note.admin   { background: #eef2ff; border-color: #c7d2fe; }
.note.cant_do { background: #fff1f2; border-color: #fecaca; }
.note.reply   { margin-left: 18px; }
.note-meta { font-size: .82rem; color: var(--ink-2); margin-bottom: 4px; }
.note-body { font-size: .98rem; white-space: pre-wrap; }
.reply-form summary { display:inline-block; margin-top: 6px; }
.reply-form[open] summary { color: var(--ink-2); }
.reply-form form { margin-top: 8px; }

.actions { margin-top: 12px; display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.action-pop { width: 100%; }
.action-pop[open] summary { background: var(--ink); color:#fff; }
.action-pop form { margin-top: 10px; display:flex; flex-direction:column; gap:8px; }

.btn, summary.btn {
    display: inline-flex; align-items:center; justify-content:center;
    min-height: 46px; padding: 0 18px;
    border-radius: 10px; border: 1px solid var(--line);
    background: #fff; color: var(--ink); font-weight: 600; font-size: .98rem;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    list-style: none;
}
summary.btn::-webkit-details-marker { display: none; }
summary.btn { display: inline-flex; }
.btn.primary { background: var(--primary); color:#fff; border-color: var(--primary); }
.btn.ok      { background: var(--ok); color:#fff; border-color: var(--ok); }
.btn.warn    { background: var(--warn); color:#fff; border-color: var(--warn); }
.btn.ghost   { background: #fff; }
.btn.small   { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn:active  { transform: translateY(1px); }

.link-btn {
    background: none; border: 0; padding: 4px 6px;
    color: var(--ink-2); cursor: pointer; font-size: .9rem;
    text-decoration: underline; text-underline-offset: 3px;
}
.link-btn.danger { color: var(--danger); }

.inline { display:inline; margin: 0; }

textarea, input[type=text], input[type=password] {
    width: 100%; max-width: 100%;
    font: inherit;
    border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; background: #fff;
    -webkit-appearance: none;
}
textarea { min-height: 72px; resize: vertical; }
label { display: block; margin: 8px 0 14px; }
label > input { display:block; margin-top: 6px; }

.empty {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 28px 18px; text-align: center; color: var(--ink-2);
}

.alert {
    background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
    border-radius: 10px; padding: 10px 12px; margin: 0 0 14px;
}

.past { margin-top: 24px; }
.past > summary {
    cursor: pointer; padding: 12px 14px; background: var(--card);
    border: 1px solid var(--line); border-radius: 10px;
    color: var(--ink-2); font-weight: 600;
}
.past[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.sync-form { text-align: center; margin: 20px 0 0; }

/* View tabs */
.view-tabs {
    display: flex; gap: 6px; margin: 0 0 14px;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.view-tabs a {
    flex: 1; text-align: center; padding: 10px 0;
    border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 600;
}
.view-tabs a.active { background: var(--ink); color: #fff; }

/* Hours form on Fatto */
.hours-label { display:flex; flex-direction:column; gap: 6px; margin: 0 0 8px; }
.hours-label input { font-size: 1.1rem; }

/* Monthly summary (admin) */
.month-summary {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 14px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.month-summary h3 { margin: 0 0 10px; font-size: 1rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.ms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-cell { padding: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.ms-label { font-size: .82rem; color: var(--ink-2); }
.ms-hours { font-size: 1.4rem; font-weight: 700; color: var(--ink); margin-top: 2px; }
.ms-cost  { margin-top: 2px; }

/* Calendar */
.cal-nav {
    display:flex; align-items:center; justify-content:space-between;
    margin: 0 0 10px; padding: 10px 14px;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.cal-arrow {
    text-decoration:none; color: var(--ink); font-size: 1.6rem; line-height: 1;
    width: 36px; height: 36px; display:flex; align-items:center; justify-content:center;
    border-radius: 8px; background: #f1f5f9;
}
.cal-title { font-weight: 700; text-transform: capitalize; }

table.calendar {
    width: 100%; border-collapse: separate; border-spacing: 4px;
    background: var(--card); border-radius: 14px; padding: 8px;
    border: 1px solid var(--line); box-shadow: var(--shadow);
    table-layout: fixed;
}
table.calendar th {
    font-size: .72rem; color: var(--ink-2); font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; padding: 6px 0;
}
.cal-cell {
    aspect-ratio: 1 / 1;
    background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
    text-align: left; vertical-align: top; padding: 4px 6px;
    position: relative;
}
.cal-cell.out { opacity: .35; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell .day-num { font-size: .82rem; font-weight: 600; }
.cal-cell a {
    display:block; height: 100%; text-decoration: none; color: inherit;
}
.cal-cell .dot {
    display: block; width: 8px; height: 8px; border-radius: 999px;
    background: var(--ink-2);
    position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
}
.cal-cell.st-pending     .dot { background: #2563eb; }
.cal-cell.st-done        .dot { background: #16a34a; }
.cal-cell.st-cant_do     .dot { background: #ea580c; }
.cal-cell.st-no_cleaning .dot { background: #94a3b8; }
.cal-cell.has-event { background: #eef2ff; }
.cal-cell.st-done       { background: #f0fdf4; }
.cal-cell.st-cant_do    { background: #fff7ed; }
.cal-cell.st-no_cleaning { background: #f1f5f9; }
.cal-cell .cell-hours {
    position: absolute; top: 4px; right: 4px;
    font-size: .65rem; font-weight: 700; color: #166534;
}

.cal-legend { list-style: none; padding: 8px 0; margin: 10px 0 0; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.cal-legend li { display:flex; align-items:center; gap: 6px; }
.cal-legend .dot { display:inline-block; width: 9px; height: 9px; border-radius: 999px; position: static; transform: none; }
.cal-legend .st-pending     { background: #2563eb; }
.cal-legend .st-done        { background: #16a34a; }
.cal-legend .st-cant_do     { background: #ea580c; }
.cal-legend .st-no_cleaning { background: #94a3b8; }

/* Login */
.login-body {
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 60%, #0f766e 130%);
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-card {
    background: var(--card); width: 100%; max-width: 360px;
    border-radius: 18px; padding: 22px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.brand { text-align: center; margin-bottom: 14px; }
.brand-mark { font-size: 32px; margin-bottom: 4px; }
.brand h1 { margin: 0; font-size: 1.25rem; }
.brand p { margin: 2px 0 0; font-size: .9rem; }
.login-card .btn { width: 100%; margin-top: 6px; }
