:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #dde1e7;
  --primary: #2b5d8a;
  --primary-text: #ffffff;
  --danger: #b42318;
  --ok: #1f7a4a;
  --booking: #1e5bc6;
  --airbnb: #e0565b;
  --direct: #2e9d5b;
  --notice: #fff8e1;
  --alert: #fdecea;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1e222a;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --border: #333a44;
    --primary: #5b9bd5;
    --primary-text: #0d1117;
    --danger: #f2716a;
    --ok: #4cc38a;
    --notice: #3a3218;
    --alert: #3d1f1d;
  }
}

* { box-sizing: border-box; }
/* Layout rules like .row { display: flex } must not override the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 1000px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
a { color: var(--primary); }
.muted { color: var(--muted); font-weight: normal; }
.nowrap { white-space: nowrap; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 16px; position: sticky; top: 0; z-index: 10;
}
/* Only the page links scroll sideways on a narrow phone; the bell and account stay put. */
.topbar nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar nav a {
  text-decoration: none; color: var(--text); padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
.topbar nav a.active { background: var(--primary); color: var(--primary-text); }
.topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; color: var(--muted);
}
.bell .icon { width: 22px; height: 22px; }
.bell:hover, .bell.active { background: var(--border); color: var(--text); }
.bell.unread { color: var(--danger); }
.bell .badge { position: absolute; top: 2px; right: 0; font-size: 0.7rem; line-height: 1.4; }

.account-menu { position: relative; }
.account-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 8px; color: var(--text);
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { background: var(--border); }
.account-menu summary .icon:first-child { width: 22px; height: 22px; }
.account-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.account-menu .menu a, .menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 6px; text-decoration: none; color: var(--text);
  background: none; border: none; font: inherit; cursor: pointer;
}
.account-menu .menu a:hover, .menu-item:hover, .account-menu .menu a.active { background: var(--border); }
.menu-item.danger { color: var(--danger); }
@media (max-width: 600px) {
  .account-name { display: none; }
}

.heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 0.75rem; }
.heading h1, .heading h2 { margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.card.alert { background: var(--alert); }
.notice { background: var(--notice); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.error { color: var(--danger); }

button, .button {
  display: inline-block; font: inherit; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-text);
  border: 1px solid var(--primary); border-radius: 8px; padding: 8px 14px;
}
.button.secondary { background: transparent; color: var(--primary); }
button.link { background: none; border: none; padding: 0 4px; color: var(--primary); }
button.danger, .danger { color: var(--danger); }
.url { font-size: 0.8rem; word-break: break-all; }
.icon { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }
/* Buttons with icon + text line up the two. */
button:has(.icon), .button:has(.icon) { display: inline-flex; align-items: center; gap: 6px; }
/* Icon-only buttons in rows: quiet until hovered. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--border); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.copied { color: var(--ok); }
.copy-field { display: flex; align-items: center; gap: 6px; }
.copy-field input { flex: 1; }
button.big { padding: 14px 22px; font-size: 1.05rem; background: var(--ok); border-color: var(--ok); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
/* Checkboxes and radios keep their own size (the 100% width above is for text fields). */
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; padding: 0; margin: 0; flex: none; accent-color: var(--primary); }
.urgent-check { font-weight: 600; }
.urgent-check input { accent-color: var(--danger); }
.narrow-form { max-width: 520px; }
.copy { font-family: ui-monospace, monospace; font-size: 0.85rem; }

form.inline, .inline { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
form.inline input, form.inline select { width: auto; }
.filters { margin-bottom: 12px; }
.assign-row { margin-top: 6px; }
.assign-row select { font-size: 0.9rem; padding: 4px 8px; }
dialog.modal {
  border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  background: var(--surface); color: var(--text);
  width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.user-row.revoked > div:first-child { opacity: 0.55; }
.row-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.role-badge { display: inline-block; font-size: 0.8rem; padding: 1px 9px; border-radius: 999px; background: var(--border); margin-left: 4px; }
.role-badge.role-owner { background: var(--primary); color: var(--primary-text); }
.role-badge.role-maintenance { background: #b7791f; color: #fff; }
.role-badge.role-cleaner { background: var(--direct); color: #fff; }
.field { display: flex; flex-direction: column; gap: 4px; }
.code-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.code-inline { font-weight: 700; letter-spacing: 0.15em; font-variant-numeric: tabular-nums; }
.copy-btn { font-size: 0.8rem; padding: 2px 10px; background: transparent; color: var(--primary); }
.code-display .copy-btn { vertical-align: middle; letter-spacing: normal; font-weight: 400; }
.role-picker { position: relative; }
.role-picker-button {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.role-picker-menu {
  margin-top: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  max-height: 260px; overflow-y: auto;
}
.role-picker-list { list-style: none; margin: 0; padding: 4px 0; }
.role-picker-item { display: flex; align-items: center; }
.role-picker-item.selected { background: var(--border); }
.role-picker-choose {
  flex: 1; text-align: left; background: none; border: none; color: var(--text); border-radius: 0; padding: 9px 12px;
}
.role-picker-choose:hover, .role-picker-delete:hover { background: var(--border); }
.role-picker-delete {
  background: none; border: none; color: var(--muted); border-radius: 0; padding: 9px 14px; font-size: 1.1rem; line-height: 1;
}
.role-picker-delete:hover { color: var(--danger); }
.role-picker-new { border-top: 1px solid var(--border); padding: 6px; }
.role-picker-add { width: 100%; text-align: left; background: none; border: none; color: var(--primary); padding: 6px; }
.role-picker-new-form { display: flex; gap: 6px; }
.role-picker-new-form input { flex: 1; }
.role-picker-error, .role-picker-required { margin: 6px 0 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.stack label.check { flex-direction: row; align-items: center; gap: 10px; flex: none; cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
legend { font-weight: 600; padding: 0 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { min-width: 140px; }
.actions { display: flex; gap: 16px; align-items: center; }
.narrow { max-width: 420px; margin: 10vh auto 0; }
.quick-login { display: flex; flex-direction: column; gap: 8px; }
.quick-login p { margin: 0; }
.big-wide { width: 100%; padding: 14px; font-size: 1.05rem; }
.secondary-btn { background: transparent; color: var(--primary); }
.code-input { font-size: 2rem; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.code-display { font-size: 2.2rem; font-weight: 700; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; margin: 0.25rem 0; }
.muted-on-primary { opacity: 0.8; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.inactive td { opacity: 0.45; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.booking, .stay.booking { background: var(--booking); }
.dot.airbnb, .stay.airbnb { background: var(--airbnb); }
.dot.direct, .stay.direct { background: var(--direct); }
.legend { display: flex; gap: 16px; font-size: 0.9rem; }

.small { font-size: 0.85rem; }
.badge { display: inline-block; min-width: 1.3em; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.75rem; text-align: center; }
.notification.unread { border-left: 4px solid var(--primary); }
.tag { display: inline-block; font-size: 0.8rem; padding: 1px 8px; border-radius: 999px; background: var(--border); }
.tag.done { background: var(--ok); color: #fff; }
.tag.urgent { background: var(--danger); color: #fff; }

.apartment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.apartment-card {
  display: flex; flex-direction: column; gap: 10px; margin: 0;
  text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s;
}
.apartment-card:hover, .apartment-card:focus-visible { border-color: var(--primary); transform: translateY(-2px); }
.apartment-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.apartment-card-head h2 { margin: 0; }
.status { font-size: 0.8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.status.occupied { background: var(--booking); color: #fff; }
.status.free { background: var(--ok); color: #fff; }
.apartment-now { margin: 0; }
.apartment-card .muted.small { margin: -6px 0 0; }
.apartment-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.apartment-facts li { display: inline-flex; align-items: center; gap: 6px; }
.apartment-card-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: 10px; font-size: 0.9rem; color: var(--muted);
}
.apartment-card-foot > span { display: inline-flex; align-items: center; gap: 6px; }
.apartment-card-foot .tag.urgent { display: inline-flex; align-items: center; gap: 4px; }
.apartment-card-foot .tag .icon { width: 14px; height: 14px; }
.card-arrow { margin-left: auto; color: var(--primary); }
.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.day p { margin: 0.3rem 0; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.calendar .wd { text-align: center; font-size: 0.8rem; color: var(--muted); padding: 4px 0; }
.calendar .cell {
  background: var(--surface); min-height: 76px; padding: 4px; border-radius: 6px;
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.calendar .cell.out { opacity: 0.45; }
.calendar .cell.today { outline: 2px solid var(--primary); }
.calendar .num { font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.calendar .stay {
  color: #fff; font-size: 0.75rem; border-radius: 4px; padding: 1px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none;
}
.calendar .out-mark { font-size: 0.75rem; color: var(--muted); }

.guest-header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 16px;
}
.guest-header .lang { display: flex; gap: 4px; }
.guest-header .lang a { text-decoration: none; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.guest-header .lang a.active { background: var(--primary); color: var(--primary-text); }
.guest-main { max-width: 520px; }
.door { text-align: center; }
.door-code { font-size: 3rem; font-weight: 700; letter-spacing: 0.3em; margin: 0.5rem 0; font-variant-numeric: tabular-nums; }
.temp-row { display: flex; align-items: center; gap: 12px; }
.temp-row output { min-width: 4.5em; font-size: 1.2rem; font-weight: 600; }
.time-form { margin-bottom: 16px; }
.guest-links { margin-top: 8px; }
a.button.big-wide { display: block; text-align: center; }
.big-notice { font-size: 1.15rem; padding: 16px; }
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.qr-card { text-align: center; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: #111; }
.qr-card svg { width: 220px; height: 220px; }
.qr-card h2 { margin-bottom: 4px; }
.qr-card .url { color: #555; }
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
}

.tasks { list-style: none; padding: 0; }
.task { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.task.done { opacity: 0.6; }
.task-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.task-actions .icon-btn { align-self: flex-end; }
.issue-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.departure { display: inline-flex; align-items: center; gap: 6px; }
.departure .icon { width: 16px; height: 16px; }
.departure { display: inline-block; margin: 4px 0; padding: 2px 10px; border-radius: 999px; font-size: 0.9rem; }
.departure.left { background: var(--ok); color: #fff; }
.departure.inside { background: var(--border); }
.departure.unconfirmed { background: #b7791f; color: #fff; }

@media (max-width: 600px) {
  .calendar .cell { min-height: 56px; }
  .calendar .stay { font-size: 0.65rem; }
}
