:root {
    --bg: #0f1420;
    --panel: #161d2e;
    --panel-2: #1c2438;
    --border: #2a3450;
    --text: #e6e9f2;
    --text-dim: #8891a8;
    --accent: #4f8cff;
    --accent-2: #2fbf8f;
    --danger: #e5566d;
    --warn: #e6a23c;
    --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    background: var(--bg);
    overflow-x: hidden;
    overscroll-behavior: none;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
    overscroll-behavior: none;
}
body.modal-open { overflow: hidden; }

a, button, .mg-cell, .btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* Login */
.login-body {
    min-height: 100vh;
    min-height: 100dvh; /* accounts for mobile Safari's collapsing address bar - 100vh alone leaves a blank gap */
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #1a2440, var(--bg));
}
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 320px;
    max-width: 100%;
    text-align: center;
}
.login-logo {
    display: block;
    height: 64px;
    width: auto;
    margin: 0 auto 24px;
}
@media (max-width: 480px) {
    .login-logo { height: 44px; }
    .login-card { padding: 28px 24px; }
}
.login-card form button[type=submit] { width: 100%; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }

input, select, textarea, button {
    font-family: inherit;
    font-size: 14px;
}
input[type=text], input[type=password], input[type=date], input[type=number], input[type=tel], select, textarea {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text);
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.alert { padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; }
.alert-error { background: rgba(229,86,109,0.15); color: #ff8595; border: 1px solid rgba(229,86,109,0.4); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-icon { width: 36px; height: 36px; padding: 0; font-size: 15px; }

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; }
.brand img { height: 34px; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.page { padding: 20px 24px 60px; }

.month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.month-nav h2 { margin: 0; min-width: 180px; font-size: 20px; }
.sync-status { font-size: 13px; color: var(--text-dim); }
.sync-status.sync-ok { color: #2fbf6f; }
.sync-status.sync-error { color: #e05a5a; }

/* Month / next-30-days toggle - segmented control, both options always visible. */
.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.view-toggle-btn {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-dim);
    background: var(--panel-2);
    text-decoration: none;
    white-space: nowrap;
}
.view-toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }

@media (max-width: 560px) {
    .month-nav { flex-wrap: wrap; }
    .sync-status { flex-basis: 100%; }
}

/* Mobile per-room month view (shown instead of the desktop grid on small screens) */
.mobile-cal { display: none; }

/* Home-screen overview: a mini month calendar per room, tap one to open its full
   interactive calendar in a popup. */
.mini-cal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.mini-cal-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
}
.mini-cal-card:hover { border-color: var(--accent); }

/* Same one-column-per-day spanning-bar technique as the full calendar, just scaled
   down - reservations render as one real rounded/pill shape instead of a row of
   separate colored squares. */
.mini-cal-month {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    row-gap: 1px;
}
.mini-wd { font-size: 7.5px; text-align: center; color: var(--text-dim); text-transform: uppercase; }
.mini-day-bg {
    position: relative;
    z-index: 1;
    background: var(--panel);
    border-radius: 1px;
}
.mini-daynum {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.mini-daynum-chip {
    font-size: 8px;
    color: var(--text);
    background: rgba(15, 20, 32, 0.55);
    border: 0.5px solid rgba(230, 233, 242, 0.25);
    border-radius: 3px;
    padding: 0 2.5px;
    line-height: 1.4;
}
.mini-cal-month .res-bar {
    position: relative;
    z-index: 2;
    margin: 0;
    padding: 0;
    border-radius: 9px; /* pill shape at true start/end, same technique as the big calendar */
    box-shadow: none;
    cursor: default;
}
.mini-cal-month .res-bar.mini-flat-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.mini-cal-month .res-bar.mini-flat-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mini-divider { position: relative; z-index: 2; pointer-events: none; }
.mini-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    bottom: 15%;
    width: 1px;
    background: rgba(0, 0, 0, 0.35);
}
.mini-cal-label { margin-top: 9px; font-size: 13.5px; font-weight: 600; text-align: center; }

/* Popup showing a single room's full interactive calendar */
.room-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 9, 16, 0.7);
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 20px 12px;
    z-index: 10;
}
.room-modal-overlay.open { display: flex; }
.room-modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    width: 100%;
    max-width: 480px;
}
.room-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.room-modal-header span { font-weight: 600; font-size: 16px; }
/* One column per day. A reservation renders as one real spanning element per
   week-row it touches, so there's never a seam between days to visually bridge -
   it's just one shape. */
.month-grid-7 {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    row-gap: 3px;
}
.mg-wd {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    text-transform: uppercase;
    color: var(--text-dim);
}
.mg-cell {
    position: relative;
    z-index: 1;
    margin: 1px;
    border-radius: 6px;
    background: var(--panel-2);
    cursor: pointer;
}
.mg-cell.mg-today { box-shadow: inset 0 0 0 2px var(--accent); }
.mg-cell.day-slot:hover { background: rgba(79,140,255,0.15); }

.mg-daynum {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.mg-daynum-chip {
    font-size: 12px;
    color: var(--text);
    font-weight: 600;
    background: rgba(15, 20, 32, 0.55);
    border: 1px solid rgba(230, 233, 242, 0.25);
    border-radius: 5px;
    padding: 1px 5px;
}

.month-grid-7 .res-bar {
    position: relative;
    z-index: 2;
    margin: 1px 0;
    padding: 0;
    border-radius: 21px; /* pill shape at true start/end - makes bookings pop out from the day grid */
    box-shadow: none;
}
.month-grid-7 .res-bar.mg-flat-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.month-grid-7 .res-bar.mg-flat-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Faint tick marks at each day boundary inside a connected multi-night block, so it
   still reads as individual days without reintroducing a visible gap. */
.mg-divider {
    position: relative;
    z-index: 2;
    pointer-events: none;
}
.mg-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background: rgba(0, 0, 0, 0.3);
}

/* Hidden by default (desktop); shown only below the mobile breakpoint. */
.mobile-only { display: none; }

@media (max-width: 820px) {
    .cal-wrap { display: none; }
    .mobile-cal { display: block; }
    .mobile-only { display: inline-flex; }

    /* iOS Safari auto-zooms the page when a focused input's font is under 16px. */
    input, select, textarea { font-size: 16px; }
    .date-display { font-size: 15px; }

    /* Reclaim the wasted side margins on phones - the mini calendars use the extra width. */
    .page { padding-left: 10px; padding-right: 10px; }
}

/* Today's operational brief (mobile only) */
.brief-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}
.brief-header h3 { margin: 0; text-align: center; flex: 1; }
.brief-section { margin-bottom: 16px; }
.brief-section h4 {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-icon-inline {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.btn-icon-inline:hover { color: var(--accent); }
.btn-icon-spacer { width: 36px; height: 36px; flex-shrink: 0; }
.brief-empty { margin: 0; font-size: 13px; color: var(--text-dim); }
.brief-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.brief-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
}
.brief-room { font-weight: 600; font-size: 13.5px; }
.brief-detail { font-size: 13px; color: var(--text-dim); }
.brief-detail i { margin-right: 4px; }
.brief-detail .fa-bath { color: #4f8cff; }
.brief-detail .fa-bed { color: #2fbf8f; }

.brief-hint { margin: -4px 0 8px; font-size: 12px; color: var(--text-dim); }

/* Reservation-based jobs planner: one card per stay, with a horizontally
   scrollable row of tappable per-night chips - cycles empty/towels/sheets/both,
   same order as the desktop grid strip. */
.job-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}
.job-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.job-guest { font-size: 12.5px; color: var(--text-dim); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { margin: 2px 0 10px; font-size: 12px; color: var(--text-dim); }
.night-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
.night-chip {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 46px;
    min-height: 44px;
    padding: 6px 2px;
    border-radius: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    cursor: pointer;
    touch-action: manipulation;
}
.night-chip:active { filter: brightness(1.2); }
.night-chip-date { font-size: 10px; color: var(--text-dim); text-transform: uppercase; white-space: nowrap; }
.night-chip-icon { font-size: 13px; min-height: 15px; }
.night-chip-icon .fa-bath { color: #4f8cff; }
.night-chip-icon .fa-bed { color: #2fbf8f; }
.night-chip.hk-towels { border-color: rgba(79,140,255,0.4); background: rgba(79,140,255,0.12); }
.night-chip.hk-sheets { border-color: rgba(47,191,143,0.4); background: rgba(47,191,143,0.12); }
.night-chip.hk-both { border-color: rgba(230,162,60,0.4); background: rgba(230,162,60,0.12); }

/* Calendar grid */
.cal-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.cal-grid {
    display: grid;
    grid-template-columns: 160px repeat(var(--days), minmax(38px, 1fr));
    grid-auto-rows: 58px;
    background: var(--panel);
}
.cal-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}
.cal-head {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    background: var(--panel-2);
    color: var(--text-dim);
    font-size: 11px;
    position: sticky;
    top: 0;
    z-index: 2;
}
.cal-head .dow { text-transform: uppercase; letter-spacing: 0.5px; }
.cal-head .dnum { font-size: 14px; color: var(--text); font-weight: 600; }
.cal-head.weekend { background: #212b46; }
.cal-head.is-today { background: rgba(79,140,255,0.18); color: var(--accent); }
.cal-head.is-today .dnum { color: var(--accent); }

.cal-label {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--panel-2);
    padding: 0 12px;
    justify-content: space-between;
    gap: 6px;
}
.room-name { font-weight: 600; }

.category-row {
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
    color: var(--accent);
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0 12px;
    position: sticky;
    left: 0;
}

.day-slot { cursor: pointer; touch-action: none; }
.day-slot.weekend { background: rgba(255,255,255,0.02); }
.day-slot:hover { background: rgba(79,140,255,0.08); }
.day-slot.drag-highlight { background: rgba(79,140,255,0.4) !important; box-shadow: inset 0 0 0 1px rgba(79,140,255,0.6); }

/* Housekeeping marker row, stacked directly above each room's row. Desktop grid
   only - click cycles empty -> towels -> sheets -> empty for that room/day. */
.hk-label { background: var(--panel-2); }
.hk-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-dim);
    background: var(--panel);
}
.hk-cell:hover { background: rgba(79,140,255,0.12); }
.hk-cell.hk-towels { color: #4f8cff; background: rgba(79,140,255,0.12); }
.hk-cell.hk-sheets { color: #2fbf8f; background: rgba(47,191,143,0.12); }
.hk-cell.hk-both { color: var(--warn); background: rgba(230,162,60,0.15); gap: 3px; }
.hk-cell.hk-both i { font-size: 0.75em; }

.res-bar {
    margin: 6px 2px;
    min-width: 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    z-index: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.res-bar:hover { filter: brightness(1.1); }
.res-bar.cont-before { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.res-bar.cont-after { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.res-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Reservation status colors */
.res-bar.src-booking { background: linear-gradient(135deg, #0057b8, #003580); color: #fff; }
.res-bar.pay-none { background: linear-gradient(135deg, #f0cf4d, #d9ad1e); color: #3a2f00; }
.res-bar.pay-partial { background: linear-gradient(135deg, #9de3b4, #69cb8f); color: #0d2b17; }
.res-bar.pay-full { background: linear-gradient(135deg, #2fbf6f, #22995a); color: #fff; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 14px;
    font-size: 12.5px;
    color: var(--text-dim);
}
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}
.legend-dot.src-booking { background: linear-gradient(135deg, #0057b8, #003580); }
.legend-dot.pay-none { background: linear-gradient(135deg, #f0cf4d, #d9ad1e); }
.legend-dot.pay-partial { background: linear-gradient(135deg, #9de3b4, #69cb8f); }
.legend-dot.pay-full { background: linear-gradient(135deg, #2fbf6f, #22995a); }

.remaining-line { margin: -4px 0 0; font-size: 13px; color: var(--text-dim); }
.remaining-line span { color: var(--text); font-weight: 600; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6,9,16,0.7);
    /* flex-start, not center: centering a taller-than-viewport child clips its start
       with no way to scroll back up to it - top-aligning inside a scrollable overlay
       keeps the whole modal reachable regardless of how tall its content gets. */
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 20px 0;
    z-index: 10;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 380px;
    max-width: 92vw;
}
.modal h3 { margin: 0 0 16px; }
.modal-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}
.modal-title-row h3 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-title-row .btn-icon-inline { flex-shrink: 0; font-size: 16px; }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }
.checkbox-field {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}
.checkbox-field input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }

.stepper { display: flex; align-items: stretch; gap: 0; }
.stepper-btn {
    width: 34px;
    height: 40px;
    flex-shrink: 0;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.stepper-btn:first-child { border-radius: 6px 0 0 6px; }
.stepper-btn:last-child { border-radius: 0 6px 6px 0; }
.stepper input[type=number] {
    width: 100%;
    height: 40px;
    text-align: center;
    border-radius: 0;
    border-left: none;
    border-right: none;
    -moz-appearance: textfield;
}
.stepper input[type=number]::-webkit-inner-spin-button,
.stepper input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.confirm-summary p { margin: 0 0 6px; font-size: 13.5px; color: var(--text); }
.confirm-summary p:first-child { font-weight: 600; font-size: 15px; }
#confirm-breakdown-wrap { max-height: 220px; overflow-y: auto; margin-bottom: 12px; }
.confirm-total { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-dim); margin: 4px 0; }
.confirm-total span { color: var(--text); font-weight: 600; }

/* Native date inputs always render in the browser's own locale format (e.g. mm/dd/yyyy).
   To show a Greek-style label instead, the input's own text is hidden and a formatted
   read-only label is overlaid on top - the native picker underneath still works normally. */
.date-field { position: relative; }
.date-field input[type=date] { color: transparent; }
.date-field.wrapped input[type=date] { min-height: 52px; }
.date-field input[type=date]::-webkit-datetime-edit { color: transparent; }
.date-display {
    position: absolute;
    inset: 0;
    left: 10px;
    right: 28px;
    display: flex;
    align-items: center;
    pointer-events: none;
    color: var(--text);
    font-size: 14px;
    line-height: 1.25;
    white-space: normal;
    overflow: hidden;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; }

/* Settings page */
.settings-help {
    color: var(--text-dim);
    font-size: 13.5px;
    max-width: 640px;
    line-height: 1.5;
    margin-bottom: 20px;
}
.settings-rooms { display: flex; flex-direction: column; gap: 10px; max-width: 780px; }
.settings-row { display: flex; align-items: center; gap: 10px; }
.settings-room-name { width: 90px; flex-shrink: 0; font-weight: 600; }
.settings-actions { margin-top: 24px; display: flex; align-items: center; gap: 12px; }
#capacity-status { font-size: 12.5px; color: var(--accent-2); }
.settings-subhead { font-size: 15px; margin: 28px 0 14px; }
.settings-subhead:first-of-type { margin-top: 0; }

.inline-field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-dim); width: 140px; }

.rules-table-wrap { max-width: 780px; overflow-x: auto; }
.rules-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rules-table th, .rules-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rules-table th { color: var(--text-dim); font-weight: 600; font-size: 12px; }
.rules-table .btn-danger { padding: 4px 10px; font-size: 12px; }
.rule-actions { display: flex; gap: 6px; white-space: nowrap; }
.rule-actions .btn { padding: 4px 10px; font-size: 12px; }
.rule-cat select, .rule-start input, .rule-end input, .rule-price input { padding: 5px 7px; font-size: 12.5px; }

.add-rule-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; max-width: 780px; }
.add-rule-row select, .add-rule-row input { width: auto; flex: 1; min-width: 120px; }
