:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --surface-raised: #ffffff;
  --ink: #14171f;
  --ink-soft: #343a46;
  --muted: #667085;
  --muted-soft: #98a2b3;
  --line: #e3e7ee;
  --line-strong: #cfd6df;
  --accent: #d92d20;
  --accent-dark: #b42318;
  --accent-soft: #fff1f0;
  --green: #067647;
  --green-bg: #ecfdf3;
  --amber: #b54708;
  --amber-bg: #fffaeb;
  --blue: #175cd3;
  --blue-bg: #eff8ff;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.06);
  --shadow-lg: 0 24px 70px rgba(20, 23, 31, 0.18);
  --radius: 8px;
  --header-height: 84px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background:
    linear-gradient(180deg, #ffffff 0, #f4f5f7 240px),
    var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.shell {
  min-height: 100svh;
  padding: 24px;
}

.app-view,
.login-view {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.login-view {
  min-height: calc(100svh - 48px);
  height: calc(100svh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 480px);
  align-items: center;
  align-content: center;
  gap: clamp(32px, 7vw, 96px);
}

.brand-block {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.brand-block::after {
  content: "安全管理激活码、有效期和设备额度";
  grid-column: 2;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 13px) 19px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.12);
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.primary-button,
.password-row button,
.floating-button {
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.password-row button,
.primary-button {
  min-height: 44px;
  padding: 0 18px;
}

.primary-button:hover,
.password-row button:hover,
.floating-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.ghost-button,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  padding: 0 12px;
  transition: border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  transform: translateY(-1px);
}

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

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.app-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding-bottom: 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: var(--header-height);
  margin: -24px -24px 0;
  padding: 18px 24px 12px;
  border-bottom: 1px solid rgba(227, 231, 238, 0.78);
  background: rgba(250, 251, 252, 0.86);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  font-size: clamp(30px, 4vw, 44px);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stats-strip div {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.stats-strip div:last-child {
  border-right: 0;
}

.stats-strip span {
  display: block;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 900;
  line-height: 1;
}

.stats-strip small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, auto);
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) minmax(132px, 1fr);
  gap: 10px;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.list-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.license-list {
  display: grid;
  gap: 8px;
}

.license-item {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(220px, 0.7fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  padding: 14px 16px;
  color: inherit;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.license-item:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 30px rgba(20, 23, 31, 0.08);
  transform: translateY(-1px);
}

.license-main,
.license-detail {
  min-width: 0;
}

.license-code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
}

.license-note {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.license-note strong {
  margin-right: 8px;
  color: var(--ink-soft);
  font-weight: 900;
}

.license-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill {
  justify-self: end;
  align-self: center;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-active {
  background: var(--green-bg);
  color: var(--green);
}

.status-expiring {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-expired,
.status-frozen {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-permanent {
  background: var(--blue-bg);
  color: var(--blue);
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 42px 16px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 850;
}

.floating-button {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 5;
  width: 68px;
  height: 68px;
  box-shadow: var(--shadow-lg);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(20, 23, 31, 0.34);
  animation: fadeIn 160ms ease-out;
}

.drawer {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 11;
  width: min(520px, calc(100vw - 48px));
  max-height: calc(100svh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: drawerIn 180ms ease-out;
}

.drawer form {
  display: grid;
  gap: 16px;
}

.drawer-head,
.drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.switch-row input {
  width: 22px;
  min-height: 22px;
}

.record-details {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.record-details div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.record-details dt,
.record-details dd {
  min-width: 0;
  margin: 0;
}

.record-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.record-details dd {
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.created-codes {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
}

.drawer-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  padding-top: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(420px, calc(100vw - 36px));
  transform: translateX(-50%);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  font-weight: 800;
}

@keyframes drawerIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 960px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .license-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .license-detail {
    grid-column: 1 / -1;
  }

  .license-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  :root {
    --header-height: 78px;
  }

  html {
    background:
      linear-gradient(180deg, #ffffff 0, #f4f5f7 180px),
      var(--bg);
  }

  .shell {
    padding: 14px;
  }

  .login-view {
    min-height: calc(100svh - 28px);
    height: calc(100svh - 28px);
    grid-template-columns: 1fr;
    align-content: center;
    gap: 28px;
    overflow: auto;
  }

  .brand-block {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
  }

  .brand-block::after {
    grid-column: 1 / -1;
    font-size: 14px;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .login-form {
    padding: 16px;
  }

  .password-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }

  .app-view {
    gap: 12px;
    padding-bottom: 92px;
  }

  .topbar {
    min-height: var(--header-height);
    margin: -14px -14px 0;
    padding: 14px;
  }

  .topbar h1 {
    font-size: 30px;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-strip div {
    padding: 14px;
  }

  .stats-strip div:nth-child(2) {
    border-right: 0;
  }

  .stats-strip div:nth-child(1),
  .stats-strip div:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }

  .toolbar {
    padding: 12px;
  }

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

  .license-item {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
  }

  .status-pill {
    justify-self: start;
  }

  .license-note {
    white-space: normal;
  }

  .meta-chip {
    min-height: 30px;
  }

  .drawer {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: calc(100svh - 18px);
    border-radius: 12px 12px 0 0;
    padding: 18px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .floating-button {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 62px;
    height: 62px;
  }
}

@media (max-width: 390px) {
  .topbar {
    align-items: flex-start;
  }

  .ghost-button {
    min-height: 36px;
    padding: 0 10px;
  }

  .stats-strip span {
    font-size: 24px;
  }

  .license-code {
    font-size: 14px;
  }
}
