:root {
  color-scheme: light;
  --bg: #f3f7f5;
  --panel: #ffffff;
  --text: #17221e;
  --muted: #68766f;
  --line: #dce6e1;
  --green: #009d73;
  --green-dark: #08775d;
  --green-soft: #e7f7f1;
  --red: #c53a45;
  --red-soft: #fff0f1;
  --amber: #a66b08;
  --amber-soft: #fff6df;
  --shadow: 0 12px 40px rgba(25, 60, 47, .08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(0, 157, 115, .18), transparent 35%),
    linear-gradient(145deg, #f7fbf9 0%, #e9f4ef 100%);
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 22px;
  padding: 38px;
  border: 1px solid rgba(0, 157, 115, .18);
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 28px 80px rgba(16, 73, 54, .16);
}

.login-card img { border-radius: 20px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
h2 { font-size: 23px; letter-spacing: -.02em; }
h3 { font-size: 15px; }
.eyebrow { color: var(--green-dark); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.muted { margin-top: 6px; color: var(--muted); }

label { display: grid; gap: 7px; color: #3c4b44; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfdad5;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 157, 115, .13);
}

button {
  min-height: 41px;
  border: 0;
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 750;
  transition: transform .12s, background .12s, opacity .12s;
}
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .55; }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-dark); }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--text); }
.secondary:hover, .ghost:hover { background: #edf5f1; }
.ghost { background: transparent; color: var(--text); }
.danger { background: var(--red-soft); color: var(--red); }
.danger:hover { background: #ffe0e3; }
.danger-text { color: var(--red); }
.full { width: 100%; }

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px max(22px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand img { border-radius: 12px; }
.brand h1 { font-size: 20px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.page { width: min(1440px, 100%); margin: auto; padding: 26px 22px 50px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}
.metric {
  display: grid;
  gap: 7px;
  min-height: 105px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 6px 24px rgba(27, 74, 57, .04);
}
.metric span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { align-self: end; font-size: 30px; }
.metric.success strong { color: var(--green-dark); }
.metric.warning strong { color: var(--amber); }
.metric.danger strong { color: var(--red); }

.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}
.panel-heading .eyebrow { margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.wide { grid-column: 1 / -1; }
.version-badge, .status-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}
.status-badge.expired { background: var(--amber-soft); color: var(--amber); }
.status-badge.revoked { background: var(--red-soft); color: var(--red); }

.issued-key {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
  margin-top: 15px;
  padding: 15px;
  border: 1px solid rgba(0, 157, 115, .25);
  border-radius: 12px;
  background: var(--green-soft);
}
.issued-key span { grid-column: 1 / -1; color: var(--green-dark); font-size: 12px; font-weight: 700; }
.issued-key strong { word-break: break-all; font-size: 16px; letter-spacing: .04em; }
.message { min-height: 20px; margin-top: 12px; color: var(--green-dark); font-size: 13px; }
.message.error { color: var(--red); }

.licenses-panel { padding: 0; overflow: hidden; }
.licenses-heading { align-items: center; padding: 22px 22px 0; }
.filters { display: flex; gap: 9px; width: min(570px, 55%); }
.filters input { flex: 1; }
.filters select { width: 185px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8fbf9; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
td { font-size: 13px; }
td strong { display: block; max-width: 310px; overflow: hidden; text-overflow: ellipsis; }
.key-cell { white-space: nowrap; color: #34443c; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.row-action { min-height: 34px; padding: 6px 10px; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(680px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 30px 100px rgba(13, 44, 33, .35);
}
dialog::backdrop { background: rgba(14, 30, 24, .56); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 17px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.dialog-heading h2 { margin-top: 5px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 17px; }
.icon-button { min-width: 38px; padding: 0; background: #f0f5f2; color: var(--muted); font-size: 25px; }
.activations { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fafcfb; }
.section-title { display: flex; justify-content: space-between; gap: 10px; }
.section-title span { color: var(--muted); font-size: 12px; }
.activation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.activation-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activation-row small { color: var(--muted); }
.activation-row button { grid-column: 2; grid-row: 1 / span 2; min-height: 34px; }
.no-activations { color: var(--muted); font-size: 13px; }
.dialog-actions { display: flex; align-items: center; gap: 9px; }
.spacer { flex: 1; }

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: 380px;
  padding: 13px 16px;
  border-radius: 11px;
  background: #18372c;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: .2s;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f2932; }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .layout { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 700px) {
  .topbar { position: static; flex-direction: column; align-items: stretch; }
  .top-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .top-actions button:first-child { grid-column: 1 / -1; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 88px; }
  .page { padding: 18px 12px 36px; }
  .panel { padding: 17px; }
  .licenses-heading { align-items: stretch; flex-direction: column; padding: 17px 17px 0; }
  .filters { flex-direction: column; width: 100%; }
  .filters select { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .issued-key { grid-template-columns: 1fr; }
  .dialog-actions { flex-wrap: wrap; }
  footer { flex-direction: column; }
}
