:root {
  --bg: #f4f3ef;
  --surface: #fffefa;
  --surface-2: #ece9e2;
  --ink: #232821;
  --muted: #6d7169;
  --line: #ddd8cf;
  --accent: #477b75;
  --accent-strong: #2f5f5a;
  --mine: #3f837f;
  --mine-soft: #d7ebe8;
  --other: #9b4f63;
  --other-soft: #efd8df;
  --danger: #9f3f3a;
  --shadow: 0 22px 55px rgba(44, 48, 42, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

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

.shell {
  padding: 22px;
}

.topbar,
.toolbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.topbar {
  align-items: flex-start;
  min-height: var(--logo-header-height, 124px);
  margin: 0 auto 4px;
  max-width: 1500px;
  pointer-events: none;
  position: relative;
}

.brand-logo {
  filter: drop-shadow(0 12px 20px rgba(35, 38, 34, 0.14));
  height: var(--logo-height, 210px);
  left: 50%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  position: absolute;
  top: var(--logo-top, 0px);
  transform: translateX(-50%);
  width: var(--logo-width, 278px);
  z-index: 0;
}

.topbar > div {
  margin-top: max(0px, var(--logo-top, 0px));
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.topbar h1 {
  font-size: var(--brand-title-size, 32px);
  font-weight: var(--brand-title-weight, 900);
  line-height: var(--brand-title-line-height, 1.05);
}

.topbar .eyebrow {
  font-size: var(--brand-eyebrow-size, 12px);
}

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

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.auth-view {
  display: grid;
  min-height: 70vh;
  place-items: center;
}

.auth-card,
.panel,
.dialog,
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 430px;
  padding: 22px;
  width: 100%;
}

.panel {
  margin: 0 auto;
  max-width: 1500px;
  overflow: hidden;
}

.toolbar {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.toolbar p {
  color: var(--muted);
  margin-bottom: 0;
}

.booking-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.booking-legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
}

.legend-swatch {
  border-radius: 4px;
  display: inline-block;
  height: 11px;
  width: 22px;
}

.legend-swatch.mine {
  background: var(--mine);
}

.legend-swatch.other {
  background: var(--other);
}

.toolbar-actions,
.actions,
.user-bar,
.view-tabs,
.focus-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.week-nav {
  align-items: center;
  display: flex;
  gap: 8px;
}

.month-nav,
.date-range-controls,
.stats-date-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-date-controls {
  justify-content: flex-end;
}

.icon-button {
  min-width: 38px;
  padding-left: 10px;
  padding-right: 10px;
}

.month-nav .icon-button {
  margin-top: 22px;
}

.week-picker-control {
  margin-left: 14px;
}

.arrow-button {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.arrow-button::before,
.arrow-button::after {
  border-color: currentColor;
  border-style: solid;
  content: "";
  height: 7px;
  opacity: 0.78;
  transform: rotate(45deg);
  width: 7px;
}

.arrow-button.previous::before {
  border-width: 0 0 2px 2px;
}

.arrow-button.previous::after {
  display: none;
}

.arrow-button.next::before {
  display: none;
}

.arrow-button.next::after {
  border-width: 2px 2px 0 0;
}

.view-tabs {
  margin: calc(var(--logo-top, 0px) + var(--logo-height, 210px) - var(--logo-header-height, 124px) - 80px) auto 14px;
  max-width: 1500px;
  position: relative;
  z-index: 2;
}

.tab,
.button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
}

.tab {
  background: var(--surface-2);
  color: var(--muted);
}

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

.button.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.button.danger {
  background: #f1dedb;
  color: var(--danger);
  margin-right: auto;
}

.button.ghost {
  background: transparent;
  color: var(--accent-strong);
  padding-left: 8px;
  padding-right: 8px;
}

.email-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 9px;
}

.email-status.verified {
  background: var(--mine-soft);
  color: var(--accent-strong);
}

.email-status.unverified {
  background: #f6eee1;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 10px;
}

.field.compact input {
  min-width: 170px;
}

.stack {
  display: grid;
  gap: 14px;
}

.message {
  color: var(--danger);
  font-weight: 800;
  min-height: 18px;
}

.calendar {
  display: grid;
  grid-template-columns: 180px repeat(7, minmax(160px, 1fr));
  min-width: 1300px;
  overflow: auto;
}

.calendar > div {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 54px;
  padding: 10px;
}

.head,
.equipment {
  background: var(--surface);
  font-weight: 900;
  position: sticky;
  z-index: 2;
}

.head {
  top: 0;
}

.equipment {
  left: 0;
}

.corner {
  left: 0;
  z-index: 4;
}

.head.today,
.day-cell.today,
.focus-day.today,
.focus-slot.today {
  background: #f4eadf;
}

.equipment-link {
  background: transparent;
  border: 0;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 900;
  padding: 0;
  text-align: left;
}

.equipment-link span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 3px;
}

.equipment.inactive,
.day-cell.inactive,
.focus-slot.inactive {
  background: #e5e7e4;
}

.equipment.inactive .equipment-link {
  color: #6f7670;
}

.time-segment.inactive,
.time-segment.inactive:hover {
  background: rgba(111, 118, 112, 0.18);
  cursor: not-allowed;
}

.day-cell {
  background: #fbfdf8;
  cursor: crosshair;
  position: relative;
}

.time-band {
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(4.166% - 1px),
      rgba(68, 70, 62, 0.13) calc(4.166% - 1px),
      rgba(68, 70, 62, 0.13) 4.166%
    ),
    linear-gradient(to bottom, #fbfdf8, #e6eee8);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 32px;
  overflow: hidden;
  position: relative;
}

.time-band::before,
.time-band::after {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  position: absolute;
  top: 9px;
  z-index: 1;
}

.time-band::before {
  content: "00";
  left: 6px;
}

.time-band::after {
  content: "00";
  right: 6px;
}

.time-segment {
  cursor: crosshair;
  height: 100%;
  position: absolute;
  top: 0;
  touch-action: pan-y;
}

.time-segment.available:hover,
.time-segment.selected,
.focus-slot.available:hover,
.focus-slot.selected {
  background: var(--accent-soft);
}

.time-segment.selected {
  background: rgba(68, 126, 116, 0.42) !important;
  box-shadow: inset 0 0 0 1px rgba(36, 84, 78, 0.28);
  z-index: 1;
}

.time-segment.available.inactive:hover {
  background: rgba(111, 118, 112, 0.18);
}

.time-segment.booked.mine,
.focus-slot.booked.mine {
  background: var(--mine-soft);
}

.time-segment.booked.other,
.focus-slot.booked.other {
  background: var(--other-soft);
}

.booking-pill {
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  overflow: hidden;
  padding: 4px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 2;
}

.booking-pill.absolute {
  bottom: 4px;
  left: 0;
  position: absolute;
  top: 4px;
}

.booking-pill.mine {
  background: var(--mine);
}

.booking-pill.other {
  background: var(--other);
}

.booking-pill.compact,
.focus-pill.compact {
  color: transparent;
}

.time-head {
  align-items: center;
  background: var(--surface);
  color: var(--muted);
  display: flex;
  font-size: 11px;
  font-weight: 900;
  justify-content: center;
  min-height: 50px;
  padding: 4px;
  position: sticky;
  top: 0;
  writing-mode: vertical-rl;
  z-index: 2;
}

.time-head.hour,
.focus-slot.hour {
  border-left: 1px solid #c7c0b4;
}

.focus-day {
  align-items: center;
  background: var(--surface);
  display: flex;
  font-weight: 900;
  left: 0;
  min-height: 44px;
  position: sticky;
  z-index: 2;
}

.focus-slot {
  background: #fbfdf8;
  cursor: crosshair;
  min-height: 44px !important;
  padding: 0 !important;
  position: relative;
  touch-action: pan-y;
}

.focus-slot.inactive {
  cursor: not-allowed;
}

.focus-slot.pending {
  background: #b8d6cc;
}

.focus-pill {
  border: 0;
  border-radius: 6px;
  bottom: 6px;
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  left: 2px;
  overflow: hidden;
  padding: 3px 6px;
  position: absolute;
  text-overflow: ellipsis;
  top: 6px;
  white-space: nowrap;
  z-index: 3;
}

.focus-pill.mine {
  background: var(--mine);
}

.focus-pill.other {
  background: var(--other);
}

.pending-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.admin-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  padding: 16px;
}

.stats-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.stats-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-summary.personal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 900;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin-top: 5px;
}

.stats-columns {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
}

.stats-columns.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-panel {
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: 180px minmax(360px, 1fr) minmax(260px, 0.9fr);
  padding: 14px;
}

.chart-panel.personal-chart {
  grid-template-columns: 180px minmax(360px, 1fr) minmax(220px, 0.7fr);
}

.chart-panel h3 {
  margin-bottom: 0;
}

.pie-wrap {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

#adminPieMount,
#userPieMount {
  opacity: 1;
  transform: scale(1);
  transition: opacity 160ms ease, transform 160ms ease;
}

#adminPieMount.updating,
#userPieMount.updating {
  opacity: 0.38;
  transform: scale(0.985);
}

.pie-chart {
  aspect-ratio: 1;
  border: 8px solid var(--surface-2);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(35, 38, 34, 0.12);
  width: 150px;
}

.pie-legend {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.pie-legend span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 800;
  gap: 7px;
}

.pie-legend i {
  border-radius: 4px;
  height: 12px;
  width: 18px;
}

.pie-legend strong {
  color: var(--ink);
  margin-left: 2px;
  white-space: nowrap;
}

.pie-legend em {
  color: var(--muted);
  flex: 0 1 auto;
  font-style: normal;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.pie-filters.single {
  grid-template-columns: 1fr;
}

.pie-filters > div {
  background: var(--surface-2);
  border-radius: 8px;
  max-height: 230px;
  overflow: auto;
  padding: 10px;
}

.pie-check {
  align-items: center;
  display: flex;
  gap: 7px;
  margin-top: 7px;
}

.pie-check input {
  accent-color: var(--accent);
}

.pie-check span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.stat-row,
.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 10px;
}

.stat-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) 88px 130px;
}

.stat-row.compact {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) 88px;
}

.stat-row span,
.user-row span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.usage-bar {
  background: var(--surface-2);
  border-radius: 999px;
  height: 12px;
  margin-top: 8px;
  overflow: hidden;
}

.usage-fill {
  background: var(--accent);
  height: 100%;
}

.admin-card {
  box-shadow: none;
  padding: 16px;
}

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

.dialog {
  max-width: 640px;
  padding: 22px;
  width: min(100%, 640px);
}

.booking-owner {
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  padding: 10px;
}

.booking-owner strong {
  color: var(--ink);
}

.booking-owner span {
  font-size: 13px;
  font-weight: 800;
}

.booking-time-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.booking-time-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.booking-time-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.booking-time-head strong {
  color: var(--accent-strong);
  font-size: 13px;
}

.booking-time-hours {
  color: var(--muted);
  display: grid;
  font-size: 11px;
  font-weight: 900;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 10px;
}

.booking-time-hours span:last-child {
  text-align: right;
}

.booking-time-hours span:not(:first-child):not(:last-child) {
  text-align: center;
}

.booking-slider-track {
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(4.166% - 1px),
      rgba(68, 70, 62, 0.16) calc(4.166% - 1px),
      rgba(68, 70, 62, 0.16) 4.166%
    ),
    linear-gradient(to bottom, #fbfdf8, #e6eee8);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: crosshair;
  height: 36px;
  margin-top: 4px;
  position: relative;
  touch-action: none;
}

.booking-slider-track.disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

.booking-slider-selection {
  background: rgba(68, 126, 116, 0.42);
  border: 1px solid rgba(36, 84, 78, 0.28);
  border-radius: 999px;
  bottom: 4px;
  cursor: grab;
  min-width: 10px;
  position: absolute;
  top: 4px;
}

.booking-slider-handle {
  background: var(--accent-strong);
  border: 2px solid #f6f2ec;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(35, 38, 34, 0.18);
  cursor: ew-resize;
  height: 22px;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  touch-action: none;
  width: 22px;
}

.booking-slider-handle.start {
  left: -11px;
}

.booking-slider-handle.end {
  right: -11px;
}

.booking-tooltip {
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: white;
  display: none;
  font-size: 13px;
  font-weight: 800;
  left: 0;
  max-width: 280px;
  padding: 9px 10px;
  pointer-events: none;
  position: fixed;
  top: 0;
  z-index: 40;
}

.booking-tooltip.open {
  display: block;
}

.booking-tooltip strong,
.booking-tooltip span {
  display: block;
}

.booking-tooltip span {
  color: #ded9d0;
  font-size: 12px;
  margin-top: 3px;
}

.admin-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 10px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.admin-row span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.admin-row .button {
  min-height: 34px;
}

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

.site-footer {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 20px auto 0;
  max-width: 1500px;
  opacity: 0.72;
  padding: 0 2px 4px;
  text-align: center;
}

@media (max-width: 850px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 0;
    pointer-events: auto;
  }

  .topbar > div {
    margin-top: 0;
  }

  .topbar > div:first-child {
    order: 1;
  }

  .topbar h1 {
    font-size: min(var(--brand-title-size, 32px), 28px);
  }

  .brand-logo {
    align-self: center;
    height: auto;
    left: auto;
    margin: -6px auto -4px;
    max-height: 150px;
    max-width: 78vw;
    order: 0;
    position: relative;
    top: auto;
    transform: none;
    width: min(var(--logo-width, 278px), 78vw);
  }

  .user-bar {
    justify-content: flex-start;
    order: 2;
    width: 100%;
  }

  .view-tabs {
    margin: 8px auto 12px;
    width: 100%;
  }

  .view-tabs .tab {
    flex: 1 1 110px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .stats-summary,
  .stats-columns,
  .admin-grid,
  .chart-panel,
  .pie-filters,
  .pie-legend,
  .stat-row,
  .stat-row.compact,
  .two-col {
    grid-template-columns: 1fr;
  }

  .week-picker-control {
    margin-left: 0;
  }
}
