:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --panel: #ffffff;
  --ink: #20231f;
  --muted: #687064;
  --line: #dfe4da;
  --primary: #b82042;
  --primary-dark: #891a33;
  --soft: #fae9ee;
  --good: #247a4a;
  --good-soft: #dff3e8;
  --warn: #9a640f;
  --warn-soft: #fff1d4;
  --shadow: 0 12px 34px rgba(37, 43, 33, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0.72rem 0.95rem;
}

a.whatsapp-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #1f8f55;
  color: #fff;
  font-weight: 800;
  padding: 0.72rem 0.95rem;
  text-decoration: none;
}

a.whatsapp-link:hover {
  background: #176b40;
}

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

button.secondary,
button.ghost {
  background: #f0f2ed;
  color: var(--ink);
}

button.secondary:hover,
button.ghost:hover {
  background: #e4e9df;
}

button.danger {
  background: #f3e2e5;
  color: #882235;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0.72rem 0.8rem;
}

textarea {
  resize: vertical;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 410px);
  gap: 24px;
  align-items: end;
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  max-width: 760px;
  font-size: clamp(2rem, 4vw, 4.1rem);
}

h2,
h3 {
  font-size: 1.2rem;
}

h3 {
  margin: 0;
}

.profile-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-panel {
  display: grid;
  gap: 12px;
}

.auth-tabs {
  display: inline-flex;
  justify-self: start;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f0;
  padding: 4px;
}

.profile-dashboard {
  display: grid;
  gap: 14px;
}

.profile-dashboard small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.profile-fields {
  display: grid;
  gap: 8px;
}

.profile-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.profile-row input {
  min-width: 0;
}

.notice {
  margin-top: 16px;
  border: 1px dashed #c8cec1;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 18px;
}

.admin-panel {
  margin-top: 16px;
}

.admin-form,
.admin-dashboard {
  display: grid;
  gap: 10px;
}

.admin-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-dashboard small,
.admin-message {
  color: var(--muted);
}

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-stats span {
  border-radius: 999px;
  background: #eef1ea;
  color: #4e574a;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 9px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.member-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.members-list,
.availability-results {
  display: grid;
  gap: 10px;
}

.member-item,
.available-user-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.member-item {
  cursor: pointer;
}

.member-item.is-selected {
  border-color: var(--primary);
  background: var(--soft);
}

.member-item strong,
.available-user-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.member-item small,
.available-user-item small {
  color: var(--muted);
}

.available-user-item {
  display: grid;
  gap: 10px;
}

.available-user-actions {
  display: flex;
  gap: 8px;
}

.calendar-results {
  margin-top: 14px;
}

.results-heading {
  margin-top: 4px;
}

.calendar-heading {
  align-items: start;
}

.calendar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 1.4rem;
}

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

.calendar-mode-switch {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f0;
  padding: 4px;
}

.mode-button {
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
}

.mode-button:hover,
.mode-button.is-active {
  background: #fff;
  color: var(--ink);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 999px;
  vertical-align: middle;
}

.dot.available {
  background: var(--good);
}

.dot.busy {
  background: var(--warn);
}

.calendar-grid {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(88px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 760px;
}

.calendar-scroll {
  max-height: 66vh;
  overflow: auto;
  border-radius: 8px;
}

.calendar-cell {
  min-height: 42px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 6px;
}

.calendar-cell:nth-child(8n) {
  border-right: 0;
}

.calendar-head,
.time-cell {
  background: #f3f5f0;
  color: var(--muted);
  font-weight: 800;
}

.calendar-head {
  min-height: 48px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.time-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  font-size: 0.78rem;
}

.slot {
  display: flex;
  min-width: 88px;
  min-height: 42px;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.slot strong {
  font-size: 0.78rem;
}

.slot.is-mine {
  background: var(--good-soft);
}

.slot.has-availability {
  background: #f6fbf8;
}

.slot.can-request {
  box-shadow: inset 0 0 0 2px var(--warn-soft);
}

.slot.is-selected-slot {
  background: var(--warn-soft);
  box-shadow: inset 0 0 0 2px var(--warn);
}

.slot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pill {
  display: inline-flex;
  max-width: 100%;
  border-radius: 999px;
  background: #eef1ea;
  color: #4e574a;
  font-size: 0.66rem;
  font-weight: 800;
  padding: 3px 7px;
  overflow-wrap: anywhere;
}

.pill.mine {
  background: #cdebd9;
  color: #195f37;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
}

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

  .roster-panel {
    order: 2;
  }

  .calendar-panel {
    order: 1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding: 10px 0 18px;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  h1 {
    font-size: 2rem;
  }

  .profile-row,
  .panel-heading,
  .calendar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-row {
    display: grid;
  }

  .calendar-grid {
    grid-template-columns: 56px repeat(7, 104px);
  }
}
