:root {
  color-scheme: dark;
  --bg: #15130f;
  --surface: #211e19;
  --surface-strong: #28231d;
  --ink: #f4eadc;
  --muted: #b9ad9d;
  --line: #40382e;
  --accent: #2e9d8e;
  --accent-dark: #6ed2c5;
  --partial: #51400f;
  --partial-line: #d4a72b;
  --booked: #173d29;
  --booked-line: #48a867;
  --warm: #e1a15e;
  --danger: #e05f5f;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(18, 16, 13, 0.92), rgba(27, 24, 19, 0.98)),
    repeating-linear-gradient(90deg, rgba(225, 161, 94, 0.06) 0 1px, transparent 1px 56px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-auth-required .app-shell {
  filter: blur(2px);
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--warm);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.06;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
}

.stats span {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(40, 35, 29, 0.84);
  padding: 7px 12px;
  border-radius: 8px;
}

.stats b {
  color: var(--ink);
}

.topbar-right {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.account-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.account-box span {
  max-width: 280px;
  overflow-wrap: anywhere;
}

.compact-button {
  min-width: 88px;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(33, 30, 25, 0.82);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  padding: 16px;
  margin-bottom: 18px;
}

.auth-copy {
  min-width: 0;
}

.auth-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.auth-panel.is-logged {
  border-color: rgba(46, 157, 142, 0.56);
}

.auth-panel.is-logged .auth-status {
  color: var(--accent-dark);
}

.auth-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.auth-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.auth-message {
  grid-column: 1 / -1;
  margin: -2px 0 0;
}

.auth-message.is-success {
  color: var(--accent-dark);
}

.auth-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

#authForm.is-login .auth-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171511;
  padding: 4px;
}

.auth-tabs[hidden] {
  display: none;
}

.auth-form.is-profile .auth-tabs {
  display: none;
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.auth-tab.is-active {
  background: var(--accent);
  color: #ffffff;
}

.auth-tab:not(.is-active):hover,
.auth-tab:not(.is-active):focus-visible {
  color: var(--accent-dark);
}

.day-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.tabs {
  min-width: 0;
  display: flex;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
}

.day-tab {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
}

.tab {
  appearance: none;
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.delete-day-button {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(40, 35, 29, 0.86);
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.delete-day-button:hover,
.delete-day-button:focus-visible {
  border-color: var(--danger);
  background: #3a211f;
  color: var(--danger);
}

.delete-day-button:disabled {
  cursor: not-allowed;
  opacity: 0.34;
}

.delete-day-button:disabled:hover {
  border-color: var(--line);
  background: rgba(40, 35, 29, 0.86);
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(560px, 680px);
  gap: 28px;
  align-items: start;
}

.places,
.participants {
  min-width: 0;
}

.participants {
  position: sticky;
  top: 20px;
  border-left: 1px solid var(--line);
  padding-left: 24px;
}

.section-title {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title > div {
  min-width: 0;
  flex: 1;
}

.day-theme-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  max-width: 680px;
}

.day-theme-field {
  display: grid;
  gap: 6px;
}

.day-theme-field span {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
}

.day-theme-field input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171511;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-weight: 700;
}

.day-theme-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 165, 152, 0.22);
  outline: none;
}

.day-theme-field input:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.82;
}

.save-theme-button {
  min-width: 108px;
}

.current-day-date {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.ghost-button,
.danger-button,
.primary-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.ghost-button {
  background: rgba(40, 35, 29, 0.9);
  border-color: var(--line);
  color: var(--muted);
  padding: 0 12px;
  font-weight: 700;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.primary-button,
.danger-button {
  min-width: 130px;
  padding: 0 16px;
  color: #ffffff;
  font-weight: 850;
}

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

.primary-button:hover,
.primary-button:focus-visible {
  background: #37b5a4;
}

.create-day-button {
  align-self: center;
  min-width: 108px;
  margin-bottom: 6px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.place-card {
  appearance: none;
  width: 100%;
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  box-shadow: 0 6px 18px rgba(31, 28, 24, 0.06);
}

.place-card:hover,
.place-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  outline: none;
}

.place-card.is-booked {
  background: var(--booked);
  border-color: var(--booked-line);
}

.place-card.is-partial {
  background: var(--partial);
  border-color: var(--partial-line);
}

.place-main {
  display: grid;
  gap: 7px;
}

.place-title {
  font-size: 18px;
  line-height: 1.18;
  font-weight: 850;
}

.place-detail {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

.place-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 28px;
  border-radius: 999px;
  background: #332d25;
  color: var(--muted);
  padding: 3px 9px;
  white-space: nowrap;
}

.place-card.is-booked .status-pill {
  background: #2f8e52;
  color: #ffffff;
}

.place-card.is-partial .status-pill {
  background: #b2780f;
  color: #ffffff;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(33, 30, 25, 0.92);
}

.participants .table-wrap {
  overflow-x: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.3;
}

th {
  color: var(--muted);
  background: #2d271f;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.participants th:nth-child(1),
.participants td:nth-child(1) {
  width: 18%;
}

.participants th:nth-child(2),
.participants td:nth-child(2) {
  width: 19%;
}

.participants th:nth-child(3),
.participants td:nth-child(3) {
  width: 12%;
}

.participants th:nth-child(4),
.participants td:nth-child(4) {
  width: 35%;
}

.participants th:nth-child(5),
.participants td:nth-child(5) {
  width: 16%;
}

.participants td {
  overflow-wrap: anywhere;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr.is-paid td {
  background: rgba(23, 61, 41, 0.54);
}

.paid-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-dark);
  font-weight: 800;
  white-space: nowrap;
}

.paid-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.empty-state {
  margin: 0;
  padding: 20px 14px;
  color: var(--muted);
}

.table-wrap.has-rows .empty-state {
  display: none;
}

.booking-dialog {
  width: min(620px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.users-dialog {
  width: min(780px, calc(100% - 28px));
}

.users-table-wrap table {
  min-width: 650px;
}

.booking-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.booking-form {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.booking-slots {
  display: grid;
  gap: 12px;
}

.player-slot {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #211d18;
  padding: 14px;
}

.player-slot legend {
  padding: 0 6px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
}

.slot-user-tools {
  display: grid;
  grid-template-columns: minmax(150px, max-content) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.slot-user-tools .ghost-button {
  min-height: 46px;
}

.slot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: end;
}

.icon-button {
  width: 40px;
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #332d25;
  border-color: var(--line);
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: #40372d;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.field input,
.field select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171511;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.field select {
  cursor: pointer;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 157, 142, 0.24);
}

.field input:disabled,
.field select:disabled,
.slot-user-tools .ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-error {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 750;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dialog-actions-right {
  justify-content: flex-end;
}

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

.danger-button:hover,
.danger-button:focus-visible {
  background: #b93838;
}

.danger-button.is-hidden {
  visibility: hidden;
}

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

  .participants {
    position: static;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 22px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding: 16px 0 22px;
  }

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

  .topbar-right,
  .account-box {
    justify-items: stretch;
    justify-content: flex-start;
  }

  h1 {
    font-size: 30px;
  }

  .stats {
    justify-content: flex-start;
  }

  .day-switcher {
    align-items: stretch;
    flex-direction: column;
    padding-bottom: 12px;
  }

  .auth-panel {
    grid-template-columns: 1fr;
  }

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

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

  #authForm.is-login .auth-form-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
  }

  .create-day-button {
    width: 100%;
    margin-bottom: 0;
  }

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

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

  .day-theme-form {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .save-theme-button {
    width: 100%;
  }

  .participants .table-wrap {
    border: 0;
    background: transparent;
  }

  .participants table,
  .participants tbody,
  .participants tr,
  .participants td {
    display: block;
    width: 100%;
  }

  .participants thead {
    display: none;
  }

  .participants tbody {
    display: grid;
    gap: 10px;
  }

  .participants tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(33, 30, 25, 0.92);
    overflow: hidden;
    padding: 8px 12px;
  }

  .participants tbody tr.is-paid {
    border-color: rgba(63, 180, 109, 0.5);
  }

  .participants tbody tr.is-paid td {
    background: transparent;
  }

  .participants td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }

  .participants td:last-child {
    border-bottom: 0;
  }

  .participants td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
  }

  .participants .paid-check {
    justify-content: flex-start;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .slot-user-tools {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .danger-button {
    width: 100%;
  }
}
