*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #667EEA;
  --primary-dark: #764BA2;
  --accent: #F093FB;
  --accent-hot: #F5576C;
  --bg: #F8F9FE;
  --surface: #FFFFFF;
  --surface-glass: rgba(255,255,255,0.72);
  --text: #1A1A2E;
  --text-secondary: #6C6C8A;
  --text-muted: #9CA3AF;
  --success: #00C9A7;
  --success-bg: #E6FBF5;
  --warning: #FFB347;
  --warning-bg: #FFF7E6;
  --danger: #FF6B6B;
  --danger-bg: #FFEDED;
  --border: #E8E8F0;
  --sidebar-bg: linear-gradient(180deg, #1A1A2E 0%, #16213E 100%);
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  --gradient-accent: linear-gradient(135deg, var(--accent) 0%, var(--accent-hot) 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.1);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1200px; margin: 0 auto; padding: 1rem; }

/* ─── Sidebar ─── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: #fff;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  padding: 0;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: #D0D0DC; border-radius: 3px; }
.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.5rem;
}
.sidebar-brand strong {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.02em;
}
.sidebar ul.sidebar-nav { list-style: none; padding: 0 0.5rem; margin: 0; }
.sidebar li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  color: #B0B8C8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar li a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  transform: translateX(2px);
}
.sidebar li a.active {
  background: linear-gradient(135deg, rgba(102,126,234,0.35) 0%, rgba(118,75,162,0.35) 100%);
  color: #fff;
  font-weight: 600;
  position: relative;
}
.sidebar li a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gradient-accent);
  border-radius: 0 3px 3px 0;
}
.sidebar .nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }
.sidebar .nav-section {
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}
.sidebar .nav-section:first-child { margin-top: 0; }
.sidebar h3 {
  padding: 0.5rem 0.75rem 0.35rem;
  margin: 0;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* ─── Main Content ─── */
.main-content {
  margin-left: 240px;
  padding: 1.75rem 2rem;
  height: 100vh;
  overflow-y: auto;
}

/* ─── Page Header ─── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
}
.page-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card:nth-child(2)::before { background: var(--gradient-accent); }
.stat-card:nth-child(3)::before { background: linear-gradient(135deg, #00C9A7, #00D4AA); }
.stat-card:nth-child(4)::before { background: linear-gradient(135deg, #FFB347, #FF6B6B); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-card .stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.35rem;
  font-weight: 500;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 2px 12px rgba(102,126,234,0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(102,126,234,0.45);
  transform: translateY(-1px);
}
.btn-danger {
  background: linear-gradient(135deg, #FF6B6B 0%, #EE5A5A 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(255,107,107,0.25);
}
.btn-danger:hover {
  box-shadow: 0 4px 16px rgba(255,107,107,0.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #D0D0DC;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─── Tables ─── */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 0.7rem 1rem; text-align: left; }
th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}
td {
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
tr:hover td { background: rgba(102,126,234,0.03); }
tr:last-child td { border-bottom: none; }
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── Alerts ─── */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid;
}
.alert-success { background: var(--success-bg); color: #065F46; border-color: var(--success); }
.alert-error { background: var(--danger-bg); color: #991B1B; border-color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: #92400E; border-color: var(--warning); }

/* ─── Pagination ─── */
.pagination { display: flex; gap: 0.4rem; align-items: center; margin-top: 1.25rem; }
.pagination a, .pagination span {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}
.pagination span.current {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.pagination a {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.pagination a:hover {
  background: var(--bg);
  color: var(--text);
}

/* ─── Links ─── */
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─── Login Page ─── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667EEA 0%, #764BA2 50%, #F093FB 100%);
  padding: 2rem;
}
.login-card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.3);
}
.login-card h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* ─── Sidebar toggle (mobile) ─── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ─── Badge ─── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg); color: #065F46; }
.badge-warning { background: var(--warning-bg); color: #92400E; }
.badge-danger { background: var(--danger-bg); color: #991B1B; }

/* ─── Dashboard (工作台) ─── */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-secondary { color: var(--text-secondary); }
.text-muted-2 { color: var(--text-muted); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.metric-item { text-align: center; }
.metric-item .metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}
.metric-item .metric-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}
.metric-item .metric-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.dash-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.25rem;
}
.dash-row .card { margin-bottom: 1.25rem; }
.card-header {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pending-list { list-style: none; margin: 0; padding: 0; }
.pending-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}
.pending-list li.pending { background: rgba(255,179,71,0.08); }
.pending-list li.done { background: var(--bg); }
.pending-list .dot { flex-shrink: 0; }
.pending-list li.pending .dot { color: var(--warning); }
.pending-list li.done .dot { color: var(--success); }

.deadline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}
.deadline-row .dl-label { font-weight: 600; }

.step-list { list-style: none; margin: 0; padding: 0; }
.step-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.step-list li:last-child { border-bottom: none; }
.step-list .step-num {
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step-list .step-info { flex: 1; }
.step-list .step-title { font-weight: 600; }
.step-list .step-desc { color: var(--text-muted); font-size: 0.78rem; }

.amount-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; height: 100vh; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 1rem; padding-top: 3.5rem; height: 100vh; }
  .menu-toggle { display: block; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .dash-row { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ─── Usage Guide ─── */
.usage-guide {
  background: linear-gradient(135deg, #f0f7ff 0%, #f8fbff 100%);
  border: 1px solid #d0e0f0;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.7;
}
.usage-guide summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
  display: inline-block;
}
.usage-guide summary:hover { text-decoration: underline; }
.usage-guide[open] summary { margin-bottom: 0.5rem; }
.usage-guide p { margin: 0.3rem 0; color: #4a5568; }
.usage-guide .step { color: var(--primary); font-weight: 600; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D0D0DC; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #B0B0BC; }

/* ─── Selection ─── */
::selection { background: rgba(102,126,234,0.2); }
