:root {
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #172033;
  line-height: 1.5;
  background: #334bd5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 32px 18px;
  padding: max(32px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  display: flex;
  background: linear-gradient(125deg, #1769e9 0%, #334bd5 48%, #782ab8 100%);
}

main { width: min(100%, 540px); margin: auto; }

.panel {
  padding: 29px 34px 28px;
  border: 1px solid #ffffffb3;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 70px #101d5c35;
}

h1 { margin: 0 0 25px; text-align: center; font-size: 1.75rem; font-weight: 650; letter-spacing: .02em; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .56; cursor: default; }
button:focus-visible { outline: 3px solid #b4aaff; outline-offset: 3px; }

input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid #d9dfe8;
  border-radius: 10px;
  color: #172033;
  background: #fff;
  font-size: 1rem;
}

input::placeholder { color: #647087; }
input:focus { outline: none; border-color: #5261de; box-shadow: 0 0 0 3px #5261de25; }
input[aria-invalid="true"] { border-color: #be5668; }
input:disabled { background: #f6f7fa; }

.primary {
  min-height: 48px;
  min-width: 90px;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(120deg, #2765dd, #7440c8);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 3px 9px #4761cf26;
}

.primary:hover:enabled { filter: brightness(1.08); }

.text-button {
  min-height: 44px;
  padding: 5px 3px;
  border: 0;
  border-radius: 5px;
  color: #464fa1;
  background: transparent;
  font-size: .875rem;
  white-space: nowrap;
}

.text-button:hover:enabled { text-decoration: underline; }

.details { padding: 5px 18px; border-radius: 14px; background: #f7f8fa; }
.details dl, .details dd { margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; min-height: 58px; gap: 14px; border-bottom: 1px solid #e6e9ef; }
.row dt, .row label { flex-shrink: 0; color: #5b667b; font-size: .9375rem; }
.row dd { text-align: right; font-size: .9375rem; font-weight: 550; overflow-wrap: anywhere; }
.expiry-checked { display: block; color: #5e687e; font-size: .75rem; font-weight: 400; }
.row:last-child:not(.device-row) { border-bottom: 0; }
.device-row { padding: 8px 0; }
.device-row input { max-width: 278px; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 99px; color: #505b72; background: #e9edf5; }
.badge.active { color: #1d683f; background: #e7f5ed; }
.badge.inactive, .badge.disabled { color: #9b344c; background: #fcebf0; }
.badge.expired, .badge.unverified { color: #87510c; background: #fff0da; }

.recharge-form { margin-top: 24px; }
.recharge-form label { display: block; margin-bottom: 10px; font-size: 1.1875rem; font-weight: 600; }
.controls { display: flex; gap: 10px; }
.footer { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.footer .hint { margin: 0 auto 0 0; }
.hint { margin: 12px 0 0; color: #5e687e; font-size: .8125rem; }
.hint code { color: #34437a; overflow-wrap: anywhere; }
.feedback { margin: 9px 0 0; color: #53607a; font-size: .875rem; overflow-wrap: anywhere; }
.feedback.error { color: #a23c54; }
.feedback.success { color: #1d683f; }
.feedback.pending { color: #87510c; }

#loading { text-align: center; }
#loading .feedback { margin: 0; }

@media (max-width: 440px) {
  body { padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .panel { padding: 20px 17px 17px; border-radius: 18px; }
  h1 { margin-bottom: 20px; font-size: 1.5rem; }
  .details { padding: 4px 12px; }
  .row { min-height: 52px; gap: 9px; }
  .row input { font-size: 1rem; }
  .controls { flex-direction: column; }
  .recharge-form { margin-top: 20px; }
}
