:root {
  color-scheme: light;
  --bg: #eef4fb;
  --panel: #ffffff;
  --ink: #18263b;
  --text: #42536b;
  --muted: #70809a;
  --line: #dce6f3;
  --soft-line: #edf2f8;
  --blue: #1677ff;
  --green: #2f9d4d;
  --orange: #d88620;
  --red: #d94b4b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
}

body,
button,
input {
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

body {
  color: var(--text);
}

button,
input {
  font-size: 14px;
}

button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

button.primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

button.primary:hover {
  color: #fff;
  background: #0868eb;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 2px solid rgba(22, 119, 255, 0.12);
  border-color: var(--blue);
}

a {
  color: var(--blue);
  text-decoration: none;
}

p,
h1,
h2 {
  margin: 0;
}

.app-shell {
  width: 100vw;
  min-height: 100vh;
}

.login-view {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(24, 38, 59, 0.08);
}

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

.brand-badge,
.admin-brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.brand h1,
.topbar h1,
.panel h2 {
  color: var(--ink);
}

.brand p,
.topbar p,
.panel p {
  margin-top: 4px;
  color: var(--muted);
}

.login-form,
.user-form,
.package-form {
  display: grid;
  gap: 14px;
}

.login-form label,
.user-form label,
.package-form label {
  display: grid;
  gap: 8px;
}

.login-form span,
.user-form span,
.package-form span,
.field-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.login-tip {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-status {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #d7e4f3;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbff;
  font-size: 13px;
  line-height: 1.5;
}

.form-status.ok {
  border-color: #b8e2c1;
  color: var(--green);
  background: #effaf2;
}

.form-status.error {
  border-color: #f0b0b0;
  color: var(--red);
  background: #fff0f0;
}

.dashboard-view {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  min-height: 100vh;
}

.admin-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fff;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 0 18px;
  border-bottom: 1px solid var(--soft-line);
}

.admin-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #1e2a3a;
}

.admin-brand strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.admin-brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.admin-menu {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  padding: 16px 12px;
  overflow: auto;
}

.admin-menu-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border-color: transparent;
  color: var(--text);
  text-align: left;
  background: transparent;
}

.admin-menu-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  border-radius: 5px;
  color: #6f829e;
  background: #f2f6fb;
  font-size: 14px;
  font-weight: 800;
}

.admin-menu-item.active {
  border-color: #d6e6ff;
  color: var(--blue);
  background: #eef6ff;
  font-weight: 800;
}

.admin-sidebar-footer {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--soft-line);
}

.admin-content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-main {
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.admin-view {
  display: none;
}

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

.status-pill {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid #cad7e8;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
}

.status-pill.ok {
  border-color: #b8e2c1;
  color: var(--green);
}

.status-pill.warn {
  border-color: #f1d1a2;
  color: var(--orange);
}

.status-pill.error {
  border-color: #f0b0b0;
  color: var(--red);
}

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

.stat-panel {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

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

.stat-panel strong {
  color: var(--ink);
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.package-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
}

.points-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.7fr) minmax(620px, 1.3fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 31, 50, 0.42);
}

.modal-panel {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(18, 31, 50, 0.22);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.user-form,
.package-form,
.redemption-form,
.client-package-form,
.build-status-body {
  padding: 18px 20px 20px;
}

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

.redemption-form label {
  display: grid;
  gap: 8px;
}

.redemption-form span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.generated-code-panel {
  display: grid;
  gap: 10px;
  margin: 0 20px 20px;
  padding: 14px;
  border: 1px solid #b8e2c1;
  border-radius: 8px;
  background: #effaf2;
}

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

.generated-code-panel textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #b8e2c1;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: 13px/1.65 Consolas, monospace;
}

.generated-code-panel p {
  color: var(--muted);
  font-size: 12px;
}

.redemption-table-panel {
  min-width: 0;
}

.redemption-code-preview {
  white-space: nowrap;
}

.inline-switch,
.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.inline-switch input,
.feature-item input {
  width: 16px;
  min-height: 16px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-tools input {
  width: 220px;
}

.table-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 520px;
}

.user-list-panel {
  min-height: calc(100vh - 148px);
}

.table-wrap {
  min-height: 0;
  overflow: auto;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--soft-line);
  vertical-align: top;
  font-size: 13px;
}

.row-title {
  color: var(--ink);
  font-weight: 700;
}

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

.tag {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 12px;
}

.tag.green {
  background: #effaf2;
  color: var(--green);
}

.tag.orange {
  background: #fff7ea;
  color: var(--orange);
}

.tag.red {
  background: #fff0f0;
  color: var(--red);
}

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

.quick-actions,
.package-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 20px 20px;
}

.client-package-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border-bottom: 1px solid var(--soft-line);
}

.client-package-form label {
  display: grid;
  gap: 8px;
}

.client-package-form span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.client-package-form input[type="file"] {
  padding: 8px 10px;
}

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

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

.package-library-panel {
  grid-column: 1 / -1;
}

.package-library-panel .package-actions {
  padding: 0;
}

.package-table-wrap {
  max-height: 420px;
}

.logo-uploader {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.logo-uploader strong {
  display: block;
  color: var(--ink);
}

.logo-uploader p {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.app-logo-preview {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #fff;
  background: #1e2a3a;
  font-size: 20px;
  font-weight: 900;
}

.app-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.feature-section {
  display: grid;
  gap: 10px;
}

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

.feature-item {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.feature-item.locked {
  background: #f8fbff;
}

.build-status-body {
  display: grid;
  gap: 14px;
}

.build-status-text {
  color: var(--text);
  line-height: 1.6;
}

.output-link {
  display: inline-flex;
  width: max-content;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #cde0ff;
  border-radius: 6px;
  background: #f5f9ff;
  font-size: 13px;
}

.build-logs {
  min-height: 320px;
  max-height: 520px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #d9e4f2;
  border-radius: 8px;
  color: #dbe7ff;
  background: #172033;
  font: 12px/1.65 Consolas, "Microsoft YaHei UI", monospace;
  white-space: pre-wrap;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

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

@media (max-width: 1180px) {
  .summary-grid,
  .package-grid,
  .points-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .table-panel {
    min-height: 460px;
  }
}

@media (max-width: 760px) {
  .dashboard-view {
    grid-template-columns: 1fr;
    height: auto;
  }

  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    grid-template-rows: auto auto;
  }

  .admin-menu {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .admin-sidebar-footer {
    display: none;
  }

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

  .feature-list {
    grid-template-columns: 1fr;
  }

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

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

  .modal-backdrop {
    padding: 12px;
  }
}
