:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #111827;
  --muted: #7a8494;
  --line: #e4e9f2;
  --accent: #ff4662;
  --accent-soft: #fff0f3;
  --green: #17a673;
  --blue: #2563eb;
  --amber: #b7791f;
  --danger: #dc2626;
  --sidebar: #101827;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 238px;
  background: var(--sidebar);
  color: #fff;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  line-height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #39c7ff, var(--accent));
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #94a3b8;
  font-size: 12px;
}

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

.nav a {
  color: #d7deea;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  margin-left: 238px;
  padding: 24px 28px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
}

.page-subtitle {
  margin-top: 6px;
  color: var(--muted);
}

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

.admin-link,
.logout {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.admin-link {
  color: var(--blue);
}

.flash-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  background: #eef2ff;
  color: #3730a3;
}

.flash.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.flash.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.stat {
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 14px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.stat.warn strong,
.price {
  color: var(--accent);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.quick-grid a {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  text-decoration: none;
  font-weight: 700;
}

.quick-grid a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 800;
}

td input,
td select,
td textarea,
.filter-form input,
.filter-form select,
.admin-form input,
.admin-form select,
.admin-form textarea,
.actions input,
.actions select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.table-scroll {
  overflow-x: auto;
}

td textarea {
  min-height: 58px;
  padding: 8px 10px;
  resize: vertical;
}

.admin-form textarea {
  padding: 10px;
  resize: vertical;
}

.admin-form input[type="file"],
.image-upload input[type="file"] {
  height: auto;
  padding: 6px;
  font-size: 12px;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-weight: 400;
}

.filter-form input {
  width: 220px;
}

.filter-form select {
  width: 140px;
}

.filter-form button,
.admin-form button,
.mini-btn {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.mini-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.mini-btn.danger {
  background: var(--danger);
}

.mini-btn.secondary {
  background: #64748b;
}

.badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.muted-badge {
  background: #f1f5f9;
  color: #64748b;
}

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

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

.form-panel {
  padding-bottom: 4px;
}

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

.admin-form.stacked,
.settings-form {
  grid-template-columns: 1fr;
}

.product-form,
.player-form,
.order-create-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: #475467;
  font-size: 13px;
  font-weight: 700;
}

.admin-form .wide {
  grid-column: span 2;
}

.admin-form .checkbox,
.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #475467;
}

.admin-form .checkbox input,
.inline-check input {
  width: auto;
  min-height: auto;
}

.admin-form button {
  align-self: end;
}

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

.actions form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.actions input {
  width: 130px;
}

.announcement-table {
  min-width: 1180px;
}

.announcement-copy {
  min-width: 260px;
}

.announcement-copy,
.stacked-fields,
.status-stack {
  display: grid;
  gap: 8px;
}

.stacked-fields {
  min-width: 205px;
}

.split-inputs {
  display: grid;
  gap: 8px;
  min-width: 100px;
}

.split-inputs input + input {
  margin-top: 4px;
}

.order-actions {
  min-width: 330px;
}

.order-actions select {
  width: 120px;
}

.url-cell {
  max-width: 460px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-cell {
  min-width: 210px;
}

.image-upload {
  display: grid;
  justify-items: start;
  gap: 7px;
}

.image-upload a {
  display: inline-flex;
}

.image-upload small {
  color: var(--muted);
  font-size: 12px;
}

.image-preview,
.image-placeholder {
  width: 92px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.image-preview {
  display: block;
  object-fit: cover;
}

.image-preview.square {
  width: 64px;
  border-radius: 10px;
}

.image-preview.banner {
  width: 120px;
}

.image-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.voice-cell {
  min-width: 240px;
}

.voice-upload {
  display: grid;
  gap: 7px;
}

.voice-upload input[type="file"] {
  height: auto;
  padding: 6px;
  font-size: 12px;
}

.voice-upload small,
.voice-placeholder {
  color: var(--muted);
  font-size: 12px;
}

.voice-preview {
  width: 220px;
  height: 34px;
}

.coupon-card {
  margin-top: 18px;
}

.coupon-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.coupon-form small {
  color: var(--muted);
  font-size: 11px;
}

.coupon-grant-form {
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
}

.coupon-delete-form {
  margin-top: 12px;
  text-align: right;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: linear-gradient(135deg, #eef4ff, #f7f7fb);
}

.login-card {
  width: 380px;
  padding: 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

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

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

.login-card label {
  display: block;
  margin: 14px 0 8px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.login-card button {
  width: 100%;
  height: 44px;
  margin-top: 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.error {
  padding: 10px 12px;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 8px;
}

@media (max-width: 1180px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
  }

  .two-col,
  .admin-form,
  .product-form,
  .player-form,
  .order-create-form {
    grid-template-columns: 1fr;
  }

  .coupon-form,
  .coupon-grant-form {
    grid-template-columns: 1fr;
  }
}
