:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d8ded6;
  --soft: #eef2ed;
  --accent: #157f74;
  --accent-strong: #0f6159;
  --danger: #ba3434;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #202b33;
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f3cf72;
  color: #202b33;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.05;
}

.brand p,
.small {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.profile {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.profile-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.dot {
  width: 15px;
  height: 15px;
  border-radius: 99px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.nav-list,
.people-list,
.mail-list {
  display: grid;
  gap: 8px;
}

.nav-btn,
.person-btn,
.mail-btn {
  width: 100%;
  text-align: left;
  color: inherit;
  background: transparent;
  border-radius: 8px;
  padding: 10px 12px;
}

.nav-btn.active,
.nav-btn:hover,
.person-btn:hover,
.mail-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.gear-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #202b33;
  background: #f3cf72;
  border-radius: 8px;
  font-size: 24px;
  line-height: 1;
}

.help-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #3d5968;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.gear-btn:hover,
.help-btn:hover {
  background: #ffd978;
  color: #202b33;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar-actions {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sidebar-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-top-actions .secondary {
  color: var(--ink);
  flex: 1;
}

.main {
  min-width: 0;
  padding: 22px;
  display: grid;
  gap: 16px;
}

.topbar,
.calendar-head,
.toolbar,
.form-actions,
.dialog-head,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar {
  justify-content: space-between;
}

.toolbar {
  flex-wrap: wrap;
}

.calendar-head {
  justify-content: space-between;
  flex-wrap: wrap;
}

.title-block h2 {
  margin: 0;
  font-size: 28px;
}

.title-block p {
  margin: 4px 0 0;
  color: var(--muted);
}

.segmented {
  display: flex;
  padding: 3px;
  background: var(--soft);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.segmented button {
  min-width: 62px;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(31, 41, 51, 0.12);
}

.icon-btn,
.primary,
.secondary,
.danger,
.ghost {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  padding: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

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

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

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

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

.ghost {
  color: inherit;
  background: transparent;
}

.calendar-wrap,
.admin-panel,
.settings-panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.05);
}

.calendar-wrap {
  overflow: hidden;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  padding: 10px;
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.day-cell {
  position: relative;
  min-height: 116px;
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.day-cell.outside {
  background: #f7f8f7;
  color: #9ca3af;
}

.day-cell.today .date-num {
  background: var(--accent);
  color: #fff;
}

.date-num {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 750;
}

.event-list {
  display: grid;
  gap: 4px;
  margin-top: 7px;
}

.reservation-line {
  width: 100%;
  min-height: 22px;
  margin-top: 5px;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  color: #315c37;
  background: #e6f4df;
  border: 1px solid #bdd8b7;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  text-align: left;
}

.reservation-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reservation-line.editable:hover {
  background: #d8edcf;
}

.pickleball-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: #d7ef65;
  stroke: #315c37;
  stroke-width: 1.2;
}

.pickleball-icon circle:not(:first-child) {
  fill: #315c37;
  stroke: none;
}

.reservation-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.reservation-entry {
  padding: 14px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.reservation-entry-head,
.court-choices {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.reservation-entry-head {
  justify-content: space-between;
}

.reservation-users {
  min-width: 0;
}

.reservation-user-list {
  max-height: 190px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.reservation-user-list .check-row {
  padding: 7px 8px;
  border-radius: 6px;
}

.reservation-user-list .check-row:hover {
  background: var(--soft);
}

.compact-btn {
  min-height: 32px;
  padding: 0 10px;
}

.event-pill {
  min-height: 24px;
  border-radius: 5px;
  padding: 4px 7px;
  color: #fff;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.week-view,
.day-view {
  display: grid;
  grid-template-columns: 88px repeat(7, minmax(0, 1fr));
}

.day-view {
  grid-template-columns: 88px minmax(0, 1fr);
}

.time-col,
.week-col,
.single-day {
  border-right: 1px solid var(--line);
}

.time-slot,
.week-slot,
.day-slot {
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.time-slot {
  color: var(--muted);
  font-size: 12px;
  background: #fbfcfb;
}

.week-label {
  min-height: 52px;
  padding: 10px;
  font-weight: 750;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.mini-month {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mini-month h3 {
  margin: 0;
  padding: 9px 10px;
  font-size: 14px;
  background: #fbfcfb;
  border-bottom: 1px solid var(--line);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
}

.mini-day {
  min-height: 24px;
  background: #fff;
  position: relative;
  font-size: 10px;
  color: var(--muted);
  padding: 3px;
}

.mini-line {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 3px;
  height: 3px;
  border-radius: 8px;
}

.mini-reservation {
  position: absolute;
  top: 1px;
  right: 1px;
  display: flex;
}

.mini-reservation .pickleball-icon {
  width: 9px;
  height: 9px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(246, 247, 244, 0.88), rgba(246, 247, 244, 0.88)),
    url("https://images.unsplash.com/photo-1494526585095-c41746248156?auto=format&fit=crop&w=1800&q=80");
  background-size: cover;
  background-position: center;
}

.login-card {
  width: min(760px, 100%);
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 34px;
}

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

.field label,
.check-row {
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 64px;
}

.password-toggle {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 40px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  background: var(--soft);
}

.password-toggle:hover {
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .eye-slash {
  stroke-width: 2.4;
}

.sidebar-field label {
  color: rgba(255, 255, 255, 0.72);
}

.sidebar-field select {
  color: var(--ink);
  background: #fff;
}

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

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink);
}

.check-row input {
  margin-top: 2px;
}

.admin-panel,
.settings-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.admin-panel .small,
.settings-panel .small,
.login-card .small {
  color: var(--muted);
}

.mail-date {
  display: inline-block;
  margin: 3px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.category-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.fixed-category {
  color: var(--muted);
}

.face-choice {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fbfcfb;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

.table th {
  color: var(--muted);
  font-size: 12px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 27, 33, 0.44);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.dialog {
  width: min(520px, 100%);
  max-height: min(820px, 92vh);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.wide-dialog {
  width: min(980px, 100%);
}

.dialog-head {
  justify-content: space-between;
}

.dialog-head h2 {
  margin: 0;
  font-size: 22px;
}

.weekly-pickleball-dialog .dialog-head h2 {
  font-size: 30px;
  font-weight: 800;
}

.weekly-pickleball-content {
  display: grid;
  gap: 18px;
  padding: 8px 2px;
}

.weekly-pickleball-day {
  display: grid;
  gap: 5px;
}

.weekly-schedule-line {
  font-weight: 800;
  font-size: 17px;
}

.weekly-player {
  padding-left: 28px;
  font-size: 15px;
}

.weekly-pickleball-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.copy-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 3px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-tabs button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.settings-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(31, 41, 51, 0.12);
}

.settings-window-body {
  display: grid;
  gap: 14px;
}

.help-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 28px;
}

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

.help-content h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.help-content p {
  margin: 0 0 9px;
  color: #44515b;
  font-size: 14px;
  line-height: 1.55;
}

.help-content p:last-child {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  color: #fff;
  background: #202b33;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.inactivity-warning {
  background: #8a4b00;
  border: 1px solid #f3cf72;
}

.context-menu {
  position: fixed;
  min-width: 250px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.context-menu button {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  color: var(--ink);
  text-align: left;
  border-radius: 6px;
  background: transparent;
}

.context-menu button:hover {
  background: var(--soft);
}

.empty {
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(8, 30px);
  gap: 8px;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 99px;
  border: 3px solid transparent;
}

.swatch.selected {
  border-color: #202b33;
}

.swatch.used {
  opacity: 0.28;
  cursor: not-allowed;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.spectrum-picker {
  width: 52px;
  height: 40px;
  padding: 2px;
}

.notice {
  color: #704800;
  background: #fff2cf;
  border: 1px solid #e8cc86;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

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

  .sidebar {
    min-height: auto;
  }

  .login-card,
  .two-col,
  .reservation-editor,
  .help-content {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .main {
    padding: 12px;
  }

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

  .weekly-pickleball-dialog .dialog-head h2 {
    font-size: 24px;
  }

  .day-cell {
    min-height: 86px;
    padding: 5px;
  }

  .weekday {
    padding: 8px 4px;
    text-align: center;
  }

  .event-pill {
    font-size: 11px;
    padding: 3px 5px;
  }

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

  .week-view {
    grid-template-columns: 58px repeat(7, minmax(84px, 1fr));
    overflow-x: auto;
  }
}
