:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --strong-line: #b9c4d4;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --green: #0f8f70;
  --red: #c03535;
  --shadow: 0 20px 60px rgba(20, 31, 55, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  font-weight: 650;
  cursor: pointer;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 650;
  text-decoration: none;
}

button:hover {
  background: var(--primary-2);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost:hover {
  border-color: var(--strong-line);
  background: var(--panel-2);
}

.hidden {
  display: none !important;
}

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

.redeem-page {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 32px;
}

.redeem-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 0.75fr);
  gap: 28px;
  align-items: center;
}

.redeem-copy h1 {
  max-width: 720px;
}

.redeem-copy .muted {
  max-width: 620px;
  font-size: 17px;
  line-height: 1.7;
}

.redeem-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.redeem-points span {
  min-height: 72px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.redeem-panel {
  display: grid;
  gap: 18px;
}

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

.config-box div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.config-box span {
  color: var(--muted);
  font-size: 12px;
}

.config-box strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

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

.status-grid div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.status-grid span {
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.muted,
.panel-heading p {
  color: var(--muted);
  margin-bottom: 0;
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.error-text {
  min-height: 20px;
  color: var(--red);
  margin: 0;
  font-size: 13px;
}

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

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.small-note {
  font-size: 13px;
  line-height: 1.6;
}

.dashboard {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin-bottom: 0;
}

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

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

.stats-grid article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-grid article {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
}

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

.stats-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(480px, 1.1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
  box-shadow: 0 8px 28px rgba(20, 31, 55, 0.04);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

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

.full {
  grid-column: 1 / -1;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
}

.segmented input:checked + label {
  background: var(--primary);
  color: #fff;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.result-list {
  display: grid;
  gap: 12px;
}

.result-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-2);
}

.result-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.result-card h3 {
  margin: 0;
  font-size: 15px;
}

.result-card code {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow-wrap: anywhere;
  color: #111827;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

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

.key-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 520px) 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 750;
}

td code {
  color: #111827;
  overflow-wrap: anywhere;
}

.key-code {
  display: block;
  max-width: 420px;
  line-height: 1.45;
}

.muted-cell {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.ok {
  color: var(--green);
}

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

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

  .redeem-shell {
    grid-template-columns: 1fr;
  }

  .redeem-points {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

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

  .topbar-actions,
  .inline-actions,
  .form-actions {
    width: 100%;
  }

  .topbar-actions button,
  .topbar-actions .button-link,
  .inline-actions button,
  .form-actions button {
    flex: 1;
  }

  .redeem-page {
    padding: 18px;
  }

  .config-box {
    grid-template-columns: 1fr;
  }

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