* {
  box-sizing: border-box;
}

:root {
  --blue-1: #2574ea;
  --blue-2: #1d5fd0;
  --blue-soft: #2d82ff;
  --red-1: #ff4b3e;
  --red-2: #ef3d2f;
  --green-1: #22c55e;
  --green-2: #1ead52;
  --cyan-1: #36b8ea;
  --cyan-2: #3b82f6;
  --bg: #e9eef7;
  --panel: #ffffff;
  --text: #13233e;
  --muted: #617087;
  --border: #d8e0ee;
  --shadow: 0 18px 40px rgba(18, 32, 58, 0.08);
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Inter", sans-serif;
  background: #eef3fb;
  color: var(--text);
}

.admin-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #eef3fb 0%, #e7edf7 100%);
}

.admin-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 38px 20px 56px;
}

.topbar {
  background: linear-gradient(135deg, var(--blue-1) 0%, var(--blue-2) 100%);
  color: #fff;
  border-radius: 24px;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: var(--shadow);
}

.topbar-main h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 800;
}

.topbar-main p {
  margin: 8px 0 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  margin-top: 18px;
  padding: 24px 18px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 20px;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group label {
  font-size: 14px;
  font-weight: 700;
  color: #223451;
}

.field-group input,
.field-group select {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-group input:focus,
.field-group select:focus {
  border-color: var(--blue-soft);
  box-shadow: 0 0 0 4px rgba(45, 130, 255, 0.12);
}

.field-span-2 {
  grid-column: span 2;
}

.panel-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-btn {
  border: none;
  border-radius: 14px;
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.admin-btn:hover {
  opacity: 0.97;
}

.admin-btn:active {
  transform: scale(0.99);
}

.admin-btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.admin-btn-block {
  width: 100%;
}

.admin-btn-sm {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 14px;
}

.admin-btn-primary {
  background: linear-gradient(135deg, #2c7ef7 0%, #1e5fd2 100%);
}

.admin-btn-secondary {
  background: linear-gradient(135deg, #2d86ff 0%, #2569df 100%);
}

.admin-btn-danger {
  background: linear-gradient(135deg, var(--red-1) 0%, var(--red-2) 100%);
}

.admin-btn-success {
  background: linear-gradient(135deg, #18b353 0%, #129446 100%);
}

.status-line {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.status-line.success {
  color: #0d9f45;
}

.status-line.error {
  color: #d93025;
}

.admin-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(18px);
  background: rgba(12, 20, 34, 0.94);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 9999;
  max-width: calc(100vw - 24px);
  text-align: center;
}

.admin-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Login */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 22px;
  text-align: center;
}

.login-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 28px;
  background: linear-gradient(135deg, var(--blue-1) 0%, var(--blue-2) 100%);
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.login-desc {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.auth-form {
  text-align: left;
}

.back-home-link {
  display: inline-block;
  margin-top: 18px;
  color: #2264d8;
  text-decoration: none;
  font-weight: 700;
}

/* Stats */
.stats-cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  border-radius: 22px;
  color: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-card-blue {
  background: linear-gradient(135deg, #2676eb 0%, #1f57c7 100%);
}

.stat-card-green {
  background: linear-gradient(135deg, #2dc95d 0%, #1db148 100%);
}

.stat-card-cyan {
  background: linear-gradient(135deg, #31b7e2 0%, #4482f5 100%);
}

.stat-icon {
  font-size: 18px;
  margin-bottom: 10px;
}

.stat-number {
  font-size: 54px;
  line-height: 1;
  font-weight: 800;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 16px;
  font-weight: 700;
}

.filter-bar {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 16px;
  align-items: end;
}

.search-field input {
  min-height: 50px;
}

.filter-submit-wrap {
  display: flex;
  align-items: flex-end;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
}

.stats-table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
  background: #fff;
}

.stats-table th,
.stats-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 14px;
}

.stats-table th {
  background: #f4f7fc;
  color: #1f3762;
  font-size: 15px;
  font-weight: 800;
}

.stats-table tbody tr:last-child td {
  border-bottom: none;
}

.link-cell a {
  color: #253bd0;
  text-decoration: none;
  word-break: break-all;
  line-height: 1.6;
}

.link-cell a:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2d86ff 0%, #2569df 100%);
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.mono-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}

.table-empty {
  text-align: center !important;
  color: var(--muted);
  padding: 28px 16px !important;
}

/* Responsive */
@media (max-width: 980px) {
  .stats-cards {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .admin-shell {
    padding: 18px 12px 36px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .admin-btn,
  .topbar-actions a.admin-btn {
    flex: 1 1 auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: span 1;
  }

  .panel {
    padding: 18px 14px;
    border-radius: 20px;
  }

  .stat-number {
    font-size: 44px;
  }
}