:root {
  --bg: #eef1f8;
  --ink: #152036;
  --muted: #5f6b83;
  --line: #d7deec;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --accent: #2256e8;
  --accent-strong: #1a43b8;
  --accent-soft: #dce7ff;
  --danger: #c83939;
  --success: #1d8f5b;
  --warning: #b17d15;
  --shadow: 0 20px 44px rgba(12, 27, 59, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at -10% 0%, #cad8ff 0%, transparent 70%),
    radial-gradient(820px 520px at 110% 20%, #d8f0ff 0%, transparent 65%),
    linear-gradient(180deg, #f7f9ff 0%, var(--bg) 100%);
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(480px 280px at 22% 86%, rgba(34, 86, 232, 0.08), transparent 72%),
    radial-gradient(620px 360px at 78% 18%, rgba(56, 179, 211, 0.09), transparent 73%);
  animation: float-layer 14s ease-in-out infinite alternate;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 22px 20px 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-family: "Sora", sans-serif;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(145deg, #2256e8, #2b2d7c);
}

.brand-text {
  font-family: "Sora", sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-text strong {
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-links a {
  text-decoration: none;
  color: #2b3855;
  font-weight: 600;
  font-size: 0.93rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #b7c7f3;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(148, 165, 196, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
}

.panel,
.stat-card {
  padding: 18px;
}

.panel h1,
.panel h2,
.panel h3 {
  margin: 0 0 10px;
  font-family: "Sora", sans-serif;
  letter-spacing: 0.01em;
}

.panel h2 {
  font-size: 1.2rem;
}

.panel p {
  margin: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.text-link {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.top-gap {
  margin-top: 8px;
}

.stat-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.stat-card h3 {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card p {
  margin-top: 12px;
  font-size: clamp(1.3rem, 2vw, 1.9rem);
  font-family: "Sora", sans-serif;
  font-weight: 700;
}

.grid-3,
.grid-2,
.grid-1 {
  display: grid;
  gap: 16px;
}

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

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

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.93rem;
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d2e8;
  border-radius: 11px;
  padding: 10px 12px;
  background: var(--panel-strong);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #9bb7ff;
  border-color: #7697f5;
}

input:disabled {
  background: #eef1f7;
  color: #78829a;
}

.check-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 11px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: linear-gradient(145deg, #2d6cf0, #204eb9);
  color: #ffffff;
}

.btn-primary:hover {
  background: linear-gradient(145deg, #285fd4, #1b449f);
}

.btn-secondary {
  background: #e4ebff;
  color: #1c43a5;
  border: 1px solid #bfd0fb;
}

.btn-secondary:hover {
  background: #d8e3ff;
}

.btn-ghost {
  background: #ffffff;
  color: #3a4662;
  border: 1px solid #cfdaef;
}

.btn-ghost:hover {
  background: #f5f8ff;
}

.btn-danger {
  background: #ffe8e8;
  color: #a42828;
  border: 1px solid #f6c6c6;
}

.btn-mini {
  border: 1px solid #ccd7ee;
  background: #ffffff;
  color: #233250;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.inline-form,
.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-actions {
  flex-wrap: wrap;
}

.search-inline input {
  min-width: 240px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

thead th {
  text-align: left;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid #d7deec;
  padding: 10px 8px;
}

tbody td {
  border-bottom: 1px solid #e4e9f3;
  padding: 10px 8px;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

code {
  background: #eff3fb;
  border: 1px solid #d8e0f0;
  border-radius: 7px;
  padding: 2px 6px;
  font-size: 0.86rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.75rem;
  background: #eaf0ff;
  color: #2a4692;
  border: 1px solid #c6d5fa;
}

.tag-active {
  background: #e6f8ef;
  color: var(--success);
  border-color: #bde8ce;
}

.tag-revoked {
  background: #ffe9e9;
  color: var(--danger);
  border-color: #f3c0c0;
}

.flash {
  border-radius: 12px;
  border: 1px solid #c7d7ff;
  background: #e9f0ff;
  color: #1f449a;
  padding: 12px 14px;
  font-weight: 600;
}

.flash-success {
  border-color: #b9e4cb;
  background: #e8f8ef;
  color: #186d45;
}

.flash-error {
  border-color: #f2bcbc;
  background: #ffe9e9;
  color: #9f2b2b;
}

.flash-info {
  border-color: #c7d7ff;
  background: #e9f0ff;
  color: #1f449a;
}

details {
  margin-top: 6px;
}

summary {
  cursor: pointer;
  color: #263658;
  font-weight: 600;
}

pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 9px;
  background: #111a2d;
  color: #dce6ff;
  overflow-x: auto;
  font-size: 0.78rem;
  max-height: 220px;
}

.note-form {
  width: 100%;
}

.note-form input[type="text"] {
  min-width: 190px;
}

.auth-page .topbar {
  justify-content: center;
}

.auth-wrap {
  min-height: calc(100vh - 220px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(470px, 100%);
  padding: 24px;
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-card p {
  margin-bottom: 16px;
  color: var(--muted);
}

.site-footer {
  text-align: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 1120px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .grid-2,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    flex-wrap: wrap;
  }

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

@media (max-width: 640px) {
  .shell {
    padding: 14px 10px 24px;
  }

  .panel,
  .stat-card {
    padding: 14px;
  }

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

  .nav-links {
    width: 100%;
    justify-content: center;
  }

  .search-inline {
    width: 100%;
  }

  .search-inline input {
    min-width: 0;
  }
}

@keyframes float-layer {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-18px);
  }
}
