:root {
  --bg: #030405;
  --panel: #0b0c0f;
  --panel-soft: #12100c;
  --line: rgba(218, 157, 57, .34);
  --line-soft: rgba(255, 255, 255, .08);
  --gold: #f5c05f;
  --gold-2: #d99428;
  --text: #f8e1b8;
  --muted: #9b8b72;
  --danger: #ff7d5e;
  --green: #76d391;
  --blue: #78b9ff;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(55, 35, 11, .28), transparent 260px),
    linear-gradient(135deg, rgba(245, 192, 95, .06), transparent 38%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -18px -14px 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: rgba(3, 4, 5, .96);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-title {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.brand-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.save-pill {
  flex: 0 0 auto;
  min-width: 78px;
  min-height: 36px;
  border: 0;
  border-radius: 18px;
  color: #4e2810;
  background: linear-gradient(180deg, #ffd47d, #d99428);
  font-weight: 900;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  flex: 0 0 auto;
  min-width: 62px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(245, 192, 95, .22);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(12, 13, 16, .86);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.tab.active {
  color: var(--gold);
  border-color: var(--gold-2);
  background: rgba(245, 192, 95, .12);
}

.content,
.stack {
  width: 100%;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.card {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 11, 13, .92);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .24);
}

.section-title {
  margin: 2px 0 12px;
  color: var(--gold);
  font-size: 17px;
  line-height: 1.25;
  font-weight: 900;
}

.sub-title {
  color: var(--gold);
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.metric-value {
  color: var(--gold);
  font-size: 25px;
  line-height: 1.15;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.todo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.todo-row:first-child {
  border-top: 0;
}

.todo-main {
  min-width: 0;
}

.todo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.title-row {
  align-items: flex-start;
}

.badge {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid rgba(245, 192, 95, .35);
  border-radius: 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.badge.green {
  color: var(--green);
  border-color: rgba(118, 211, 145, .45);
}

.badge.danger {
  color: var(--danger);
  border-color: rgba(255, 125, 94, .45);
}

.pay-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.pay-note {
  margin-top: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  color: var(--text);
  background: rgba(2, 3, 5, .82);
  outline: none;
}

.textarea {
  min-height: 78px;
  padding: 10px 12px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(245, 192, 95, .72);
}

.upload-input {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  width: 100%;
  margin-top: 10px;
}

.category-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 8px;
  width: min(100%, 560px);
}

.table-fields {
  width: min(100%, 520px);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(245, 192, 95, .35);
  border-radius: 8px;
  color: var(--gold);
  background: rgba(245, 192, 95, .08);
  font-weight: 800;
}

.btn.primary {
  color: #4e2810;
  border-color: transparent;
  background: linear-gradient(180deg, #ffd47d, #d99428);
}

.btn.danger {
  color: #ffcfbd;
  border-color: rgba(255, 125, 94, .45);
  background: rgba(255, 125, 94, .08);
}

.btn.ghost {
  color: var(--muted);
  border-color: rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .03);
}

.btn.compact {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  font-size: 12px;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.seat {
  min-height: 108px;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
}

.seat.empty {
  color: var(--muted);
}

.seat.reserved {
  border-color: rgba(120, 185, 255, .58);
}

.seat.playing {
  border-color: rgba(245, 192, 95, .72);
}

.seat-avatar,
.member-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(245, 192, 95, .36);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(245, 192, 95, .08);
  font-weight: 900;
}

.seat-avatar {
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
}

.member-avatar {
  width: 42px;
  height: 42px;
}

.seat-avatar img,
.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.seat-no {
  color: var(--gold);
  font-weight: 900;
}

.seat-player {
  width: 100%;
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.category-add-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed rgba(245, 192, 95, .28);
  border-radius: 8px;
  background: rgba(245, 192, 95, .045);
}

.category-product-form {
  margin-top: 10px;
}

.sub-card {
  padding: 12px;
  border: 1px solid rgba(245, 192, 95, .2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
}

.preview-wrap {
  margin-top: 12px;
}

.preview-img {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(245, 192, 95, .22);
  background: rgba(255, 255, 255, .04);
}

.member-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-items {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.application-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.franchise-card .compact-list {
  margin-top: 12px;
}

.empty {
  min-height: 42px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.bottom-toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 50;
  padding: 12px 14px;
  border: 1px solid rgba(245, 192, 95, .34);
  border-radius: 8px;
  color: var(--gold);
  background: rgba(6, 7, 9, .96);
  transform: translateY(120%);
  transition: transform .2s ease;
}

.bottom-toast.show {
  transform: translateY(0);
}

.loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

@media (max-width: 420px) {
  .brand-title {
    font-size: 18px;
  }

  .inline-form,
  .category-fields {
    grid-template-columns: 1fr;
  }

  .inline-form .btn {
    width: 100%;
  }

  .row {
    align-items: flex-start;
  }

  .todo-row {
    grid-template-columns: 1fr;
  }

  .todo-actions {
    justify-content: flex-start;
  }
}

@media (min-width: 780px) {
  .app-shell {
    padding-inline: 18px;
  }

  .topbar {
    margin-inline: -18px;
    padding-inline: 18px;
  }

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

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