:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe5ef;
  --text: #1f2937;
  --muted: #667085;
  --primary: #176b87;
  --primary-dark: #124f65;
  --accent: #d97706;
  --danger: #b42318;
  --success: #027a48;
  --shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #102a43;
  color: white;
  padding: 22px 16px;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #4fb3bf;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #bcccdc;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d9e2ec;
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #1f4e5f;
  color: white;
}

.upload-progress {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #d9e2ec;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.2s ease;
}

.shell {
  min-height: 100vh;
  margin-left: 248px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 251, 0.92);
  padding: 18px 28px;
  backdrop-filter: blur(12px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
}

.admin-badge span {
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 24px 28px 40px;
}

.admin-locked .sidebar,
.admin-locked .topbar {
  display: none;
}

.admin-locked .shell {
  display: grid;
  min-height: 100vh;
  margin-left: 0;
  place-items: center;
}

.admin-locked .content {
  width: min(460px, calc(100% - 32px));
  padding: 0;
}

.admin-login-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  padding: 0 0 24px;
  color: var(--text);
}

.admin-login-panel .field {
  margin-bottom: 14px;
}

.admin-login-panel .full {
  width: 100%;
}

.auth-help {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
  margin-bottom: 16px;
}

.auth-help p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-help code {
  display: block;
  margin-top: 10px;
  border-radius: 6px;
  background: #102a43;
  color: white;
  padding: 12px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  word-break: break-all;
}

.secret-box {
  display: inline-block;
  border-radius: 6px;
  background: #102a43;
  color: white;
  padding: 8px 10px;
  font-family: Consolas, monospace;
  font-weight: 800;
  letter-spacing: 1px;
  word-break: break-all;
}

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

.stat,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

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

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  overflow: hidden;
}

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

.panel-header h2 {
  font-size: 16px;
}

.panel-body {
  padding: 16px 18px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

td {
  font-size: 14px;
}

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

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.normal,
.badge.active,
.badge.completed,
.badge.claimed,
.badge.approved {
  background: #dcfae6;
  color: var(--success);
}

.badge.pending,
.badge.reviewing,
.badge.in_progress {
  background: #fef0c7;
  color: #b54708;
}

.badge.pending_authorization,
.badge.pending-authorization,
.badge.frozen,
.badge.rejected {
  background: #fee4e2;
  color: var(--danger);
}

.badge.combo {
  background: #e0f2fe;
  color: #026aa2;
}

.badge.normal-order {
  background: #eef4ff;
  color: #3538cd;
}

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

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
}

.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn:disabled:hover {
  border-color: var(--line);
  color: inherit;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.danger {
  border-color: #fecdca;
  color: var(--danger);
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  display: none;
  border-radius: 8px;
  background: #102a43;
  color: white;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.modal.show {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 42, 67, 0.36);
}

.modal-panel {
  position: absolute;
  inset: 48px 48px 48px auto;
  display: flex;
  flex-direction: column;
  width: min(980px, calc(100vw - 96px));
  border-radius: 8px;
  background: white;
  box-shadow: 0 24px 80px rgba(16, 42, 67, 0.28);
}

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

.modal-header h2 {
  font-size: 18px;
}

.modal-header p {
  margin-top: 5px;
  color: var(--muted);
}

.modal-body {
  overflow: auto;
  padding: 18px 20px 22px;
}

.icon-btn {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

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

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

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

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
}

.field textarea {
  resize: vertical;
}

.section-gap {
  margin-top: 18px;
}

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

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

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

.info-item strong {
  font-size: 18px;
}

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

.combo-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.save-result {
  min-height: 22px;
  margin-top: 10px;
  color: var(--success);
  font-weight: 700;
}

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

.material-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.material-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f2f4f7;
}

.material-card div {
  padding: 10px;
}

.material-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-config-list {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.content-config-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.content-config-card h4 {
  margin: 0 0 12px;
  font-size: 18px;
}

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

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

  .shell {
    margin-left: 0;
  }

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

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

  .content {
    padding: 18px;
  }

  .modal-panel {
    inset: 24px 14px;
    width: auto;
  }

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

  .info-strip,
  .combo-items,
  .material-grid {
    grid-template-columns: 1fr;
  }
}
