:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --accent: #3b82f6;
  --danger: #b42318;
  --success: #067647;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
 body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); letter-spacing: 0; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
  .portal-header { min-height: 64px; padding: 0 28px; background: #12346a; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
 .portal-brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; font-weight: 750; white-space: nowrap; line-height: 1; }
 .portal-brand-name { display: inline-flex; align-items: center; min-height: 34px; line-height: 1.2; }
  .portal-brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: #2563eb; border-radius: 8px; box-shadow: 0 6px 14px rgba(37,99,235,.28); }
.portal-header small { color: #bbc4d5; }
  .auth-layout { min-height: calc(100vh - 64px); display: grid; grid-template-columns: minmax(300px, 440px) minmax(360px, 520px); justify-content: center; align-items: center; gap: 48px; padding: 30px 28px; }
  .auth-intro h1 { margin: 0 0 10px; max-width: 560px; color: #12346a; font-size: 38px; line-height: 1.2; }
 .auth-intro > p { color: var(--muted); line-height: 1.65; margin: 0; }
.plan-list { display: grid; gap: 1px; border: 1px solid var(--line); background: var(--line); }
.plan-row { background: var(--surface); padding: 16px 18px; display: grid; grid-template-columns: 76px 1fr; gap: 18px; }
.plan-row strong { color: var(--brand-dark); }
.plan-row span { color: var(--muted); }
.auth-panel { width: min(100%, 440px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 14px 36px rgba(16, 24, 40, .08); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin: -4px 0 24px; }
.tab { border: 0; background: transparent; padding: 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 700; }
.auth-form { display: grid; gap: 17px; }
.auth-form.hidden, .hidden { display: none !important; }
label { display: grid; gap: 7px; font-size: 14px; font-weight: 650; }
  input, select { width: 100%; min-height: 46px; border: 1px solid #c6ccd7; border-radius: 8px; padding: 10px 12px; background: #fff; color: var(--ink); font-size: 16px; }
input:focus, select:focus { outline: 3px solid rgba(37, 99, 235, .14); border-color: var(--brand); }
  .primary, .secondary, .danger-button { min-height: 44px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 700; }
.primary { background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-dark); }
.secondary { background: #fff; color: var(--ink); border-color: #bfc6d2; }
.danger-button { color: var(--danger); background: #fff; border-color: #f0b5ae; }
  .form-message { min-height: 22px; margin: 0; font-size: 14px; color: var(--danger); }
  .form-message.success { color: var(--success); }
  .auth-help { margin: -4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.license-view h2 { margin: 0 0 8px; font-size: 24px; }
.license-view > p { color: var(--muted); line-height: 1.7; }
.account-line { margin: 20px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.account-line strong { color: var(--ink); }
.redeem-form { display: grid; gap: 14px; }
.redeem-form input { text-transform: uppercase; font-family: Consolas, monospace; }
.portal-foot-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
.link-button { border: 0; padding: 8px 0; background: none; color: var(--brand-dark); }

.admin-shell { min-height: 100vh; }
.admin-main { max-width: 1240px; margin: 0 auto; padding: 30px 24px 60px; }
.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.admin-heading h1 { margin: 0 0 6px; font-size: 28px; }
.admin-heading p { margin: 0; color: var(--muted); }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); margin-bottom: 24px; }
.metric { padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.metric strong { font-size: 25px; }
.admin-section { padding: 24px 0 30px; border-top: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 20px; }
.card-form { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 12px; align-items: end; background: #fff; border: 1px solid var(--line); padding: 18px; margin-bottom: 18px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 820px; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #e6e9ef; vertical-align: middle; }
th { background: #f7f8fa; color: #475467; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; padding: 3px 8px; border-radius: 4px; background: #eef2f6; color: #475467; font-size: 12px; font-weight: 700; }
.status.active, .status.unused { background: #e8f7f1; color: var(--success); }
.status.disabled { background: #fff1ef; color: var(--danger); }
.status.used { background: #fff5e7; color: #9a5b05; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions button { padding: 5px 9px; min-height: 32px; }
.generated { background: #172033; color: #f8fafc; padding: 16px; margin-bottom: 18px; border-radius: 5px; }
.generated-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.generated pre { margin: 0; white-space: pre-wrap; word-break: break-all; line-height: 1.7; }
.admin-message { color: var(--danger); min-height: 22px; }
.admin-message.success { color: var(--success); }
  @media (max-width: 820px) {
    body { overflow-x: hidden; }
    .auth-layout { grid-template-columns: 1fr; gap: 18px; padding: 22px 18px; }
  .auth-intro h1 { font-size: 30px; }
    .auth-panel { width: 100%; }
    .portal-header { min-height: 70px; padding: 12px 18px; align-items: flex-start; flex-wrap: wrap; gap: 8px 14px; }
    .portal-header-note { flex-basis: 100%; }
    input, select { font-size: 16px; min-height: 48px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .card-form { grid-template-columns: 1fr; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
 }

@media (max-width: 430px) {
  .portal-header-note { font-size: 11px; }
  .auth-layout { padding: 22px 14px; }
  .auth-panel { padding: 22px 18px; }
}
