* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #303133;
  --muted: #909399;
  --line: #dcdfe6;
  --line-soft: #ebeef5;
  --primary: #409eff;
  --primary-deep: #337ecc;
  --danger: #f56c6c;
  --success-bg: #f0f9ff;
  --success-text: #67c23a;
  --error-bg: #fef0f0;
  --error-text: #f56c6c;
  --sidebar: #304156;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

a {
  color: inherit;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  padding: 20px 16px;
  color: #e5eefc;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #94a3b8;
}

.side-nav {
  display: grid;
  gap: 4px;
  margin-top: 28px;
}

.side-nav a,
.front-link,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
}

.side-nav a {
  justify-content: flex-start;
  padding: 0 12px;
  color: #cbd5e1;
}

.side-nav a:hover,
.side-nav a.active {
  color: #fff;
  background: var(--primary);
}

.side-nav a.active {
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
}

.front-link {
  color: #dbeafe;
  background: rgba(255, 255, 255, 0.08);
}

.user-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.user-box span {
  color: #94a3b8;
  font-size: 13px;
}

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

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

.topbar h1,
.panel h2,
.locale-panel h3,
.login-card h1 {
  margin: 0;
  letter-spacing: -0.03em;
}

.topbar h1 {
  font-size: 30px;
}

.caption {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.panel,
.metric-card,
.record-card,
.login-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.panel {
  margin-bottom: 18px;
  padding: 20px;
}

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

.hint {
  color: var(--muted);
  font-size: 14px;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  font-weight: 700;
}

.notice.success {
  color: var(--success-text);
  background: var(--success-bg);
}

.notice.error {
  color: var(--error-text);
  background: var(--error-bg);
}

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

.metric-card {
  padding: 18px;
}

.metric-card span,
.table-row span,
.record-card summary span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
}

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

.quick-grid a {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.table-list,
.record-list {
  display: grid;
  gap: 10px;
}

.table-row,
.record-card summary {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.table-row {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.table-row img,
.record-card summary img {
  width: 76px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  background: #e2e8f0;
}

.table-row strong,
.table-row span,
.record-card summary strong,
.record-card summary span {
  display: block;
}

.text-link {
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(31, 99, 242, 0.18);
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-line input {
  width: 18px;
  height: 18px;
}

.locale-panel {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.locale-panel h3 {
  margin-bottom: 14px;
  color: #1d4ed8;
  font-size: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.primary-button,
.danger-button,
.ghost-button {
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
}

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

.primary-button:hover {
  background: var(--primary-deep);
}

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

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

.sidebar .ghost-button {
  width: 100%;
  color: #e2e8f0;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.16);
}

.record-card {
  overflow: hidden;
}

.record-card summary {
  padding: 12px;
  cursor: pointer;
  list-style: none;
  background: var(--surface-soft);
}

.record-card summary::-webkit-details-marker {
  display: none;
}

.record-card summary b {
  color: var(--primary);
}

.record-form {
  padding: 16px;
  border-top: 1px solid var(--line-soft);
}

.delete-form {
  padding: 0 16px 16px;
}

.source-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface-soft);
}

.source-box span {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(31, 99, 242, 0.14), transparent 32%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
}

.login-card h1 {
  font-size: 30px;
}

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

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

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

  .sidebar {
    position: static;
    height: auto;
    gap: 18px;
  }

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

  .sidebar-footer {
    grid-template-columns: 1fr auto auto;
    align-items: end;
  }
}

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

  .topbar,
  .panel-head {
    flex-direction: column;
  }

  .side-nav,
  .quick-grid,
  .metrics-grid,
  .form-grid,
  .sidebar-footer {
    grid-template-columns: 1fr;
  }

  .table-row,
  .record-card summary {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .table-row > span,
  .record-card summary b {
    grid-column: 2;
  }

  .panel,
  .login-card {
    padding: 16px;
  }
}

/* Modal/Dialog Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-soft);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--muted);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--line);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
}

/* Table Styles */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.data-table thead {
  background: var(--surface-soft);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.data-table tbody tr:hover {
  background: var(--surface-soft);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table img {
  width: 60px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
}

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

.table-actions button {
  padding: 6px 12px;
  font-size: 13px;
  min-height: auto;
}

/* Toolbar Styles */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.toolbar-right {
  display: flex;
  gap: 12px;
}

.search-input {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.active {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-badge.inactive {
  background: var(--surface-soft);
  color: var(--muted);
}
