:root {
  --bg-main: #020617;
  --bg-secondary: #0b1120;
  --panel: rgba(10, 25, 47, 0.78);
  --panel-strong: rgba(9, 32, 58, 0.95);
  --text: #dbeafe;
  --text-soft: #93c5fd;
  --primary: #38bdf8;
  --primary-strong: #0ea5e9;
  --danger: #f87171;
  --ok: #4ade80;
  --border: rgba(56, 189, 248, 0.35);
  --shadow: 0 20px 45px rgba(2, 6, 23, 0.65);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 12% 20%, rgba(14, 165, 233, 0.18), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(59, 130, 246, 0.16), transparent 28%),
    linear-gradient(160deg, var(--bg-main) 0%, var(--bg-secondary) 100%);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--primary);
}

a:hover {
  color: #7dd3fc;
}

.topbar {
  background: linear-gradient(90deg, rgba(3, 7, 18, 0.95), rgba(5, 25, 43, 0.95));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  color: var(--text);
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar a {
  color: var(--text);
  text-decoration: none;
  margin-right: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.topbar-actions a {
  margin-right: 0;
}

.topbar-actions .inline-form {
  margin: 0;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.45rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(14, 42, 71, 0.88);
  color: var(--text);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.topbar-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.topbar-btn:hover {
  color: #e0f2fe;
}

.brand a {
  font-weight: 800;
  letter-spacing: 0.06em;
}

.container {
  max-width: 1120px;
  margin: 1.8rem auto;
  padding: 0 1rem;
}

.auth-box {
  max-width: 420px;
  margin: 9vh auto;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.3rem;
  box-shadow: var(--shadow);
}

.auth-box h1 {
  margin-top: 0.2rem;
  margin-bottom: 1rem;
  letter-spacing: 0.04em;
}

.auth-box form,
.form-grid,
.form-inline,
.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.auth-box form {
  flex-direction: column;
  align-items: stretch;
}

.otp-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.otp-digit {
  text-align: center;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

input,
select,
button {
  padding: 0.56rem 0.62rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 42, 71, 0.88);
  color: var(--text);
}

input::placeholder {
  color: #7aa6c7;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(15, 55, 88, 0.95);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

button:focus,
button:active {
  outline: none;
  background: var(--primary-strong);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px rgba(14, 42, 71, 0.95) inset;
  transition: background-color 9999s ease-in-out 0s;
}

button,
.button {
  background: var(--primary);
  color: #04111f;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  transition: transform 120ms ease, background-color 120ms ease;
}

button:hover,
.button:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

button:disabled {
  background: rgba(100, 116, 139, 0.45);
  color: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

th,
td {
  padding: 0.62rem;
  border-bottom: 1px solid rgba(56, 189, 248, 0.18);
  text-align: left;
}

th {
  background: rgba(2, 12, 26, 0.8);
  color: var(--text-soft);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

tr:hover td {
  background: rgba(56, 189, 248, 0.07);
}

.cards,
.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.links {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.links a {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(2, 12, 26, 0.6);
  text-decoration: none;
}

.flash {
  padding: 0.62rem 0.82rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  border: 1px solid transparent;
}

.flash.error {
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
}

.flash.success {
  background: rgba(74, 222, 128, 0.12);
  color: #bbf7d0;
  border-color: rgba(74, 222, 128, 0.38);
}

.section-block {
  margin-top: 1.4rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.section-head h2 {
  margin: 0;
}

.btn-plus {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
}

button.danger {
  background: #ef4444;
  color: #fff;
}

button.secondary {
  background: rgba(148, 163, 184, 0.25);
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.75);
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-box {
  width: min(560px, 94vw);
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.modal-box h3 {
  margin-top: 0.1rem;
}

.modal .form-grid {
  display: grid;
  gap: 0.6rem;
}

.mfa-qr-wrap {
  margin: 0.5rem 0 1rem;
}

.mfa-qr-wrap img {
  width: 220px;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0.45rem;
}

.section-block td:last-child {
  white-space: nowrap;
}

.section-block td:last-child .inline-form {
  display: inline-flex;
  flex-wrap: nowrap;
  vertical-align: middle;
  margin-right: 0.35rem;
  margin-bottom: 0.25rem;
}

.section-block td:last-child .inline-form input,
.section-block td:last-child .inline-form select {
  width: auto;
  min-width: 110px;
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  table {
    font-size: 0.9rem;
  }

  .container {
    margin-top: 1rem;
  }
}
