:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-strong: #eef3f3;
  --ink: #172426;
  --muted: #5d6b70;
  --line: #d8e1e2;
  --accent: #0b6f6b;
  --accent-dark: #064f4c;
  --accent-soft: #d9efed;
  --booked-bg: #eadfc8;
  --booked-border: #cdb98f;
  --fixed-bg: #dfe9e6;
  --fixed-border: #9fb8b0;
  --danger: #a33a32;
  --danger-soft: #ffe4e1;
  --shadow: 0 18px 50px rgba(21, 36, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 100%;
  padding: 26px clamp(18px, 4vw, 44px) 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  font-weight: 760;
}

h2 {
  font-size: 1.35rem;
  font-weight: 720;
}

h3 {
  font-size: 1rem;
  font-weight: 720;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  width: 100%;
  max-width: 100%;
  padding: 0 clamp(18px, 4vw, 44px) 42px;
}

.is-locked .layout {
  display: none;
}

.layout > * {
  min-width: 0;
}

.dashboard-band {
  grid-column: 1 / -1;
}

.cleaning-banner,
.calendar-section,
.panel-block,
.measurements-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.cleaning-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 122px;
  padding: 24px;
  border-left: 7px solid var(--accent);
}

.cleaning-banner h2 {
  margin-top: 6px;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.cleaning-banner p:last-child {
  margin-top: 6px;
  color: var(--muted);
}

.calendar-section,
.measurements-section {
  padding: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-header.compact {
  margin-bottom: 12px;
}

.week-controls,
.button-row,
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-actions {
  justify-content: flex-end;
}

.auth-status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 720;
}

.button-row.end {
  justify-content: flex-end;
}

.button-row.split {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 680;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.ghost-button,
.icon-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.calendar-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.free {
  background: var(--accent);
}

.legend-dot.booked {
  background: var(--booked-border);
}

.legend-dot.fixed {
  background: var(--fixed-border);
}

.calendar-shell {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.calendar-grid {
  --calendar-height: 952px;
  display: grid;
  grid-template-columns: 76px repeat(7, minmax(138px, 1fr));
  grid-template-rows: 64px var(--calendar-height);
  min-width: 1040px;
}

.calendar-corner,
.day-header {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.calendar-corner {
  left: 0;
  z-index: 5;
  border-right: 1px solid var(--line);
}

.day-header {
  padding: 12px 12px;
  border-right: 1px solid var(--line);
}

.day-header strong,
.day-header span {
  display: block;
}

.day-header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.time-rail {
  position: sticky;
  left: 0;
  z-index: 3;
  height: var(--calendar-height);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.time-rail span {
  position: absolute;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.78rem;
}

.day-column {
  position: relative;
  height: var(--calendar-height);
  border-right: 1px solid var(--line);
  background:
    repeating-linear-gradient(
      to bottom,
      #ffffff 0,
      #ffffff 27px,
      #eef2f2 28px,
      #eef2f2 28px,
      #f8faf9 29px,
      #f8faf9 55px,
      #dfe7e7 56px
    );
  touch-action: pan-x pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.day-column:hover {
  background:
    repeating-linear-gradient(
      to bottom,
      #fbfdfc 0,
      #fbfdfc 27px,
      #dce8e6 28px,
      #dce8e6 28px,
      #f5faf9 29px,
      #f5faf9 55px,
      #d3dfdf 56px
    );
}

.event-block,
.selection-preview {
  position: absolute;
  left: 8px;
  right: 8px;
  z-index: 2;
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 24px;
  border: 1px solid;
  border-radius: 7px;
  padding: 7px 8px;
  color: var(--ink);
  text-align: left;
  overflow: hidden;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.event-block {
  box-shadow: 0 8px 24px rgba(21, 36, 38, 0.08);
}

.event-block strong,
.event-block span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-block strong {
  font-size: 0.88rem;
}

.event-block span {
  color: rgba(23, 36, 38, 0.72);
  font-size: 0.78rem;
  font-weight: 680;
}

.event-block.booking {
  background: var(--booked-bg);
  border-color: var(--booked-border);
}

.event-block.fixed {
  background: var(--fixed-bg);
  border-color: var(--fixed-border);
}

.event-block:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.selection-preview {
  z-index: 1;
  background: rgba(11, 111, 107, 0.12);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 760;
  pointer-events: none;
}

.side-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel-block {
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid > * {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 680;
}

.field-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 16px;
  line-height: 1.35;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
}

input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

.two-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.measurement-date-row::after {
  content: "";
}

.fixed-list {
  display: grid;
  gap: 8px;
}

.cleaning-month-list {
  display: grid;
  gap: 8px;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding-right: 2px;
}

.cleaning-month-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

.cleaning-month-row span {
  color: var(--ink);
  font-weight: 700;
  text-transform: capitalize;
}

.cleaning-month-row input {
  text-align: center;
  text-transform: uppercase;
  font-weight: 760;
}

.fixed-item,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.88rem;
}

.fixed-item strong,
.history-item strong {
  color: var(--ink);
}

.measurements-section {
  grid-column: 1 / -1;
}

.measurement-summary {
  color: var(--muted);
  font-weight: 680;
}

.measurement-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.chart-panel {
  min-width: 0;
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.chart-header span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfb 100%);
  overflow: hidden;
}

.chart svg {
  display: block;
  width: 100%;
  height: 220px;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: 260px;
  overflow: auto;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(12, 24, 26, 0.25);
}

dialog.blocking-dialog {
  width: min(430px, calc(100vw - 28px));
}

dialog#measurement-dialog {
  width: min(1060px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(18, 31, 34, 0.38);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.wide-dialog,
.measurement-dialog-card {
  width: 100%;
}

.dialog-time {
  color: var(--muted);
  font-weight: 680;
}

.is-hidden {
  display: none !important;
}

.form-message {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 680;
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.code-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body {
    min-width: 0;
  }

  .topbar {
    width: 100vw;
    max-width: 100vw;
    padding: 18px 14px 14px;
    overflow: clip;
  }

  h1 {
    font-size: 2rem;
  }

  .layout {
    width: 100vw;
    max-width: 100vw;
    padding: 0 12px 28px;
    overflow: clip;
  }

  .calendar-section,
  .measurements-section {
    padding: 14px;
  }

  .calendar-grid {
    grid-template-columns: 60px repeat(7, minmax(104px, 1fr));
    min-width: 788px;
  }

  .topbar,
  .cleaning-banner,
  .section-header,
  .measurement-layout {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .button-row.split {
    grid-template-columns: 1fr;
  }

  .two-columns {
    grid-template-columns: 1fr;
  }

  .measurement-date-row::after {
    display: none;
  }

  .auth-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    justify-content: stretch;
    width: 100%;
    max-width: 100%;
  }

  .auth-status {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .auth-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .code-grid {
    grid-template-columns: 1fr;
  }
}
