:root {
  --bg: #07080d;
  --panel: #11131a;
  --panel-2: #171a23;
  --text: #f7f8fb;
  --muted: #a8b0be;
  --line: rgba(255, 255, 255, 0.1);
  --red: #ff4f5e;
  --red-2: #ff7a83;
  --teal: #25d0c8;
  --green: #16a34a;
  --blue: #3b82f6;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 79, 94, 0.12), transparent 28rem),
    radial-gradient(circle at top right, rgba(37, 208, 200, 0.1), transparent 30rem),
    var(--bg);
}

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

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 19, 26, 0.96);
  box-shadow: var(--shadow);
}

.login-mark,
.admin-brand span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--teal));
  font-weight: 900;
}

.login-card h1,
.panel-head h2,
.admin-topbar h1 {
  margin: 0;
}

.login-card p,
.login-card small,
.panel-head p,
.admin-topbar p {
  margin: 0;
  color: var(--muted);
}

.login-card label,
.admin-form label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
}

.login-card input,
.admin-form input,
.admin-form textarea,
.admin-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  color: var(--text);
  background: rgba(7, 8, 13, 0.9);
  outline: none;
}

.admin-shell {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(7, 8, 13, 0.94);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 1.05rem;
}

.admin-menu {
  display: grid;
  gap: 8px;
}

.admin-menu button,
.logout-link,
.table-actions button,
td > button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-weight: 800;
}

.admin-menu button {
  width: 100%;
  padding: 0 13px;
  text-align: left;
}

.admin-menu button.is-active,
.admin-menu button:hover {
  border-color: rgba(37, 208, 200, 0.34);
  background: linear-gradient(135deg, rgba(255, 79, 94, 0.24), rgba(37, 208, 200, 0.16));
}

.logout-link {
  display: grid;
  place-items: center;
  margin-top: 22px;
}

.admin-main {
  padding: clamp(18px, 4vw, 42px);
}

.admin-topbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-panel {
  display: none;
}

.admin-panel.is-active {
  display: grid;
  gap: 22px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

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

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 79, 94, 0.18), rgba(17, 19, 26, 0.96));
  box-shadow: var(--shadow);
}

.metric-card-green {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.22), rgba(17, 19, 26, 0.96));
}

.metric-card-blue {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(17, 19, 26, 0.96));
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1;
}

.admin-form,
.table-wrap {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 19, 26, 0.95);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

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

.admin-grid-form .wide,
.ajax-status {
  grid-column: 1 / -1;
}

.switch-row {
  display: flex !important;
  align-items: center;
  flex-direction: row;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  cursor: pointer;
  font-weight: 900;
}

.admin-button-light {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.danger-bg {
  background: #dc2626;
}

.ajax-status {
  min-height: 22px;
  margin: 0;
  color: var(--teal);
  font-weight: 800;
}

.alert {
  border-radius: var(--radius);
  padding: 12px;
  font-weight: 800;
}

.alert-error {
  color: #fff;
  background: rgba(220, 38, 38, 0.24);
}

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

.table-wrap h3 {
  margin: 0 0 14px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tr.is-new-message {
  color: #fff;
  background: #15803d;
}

tr.is-new-message th,
tr.is-new-message td {
  border-color: rgba(255, 255, 255, 0.16);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions button,
td > button {
  padding: 0 12px;
}

.table-actions .danger,
.danger {
  border-color: rgba(220, 38, 38, 0.4);
  color: #fff;
  background: rgba(220, 38, 38, 0.32);
}

.split-tables {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
}

.detail-modal {
  width: min(680px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.detail-modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.modal-head h2 {
  margin: 0;
}

.modal-head button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 1.4rem;
}

.modal-body {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.modal-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

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

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

@media (max-width: 720px) {
  .admin-main {
    padding: 16px;
  }

  .admin-topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-menu,
  .metric-grid,
  .metric-grid-five,
  .admin-grid-form,
  .split-tables {
    grid-template-columns: 1fr;
  }

  .admin-grid-form .wide,
  .ajax-status {
    grid-column: auto;
  }
}
