:root {
  color-scheme: light;
  --ink: #081c19;
  --muted: #50615a;
  --paper: #f3f5ef;
  --card: #fff;
  --line: #dce3d8;
  --control-line: #b2c0b3;
  --action: #b1d600;
  --action-hover: #a5c800;
  --action-ink: #081c19;
  --brand-panel: #102c25;
  --brand-wash: #eef3e8;
  --positive: #edf5ce;
  --focus: #3d6325;
  --app-paper: #f2f3f0;
  --app-line: #dfe4de;
  --app-tint: #254b34;
  --app-fill: #e8ede6;
  --app-bar: rgb(255 255 255 / 94%);
  --control-height: 44px;
  --radius: 16px;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.mobile-only { display: none; }
body { margin: 0; background: var(--paper); color: var(--ink); }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner, main { width: min(100% - 2rem, 1160px); margin: auto; }
.topbar-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.brand, .header-tools, .user-tools, .actions { display: flex; align-items: center; gap: .65rem; }
.brand { min-width: 0; }
.brand img { flex: none; display: block; border-radius: 12px; }
.brand-name { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .65rem; }
.brand strong { display: block; font-size: 1.25rem; font-weight: 800; line-height: 1.15; letter-spacing: -.025em; }
.brand span { display: block; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.brand .brand-purpose { color: var(--ink); font-weight: 600; }
.header-tools, .user-tools { gap: .4rem; }
#user-label { padding-inline-end: .5rem; color: var(--muted); font-size: .9rem; }
main { padding-block: 1.35rem 3rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 4vw, 2.45rem); font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
h2 { font-size: 1.16rem; }
.heading {
  display: flex; align-items: end; justify-content: space-between; gap: 1rem;
  margin-bottom: .95rem; padding: 1.15rem 1.3rem; border-radius: var(--radius); color: white;
  background: radial-gradient(ellipse at top right, #244638, transparent 63%), var(--brand-panel);
}
.heading p { margin-top: .4rem; color: #e2ebdc; }
.heading > .actions { flex-wrap: wrap; justify-content: end; }
.heading .secondary { color: white; background: #17382e; border-color: #799183; }
.heading .secondary:hover:not(:disabled) { background: #264a3d; }
.heading :focus-visible { outline-color: var(--action); }
.hint { color: var(--muted); margin-top: .4rem; }
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid transparent; border-radius: 999px; font-weight: 700; cursor: pointer;
  min-height: var(--control-height); padding: .62rem .95rem; color: var(--action-ink); background: var(--action);
}
button:hover:not(:disabled) { background: var(--action-hover); }
button:disabled { opacity: .58; cursor: default; }
button.secondary, button.quiet { background: var(--card); border-color: var(--control-line); color: var(--ink); }
button.secondary:hover:not(:disabled), button.quiet:hover:not(:disabled) { background: var(--brand-wash); }
.theme-toggle, .language-toggle { display: grid; flex: none; place-items: center; width: var(--control-height); padding: 0; }
.theme-toggle svg { display: none; }
.theme-toggle[data-mode="auto"] [data-mode="auto"],
.theme-toggle[data-mode="light"] [data-mode="light"],
.theme-toggle[data-mode="dark"] [data-mode="dark"] { display: block; }
input, select, textarea {
  border-radius: 10px; border: 1px solid var(--control-line); background: var(--card); color: var(--ink);
  min-height: var(--control-height); width: 100%; padding: .5rem .65rem;
}
label { display: grid; gap: .35rem; font-size: .9rem; font-weight: 650; }
textarea { min-height: 86px; resize: vertical; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.entry { max-width: 460px; margin: 4vh auto 0; padding: 1.5rem; }
.fields { display: grid; gap: .9rem; }
.entry form { margin-top: 1.25rem; }
.entry button { justify-self: start; }
.banner {
  padding: .75rem .9rem; margin-bottom: 1rem; border-radius: 10px; background: var(--positive);
}
.warning { background: #fff1db; color: #734815; }
.error, .form-error { background: #fce7e4; color: #8a2820; }
.form-error { padding: .65rem .8rem; border-radius: 8px; margin-block: .75rem; }
.source { margin-bottom: .95rem; padding: .65rem .85rem; background: var(--brand-wash); border-radius: 10px; font-size: .88rem; }
.source.warning { background: #fff1db; }
.room-date-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem .85rem; margin-bottom: .85rem; }
.room-date-label { font-size: 1.03rem; font-weight: 750; }
.room-date-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.room-date-shortcuts { display: contents; }
.room-date-actions button { min-width: var(--control-height); }
.room-date-actions input { width: auto; max-width: 100%; }
.room-calendar-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; text-align: center; gap: .4rem; }
.room-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .2rem; }
.room-calendar-grid span { padding-block: .25rem; text-align: center; font-size: .8rem; color: var(--muted); }
.room-calendar-grid button { padding-inline: 0; font-variant-numeric: tabular-nums; }
.room-calendar-grid button:disabled { background: var(--paper); border-color: transparent; }
.room.room-planned { grid-template-columns: minmax(0, 1fr) auto; }
.filters { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters button { background: var(--card); border-color: var(--control-line); color: var(--ink); }
.filters button:hover:not(:disabled) { background: var(--brand-wash); }
.filters button[aria-pressed="true"] { background: var(--brand-panel); color: white; border-color: var(--brand-panel); }
.filters button[aria-pressed="true"]:hover:not(:disabled) { background: #244638; }
.filters [id^="count-"] { margin-inline-start: .2rem; opacity: .8; }
.lookup { display: flex; gap: .7rem; margin-bottom: 1rem; }
.lookup label { flex: 0 1 210px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.entry.card { border-top: 4px solid var(--action); }
.room-activity { margin-bottom: .85rem; background: #f8faf5; }
.room-activity-heading { display: flex; align-items: baseline; gap: .55rem; padding: .5rem .75rem .25rem; }
.room-activity-heading h2 { font-size: .95rem; }
.room-activity-heading p, .room-activity-empty { font-size: .8rem; color: var(--muted); }
.room-activity-empty { padding: 0 .75rem .55rem; }
.room-activity-list {
  --activity-row-padding: .2rem;
  max-height: calc(3 * (1lh + 2 * var(--activity-row-padding)) + 2px);
  margin: 0 .55rem .45rem .75rem; padding: 0 .25rem 0 0; list-style: none;
  overflow-y: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable;
  font: .82rem / 1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.room-activity-list li {
  display: grid; grid-template-columns: 9ch minmax(11ch, 24ch) minmax(6ch, 12ch) minmax(0, 1fr);
  gap: .75rem; align-items: baseline; padding-block: var(--activity-row-padding); overflow-wrap: anywhere;
}
.room-activity-list li + li { border-block-start: 1px solid var(--line); }
.room-activity-list time, .room-activity-actor { color: var(--muted); }
.room-activity-list time { white-space: nowrap; }
.room-activity-list::-webkit-scrollbar { -webkit-appearance: none; width: 8px; }
.room-activity-list::-webkit-scrollbar-track { background: #e9eee4; border-radius: 6px; }
.room-activity-list::-webkit-scrollbar-thumb { background: #81947a; border-radius: 6px; }
@supports not selector(::-webkit-scrollbar) {
  .room-activity-list { scrollbar-width: thin; scrollbar-color: #81947a #e9eee4; }
}
@media (max-width: 560px) {
  .room-activity-list {
    max-height: calc(3 * (2lh + 2 * var(--activity-row-padding)) + 2px);
    font-size: .77rem;
  }
  .room-activity-list li { grid-template-columns: 8ch minmax(0, 1fr) minmax(6ch, auto); gap: 0 .55rem; }
  .room-activity-list li > :last-child { grid-column: 1 / -1; }
  .room-date-actions { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; width: 100%; }
  .room-date-actions input { width: 100%; }
}
.floor { display: flex; align-items: center; gap: .75rem; margin-block: 1.2rem .5rem; }
.floor::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rooms, .accounts { display: grid; gap: .45rem; }
.room {
  display: grid; grid-template-columns: minmax(160px, 1fr) minmax(210px, 1.65fr) auto;
  align-items: center; gap: .85rem; min-height: 68px; padding: .6rem .9rem; border-radius: 12px;
}
.room-priority {
  background: #fff8e8; border-color: #dfac73; border-inline-start: 5px solid #a84313;
}
.room.mobile { grid-template-columns: minmax(0, 1fr) auto; }
.room.mobile.room-expanded {
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr;
  align-items: start; min-height: 204px; padding: .9rem; gap: .7rem;
}
.room.mobile.room-expanded:not(.room-priority) { border-inline-start: 4px solid #5077a4; }
.room.mobile.room-expanded .actions { max-width: none; align-self: end; }
.cleaning-details {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .8rem;
  margin: 0; padding-top: .6rem; border-top: 1px solid var(--line); font-size: .88rem;
}
.cleaning-details dt { color: var(--muted); font-size: .78rem; }
.cleaning-details dd { margin: .1rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.cleaning-note { grid-column: 1 / -1; }
.room-number { font-size: 1.2rem; font-weight: 750; line-height: 1; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: .28rem; align-items: center; margin-top: .35rem; }
.badges.inline { margin-top: 0; }
.badge { padding: .16rem .5rem; border-radius: 6px; font-size: .81rem; font-weight: 700; background: var(--brand-wash); color: #31473b; }
.badge.dirty, .badge.rework { background: #fce7e4; color: #8a2820; }
.badge.working { background: #e3edff; color: #203e6c; }
.badge.stayover { background: #eeebfa; color: #48386d; }
.badge.red-card { background: #a52228; color: #fff; }
button.secondary.stayover-red { color: #9c2026; border-color: #cf9496; }
button.secondary.stayover-red:hover:not(:disabled) { background: #fff0ef; }
.badge.inspection, .badge.urgent { background: #fff0d5; color: #724509; }
.badge.released { background: #e5f0dd; color: #2b5029; }
.badge.ready { background: var(--positive); color: #384b13; }
.badge.priority {
  background: #a84313; color: #fff; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.room .actions { gap: .35rem; flex-wrap: wrap; justify-content: end; }
.room-note { margin-top: .35rem; color: var(--muted); overflow-wrap: anywhere; font-size: .9rem; }
.work-started { display: block; margin-top: .28rem; color: var(--muted); font-size: .8rem; }
.work-started.prominent { color: #203e6c; font-size: .98rem; font-weight: 750; }
.working-rooms { margin-top: 1.2rem; }
.working-rooms h2 { margin-bottom: .5rem; }
.empty { padding: 1rem; color: var(--muted); }
.completed-rooms { margin-top: 1.3rem; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); }
.completed-rooms h2 { font-size: .9rem; }
.completed-rooms ul {
  display: flex; flex-wrap: wrap; gap: .25rem .9rem;
  margin: .4rem 0 0; padding: 0; list-style: none; font-size: .8rem;
}
.statistics-filters {
  display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; margin-block: 0 1rem;
}
.statistics-filters label { flex: 0 1 190px; min-width: min(145px, 100%); }
.statistics-period-controls { display: flex; flex-wrap: wrap; gap: .65rem 1rem; align-items: center; margin-bottom: .85rem; }
.statistics-period-controls .filters { margin-bottom: 0; }
.statistics-period-controls .actions { flex-wrap: wrap; }
.statistics-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .65rem; margin: 0;
}
.statistics-metrics .card { padding: .85rem; border-top: 3px solid var(--action); }
.statistics-metrics dt { color: var(--muted); font-size: .88rem; }
.statistics-metrics dd { margin: .2rem 0 0; font-size: 1.28rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.statistics-section { margin-top: 1.25rem; }
.statistics-section h2 { margin-bottom: .55rem; }
.statistics-table { overflow-x: auto; }
.statistics-table table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.statistics-table th, .statistics-table td {
  padding: .65rem .85rem; text-align: start; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.statistics-table th { background: var(--brand-wash); }
.statistics-table td { border-top: 1px solid var(--line); }
.statistics-message { margin-top: .8rem; font-size: .86rem; }
.statistics-message:not(.form-error) { color: var(--muted); }
.statistics-pagination { display: flex; justify-content: end; align-items: center; gap: .6rem; margin-top: .6rem; }
.stayover-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .4rem; }
.stayover-day { display: flex; gap: .45rem; align-items: center; min-height: 42px; padding: .35rem .55rem; border: 1px solid var(--line); border-radius: 7px; }
.stayover-day input { width: 1.1rem; min-height: 0; accent-color: var(--focus); }
.stayover-add { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
dialog { color: var(--ink); background: var(--card); width: min(590px, calc(100% - 2rem)); max-height: calc(100% - 2rem); border: 1px solid var(--line); border-top: 4px solid var(--action); border-radius: var(--radius); padding: 1rem; }
dialog::backdrop { background: rgb(8 28 25 / 60%); }
.language-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: .5rem; }
.language-options button[aria-pressed="true"] { background: var(--action); color: var(--action-ink); border-color: var(--action); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: 1rem; }
#dialog-save { margin-top: 1rem; }
#dialog-body { display: grid; gap: .8rem; }
.account, .event { display: flex; justify-content: space-between; gap: .65rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.event { display: block; overflow-wrap: anywhere; }
.account small, .event small { display: block; color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
code { overflow-wrap: anywhere; }
@media screen and (min-width: 741px) and (hover: hover) and (pointer: fine) {
  :root { font-size: 87.5%; --control-height: 36px; --radius: 12px; }
  .topbar-inner { min-height: 52px; }
  .brand img { width: 36px; height: 36px; border-radius: 9px; }
  .theme-toggle svg, .language-toggle svg { width: 17px; height: 17px; }
  main { padding-block-start: .85rem; }
  h1 { font-size: 2.15rem; }
  .heading { padding: .8rem 1rem; margin-bottom: .65rem; }
  .room-date-nav { padding: .45rem .65rem; }
  .room-date-nav, .room-activity, .source, .filters, .lookup { margin-bottom: .65rem; }
  .room-activity-list { --activity-row-padding: .14rem; }
  .floor { margin-block: .85rem .4rem; }
  .room { min-height: 52px; padding: .4rem .7rem; border-radius: 9px; }
  .room.mobile.room-expanded { min-height: 156px; }
  .stayover-day { min-height: var(--control-height); }
}
@media (max-width: 740px) {
  .heading { display: block; padding: 1rem; }
  .heading > .actions { margin-top: .8rem; justify-content: start; }
  #statistics-view > .heading button { margin-top: .75rem; }
  .room { grid-template-columns: minmax(0, 1fr) auto; }
  .room:not(.mobile) > .room-meta { grid-row: 2; grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .topbar-inner, main { width: calc(100% - 1.2rem); }
  #user-label { display: none; }
  .brand { gap: .45rem; }
  .brand-name { display: block; }
  .brand img { width: 40px; height: 40px; border-radius: 10px; }
  .brand strong { font-size: 1rem; }
  .brand span { font-size: .76rem; }
  .brand .brand-purpose { display: none; }
  .quiet { padding-inline: .45rem; font-size: .84rem; }
  .theme-toggle, .language-toggle { padding-inline: 0; }
  .room { padding: .6rem; gap: .5rem; }
  .room.mobile .actions { max-width: 148px; }
  .room.mobile .actions button { min-height: 48px; }
}

@media (max-width: 390px) {
  .topbar-inner { flex-wrap: wrap; gap: .4rem; padding-block: .5rem; }
  .header-tools { margin-inline-start: auto; max-width: 100%; }
  .user-tools { min-width: 0; }
}

.room-number, .room-activity-list time, code { unicode-bidi: isolate; }
code { direction: ltr; }
:dir(rtl) .room-date-actions > button:first-child,
:dir(rtl) #room-day-next,
:dir(rtl) .room-calendar-header > button { transform: scaleX(-1); }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf5ee;
  --muted: #b5c6b9;
  --paper: #091814;
  --card: #142821;
  --line: #324b40;
  --control-line: #688175;
  --brand-panel: #12342a;
  --brand-wash: #213c31;
  --positive: #263c1a;
  --focus: #c9e85d;
  --app-paper: #101d18;
  --app-line: #324b40;
  --app-tint: #d0ea91;
  --app-fill: #223b31;
  --app-bar: rgb(20 40 33 / 94%);
}

:root[data-theme="dark"] .heading { box-shadow: inset 0 0 0 1px var(--line); }
:root[data-theme="dark"] .filters button[aria-pressed="true"] {
  color: var(--action-ink); background: var(--action); border-color: var(--action);
}
:root[data-theme="dark"] .filters button[aria-pressed="true"]:hover:not(:disabled) { background: var(--action-hover); }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: var(--muted); opacity: 1; }

:root[data-theme="dark"] .warning, :root[data-theme="dark"] .source.warning { background: #3b2c16; color: #ffd99c; }
:root[data-theme="dark"] .error, :root[data-theme="dark"] .form-error, :root[data-theme="dark"] .badge.dirty, :root[data-theme="dark"] .badge.rework { background: #442622; color: #ffbeb5; }
:root[data-theme="dark"] .room-priority { background: #2d2618; border-color: #705536; border-inline-start-color: #f0aa64; }
:root[data-theme="dark"] .badge { color: #d7e9dd; }
:root[data-theme="dark"] .badge.working { background: #20364f; color: #c9e0ff; }
:root[data-theme="dark"] .badge.stayover { background: #352a4e; color: #e1d0ff; }
:root[data-theme="dark"] .badge.inspection, :root[data-theme="dark"] .badge.urgent { background: #493718; color: #ffe0a3; }
:root[data-theme="dark"] .badge.released { background: #243c28; color: #ccebbd; }
:root[data-theme="dark"] .badge.ready { color: #d4ec9f; }
:root[data-theme="dark"] .badge.priority { background: #8e401b; color: #fff6df; }
:root[data-theme="dark"] .badge.red-card { background: #982b32; color: #fff0f0; }
:root[data-theme="dark"] button.secondary.stayover-red { color: #ffbeb5; border-color: #a46461; }
:root[data-theme="dark"] button.secondary.stayover-red:hover:not(:disabled) { background: #442622; }
:root[data-theme="dark"] .work-started.prominent { color: #b9d8ff; }

:root[data-theme="dark"] .room-activity { background: #10231c; }
:root[data-theme="dark"] .room-activity-list::-webkit-scrollbar-track { background: #213b30; }
:root[data-theme="dark"] .room-activity-list::-webkit-scrollbar-thumb { background: #6e8f7b; }
:root[data-theme="dark"] .stayover-day input { accent-color: var(--action); }
:root[data-theme="dark"] dialog::backdrop { background: rgb(0 0 0 / 68%); }

@supports not selector(::-webkit-scrollbar) {
  :root[data-theme="dark"] .room-activity-list { scrollbar-color: #6e8f7b #213b30; }
}
