:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #2563eb;
  --brand-2: #0f766e;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden {
  display: none !important;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(37, 99, 235, 0.72)),
    var(--bg);
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 30px;
}

.login-logo {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  margin-bottom: 18px;
}

.login-panel h1 {
  font-size: 24px;
}

.login-panel p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: #344054;
  font-size: 14px;
  font-weight: 600;
}

.login-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 400;
}

.login-panel button {
  width: 100%;
  margin-top: 18px;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #fff;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #b7c0d0;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  text-align: left;
  padding: 0 12px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-user {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
}

.primary,
.ghost,
.danger {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 0 14px;
}

.primary {
  background: var(--brand);
  color: #fff;
}

.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}

.icon {
  min-width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

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

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.55;
}

.toolbar input {
  max-width: 360px;
}

.toolbar select {
  max-width: 180px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

th {
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
  font-weight: 600;
}

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

.human-cell {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  min-width: 300px;
}

.human-cell img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #e5e7eb;
}

.user-cell {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.user-avatar {
  display: flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.human-cell p,
.feedback-detail {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 0 9px;
  font-size: 12px;
}

.badge.green {
  background: #dcfce7;
  color: #166534;
}

.badge.gray {
  background: #eef2f7;
  color: #475467;
}

.badge.orange {
  background: #ffedd5;
  color: #9a3412;
}

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

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

#humanForm,
#categoryForm,
#tagForm {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  font-size: 20px;
}

.dialog-actions {
  justify-content: flex-end;
}

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

.tag-picker,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  padding: 7px 10px;
  color: #344054;
  font-size: 12px;
  font-weight: 600;
}

.tag-option input {
  width: auto;
}

.tag-list {
  margin-top: 6px;
}

.tag-list span {
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  padding: 3px 8px;
  font-size: 12px;
}

.muted-inline {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.db-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.db-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.db-grid h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.db-grid p {
  min-height: 48px;
  color: var(--muted);
  line-height: 1.6;
}

code {
  display: block;
  margin-top: 16px;
  white-space: normal;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
}

.cover-preview {
  display: none;
  width: 120px;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.cover-preview[src] {
  display: block;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.settings-form {
  display: grid;
  max-width: 880px;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.ranking-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.8fr);
  gap: 14px;
}

.notice {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 12px 14px;
  font-size: 13px;
}

.config-status {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

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

  .stats,
  .db-grid,
  .ranking-layout,
  .form-grid,
  .upload-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar input,
  .toolbar select {
    max-width: none;
  }
}
