:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --ink: #171717;
  --muted: #6f6f68;
  --line: #d8d8d0;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --soft: #eef4f2;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}

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

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

h3 {
  font-size: 14px;
}

p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.top-actions,
.namespace-control,
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.namespace-control select {
  width: auto;
  min-width: 120px;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  height: 36px;
  padding: 0 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.secondary {
  background: #334155;
}

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

.shell {
  padding: 18px 28px 36px;
}

.workspace {
  max-width: 1480px;
  margin: 0 auto;
}

.tabs {
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: enter 180ms ease-out;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 16px;
  margin-bottom: 16px;
}

.columns.wide-left {
  grid-template-columns: minmax(480px, 0.78fr) minmax(0, 1fr);
}

.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.pane-head {
  min-height: 48px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-head {
  align-items: flex-start;
}

.metric {
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.list {
  padding: 8px;
}

.row {
  padding: 12px 10px;
  border-bottom: 1px solid #ededE7;
}

.row:last-child {
  border-bottom: 0;
}

.row.inactive {
  background-color: rgba(180, 35, 24, 0.04);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: white;
  padding: 24px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(20px);
  transition: transform 200ms ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--danger);
}

.modal p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

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

.booking-block .delete-booking {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}

.booking-block:hover .delete-booking {
  opacity: 1;
}

.booking-block .delete-booking:hover {
  background: rgba(0, 0, 0, 0.4);
}

.row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  background: #f1f5f4;
  border: 1px solid #dce7e4;
  color: #164e45;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

.chip-button {
  min-height: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  background: #334155;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

label.inline {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

input, select {
  height: 34px;
  padding: 0 9px;
}

textarea {
  min-height: 72px;
  resize: vertical;
  padding: 8px 9px;
}

label.wide {
  grid-column: 1 / -1;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 6px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.checkbox-grid label {
  grid-template-columns: 18px 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfbf8;
  color: var(--ink);
}

.checkbox-grid input {
  height: auto;
}

.form-grid button {
  grid-column: 1 / -1;
}

.service-mix {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfbf8;
}

.service-mix-head,
.service-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 140px) auto;
  gap: 10px;
  align-items: end;
}

.service-mix-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.service-items {
  display: grid;
  gap: 8px;
}

.service-item:first-child {
  grid-template-columns: minmax(0, 1fr) minmax(96px, 140px);
}

.service-item .remove-service-item {
  grid-column: auto;
}

.service-mix button {
  grid-column: auto;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.status {
  display: none;
  margin: 12px 12px 0;
  border-radius: 6px;
  background: #f8faf9;
  border: 1px solid #e2e8e4;
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
}

.status:not(:empty) {
  display: block;
}

.status.success {
  border-color: #b8ddd5;
  background: #eef8f5;
  color: var(--accent-dark);
}

.status.error {
  border-color: #f0b7b1;
  background: #fff4f2;
  color: var(--danger);
}

.fact {
  background: #fafaf8;
  border: 1px solid #e8e8df;
  border-radius: 6px;
  padding: 9px;
  font-size: 12px;
}

.options .row {
  cursor: pointer;
}

.options .row:hover {
  background: #fafdfc;
}

.option-row:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.option-action {
  margin-top: 10px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  padding: 22px 16px;
}

.empty-state p {
  max-width: 680px;
}

.assignment {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-toolbar {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(180px, 240px) repeat(3, max-content);
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.time-ruler {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: 11px;
}

.time-ruler span {
  min-width: 0;
}

.calendar-list {
  display: grid;
  gap: 0;
}

.calendar-provider {
  padding: 14px 16px 16px;
  border-bottom: 1px solid #ededE7;
  min-width: 0;
}

.calendar-provider:last-child {
  border-bottom: 0;
}

.calendar-provider-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-width: 0;
}

.timeline {
  position: relative;
  height: 42px;
  border: 1px solid #e3e7df;
  border-radius: 6px;
  background:
    repeating-linear-gradient(
      90deg,
      #fbfbf8 0,
      #fbfbf8 calc(10% - 1px),
      #ecefe8 calc(10% - 1px),
      #ecefe8 10%
    );
  overflow: hidden;
}

.timeline-empty {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.booking-block {
  position: absolute;
  top: 5px;
  bottom: 5px;
  min-width: 34px;
  border-radius: 5px;
  background: var(--accent);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 8px;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.2);
}

.booking-block.travel {
  background: #7c3aed;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.2);
}

.booking-block.service {
  background: var(--accent);
}

.booking-block.busy {
  background: #475569;
  box-shadow: 0 1px 2px rgba(71, 85, 105, 0.2);
}

.booking-block strong,
.booking-block span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.booking-block strong {
  font-size: 11px;
}

.booking-block span {
  font-size: 10px;
  opacity: 0.9;
}

.calendar-bookings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.calendar-booking {
  border-left: 2px solid var(--accent);
  padding-left: 9px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.calendar-booking.travel {
  border-color: #7c3aed;
}

.calendar-booking.service {
  border-color: var(--accent);
}

.calendar-booking.busy {
  border-color: #475569;
}

.calendar-booking strong,
.calendar-booking span {
  display: block;
  overflow-wrap: anywhere;
}

.calendar-booking.muted {
  border-color: var(--line);
}

.steps {
  padding: 14px;
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #ededE7;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.formula {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #115e59;
  background: #edf7f5;
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
}

.json-snapshot {
  margin: 0;
  padding: 16px;
  max-height: 70vh;
  overflow: auto;
  background: #101828;
  color: #e6edf3;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .topbar,
  .columns,
  .columns.wide-left {
    grid-template-columns: 1fr;
    display: grid;
  }

  .top-actions {
    justify-content: start;
  }

  .form-grid,
  .facts {
    grid-template-columns: 1fr;
  }

  .service-mix-head,
  .service-item,
  .service-item:first-child {
    grid-template-columns: 1fr;
  }

  .calendar-toolbar {
    grid-template-columns: 1fr;
  }

  .time-ruler {
    grid-template-columns: repeat(3, 1fr);
    row-gap: 4px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 16px;
  }

  .shell {
    padding: 14px 12px 28px;
  }

  .calendar-provider {
    padding: 12px;
  }

  .booking-block {
    padding: 0 5px;
  }
}
