:root {
  --bg: #07111f;
  --bg-soft: #0b1828;
  --panel: rgba(15, 29, 47, 0.92);
  --panel-strong: #102238;
  --border: rgba(148, 163, 184, 0.16);
  --text: #eef6ff;
  --muted: #91a4ba;
  --accent: #1fb6d9;
  --accent-strong: #29d2ef;
  --danger: #f04f5f;
  --danger-soft: rgba(240, 79, 95, 0.12);
  --success: #53d6a2;
  --warning: #ffcf66;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(31, 182, 217, 0.13), transparent 30rem),
    radial-gradient(circle at 88% 18%, rgba(240, 79, 95, 0.08), transparent 26rem),
    linear-gradient(180deg, #07111f 0%, #081521 100%);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(20px, 4vw, 58px);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.82);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--danger), #b82643);
  color: white;
  font-weight: 900;
  font-size: 22px;
  box-shadow: 0 10px 28px rgba(240, 79, 95, 0.24);
}
.brand strong { display: block; letter-spacing: 0.04em; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

main { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 70px; }
.login-view { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login-panel { width: min(480px, 100%); }
.panel {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(17, 34, 55, 0.96), rgba(12, 25, 41, 0.96));
  box-shadow: var(--shadow);
  padding: clamp(22px, 3vw, 34px);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 4vw, 48px); letter-spacing: -0.035em; }
h2 { margin-bottom: 6px; font-size: 24px; letter-spacing: -0.02em; }
h3 { margin-bottom: 4px; }
.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.muted { color: var(--muted); line-height: 1.55; }
.compact { margin-bottom: 0; }
.page-heading, .panel-heading, .section-row, .licenses-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.page-heading { margin-bottom: 26px; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(330px, 0.8fr);
  gap: 22px;
  align-items: start;
}
.stack { display: grid; gap: 22px; }
.field-grid { display: grid; gap: 16px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

label { display: grid; gap: 8px; color: #dce8f4; font-weight: 650; font-size: 14px; }
label small, label em { color: var(--muted); font-weight: 500; font-style: normal; }
input, textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  outline: none;
  background: rgba(5, 14, 25, 0.7);
  color: var(--text);
  padding: 12px 14px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:focus, textarea:focus {
  border-color: rgba(31, 182, 217, 0.72);
  box-shadow: 0 0 0 3px rgba(31, 182, 217, 0.12);
  background: rgba(7, 18, 31, 0.9);
}
textarea { resize: vertical; min-height: 160px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.5; }

.button {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 15px;
  font-weight: 800;
  color: var(--text);
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { background: linear-gradient(135deg, #1699bd, #20c5df); color: #041018; }
.button.secondary, .button.ghost { background: rgba(255,255,255,.035); border-color: var(--border); }
.button.danger { background: var(--danger-soft); border-color: rgba(240,79,95,.28); color: #ff9da8; }
.button.danger-outline { background: transparent; border-color: rgba(240,79,95,.28); color: #ff9da8; }
.button.large { min-height: 48px; font-size: 15px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.text-button { border: 0; background: transparent; color: var(--accent-strong); font-weight: 700; }

.status-pill, .count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  font-size: 12px;
  font-weight: 800;
}
.status-pill.online { color: var(--success); border-color: rgba(83,214,162,.26); background: rgba(83,214,162,.08); }
.status-pill.offline { color: #a9b6c6; }

.module-section { display: grid; gap: 14px; }
.all-modules-card, .module-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.all-modules-card:hover, .module-card:hover { border-color: rgba(31,182,217,.38); background: rgba(31,182,217,.05); }
.all-modules-card { border-color: rgba(31,182,217,.26); background: rgba(31,182,217,.055); }
.all-modules-card input, .module-card input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.all-modules-card span, .module-card span { display: grid; gap: 3px; }
.all-modules-card small, .module-card small { color: var(--muted); font-weight: 500; }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.module-card.disabled { opacity: .45; }

.result-panel { position: sticky; top: 94px; }
.result-meta { display: grid; gap: 12px; margin: 20px 0 0; }
.result-meta div { display: grid; gap: 4px; }
.result-meta dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.result-meta dd { margin: 0; overflow-wrap: anywhere; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.notice { margin-top: 20px; border-radius: 12px; padding: 13px 14px; line-height: 1.45; font-size: 13px; }
.notice.warning { border: 1px solid rgba(255,207,102,.22); background: rgba(255,207,102,.08); color: #ffe6a6; }

.licenses-panel { margin-top: 22px; }
.license-list { display: grid; gap: 12px; margin-top: 18px; }
.license-card {
  display: grid;
  grid-template-columns: minmax(220px,1.25fr) minmax(160px,.7fr) minmax(240px,1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 16px;
  background: rgba(255,255,255,.022);
}
.license-title { font-weight: 850; }
.license-id { margin-top: 5px; color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }
.license-info { color: var(--muted); font-size: 13px; line-height: 1.55; }
.license-actions { display: grid; gap: 8px; min-width: 120px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chip { border-radius: 999px; padding: 4px 8px; background: rgba(31,182,217,.08); color: #a9ebf7; font-size: 11px; font-weight: 750; }
.state { display: inline-flex; width: fit-content; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 850; text-transform: uppercase; }
.state.active { color: var(--success); background: rgba(83,214,162,.09); }
.state.revoked { color: #ff9da8; background: var(--danger-soft); }
.empty-state { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; }
.form-error { margin: -8px 0 0; color: #ff9da8; font-size: 13px; font-weight: 650; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 48px));
  border: 1px solid rgba(31,182,217,.3);
  border-radius: 13px;
  padding: 13px 16px;
  background: #10263a;
  box-shadow: var(--shadow);
  color: #dff9ff;
  font-weight: 700;
}

@media (max-width: 1050px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .license-card { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  main { width: min(100% - 24px, 1480px); padding-top: 24px; }
  .topbar { padding-inline: 14px; }
  .page-heading, .panel-heading, .section-row { align-items: stretch; flex-direction: column; }
  .field-grid.two, .module-grid, .license-card { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { border-radius: 16px; padding: 20px; }
  .topbar-actions .status-pill { display: none; }
}

select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  outline: none;
  background: rgba(5, 14, 25, 0.7);
  color: var(--text);
  padding: 12px 14px;
}
select:focus {
  border-color: rgba(31, 182, 217, 0.72);
  box-shadow: 0 0 0 3px rgba(31, 182, 217, 0.12);
}
select:disabled { opacity: .55; cursor: not-allowed; }

.license-type-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.license-type-tab {
  display: grid;
  gap: 5px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  background: rgba(255,255,255,.025);
  color: var(--text);
}
.license-type-tab span { color: var(--muted); font-size: 12px; }
.license-type-tab.active {
  border-color: rgba(31,182,217,.55);
  background: rgba(31,182,217,.09);
  box-shadow: inset 0 0 0 1px rgba(31,182,217,.08);
}
.notice.info {
  border: 1px solid rgba(31,182,217,.24);
  background: rgba(31,182,217,.07);
  color: #c8f5ff;
  margin: 0 0 22px;
}
.package-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,.025);
}
.package-summary div {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.package-summary span { color: var(--muted); font-size: 11px; }
.package-summary strong { overflow-wrap: anywhere; }
.organization-chip {
  background: rgba(240,79,95,.10);
  color: #ffadb6;
}
code { font-family: "SFMono-Regular", Consolas, monospace; }

@media (max-width: 850px) {
  .license-type-switch { grid-template-columns: 1fr; }
  .package-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

.license-type-switch {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-grid.single-column {
  grid-template-columns: 1fr;
}

.package-manager-grid {
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(360px, 1.2fr);
  gap: 22px;
  margin-top: 24px;
}

.package-admin-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.package-admin-card {
  display: grid;
  gap: 5px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px;
  background: rgba(255,255,255,.025);
  color: var(--text);
}

.package-admin-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.package-admin-card:hover,
.package-admin-card.active {
  border-color: rgba(31,182,217,.42);
  background: rgba(31,182,217,.06);
}

.package-editor {
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 18px;
  background: rgba(255,255,255,.018);
}

@media (max-width: 900px) {
  .license-type-switch,
  .package-manager-grid {
    grid-template-columns: 1fr;
  }
}
