@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --primary-50: #dbeafe;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ─── LOGIN PAGE ─── */
#login-page {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 40%, #0ea5e9 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#login-page.hidden { display: none; }

.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  width: 400px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
  animation: slideUp 0.4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: #1e293b; }
.login-logo p { font-size: 13px; color: #94a3b8; margin-top: 4px; }

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: #475569; margin-bottom: 8px;
}
.form-group input {
  width: 100%; padding: 12px 16px;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  font-size: 14px; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.2s; letter-spacing: 0.5px;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.4); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.login-error {
  background: #fef2f2; color: #dc2626;
  border: 1px solid #fecaca; border-radius: 8px;
  padding: 10px 14px; font-size: 13px;
  margin-top: 16px; display: none;
}
.login-error.show { display: block; }

/* ─── SIDEBAR ─── */
#sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-brand h2 {
  color: white; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  margin-bottom: 4px; user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: rgba(37,99,235,0.2); color: #60a5fa; }
.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid #1e293b;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s;
}
.user-info:hover { background: var(--sidebar-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.user-info .name { color: #e2e8f0; font-size: 13px; font-weight: 500; }
.user-info .role { color: #64748b; font-size: 11px; }

/* ─── MAIN ─── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: white; border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.breadcrumb .sep { color: #cbd5e1; }
.breadcrumb .current { color: var(--primary); font-weight: 500; }
.breadcrumb .parent { color: #94a3b8; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.content { flex: 1; overflow-y: auto; padding: 28px; }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── HOME ─── */
.welcome-banner {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
  border-radius: var(--radius); padding: 32px 36px;
  margin-bottom: 24px; color: white; position: relative; overflow: hidden;
}
.welcome-banner::before {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 200px; height: 200px; background: rgba(255,255,255,0.06); border-radius: 50%;
}
.welcome-banner::after {
  content: ''; position: absolute; right: 60px; bottom: -40px;
  width: 150px; height: 150px; background: rgba(255,255,255,0.04); border-radius: 50%;
}
.welcome-banner h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.welcome-banner p { font-size: 14px; opacity: 0.8; }

.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 54px; height: 54px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; }
.stat-icon.purple { background: #ede9fe; }
.stat-info .label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.stat-info .value {
  font-size: 32px; font-weight: 700; color: var(--text);
  line-height: 1; display: flex; align-items: center; gap: 10px;
}
.stat-info .sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.loading-dot {
  width: 8px; height: 8px; background: #cbd5e1; border-radius: 50%;
  display: inline-block; animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.quick-actions {
  background: white; border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow);
}
.quick-actions h3 { font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.quick-item {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 16px; border-radius: 10px; border: 1.5px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.quick-item:hover { border-color: var(--primary); background: var(--primary-bg); }
.quick-item .qi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.quick-item .qi-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── SECTION HEADER ─── */
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.section-header h2 { font-size: 20px; font-weight: 700; }
.section-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ─── SEARCH BAR ─── */
.search-bar {
  background: white; border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.search-bar label { font-size: 14px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }

.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  padding: 9px 36px 9px 14px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--text);
  background: white; cursor: pointer; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s; min-width: 130px;
}
.select-wrap select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.select-wrap::after {
  content: ''; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; border-left: 4px solid transparent;
  border-right: 4px solid transparent; border-top: 5px solid #94a3b8; pointer-events: none;
}

.search-input {
  flex: 1; min-width: 200px; padding: 9px 14px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn {
  padding: 9px 22px; border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─── TABLE ─── */
.table-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8fafc; border-bottom: 1px solid var(--border); }
thead th {
  padding: 13px 20px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 14px 20px; font-size: 14px; color: var(--text); }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #fef3c7; color: #92400e; }

/* ─── USER INFO RESULT ─── */
.result-card {
  background: white; border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.result-card h3 {
  font-size: 15px; font-weight: 600; margin-bottom: 18px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.info-item .key {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.info-item .val { font-size: 15px; color: var(--text); font-weight: 500; }

/* ─── PAGINATION ─── */
.pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.page-info { font-size: 13px; color: var(--text-muted); margin-right: 8px; }
.pg-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); background: white;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.15s; color: var(--text);
}
.pg-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pg-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── EMPTY / ERROR / SUCCESS ─── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

.error-banner {
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 12px 16px;
  font-size: 14px; color: #dc2626; margin-top: 12px; display: none;
}
.error-banner.show { display: block; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); display: none;
  align-items: center; justify-content: center; z-index: 500;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 16px; padding: 32px 36px;
  width: 440px; max-width: 90vw;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2); animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 24px; }
.modal-field { margin-bottom: 20px; }
.modal-field label {
  display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 8px;
}
.modal-field .readonly-val {
  padding: 10px 14px; background: #f8fafc;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text-muted);
}
.radio-group { display: flex; gap: 20px; align-items: center; }
.radio-option {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 15px; font-weight: 500;
}
.radio-option input[type="radio"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.number-input {
  display: flex; align-items: center; border: 1.5px solid var(--border);
  border-radius: 8px; overflow: hidden; width: fit-content;
}
.num-btn {
  width: 38px; height: 38px; border: none; background: #f8fafc;
  cursor: pointer; font-size: 18px; color: #64748b;
  transition: background 0.15s; display: flex; align-items: center; justify-content: center;
}
.num-btn:hover { background: #e2e8f0; }
.num-val {
  width: 60px; text-align: center; border: none; outline: none;
  font-size: 15px; font-family: inherit; font-weight: 600;
  background: white; padding: 0 8px; height: 38px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }
.btn-cancel {
  padding: 10px 22px; border: 1.5px solid var(--border);
  background: white; color: var(--text-muted); border-radius: 8px;
  font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.btn-cancel:hover { border-color: #94a3b8; color: var(--text); }
.btn-confirm {
  padding: 10px 24px; background: var(--primary); color: white;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.btn-confirm:hover { background: var(--primary-dark); }
.btn-confirm:disabled { opacity: 0.6; cursor: not-allowed; }

.modal-error { color: #dc2626; font-size: 13px; margin-top: 12px; display: none; }
.modal-error.show { display: block; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: white;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── TOAST 提示 ─── */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: #1e293b; color: white;
  padding: 12px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 9999; transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
.toast-icon { font-size: 16px; }
