:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel-2: #172235;
  --border: #24324a;
  --text: #eef4ff;
  --muted: #9fb0cc;
  --primary: #4f8cff;
  --primary-2: #3a74e8;
  --success: #20b26b;
  --warning: #e0a61f;
  --danger: #de5b5b;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  --radius: 18px;
  --radius-sm: 12px;
  --container: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #0b1220 0%, #0f1727 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

body { min-height: 100vh; }

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

img { max-width: 100%; display: block; }

button, input, textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  backdrop-filter: blur(10px);
  background: rgba(11, 18, 32, 0.82);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, #73a6ff 100%);
  color: white;
  font-weight: 700;
}

.brand-link small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.topbar__nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-link {
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.page-container {
  width: min(var(--container), calc(100% - 32px));
  margin: 28px auto 56px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.page-head h1,
.auth-card h1 {
  margin: 6px 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.1;
}

.page-head p,
.auth-card p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.eyebrow {
  display: inline-block;
  color: #8cb2ff;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.auth-card {
  width: min(100%, 520px);
  background: rgba(18, 26, 43, 0.96);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card__head {
  margin-bottom: 20px;
}

.auth-card__footer {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--muted);
}

.auth-card__footer a {
  color: #aecdff;
  font-weight: 600;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.card,
.metric-card {
  background: rgba(18, 26, 43, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: 22px;
}

.card__head {
  margin-bottom: 18px;
}

.card__head h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.card__head p {
  margin: 0;
  color: var(--muted);
}

.metric-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.metric-value {
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  line-height: 1.1;
}

.metric-card small {
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 15px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(79, 140, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.15);
}

.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 600;
}

.btn:hover { transform: translateY(-1px); }

.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: white;
}

.btn-secondary {
  background: linear-gradient(135deg, #3f8cff 0%, #6f61ff 100%);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #cc4f4f 0%, #aa3333 100%);
  color: white;
}

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}

.alert {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(32, 178, 107, 0.14);
  border-color: rgba(32, 178, 107, 0.35);
  color: #b7f4d4;
}

.alert-error {
  background: rgba(222, 91, 91, 0.14);
  border-color: rgba(222, 91, 91, 0.35);
  color: #ffd0d0;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.info-row:last-child {
  border-bottom: 0;
}

.hint-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.hint-box strong {
  display: block;
  margin-bottom: 6px;
}

.hint-box p {
  margin: 0;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
}

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

.table th,
.table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

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

.empty-state {
  padding: 28px 18px;
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 16px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state.small {
  padding: 22px 16px;
}

.qr-panel {
  display: grid;
  place-items: center;
  min-height: 280px;
  border-radius: 16px;
  background: #ffffff;
  padding: 18px;
}

.qr-image {
  width: min(100%, 280px);
  height: auto;
}

.stack-sm {
  display: grid;
  gap: 10px;
}

.break-all {
  word-break: break-all;
}

.text-success { color: #72e2ab; }
.text-warning { color: #f1c664; }
.text-danger { color: #ff8c8c; }

@media (max-width: 980px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .topbar__nav {
    justify-content: flex-start;
  }
  .topbar__logout {
    justify-self: flex-start;
  }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .page-container {
    width: min(var(--container), calc(100% - 20px));
    margin-top: 18px;
  }
  .topbar {
    padding: 14px 12px;
  }
  .metrics-grid { grid-template-columns: 1fr; }
  .card,
  .metric-card,
  .auth-card {
    padding: 18px;
    border-radius: 16px;
  }
  .inline-actions {
    flex-direction: column;
  }
  .inline-actions .btn,
  .inline-actions form,
  .inline-actions a {
    width: 100%;
  }
  .btn {
    width: 100%;
  }
  .table {
    min-width: 360px;
  }
}
