/* ===== Flat Design System ===== */
/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: #0F172A;
  background: #F1F5F9;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
a { color: #4F6EF7; text-decoration: none; }
a:hover { color: #3B5BDB; }

/* ===== Header ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px; background: #4F6EF7; color: #fff;
  display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-title { font-size: 16px; font-weight: 600; letter-spacing: 0.3px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; opacity: .9; }
.menu-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 5px; padding: 4px;
}
.menu-btn span { display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; }

/* ===== Sidebar ===== */
.sidebar-overlay { position: fixed; inset: 0; z-index: 199; background: rgba(15,23,42,.3); }
.sidebar {
  position: fixed; top: 0; left: -270px; bottom: 0; z-index: 200;
  width: 270px; background: #fff;
  border-right: 1px solid #E2E8F0;
  transition: left .25s ease; overflow-y: auto;
}
.sidebar.open { left: 0; }
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid #F1F5F9;
}
.sidebar-header h3 { font-size: 15px; color: #0F172A; font-weight: 600; }
.close-btn { background: none; border: none; font-size: 22px; cursor: pointer; color: #94A3B8; padding: 0 4px; }
.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 20px; background: #F8FAFC; }
.user-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: #4F6EF7; display: flex; align-items: center;
  justify-content: center; font-size: 17px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-username { font-size: 15px; font-weight: 600; color: #0F172A; }
.sidebar-role { font-size: 12px; color: #64748B; margin-top: 2px; }
.nav-section { padding: 12px 0; }
.nav-label {
  padding: 8px 20px 4px; font-size: 11px; color: #94A3B8;
  text-transform: uppercase; letter-spacing: 1px;
}
.nav-item {
  display: block; padding: 10px 20px; color: #475569; font-size: 14px;
  transition: background .15s, color .15s; text-decoration: none; position: relative;
}
.nav-item:hover { background: #F8FAFC; color: #4F6EF7; }
.nav-item.router-link-exact-active { color: #4F6EF7; font-weight: 600; background: #EEF1FF; }
.nav-item.router-link-exact-active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: #4F6EF7; border-radius: 0 3px 3px 0;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: 56px; background: #fff; border-top: 1px solid #E2E8F0;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-decoration: none; color: #94A3B8; font-size: 10px; gap: 3px;
}
.bottom-nav-item.router-link-exact-active { color: #4F6EF7; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-text { font-size: 10px; }

/* ===== Layout ===== */
.main-content { flex: 1; padding-top: 56px; }
.page { min-height: calc(100vh - 56px); padding: 24px; max-width: 1200px; margin: 0 auto; }
.page-full { min-height: calc(100vh - 56px); padding: 24px; }

/* ===== Card ===== */
.card {
  background: #fff; border-radius: 12px; padding: 24px;
  margin-bottom: 16px; border: 1px solid #E2E8F0;
}
.page-title { font-size: 22px; font-weight: 700; color: #0F172A; margin-bottom: 24px; letter-spacing: -0.3px; }
.section-title { font-size: 16px; font-weight: 600; color: #0F172A; margin-bottom: 16px; }
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.page-header .page-title { margin-bottom: 0; }

/* ===== Button ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px; padding: 10px 20px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1.5; gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: #4F6EF7; color: #fff; }
.btn-primary:hover { background: #3B5BDB; }
.btn-success { background: #22C55E; color: #fff; }
.btn-success:hover { background: #16A34A; }
.btn-danger { background: #EF4444; color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-warning { background: #F59E0B; color: #fff; }
.btn-warning:hover { background: #D97706; }
.btn-outline { background: transparent; color: #475569; border: 1px solid #CBD5E1; }
.btn-outline:hover { border-color: #4F6EF7; color: #4F6EF7; }
.btn-outline-light { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn-outline-light:hover { border-color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ===== Form ===== */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 14px; color: #475569; margin-bottom: 6px; font-weight: 500; }
.form-input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid #CBD5E1; border-radius: 8px;
  font-size: 14px; color: #0F172A; background: #fff;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-input:focus { border-color: #4F6EF7; box-shadow: 0 0 0 3px rgba(79,110,247,.12); }
.form-input::placeholder { color: #94A3B8; }
textarea.form-input { height: auto; padding: 12px 14px; resize: vertical; min-height: 80px; }
select.form-input { 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='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 24px 20px;
  border: 1px solid #E2E8F0; text-align: center;
}
.stat-value { font-size: 30px; font-weight: 700; color: #0F172A; line-height: 1.2; }
.stat-label { font-size: 13px; color: #64748B; margin-top: 6px; }
.stat-primary .stat-value { color: #4F6EF7; }
.stat-success .stat-value { color: #22C55E; }
.stat-warning .stat-value { color: #F59E0B; }
.stat-danger .stat-value { color: #EF4444; }
.stat-info .stat-value { color: #6366F1; }

/* ===== Tag ===== */
.tag { display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.tag-success { background: #DCFCE7; color: #16A34A; }
.tag-warning { background: #FEF3C7; color: #D97706; }
.tag-danger { background: #FEE2E2; color: #DC2626; }
.tag-info { background: #F1F5F9; color: #64748B; }
.tag-primary { background: #EEF1FF; color: #4F6EF7; }

/* ===== Empty & Loading ===== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; }
.empty-icon { width: 56px; height: 56px; margin-bottom: 16px; border-radius: 50%; background: #F1F5F9; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #94A3B8; }
.empty-text { font-size: 14px; color: #94A3B8; margin-bottom: 16px; }
.loading { display: flex; justify-content: center; align-items: center; padding: 40px 0; gap: 10px; color: #64748B; font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid #E2E8F0; border-top-color: #4F6EF7; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== List ===== */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid #F1F5F9; }
.list-item:last-child { border-bottom: none; }
.list-left { display: flex; flex-direction: column; gap: 4px; }
.list-title { font-size: 14px; color: #0F172A; font-weight: 500; }
.list-desc { font-size: 12px; color: #64748B; }

/* ===== Grid ===== */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border: 1px solid #E2E8F0; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #F1F5F9; }
th { color: #64748B; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; background: #F8FAFC; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFC; }

/* ===== Photo Card ===== */
.photo-card { overflow: hidden; border-radius: 10px; border: 1px solid #E2E8F0; }
.photo-img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: pointer; }
.photo-info { padding: 12px; display: flex; justify-content: space-between; align-items: center; }
.photo-date { font-size: 12px; color: #64748B; }
.photo-actions { display: flex; gap: 8px; }

/* ===== Progress ===== */
.progress-wrap { margin-top: 16px; }
.progress-bar { height: 8px; background: #F1F5F9; border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s ease; background: #4F6EF7; }
.progress-text { display: flex; justify-content: space-between; font-size: 13px; color: #64748B; }

/* ===== Auth ===== */
.auth-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #F1F5F9; padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 400px; border: 1px solid #E2E8F0;
}
.auth-card .auth-header { text-align: center; margin-bottom: 28px; }
.auth-title { font-size: 26px; font-weight: 700; color: #0F172A; margin-bottom: 8px; letter-spacing: -0.5px; }
.auth-sub { font-size: 14px; color: #64748B; }
.text-muted { font-size: 13px; color: #94A3B8; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }

.error-msg { background: #FEF2F2; color: #DC2626; padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid #FECACA; }
.success-msg { background: #F0FDF4; color: #16A34A; padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid #BBF7D0; word-break: break-all; }

.password-wrap { position: relative; }
.toggle-pwd { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #4F6EF7; font-size: 12px; cursor: pointer; padding: 8px 12px; }

.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: #64748B; }
.auth-footer a { color: #4F6EF7; font-weight: 600; }

/* ===== Toast ===== */
#toast-container {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none;
}
.toast-item {
  padding: 10px 24px; border-radius: 8px; color: #fff;
  font-size: 14px; font-weight: 500;
  animation: fadeIn .25s; max-width: 80vw; text-align: center; transition: opacity .3s;
}
.toast-success { background: #22C55E; }
.toast-danger { background: #EF4444; }
.toast-warning { background: #F59E0B; }
.toast-info { background: #334155; }

/* ===== Dashboard Nav Cards ===== */
.nav-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-top: 20px; }
.nav-card {
  background: #fff; border-radius: 12px; padding: 28px 16px;
  text-align: center; border: 1px solid #E2E8F0;
  cursor: pointer; transition: border-color .15s, background .15s;
  text-decoration: none; color: #0F172A;
}
.nav-card:hover { border-color: #4F6EF7; background: #FAFBFF; }
.nav-card-icon {
  width: 44px; height: 44px; margin: 0 auto 10px;
  border-radius: 10px; background: #EEF1FF; color: #4F6EF7;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.nav-card-title { font-size: 14px; font-weight: 500; }

/* ===== Separator ===== */
.divider { height: 1px; background: #F1F5F9; margin: 20px 0; }

/* ===== Avatar ===== */
.up-avatar {
  width: 64px; height: 64px; border-radius: 14px;
  background: #4F6EF7; display: flex; align-items: center;
  justify-content: center; font-size: 26px; color: #fff; font-weight: 700;
  flex-shrink: 0;
}

/* ===== Dashboard custom ===== */
.dashboard-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.dashboard-recent { margin-top: 24px; }
.recent-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 12px; }
.recent-thumb {
  aspect-ratio: 1; border-radius: 8px; object-fit: cover;
  width: 100%; cursor: pointer; border: 1px solid #E2E8F0;
  transition: border-color .15s;
}
.recent-thumb:hover { border-color: #4F6EF7; }

/* ===== Photo Actions ===== */
.photo-actions-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ===== Key display ===== */
.key-display {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px; background: #F8FAFC; padding: 12px 16px;
  border-radius: 8px; border: 1px solid #E2E8F0;
  word-break: break-all; margin: 8px 0;
}

/* ===== Admin ===== */
.admin-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.admin-section { margin-top: 28px; }
.admin-photo-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.admin-thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; cursor: pointer; border: 1px solid #E2E8F0; }

/* ===== Card Filters ===== */
.card-filter { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.user-cards { display: flex; flex-direction: column; gap: 12px; }
.user-card-item { padding: 0; border-radius: 10px; display: flex; align-items: center; gap: 16px; }
.user-card-avatar {
  width: 48px; height: 48px; border-radius: 10px;
  background: #EEF1FF; display: flex; align-items: center;
  justify-content: center; font-size: 18px; color: #4F6EF7; font-weight: 600; flex-shrink: 0;
}
.user-card-info { flex: 1; min-width: 0; }
.user-card-name { font-size: 14px; font-weight: 600; color: #0F172A; }
.user-card-email { font-size: 12px; color: #64748B; margin-top: 2px; }
.user-card-meta { font-size: 12px; color: #64748B; display: flex; gap: 16px; margin-top: 4px; }
.user-card-action { flex-shrink: 0; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .page { padding: 16px; }
  .bottom-nav { display: flex; }
  .main-content.has-bottom { padding-bottom: 56px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px 14px; }
  .stat-value { font-size: 24px; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .nav-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats { grid-template-columns: repeat(2,1fr); }
  .admin-stats { grid-template-columns: repeat(2,1fr); }
  .recent-grid { grid-template-columns: repeat(3,1fr); }
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { margin-bottom: 10px; border: 1px solid #E2E8F0; border-radius: 10px; padding: 12px; }
  td { border: none; padding: 6px 0; }
  td:before { content: attr(data-label)': '; font-weight: 600; display: inline-block; width: 80px; color: #64748B; font-size: 12px; }
}
@media (min-width: 769px) {
  .menu-btn { display: none; }
}
@media (max-width: 480px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 16px; }
  .auth-card { padding: 32px 24px; }
  .page { padding: 12px; }
}