:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --surface-muted: #f0f2f5;
  --line: #dcdfe6;
  --line-soft: #ebeef5;
  --text: #303133;
  --text-regular: #606266;
  --text-secondary: #909399;
  --primary: #409eff;
  --primary-soft: #ecf5ff;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar,
.content {
  padding: 20px;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  overflow: hidden;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

.brand {
  padding: 4px 0 12px;
}

.brand h1,
.content-header h2 {
  margin: 0;
  font-weight: 600;
}

.brand h1 {
  font-size: 28px;
  line-height: 1.2;
}

.content-header h2 {
  font-size: 28px;
  line-height: 1.3;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 500;
}

.search-box {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  font-size: 14px;
  color: var(--text-regular);
}

.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.12);
}

.search-box select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.12);
}

.account-meta,
.muted {
  color: var(--text-secondary);
  font-size: 13px;
}

.account-list {
  display: grid;
  grid-auto-rows: min-content;
  gap: 8px;
  margin-top: 12px;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.account-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.account-item:hover {
  border-color: #c6e2ff;
  background: #fbfdff;
}

.account-item.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(64, 158, 255, 0.08);
}

.account-main {
  min-width: 0;
  flex: 1;
}

.account-item strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: normal;
  word-break: break-word;
}

.account-item p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.counts {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: start;
  font-size: 12px;
  color: var(--text-secondary);
  flex: 0 0 auto;
}

.counts span {
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.content-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.toolbar-field {
  display: grid;
  gap: 6px;
  min-width: 160px;
  font-size: 13px;
  color: var(--text-regular);
}

.toolbar-field input,
.toolbar-field select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.toolbar-field input:focus,
.toolbar-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.12);
}

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

.tabs {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}

.tab,
.page-btn,
.icon-btn {
  border: 0;
  cursor: pointer;
}

.tab {
  min-width: 88px;
  height: 36px;
  padding: 0 18px;
  background: var(--surface);
  color: var(--text-regular);
  border-right: 1px solid var(--line);
  transition: background 0.2s ease, color 0.2s ease;
}

.tab:last-child {
  border-right: 0;
}

.tab:hover {
  color: var(--primary);
}

.tab.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.loading-mask {
  position: sticky;
  top: 16px;
  z-index: 20;
  display: flex;
  justify-content: center;
  margin-bottom: -8px;
}

.loading-mask.is-hidden {
  display: none;
}

.loading-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
  color: var(--text-regular);
  font-size: 13px;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #d9ecff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.summary-chip span {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
}

.summary-chip strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--text);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  min-height: 100%;
}

.card-hitarea {
  width: 100%;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.card-hitarea:hover {
  border-color: #c6e2ff;
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.media-shell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line-soft);
}

.card-media,
.dialog-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.card-body {
  padding: 14px;
}

.card-topline,
.stats,
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-topline {
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-owner {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--primary);
}

.card-topline strong {
  font-size: 13px;
  color: var(--text-regular);
}

.caption {
  margin: 0 0 14px;
  min-height: 66px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.stats {
  font-size: 13px;
  color: var(--text-regular);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 0 24px;
}

.page-btn,
.icon-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-regular);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

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

.primary-btn:hover:not(:disabled) {
  color: #fff;
  border-color: #66b1ff;
  background: #66b1ff;
}

.page-btn:hover:not(:disabled),
.icon-btn:hover {
  color: var(--primary);
  border-color: #c6e2ff;
  background: #fbfdff;
}

.page-btn:disabled {
  cursor: not-allowed;
  color: #c0c4cc;
  background: var(--surface-soft);
}

.empty-state,
.media-fallback {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-secondary);
  background: var(--surface);
}

.media-fallback.large {
  min-height: 420px;
}

.detail-dialog {
  width: min(1180px, calc(100vw - 32px));
  border: 1px solid var(--line-soft);
  padding: 0;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.dialog-header,
.dialog-body {
  padding: 20px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  border-bottom: 1px solid var(--line-soft);
}

.dialog-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.icon-btn {
  width: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 30px;
  text-align: center;
}

.dialog-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
}

.media-panel,
.detail-fields {
  min-width: 0;
}

.carousel-viewport {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-muted);
  aspect-ratio: 1 / 1;
}

.carousel-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.detail-grid {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.detail-row {
  align-items: start;
  font-size: 13px;
}

.detail-row span {
  color: var(--text-secondary);
}

.detail-row strong {
  max-width: 220px;
  text-align: right;
  color: var(--text);
  word-break: break-word;
}

.detail-section {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-regular);
}

.detail-section p,
.detail-section pre {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-regular);
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.detail-section pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border-radius: 4px;
  background: #fafafa;
  border: 1px solid var(--line-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .account-list {
    max-height: 280px;
  }

  .content-header {
    display: grid;
    align-items: start;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .dialog-body {
    grid-template-columns: 1fr;
  }
}
