:root {
  --primary: #13bfa6;
  --secondary: #ff6b5f;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #77808b;
  --line: #e6ebf0;
  --danger: #dc3d3d;
  --shadow: 0 12px 30px rgba(19, 28, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

.field label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 800;
}

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

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

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

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

.sidebar {
  background: #111827;
  color: #fff;
  padding: 22px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  font-size: 20px;
  font-weight: 900;
}

.brand-square {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--primary);
}

.nav-button {
  width: 100%;
  min-height: 42px;
  margin-bottom: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  text-align: left;
  padding: 0 12px;
}

.nav-button.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 800;
}

.main {
  min-width: 0;
}

.admin-header {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-header h1 {
  margin: 0;
  font-size: 20px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.content {
  padding: 24px 28px 44px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(21, 30, 42, 0.04);
  padding: 20px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 14px;
}

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

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

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

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

.stat-card {
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

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

.stat-card span {
  color: var(--muted);
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) 76px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.edit-row.compact {
  grid-template-columns: repeat(5, minmax(0, 1fr)) 76px;
}

.edit-row.wide {
  grid-template-columns: 1fr 1fr 1fr 1fr 90px 76px;
}

.edit-row input,
.edit-row select {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.edit-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.mini-btn {
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.mini-btn.danger {
  border-color: #ffd2d2;
  color: var(--danger);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

td.payload {
  max-width: 440px;
  white-space: normal;
  word-break: break-word;
  color: #4b5563;
  font-size: 12px;
}

th {
  background: #f8fafc;
  font-weight: 800;
}

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

.record-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.record-tabs button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
}

.record-tabs button.is-active {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.hint {
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 18px);
  min-width: 160px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(18, 24, 33, 0.94);
  color: #fff;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 10px;
  }

  .sidebar-brand {
    padding: 0 8px 0 0;
    flex: 0 0 auto;
  }

  .nav-button {
    width: auto;
    padding: 0 14px;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .stats-grid,
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .edit-row,
  .edit-row.compact,
  .edit-row.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .admin-header {
    height: auto;
    padding: 14px 16px;
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .content {
    padding: 16px;
  }

  .stats-grid,
  .grid-4,
  .grid-3,
  .grid-2,
  .edit-row,
  .edit-row.compact,
  .edit-row.wide {
    grid-template-columns: 1fr;
  }
}
