:root {
  --bg: #f4f7f3;
  --surface: #ffffff;
  --text: #17312f;
  --muted: #63716f;
  --line: #d7e0dd;
  --brand: #14746f;
  --brand-dark: #0d5652;
  --free: #4f9f64;
  --paid: #2563eb;
  --occupied: #e0523f;
  --reserved: #d9a21b;
  --shadow: 0 12px 32px rgba(23, 49, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  min-width: 0;
  text-align: center;
}

.topbar-title strong {
  display: block;
  font-size: 17px;
}

.topbar-title span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 24px;
}

.icon-button:active,
.primary:active,
.action-row:active,
.set-tile:active,
.sector-card:active {
  transform: scale(0.98);
}

.menu {
  position: fixed;
  top: 58px;
  right: 12px;
  z-index: 30;
  width: min(260px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.menu button {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.menu button:last-child {
  border-bottom: 0;
}

.content {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 12px 28px;
}

.sync-error {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #f3b8ae;
  border-radius: 8px;
  background: #fff4f2;
  color: #9f2417;
  font-size: 14px;
  font-weight: 700;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-panel p {
  margin: 0 0 18px;
  color: var(--muted);
}

.pin-input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 24px;
  letter-spacing: 6px;
  text-align: center;
}

.primary {
  width: 100%;
  height: 50px;
  margin-top: 12px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 700;
}

.error {
  min-height: 20px;
  margin-top: 10px;
  color: #b42318;
  font-size: 14px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.sold-summary-card {
  width: 100%;
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 3px 12px rgba(23, 49, 47, 0.06);
}

.sold-summary-card strong {
  font-size: 24px;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.summary-counts span {
  padding: 8px;
  border-radius: 8px;
  background: #eef5f1;
}

.summary-counts b {
  color: var(--text);
}

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

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

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

.sector-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
}

.sector-grid.grid-view {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  overflow: visible;
  scroll-snap-type: none;
}

.sector-card {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 3px 12px rgba(23, 49, 47, 0.06);
}

.sector-grid.grid-view .sector-card {
  aspect-ratio: auto;
  min-height: 124px;
}

.sector-card strong {
  font-size: 18px;
}

.sector-card small {
  color: var(--muted);
}

.mini-dots {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.mini-dot {
  aspect-ratio: 1 / 1;
  min-height: 14px;
  border-radius: 4px;
  background: var(--free);
}

.sector-grid.grid-view .mini-dots {
  gap: 3px;
}

.sector-grid.grid-view .mini-dot {
  min-height: 7px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.set-grid {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.set-tile {
  aspect-ratio: 1.15 / 1;
  min-height: 68px;
  position: relative;
  display: grid;
  padding: 4px;
  border-radius: 8px;
  color: white;
  font-weight: 700;
  line-height: 1.1;
  overflow: hidden;
  border: 1px solid rgba(23, 49, 47, 0.12);
  box-shadow: inset 0 -14px 20px rgba(0, 0, 0, 0.08);
}

.set-label {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(12, 26, 25, 0.38);
  color: white;
  font-size: 10px;
  pointer-events: none;
}

.set-parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  height: 100%;
}

.set-part {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow: inset 0 -8px 14px rgba(0, 0, 0, 0.08);
}

.set-part.umbrella {
  grid-column: 1 / -1;
}

.set-part.selected {
  outline: 3px solid #17312f;
  outline-offset: -3px;
  box-shadow: inset 0 0 0 2px white, inset 0 -8px 14px rgba(0, 0, 0, 0.08);
}

.umbrella-symbol,
.lounger-symbol {
  position: relative;
  display: block;
  color: currentColor;
}

.umbrella-symbol {
  width: 24px;
  height: 20px;
}

.umbrella-symbol::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 10px;
  border-radius: 18px 18px 2px 2px;
  background: currentColor;
}

.umbrella-symbol::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 10px;
  width: 2px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

.lounger-symbol {
  width: 24px;
  height: 16px;
}

.lounger-symbol::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 4px;
  width: 18px;
  height: 4px;
  border-radius: 4px;
  background: currentColor;
  transform: rotate(-10deg);
}

.lounger-symbol::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 3px;
  height: 12px;
  border-radius: 3px;
  background: currentColor;
  transform: rotate(15deg);
}

.set-tile small {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 2;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(12, 26, 25, 0.38);
  font-size: 11px;
  font-weight: 700;
}

.free {
  background: var(--free);
}

.paid {
  background: var(--paid);
}

.occupied {
  background: var(--occupied);
}

.reserved {
  background: var(--reserved);
}

.partial {
  background: linear-gradient(135deg, var(--paid) 0 45%, var(--free) 45% 100%);
}

.set-part.free {
  background: var(--free);
}

.set-part.paid {
  background: var(--paid);
}

.set-part.occupied {
  background: var(--occupied);
}

.set-part.reserved {
  background: var(--reserved);
}

.set-part.paid .umbrella-symbol,
.set-part.paid .lounger-symbol,
.set-part.free .umbrella-symbol,
.set-part.free .lounger-symbol,
.set-part.occupied .umbrella-symbol,
.set-part.occupied .lounger-symbol,
.set-part.reserved .umbrella-symbol,
.set-part.reserved .lounger-symbol {
  color: rgba(255, 255, 255, 0.92);
}

.content-with-checkout {
  padding-bottom: 96px;
}

.item-checkout-bar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 35;
  width: min(520px, calc(100vw - 24px));
  min-height: 64px;
  display: grid;
  grid-template-columns: 44px 1fr minmax(128px, auto);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.item-cancel {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e6efec;
  color: var(--text);
  font-size: 24px;
}

.item-checkout-total strong,
.item-checkout-total span {
  display: block;
}

.item-checkout-total span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.item-checkout-button {
  height: 44px;
  margin-top: 0;
}

.item-checkout-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.item-charge-list {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(12, 26, 25, 0.42);
}

.modal {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.reservation-details {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  font-size: 13px;
}

.reservation-details strong {
  font-size: 15px;
}

.reservation-details span {
  color: var(--muted);
}

.modal-body {
  padding: 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

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

.action-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  text-align: left;
}

.action-row-with-price {
  cursor: default;
}

.action-main {
  min-height: 38px;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.action-row strong {
  display: block;
  font-size: 17px;
}

.price-tools {
  display: grid;
  grid-template-columns: 38px 66px 38px;
  align-items: center;
  gap: 4px;
}

.price-tools button {
  height: 38px;
  border-radius: 8px;
  background: #e6efec;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

.price-tools span {
  text-align: center;
  font-weight: 700;
}

.danger {
  color: #b42318;
}

.plain-list {
  display: grid;
  gap: 10px;
}

.history-day-card {
  width: 100%;
  color: var(--text);
  text-align: left;
}

.history-rankings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.history-rank-card,
.history-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.history-rank-card > strong,
.history-section h2 {
  display: block;
  margin: 0 0 10px;
  font-size: 18px;
}

.rank-row {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.rank-row span,
.history-rank-card > span {
  color: var(--muted);
  font-size: 13px;
}

.history-section {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.admin-tabs button {
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.admin-tabs button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.admin-time-grid,
.admin-composition-grid,
.admin-sector-grid,
.admin-user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-section-title {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.admin-section-title strong {
  font-size: 18px;
}

.admin-add-button {
  margin-top: 0;
}

.admin-inline-button {
  width: auto;
  min-width: 128px;
  height: 42px;
  margin-top: 0;
  padding: 0 14px;
}

.admin-set-row .field {
  margin-bottom: 0;
}

.admin-sector-row .field {
  margin-bottom: 0;
}

.admin-user-row .field {
  margin-bottom: 0;
}

.admin-save-row {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.list-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.list-item strong {
  display: block;
}

.list-item span,
.list-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

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

@media (max-width: 520px) {
  .modal-backdrop {
    align-items: center;
    justify-items: center;
    padding: 12px;
  }

  .modal {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

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

  .history-rankings {
    grid-template-columns: 1fr;
  }

  .metric {
    padding: 10px;
  }

  .metric strong {
    font-size: 18px;
  }

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

  .sector-card {
    min-height: 112px;
  }

  .set-grid {
    gap: 4px;
  }

  .set-tile {
    min-height: 72px;
    aspect-ratio: 1.15 / 1;
    font-size: 12px;
  }

  .set-label {
    max-width: calc(100% - 4px);
    overflow: hidden;
    font-size: 8px;
  }

  .set-parts {
    gap: 2px;
  }

  .umbrella-symbol {
    width: 20px;
    height: 18px;
  }

  .umbrella-symbol::before {
    width: 17px;
    height: 9px;
  }

  .umbrella-symbol::after {
    left: 9px;
    height: 9px;
  }

  .lounger-symbol {
    width: 20px;
    height: 14px;
  }

  .item-checkout-bar {
    grid-template-columns: 40px 1fr 112px;
  }
}
