/* ========== ChunYe Design System v2 ========== */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #0f172a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.06), 0 4px 10px -6px rgba(0,0,0,.03);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --font: "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Consolas", monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,*::before,*::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

h1,h2,h3,h4 { font-weight: 600; color: var(--text); line-height: 1.3; margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

/* Header */
.glass-header {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.glass-header h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; background: var(--surface); color: var(--text);
  transition: all var(--transition); white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: #f8faff; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; border-color: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--border-light); color: var(--text); border-color: transparent; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }

/* Input */
input[type="text"],input[type="password"],input[type="email"],input[type="number"],
input[type="time"],input[type="date"],input[type="search"],textarea,select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font);
  background: var(--surface); color: var(--text);
  transition: all var(--transition); outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th,td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); text-align: left; }
th { background: var(--bg); color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--bg); }

/* Badges */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.pill-success { background: #ecfdf5; color: #065f46; }
.pill-warning { background: #fffbeb; color: #92400e; }
.pill-danger { background: #fef2f2; color: #991b1b; }
.pill-info { background: #eff6ff; color: #1e40af; }
.pill-neutral { background: #f1f5f9; color: #475569; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .val { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.stat-card .lbl { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* Toast */
.toast {
  position: fixed; top: 20px; right: 20px;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; color: #fff;
  z-index: 9999; opacity: 0; transform: translateY(-8px);
  transition: all var(--transition); pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.4); backdrop-filter: blur(4px);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 24px; max-width: 480px; width: 90%; max-height: 80vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}

/* Layout helpers */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; } .text-center { text-align: center; } .w-full { width: 100%; }
.flex { display: flex; } .flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
/* ===== Micro-interactions & Refinements ===== */
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 0; height: 0; background: rgba(255,255,255,.2);
  border-radius: 50%; transform: translate(-50%,-50%);
  transition: width .4s, height .4s;
}
.btn:active::after { width: 200px; height: 200px; }

.card { transition: box-shadow .2s, transform .2s; }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  border-color: var(--accent);
}

.nav-item, .tab, .quick-link {
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.fade-in-stagger > * { animation: fadeInUp .4s var(--transition) both; }
.fade-in-stagger > *:nth-child(1){animation-delay:0s}
.fade-in-stagger > *:nth-child(2){animation-delay:.04s}
.fade-in-stagger > *:nth-child(3){animation-delay:.08s}
.fade-in-stagger > *:nth-child(4){animation-delay:.12s}
.fade-in-stagger > *:nth-child(5){animation-delay:.16s}
.fade-in-stagger > *:nth-child(6){animation-delay:.2s}
.fade-in-stagger > *:nth-child(7){animation-delay:.24s}
.fade-in-stagger > *:nth-child(8){animation-delay:.28s}

tbody tr { transition: background .15s; }
tbody tr:hover { background: #f8fafc; }

@keyframes shimmer { 0%{background-position:-200px 0} 100%{background-position:200px 0} }
.skeleton {
  background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 37%,#f1f5f9 63%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
}

.view, .tab-content { animation: fadeIn .25s var(--transition); }

.pill, .badge-pill { transition: all .2s; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px; cursor: pointer;
}

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .5s, transform .5s; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
