:root {
  --black: #111111;
  --red: #e21b23;
  --red-dark: #b81018;
  --paper: #f4f4f2;
  --white: #ffffff;
  --line: #d8d8d4;
  --muted: #62625d;
  --shell: min(1100px, calc(100% - 48px));
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--black);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid #383838;
  color: var(--white);
  background: var(--black);
}

.portal-brand { display: inline-flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 750; }
.portal-brand img { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; }
.portal-brand strong { color: #f04449; }
.back-link { font-size: 14px; font-weight: 700; color: #d9d9d7; }
.back-link:hover, .back-link:focus-visible { color: var(--red); }

.portal-shell { width: var(--shell); margin: 0 auto; padding: 76px 0 98px; }
.portal-kicker { margin: 0 0 9px; color: var(--red); font-size: 13px; font-weight: 850; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1, h2 { line-height: 1.08; font-weight: 850; }
h1 { margin-bottom: 0; font-size: clamp(36px, 5vw, 60px); }
h2 { margin-bottom: 0; font-size: 25px; }

.portal-message { max-width: 670px; padding: 40px 0; }
.portal-message > p:not(.portal-kicker):not(.portal-note):not(.portal-error) { max-width: 600px; margin: 21px 0 26px; color: #474743; font-size: 18px; }
.portal-note { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.portal-error { margin: 0 0 18px; padding: 10px 12px; border-left: 3px solid var(--red); background: #fff3f3; color: #8f151a; }

.portal-button, .clear-server, .copy-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}
.portal-button { padding: 10px 15px; color: var(--white); background: var(--red); }
.portal-button:hover, .portal-button:focus-visible { background: var(--red-dark); }

.portal-topbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.account-area { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; }
.account-area strong { color: var(--black); }
.logout-link { color: var(--red); font-weight: 800; }
.logout-link:hover, .logout-link:focus-visible { color: var(--red-dark); }

.portal-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 0.68fr); align-items: end; padding: 48px 0 38px; gap: 50px; }
.portal-intro > p { margin: 0; color: #555550; font-size: 16px; }
.portal-loading, .empty-licenses, .portal-api-error { padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--muted); }
.empty-licenses h2, .portal-api-error h2 { margin-bottom: 10px; color: var(--black); }
.empty-licenses p, .portal-api-error p { max-width: 600px; margin-bottom: 16px; }
.empty-licenses a, .portal-api-error a { color: var(--red); font-size: 14px; font-weight: 800; }

.license-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.license-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--white); }
.license-card-head { display: flex; justify-content: space-between; align-items: start; padding: 22px 22px 18px; gap: 18px; border-bottom: 1px solid var(--line); }
.license-card-head p { margin: 0 0 4px; color: var(--red); font-size: 13px; font-weight: 800; }
.license-card-head h2 { font-size: 20px; }
.status { min-width: max-content; padding: 4px 7px; border: 1px solid #b3b3af; border-radius: 4px; color: #4d4d49; font-size: 12px; font-weight: 850; text-transform: uppercase; }
.status-active { border-color: #299537; color: #197525; background: #f0fff2; }
.status-suspended, .status-revoked { border-color: #d2692d; color: #9a3f0d; background: #fff5ed; }

.key-block { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 17px 22px; gap: 10px; border-bottom: 1px solid var(--line); }
.key-block > span { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.key-block code { min-width: 0; overflow: hidden; color: var(--black); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.copy-key { min-height: 31px; padding: 5px 8px; border-color: var(--line); color: #454541; background: var(--white); font-size: 12px; }
.copy-key:hover, .copy-key:focus-visible { border-color: var(--black); color: var(--black); }

.license-meta { display: grid; margin: 0; padding: 0 22px; }
.license-meta > div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid #e6e6e2; }
.license-meta > div:last-child { border-bottom: 0; }
.license-meta dt { color: var(--muted); font-size: 13px; }
.license-meta dd { margin: 0; color: #383834; font-size: 13px; font-weight: 700; text-align: right; }

.license-reset { display: flex; align-items: center; justify-content: space-between; padding: 17px 22px 20px; gap: 16px; border-top: 1px solid var(--line); background: #fafaf8; }
.license-reset strong { display: block; font-size: 14px; }
.license-reset p { max-width: 290px; margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.clear-server { min-width: max-content; padding: 8px 10px; border-color: #cb3c41; color: #a3131a; background: var(--white); font-size: 13px; }
.clear-server:hover:not(:disabled), .clear-server:focus-visible:not(:disabled) { color: var(--white); background: var(--red); border-color: var(--red); }
.clear-server:disabled { border-color: #d9d9d5; color: #969691; cursor: not-allowed; background: #eeeeeb; }
.reset-wait { margin: -10px 22px 17px; color: var(--muted); font-size: 12px; text-align: right; }

:focus-visible { outline: 3px solid #f04b50; outline-offset: 3px; }

@media (max-width: 760px) {
  :root { --shell: min(100% - 32px, 1100px); }
  .portal-header { padding: 0 16px; }
  .portal-shell { padding: 48px 0 64px; }
  .portal-topbar, .portal-intro { align-items: start; flex-direction: column; grid-template-columns: 1fr; gap: 21px; }
  .license-grid { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .portal-brand { font-size: 14px; }
  .portal-brand img { width: 31px; height: 31px; }
  .back-link { font-size: 13px; }
  .account-area { align-items: start; flex-direction: column; gap: 5px; }
  .license-card-head, .license-reset { align-items: start; flex-direction: column; }
  .clear-server { width: 100%; }
  .key-block { grid-template-columns: 1fr; }
  .copy-key { width: 100%; }
  .license-meta > div { align-items: start; flex-direction: column; gap: 2px; }
  .license-meta dd { text-align: left; }
}
