/* Apple Design System - PC port of miniprogram/app.wxss */

:root {
  --bg-canvas: #ffffff;
  --bg-parchment: #f5f5f7;
  --bg-pearl: #fafafc;
  --bg-nav: #000000;

  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-muted: #cccccc;
  --text-dark-surface: #ffffff;
  --text-fine-print: #7a7a7a;

  --accent-primary: #0066cc;
  --accent-focus: #0071e3;
  --accent-link: #2997ff;

  --status-spam: #ff3b30;
  --status-ham: #34c759;
  --status-warn: #ff9500;
  --status-pending: #8e8e93;

  --border-light: #f0f0f0;
  --border-medium: #e0e0e0;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 36px;
  --spacing-xl: 56px;

  --font-display: 'PingFang SC', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-text: 'PingFang SC', 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-parchment);
  color: var(--text-primary);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
}

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

.container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-md) var(--spacing-md) var(--spacing-xl);
}

/* Hero */
.hero {
  position: relative;
  padding: var(--spacing-md) 0;
  text-align: center;
}

.hero-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-pearl);
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
}

.hero-title {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.hero-sub {
  margin: 8px auto 0;
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 720px;
  line-height: 1.55;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--spacing-sm);
  justify-content: center;
}

.hero-metric {
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
}

/* Cards */
.card {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-md);
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
}

.card-title {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.card-desc {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* Fields */
.field {
  margin-top: 12px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.field-help {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Inputs */
.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-parchment);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent-primary);
  background: var(--bg-canvas);
}

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

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2386868b' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.btn-row .btn {
  flex: 1;
  min-width: 120px;
  margin-top: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-dark-surface);
  background: var(--accent-primary);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.92;
}

.btn:active {
  transform: scale(0.97);
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: var(--text-dark-surface);
  background: var(--accent-primary);
}

.btn-ghost {
  color: var(--accent-primary);
  background: transparent;
  border: 1px solid var(--accent-primary);
}

.btn-ghost:hover {
  background: rgba(0, 102, 204, 0.06);
}

.btn-ghost[disabled],
.btn-ghost.is-disabled {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

.btn-accent {
  color: var(--accent-primary);
  background: var(--bg-pearl);
}

.btn-accent:hover {
  background: var(--bg-parchment);
}

.btn-danger {
  color: var(--text-dark-surface);
  background: var(--status-spam);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

/* Rows */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row + .row {
  margin-top: 10px;
}

.label {
  color: var(--text-secondary);
  font-size: 13px;
}

.value {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

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

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

/* KPI */
.kpi {
  padding: 16px;
  background: var(--bg-parchment);
  border-radius: var(--radius-md);
  text-align: center;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-value.small {
  font-size: 14px;
}

.kpi-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Module Cards */
.module-card {
  padding: 18px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.module-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.module-name {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}

.module-desc {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.module-tag {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 10px;
  color: var(--accent-primary);
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 102, 204, 0.1);
  border-radius: var(--radius-pill);
}

/* List Items */
.list-item {
  margin-top: 10px;
  padding: 14px 16px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.item-title {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-all;
}

.item-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

/* Tags & Chips */
.tag {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-parchment);
  cursor: pointer;
}

.tag-danger {
  color: var(--status-spam);
  background: rgba(255, 59, 48, 0.1);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-parchment);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.chip:hover {
  background: var(--bg-pearl);
}

/* Progress */
.progress-track {
  margin-top: 6px;
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--status-spam);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.progress-fill-safe {
  height: 100%;
  background: var(--status-ham);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

/* Status Labels */
.status-spam,
.status-ham,
.status-warn,
.status-pending {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

.status-spam {
  color: var(--text-dark-surface);
  background: var(--status-spam);
}

.status-ham {
  color: var(--text-dark-surface);
  background: var(--status-ham);
}

.status-warn {
  color: var(--text-dark-surface);
  background: var(--status-warn);
}

.status-pending {
  color: var(--text-primary);
  background: var(--bg-parchment);
}

/* Pager */
.pager-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pager-btn {
  flex: 1;
}

/* Misc */
.muted {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.small {
  font-size: 12px;
}

.empty {
  text-align: center;
  padding: var(--spacing-md);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background-color: #d1d1d6;
  border-radius: var(--radius-pill);
  transition: background-color 0.2s ease;
}

.switch-slider::before {
  position: absolute;
  content: '';
  height: 20px;
  width: 20px;
  left: 2px;
  top: 2px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background-color: var(--status-ham);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

/* Evidence */
.evidence-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.evidence-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.evidence-thumb {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.evidence-clickable {
  cursor: zoom-in;
}

.evidence-clickable:hover {
  opacity: 0.85;
}

.evidence-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: var(--status-spam);
  color: var(--text-dark-surface);
  font-size: 14px;
  text-align: center;
  line-height: 22px;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
}

.evidence-add {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background: var(--bg-parchment);
  border: 1px dashed var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.evidence-add:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.evidence-add-icon {
  font-size: 28px;
  color: var(--text-secondary);
  line-height: 1;
}

.evidence-add input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Credit */
.credit-score-bar {
  position: relative;
  width: 160px;
  height: 18px;
  background: var(--border-light);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.credit-fill {
  height: 100%;
  background: var(--status-ham);
  border-radius: var(--radius-pill);
}

.credit-value {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-primary);
}

/* Report Section */
.report-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.report-section-title {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.report-kpi {
  padding: 14px;
  background: var(--bg-parchment);
  border-radius: var(--radius-md);
  text-align: center;
}

.report-kpi-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.report-kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  height: 56px;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0066cc, #2997ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.topbar-tab {
  position: relative;
  padding: 8px 14px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.topbar-tab:hover {
  color: var(--text-primary);
  background: var(--bg-parchment);
}

.topbar-tab.is-active {
  color: var(--accent-primary);
  background: rgba(0, 102, 204, 0.1);
}

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

.topbar-admin {
  position: relative;
}

.topbar-admin-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-parchment);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.topbar-admin-trigger:hover {
  background: var(--bg-pearl);
}

.topbar-admin-trigger.is-active {
  color: var(--accent-primary);
  background: rgba(0, 102, 204, 0.1);
}

.topbar-admin-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.topbar-admin-item {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}

.topbar-admin-item:hover {
  background: var(--bg-parchment);
  color: var(--accent-primary);
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-parchment);
  color: var(--text-primary);
  font-size: 13px;
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0066cc, #2997ff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* Toast */
.toast-host {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  padding: 10px 18px;
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease both;
}

.toast-item.is-error {
  background: rgba(255, 59, 48, 0.95);
}

.toast-item.is-success {
  background: rgba(52, 199, 89, 0.95);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade 0.18s ease both;
}

.modal-card {
  width: min(420px, 92vw);
  padding: 24px;
  background: var(--bg-canvas);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Image preview */
.preview-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade 0.2s ease both;
}

.preview-stage {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
}

.preview-img {
  max-width: 92vw;
  max-height: 90vh;
  display: block;
  border-radius: var(--radius-md);
}

.preview-close {
  position: absolute;
  top: -42px;
  right: -2px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
}

.preview-prev {
  left: -64px;
}

.preview-next {
  right: -64px;
}

/* Picker */
.picker-value {
  min-width: 140px;
  text-align: right;
  color: var(--accent-primary);
  font-size: 13px;
}

/* Animations */
.fade-up {
  animation: fadeUp 0.35s ease both;
}

.fade-up-delay-1 {
  animation-delay: 0.06s;
}

.fade-up-delay-2 {
  animation-delay: 0.12s;
}

.fade-up-delay-3 {
  animation-delay: 0.18s;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Note textarea */
.note-textarea {
  min-height: 64px;
}

/* Threshold input */
.threshold-input {
  max-width: 200px;
}

/* Radio inline */
.radio-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13px;
}

.radio-row input[type='radio'] {
  accent-color: var(--accent-primary);
}

/* Responsive */
@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .topbar-nav .topbar-tab {
    padding: 6px 10px;
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    gap: 12px;
  }
  .hero-title {
    font-size: 26px;
  }
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}
