:root {
  --ink: #14263d;
  --ink-soft: #293c52;
  --muted: #796d61;
  --paper: #efe6d7;
  --surface: #fffaf2;
  --line: #dccfbe;
  --gold: #d7a247;
  --blue: #315b9d;
  --brand-red: #7c2638;
  --wood: #b56c3f;
  --coral: #c96a45;
  --danger: #a4382e;
  --sidebar: #173d7b;
  --lime: var(--gold);
  --teal: var(--blue);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #766a5e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-view {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--sidebar);
}

.login-view::before {
  content: "";
  position: absolute;
  top: -160px;
  left: -130px;
  width: 430px;
  height: 310px;
  background: var(--lime);
  transform: rotate(24deg);
  opacity: 0.9;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  padding: 34px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.brand-image {
  display: block;
  width: 58px;
  height: 58px;
  max-width: 58px;
  max-height: 58px;
  flex: none;
  object-fit: cover;
  border: 2px solid rgba(255, 248, 236, 0.74);
  border-radius: 8px;
  background: var(--sidebar);
}

.login-brand {
  width: 48px !important;
  height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
}

.sidebar-brand-image {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  border-width: 1px;
}

.login-card h1 {
  margin-top: 8px;
  font-size: 30px;
}

.login-note {
  margin-top: 8px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 14px;
}

.login-card .field + .field {
  margin-top: 12px;
}

.field,
.inline-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span,
.inline-field > span,
.checkin-form label > span {
  color: #62564b;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #d4c6b5;
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(49, 91, 157, 0.12);
}

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid #bc8735;
  background: var(--lime);
  color: var(--ink);
}

.secondary-button {
  border: 1px solid #d3c5b4;
  background: var(--surface);
  color: var(--ink);
}

.compact-button,
.small-button {
  min-height: 38px;
  padding: 7px 13px;
  font-size: 12px;
}

.login-button {
  width: 100%;
  margin-top: 18px;
}

.form-error {
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-copy {
  min-width: 0;
  overflow: hidden;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-brand strong {
  font-size: 16px;
}

.sidebar-brand span {
  margin-top: 4px;
  color: #c1d0e8;
  font-size: 11px;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 20px;
}

.nav-item {
  min-height: 42px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c0cee3;
  text-align: left;
  font-size: 13px;
}

.nav-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-item.active {
  background: var(--lime);
  color: var(--ink);
  font-weight: 800;
}

.sidebar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding: 18px 8px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #c1d0e8;
  font-size: 11px;
}

.sidebar-account {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

#currentAdminLabel {
  overflow: hidden;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff8ec;
  font-size: 11px;
}

.workspace {
  min-width: 0;
  padding: 26px 30px 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid #d8c9b7;
}

.topbar h1 {
  margin-top: 5px;
  font-size: 30px;
}

.checkin-form {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.checkin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkin-form input {
  width: 210px;
  min-height: 38px;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  z-index: 50;
  top: 20px;
  right: 24px;
  max-width: 380px;
  padding: 13px 17px;
  border-radius: 6px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 12px 32px rgba(20, 38, 61, 0.22);
  font-size: 13px;
}

.view-section {
  display: none;
  padding-top: 24px;
}

.view-section.active {
  display: block;
}

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

.stat-card {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-card.accent {
  border-color: #bc8735;
  background: var(--lime);
}

.stat-card.teal {
  border-color: #6689bf;
  background: #e7eef8;
}

.stat-label {
  color: #665a4e;
  font-size: 12px;
}

.stat-value {
  display: block;
  margin-top: 18px;
  font-size: 28px;
  font-weight: 900;
}

.stat-unit {
  margin-left: 4px;
  color: #665a4e;
  font-size: 11px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 26px 0 14px;
}

.toolbar.controls {
  justify-content: flex-start;
  align-items: flex-end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toolbar h2 {
  font-size: 18px;
}

.section-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.inline-field {
  min-width: 150px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #eee4d6;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f5ecdf;
  color: #665a4e;
  font-size: 11px;
  font-weight: 800;
}

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

.table-primary {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.table-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.status-badge {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 4px;
  background: #eee4d6;
  color: #605448;
  font-size: 10px;
  font-weight: 800;
}

.level-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}

.plan-level-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 50%;
  background: #48515c;
}

.plan-level-dot.level-gold {
  background: #c59a36;
}

.plan-level-dot.level-silver {
  background: #9eacb9;
}

.plan-level-dot.level-bronze {
  background: #ae6845;
}

.plan-level-dot.level-iron {
  background: #48515c;
}

.level-gold {
  background: #d4a63c;
  color: #2d2109;
}

.level-silver {
  background: #c5ced7;
  color: #273341;
}

.level-bronze {
  background: #b7744e;
  color: #fff7ee;
}

.level-iron {
  background: #48515c;
  color: #fff;
}

.level-single {
  background: #dce7e5;
  color: #294a46;
}

.level-times {
  background: #d8ecee;
  color: #234c52;
}

.role-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.role-owner {
  background: #f1dfb2;
  color: #674d16;
}

.role-manager {
  background: #dfe8f5;
  color: #294e88;
}

.role-staff {
  background: #e4ebe7;
  color: #36564b;
}

.status-badge.success {
  background: #e7eef8;
  color: #294e88;
}

.status-badge.waiting {
  background: #f5e4c7;
  color: #8a541e;
}

.status-badge.closed {
  background: #eceae5;
  color: #746c64;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-action {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #d2c4b3;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

.table-action.primary {
  border-color: #bc8735;
  background: var(--lime);
}

.table-action.danger {
  border-color: #e4b8ae;
  background: #fbece7;
  color: var(--danger);
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.entity-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.entity-card h3 {
  margin: 0;
  font-size: 18px;
}

.entity-price {
  margin-top: 18px;
  font-size: 28px;
  font-weight: 900;
}

.entity-price small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.entity-meta {
  margin-top: 12px;
  color: #675b4f;
  font-size: 12px;
  line-height: 1.7;
}

.entity-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}

.entity-benefits span {
  padding: 4px 7px;
  border-radius: 4px;
  background: #f1e7d8;
  color: #65594d;
  font-size: 10px;
}

.entity-actions {
  display: flex;
  gap: 7px;
  margin-top: 16px;
}

.settings-form {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

.modal-backdrop {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 29, 43, 0.68);
}

.modal {
  width: min(100%, 660px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.25);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin-top: 4px;
  font-size: 22px;
}

.icon-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #d3c5b4;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
}

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

.court-price-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.court-price-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #f4efe6;
  color: var(--muted);
  font-size: 12px;
}

.court-price-summary div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.court-price-summary strong {
  color: var(--ink);
  font-size: 15px;
}

.court-price-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.court-price-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.court-price-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  color: var(--ink);
  font-size: 12px;
}

.court-price-input {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.court-price-input input {
  width: 82px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #d3c5b4;
  border-radius: 5px;
  background: #ffffff;
  color: var(--ink);
  text-align: right;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  grid-column: 1 / -1;
  margin-top: 6px;
}

.scanner-modal {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.scanner-reader {
  min-height: 320px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sidebar);
}

.scanner-reader video {
  width: 100% !important;
  border-radius: 8px;
  object-fit: cover;
}

.scanner-reader img {
  display: none;
}

.scanner-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.scanner-cancel {
  align-self: center;
}

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

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .sidebar-brand {
    padding-bottom: 14px;
  }

  .main-nav {
    flex-direction: row;
    overflow-x: auto;
    margin-top: 14px;
    padding-bottom: 4px;
  }

  .nav-item {
    min-width: max-content;
  }

  .sidebar-bottom {
    display: none;
  }

  .workspace {
    padding: 20px 14px 38px;
  }

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

  .checkin-form {
    width: 100%;
  }

  .checkin-form label {
    flex: 1;
  }

  .checkin-form input {
    width: 100%;
  }

  .stats-grid,
  .entity-grid,
  .form-grid,
  .modal-form {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar.controls {
    align-items: stretch;
  }

  .court-price-grid {
    grid-template-columns: 1fr;
  }

  .court-price-summary {
    flex-direction: column;
  }

  .inline-field {
    min-width: 0;
  }
}

