/* ═══════════════════════════════════════════
   天造Portal SAAS — 白色主题设计系统 V2
   灵感：Apple + Stripe Dashboard
   特性：数据可视化 / 图表 / 响应式
   ═══════════════════════════════════════════ */

/* ═══ CSS Variables ═══ */
:root {
  --blue: #0066cc;
  --blue-hover: #0077ed;
  --blue-light: rgba(0,102,204,0.08);
  --blue-ring: rgba(0,102,204,0.3);
  --green: #34c759;
  --green-light: rgba(52,199,89,0.10);
  --orange: #f5a623;
  --orange-light: rgba(245,166,35,0.10);
  --red: #ff3b30;
  --red-light: rgba(255,59,48,0.08);
  --purple: #8B5CF6;
  --purple-light: rgba(139,92,246,0.10);

  --ink: #1d1d1f;
  --ink-secondary: #515154;
  --ink-muted: #86868b;
  --ink-disabled: #aeaeb2;

  --bg: #ffffff;
  --bg-parchment: #f5f5f7;
  --bg-card: #ffffff;
  --bg-hover: #f5f5f7;
  --bg-input: #ffffff;

  --border: #e5e5ea;
  --border-light: #f0f0f0;
  --hairline: rgba(0,0,0,0.06);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --font: system-ui, -apple-system, 'SF Pro Text', 'Inter', 'PingFang SC', sans-serif;
  --font-display: system-ui, -apple-system, 'SF Pro Display', 'Inter', 'PingFang SC', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Cascadia Code', monospace;

  --sidebar-w: 220px;
}

/* ═══ Reset ═══ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 15px; font-weight: 400; line-height: 1.5;
  color: var(--ink);
  background: var(--bg-parchment);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); }
img, svg { max-width: 100%; display: block; }

/* ═══ App Shell ═══ */
.app-sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border-light);
  padding: 28px 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.app-sidebar-logo {
  padding: 0 20px 24px;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--ink);
}
.app-sidebar-nav { flex: 1; }
.app-sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; margin: 2px 10px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-secondary); text-decoration: none;
  border-radius: var(--radius); transition: all 0.12s;
}
.app-sidebar-nav a:hover { background: var(--bg-hover); color: var(--ink); }
.app-sidebar-nav a.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }
.app-sidebar-nav .nav-icon { width: 20px; text-align: center; font-size: 15px; opacity: 0.7; }
.app-sidebar-nav a.active .nav-icon { opacity: 1; }
.app-sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border-light);
  font-size: 13px; color: var(--ink-muted);
  display: flex; align-items: center; gap: 8px;
}

.app-main {
  margin-left: var(--sidebar-w);
  padding: 32px 36px;
  min-height: 100vh;
}
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px;
}
.app-header h1 {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
  color: var(--ink);
}
.app-header-right {
  display: flex; align-items: center; gap: 16px;
  font-size: 14px; color: var(--ink-secondary);
}

/* ═══ Stats Grid ═══ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700; letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: 13px; color: var(--ink-muted);
}

/* ═══ Charts ═══ */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--ink);
}
.chart-wrap {
  position: relative; width: 100%;
}
.chart-wrap canvas { width: 100% !important; }

/* ═══ Panel ═══ */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  font-size: 17px; font-weight: 600; margin-bottom: 16px; color: var(--ink);
}

/* ═══ Table ═══ */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%; border-collapse: collapse;
}
.table thead { position: sticky; top: 0; z-index: 1; }
.table th {
  padding: 12px 16px; text-align: left;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--ink-muted);
  background: var(--bg-parchment);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px; text-align: left;
  font-size: 14px; color: var(--ink-secondary);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.table tr:hover td { background: var(--bg-hover); }
.table tr:last-child td { border-bottom: none; }
.table .mono { font-family: var(--font-mono); font-size: 13px; }

/* ═══ Badge ═══ */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; letter-spacing: 0.2px;
}
.badge-active, .badge-running, .badge-online   { background: var(--green-light); color: var(--green); }
.badge-published                                { background: var(--blue-light); color: var(--blue); }
.badge-draft                                    { background: #f5f5f7; color: var(--ink-muted); }
.badge-paused                                   { background: var(--orange-light); color: var(--orange); }
.badge-ended, .badge-expired, .badge-suspended  { background: var(--red-light); color: var(--red); }
.badge-offline                                  { background: #f5f5f7; color: var(--ink-disabled); }
.badge-fault                                    { background: var(--red-light); color: var(--red); }

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; cursor: pointer; font-family: inherit;
  font-weight: 500; border-radius: var(--radius);
  text-decoration: none; transition: all 0.12s;
  white-space: nowrap; font-size: 14px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; padding: 10px 20px; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: var(--bg); color: var(--ink); padding: 8px 16px; border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-parchment); }
.btn-success { background: var(--green-light); color: var(--green); padding: 5px 14px; font-size: 13px; }
.btn-success:hover { background: rgba(52,199,89,0.18); }
.btn-danger { background: var(--red-light); color: var(--red); padding: 5px 14px; font-size: 13px; }
.btn-danger:hover { background: rgba(255,59,48,0.15); }
.btn-sm { font-size: 13px; padding: 6px 14px; }

/* ═══ Forms ═══ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--ink-secondary); margin-bottom: 4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--ink);
  font-size: 15px; font-family: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
}
.form-select option { background: #fff; color: var(--ink); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ═══ Filter Bar ═══ */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: center;
}
.filter-bar .form-input,
.filter-bar .form-select { width: auto; min-width: 150px; }

/* ═══ Alerts ═══ */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; margin-bottom: 16px;
}
.alert-success { background: var(--green-light); color: var(--green); }
.alert-error { background: var(--red-light); color: var(--red); }

/* ═══ Modal ═══ */
.modal {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: var(--radius-xl); padding: 28px;
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-content h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ═══ Pagination ═══ */
.pagination {
  display: flex; justify-content: center; gap: 6px; margin-top: 20px;
}
.pagination a {
  padding: 7px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--ink-secondary);
  font-size: 14px; text-decoration: none; transition: all 0.12s;
}
.pagination a:hover { background: var(--bg-hover); }
.pagination a.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ═══ Empty State ═══ */
.empty-state { text-align: center; color: var(--ink-muted); padding: 40px; font-size: 14px; }

/* ═══ Info Grid ═══ */
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item .info-label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.info-item .info-value { font-size: 15px; color: var(--ink); }

/* ═══ Photo Grid ═══ */
.photo-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.photo-item {
  aspect-ratio: 3/4; background: var(--bg-parchment);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border-light);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; }

/* ═══ Settings ═══ */
.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--ink); }
.settings-section .desc { font-size: 13px; color: var(--ink-muted); margin-bottom: 12px; }

/* ═══ Responsive ═══ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-sidebar { display: none; }
  .app-main { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
}
@media (min-width: 1920px) {
  .app-main { padding: 40px 56px; }
  .stat-card .stat-value { font-size: 38px; }
}
