/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #080c18;
  color: #c8d6e5;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #111827; }
::-webkit-scrollbar-thumb { background: #2a3548; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3b82f6; }

/* ===== Login Screen ===== */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #080c18 0%, #0f172a 50%, #1a1040 100%);
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(59,130,246,0.06) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(245,158,11,0.04) 0%, transparent 50%);
  animation: loginGlow 10s ease-in-out infinite alternate;
}
@keyframes loginGlow { 0% { transform: scale(1) rotate(0deg); } 100% { transform: scale(1.1) rotate(3deg); } }
.login-box {
  position: relative; z-index: 1;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 20px;
  padding: 56px 48px 48px;
  backdrop-filter: blur(20px);
  box-shadow: 0 25px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  width: 420px;
}
.login-logo { text-align: center; margin-bottom: 36px; }
.logo-icon { font-size: 56px; display: block; margin-bottom: 12px; filter: drop-shadow(0 4px 12px rgba(59,130,246,0.3)); }
.login-logo h1 {
  font-size: 28px; font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(135deg, #60a5fa, #f59e0b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo p { color: #64748b; margin-top: 6px; font-size: 13px; }
.input-group { display: flex; gap: 10px; }
.input-group input {
  flex: 1; padding: 14px 18px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #2a3548;
  border-radius: 12px; color: #e2e8f0; outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.error-text { color: #ef4444; font-size: 12px; margin-top: 12px; text-align: center; }

/* ===== Buttons ===== */
.btn-primary {
  padding: 10px 22px; background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; border: none; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #2563eb); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(59,130,246,0.3); }
.btn-secondary {
  padding: 10px 22px; background: transparent;
  color: #94a3b8; border: 1px solid #2a3548; border-radius: 10px; cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: #475569; color: #e2e8f0; }
.btn-danger { padding: 5px 12px; background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.25); border-radius: 8px; cursor: pointer; font-size: 12px; transition: all 0.2s; }
.btn-danger:hover { background: rgba(239,68,68,0.3); }
.btn-edit { padding: 5px 12px; background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); border-radius: 8px; cursor: pointer; font-size: 12px; transition: all 0.2s; }
.btn-edit:hover { background: rgba(59,130,246,0.25); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-gold { padding: 5px 12px; background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); border-radius: 8px; cursor: pointer; font-size: 12px; }
.btn-gold:hover { background: rgba(245,158,11,0.25); }

/* ===== Layout ===== */
.main-app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 220px; min-height: 100vh; background: #0d1117;
  border-right: 1px solid #1a2332;
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100;
}
.sidebar-header {
  padding: 20px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #1a2332;
}
.logo-icon-sm { font-size: 24px; }
.sidebar-title { font-size: 16px; font-weight: 700; color: #e2e8f0; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 2px 0;
  border-radius: 10px; color: #8892a4;
  transition: all 0.2s; font-size: 13px; font-weight: 500;
}
.nav-item:hover { background: rgba(59,130,246,0.08); color: #c8d6e5; }
.nav-item.active { background: rgba(59,130,246,0.15); color: #60a5fa; font-weight: 600; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid #1a2332; }
.btn-logout {
  width: 100%; padding: 10px; background: rgba(239,68,68,0.08);
  color: #f87171; border: 1px solid rgba(239,68,68,0.15); border-radius: 10px;
  cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ===== Content ===== */
.content { flex: 1; margin-left: 220px; padding: 28px 32px; }
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.section-header h2 { font-size: 22px; font-weight: 700; color: #e2e8f0; }
.section-header h3 { font-size: 17px; font-weight: 600; color: #c8d6e5; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.search-input {
  padding: 9px 16px; background: rgba(15,23,42,0.8);
  border: 1px solid #2a3548; border-radius: 10px; color: #e2e8f0; outline: none;
  width: 220px; transition: border-color 0.2s;
}
.search-input:focus { border-color: #3b82f6; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: linear-gradient(135deg, rgba(17,24,39,0.9), rgba(15,23,42,0.9));
  border: 1px solid #1a2332; border-radius: 14px;
  padding: 20px; transition: all 0.3s;
}
.stat-card:hover { border-color: rgba(59,130,246,0.3); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }
.stat-card .stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 900; color: #e2e8f0; line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: #64748b; margin-top: 4px; font-weight: 500; }
.recent-section { margin-top: 20px; }
.recent-section h3 { font-size: 16px; font-weight: 600; color: #c8d6e5; margin-bottom: 14px; }
.recent-list { display: flex; gap: 12px; flex-wrap: wrap; }
.recent-item {
  background: rgba(17,24,39,0.8); border: 1px solid #1a2332;
  border-radius: 10px; padding: 12px 18px; min-width: 140px;
}
.recent-item .r-name { font-weight: 600; color: #e2e8f0; }
.recent-item .r-meta { font-size: 11px; color: #64748b; margin-top: 3px; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: rgba(13,17,23,0.5);
  border: 1px solid #1a2332; border-radius: 12px; overflow: hidden;
}
.data-table thead { background: rgba(15,23,42,0.8); }
.data-table th {
  padding: 12px 14px; text-align: left; font-size: 12px;
  font-weight: 600; color: #64748b; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid #1a2332;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px; border-bottom: 1px solid rgba(26,35,50,0.5);
  font-size: 13px; vertical-align: middle;
}
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: rgba(59,130,246,0.04); }
.data-table tbody tr:last-child td { border-bottom: none; }
.actions-cell { display: flex; gap: 6px; white-space: nowrap; }
.rarity-stars { color: #f59e0b; letter-spacing: 1px; }
.type-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; color: #fff;
  white-space: nowrap;
}
.category-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; background: rgba(99,102,241,0.15); color: #818cf8;
}
.stat-num { font-variant-numeric: tabular-nums; }
.total-stat { font-weight: 700; color: #f59e0b; }
.empty-state {
  text-align: center; padding: 60px 20px; color: #475569;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ===== Modal ===== */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal-content {
  background: #111827; border: 1px solid #1f2937;
  border-radius: 16px; width: 90%; max-width: 640px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid #1f2937;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: #e2e8f0; }
.modal-close {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: rgba(239,68,68,0.1); border: none; border-radius: 8px;
  color: #f87171; font-size: 20px; cursor: pointer; transition: all 0.2s;
}
.modal-close:hover { background: rgba(239,68,68,0.2); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #1f2937; display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #94a3b8; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px;
  background: rgba(15,23,42,0.8);
  border: 1px solid #2a3548; border-radius: 10px;
  color: #e2e8f0; outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: #475569; margin-top: 4px; }

/* ===== Sub-table within modal ===== */
.sub-table { width: 100%; margin-top: 12px; }
.sub-table th { font-size: 11px; padding: 6px 8px; color: #64748b; text-align: left; border-bottom: 1px solid #1f2937; }
.sub-table td { padding: 6px 8px; font-size: 12px; border-bottom: 1px solid rgba(31,41,55,0.5); }

/* ===== Type Relations Grid ===== */
.type-relations-grid { overflow-x: auto; }
.type-matrix { border-collapse: collapse; font-size: 11px; }
.type-matrix th, .type-matrix td { padding: 4px 6px; text-align: center; border: 1px solid #1a2332; min-width: 40px; }
.type-matrix th { background: rgba(15,23,42,0.8); color: #94a3b8; font-weight: 600; font-size: 10px; }
.type-matrix td { cursor: pointer; transition: all 0.15s; }
.type-matrix td:hover { outline: 2px solid #3b82f6; }
.mult-2 { background: rgba(34,197,94,0.2); color: #4ade80; font-weight: 700; }
.mult-05 { background: rgba(239,68,68,0.15); color: #f87171; }
.mult-0 { background: rgba(100,116,139,0.15); color: #475569; }
.mult-1 { color: #475569; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 22px; border-radius: 12px; font-size: 13px; font-weight: 500;
  animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  max-width: 360px;
}
.toast.success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.toast.error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.toast.info { background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { 0%, 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-title, .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .content { margin-left: 60px; padding: 20px 16px; }
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
