/* ============================================
   上号器管理系统 - 极简黑白风格
   Mobile-first, iOS Human Interface Guidelines
   ============================================ */

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

:root {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --text-primary: #1C1C1E;
  --text-secondary: #8E8E93;
  --text-tertiary: #C7C7CC;
  --border: #E5E5EA;
  --border-light: #F2F2F7;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --btn-bg: #1C1C1E;
  --btn-text: #FFFFFF;
  --btn-hover: #2C2C2E;
  --danger: #FF3B30;
  --danger-bg: #FFF0EF;
  --success: #34C759;
  --success-bg: #EDF7EE;
  --blue: #007AFF;
  --blue-bg: #EDF4FF;
  --green: #34C759;
  --green-bg: #EDF7EE;
  --purple: #AF52DE;
  --purple-bg: #F5EDFC;
  --orange: #FF9500;
  --orange-bg: #FFF5E8;
  --red: #FF3B30;
  --red-bg: #FFF0EF;
  --cyan: #5AC8FA;
  --cyan-bg: #EDF8FD;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ===== Top Navigation Bar ===== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,245,247,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-nav .back-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--border-light);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 16px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.top-nav .back-btn:hover { background: var(--border); }

.top-nav .nav-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-nav .nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.top-nav .nav-link {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}
.top-nav .nav-link:hover { color: var(--text-primary); background: var(--border-light); }
.top-nav .nav-link.active { color: var(--text-primary); font-weight: 600; }

.top-nav .logout-link {
  font-size: 14px;
  color: var(--danger);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.top-nav .logout-link:hover { background: var(--danger-bg); }

/* Mobile nav tabs */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs a {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 20px;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-tabs a:hover { color: var(--text-primary); background: var(--border-light); }
.nav-tabs a.active { color: var(--text-primary); background: var(--border); font-weight: 600; }

/* ===== Main Content ===== */
.main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 24px;
  text-align: center;
}
.page-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.page-header p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}
.card-header .card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-header .card-icon svg { width: 22px; height: 22px; }
.card-header .card-title-area { flex: 1; }
.card-header .card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.card-header .card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-header .card-action {
  flex-shrink: 0;
}

/* Icon color variants */
.icon-blue { background: var(--blue-bg); color: var(--blue); }
.icon-green { background: var(--green-bg); color: var(--green); }
.icon-purple { background: var(--purple-bg); color: var(--purple); }
.icon-orange { background: var(--orange-bg); color: var(--orange); }
.icon-red { background: var(--red-bg); color: var(--red); }
.icon-cyan { background: var(--cyan-bg); color: var(--cyan); }

/* ===== Function Cards (Home page) ===== */
.func-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.func-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: all 0.2s;
  cursor: pointer;
}
.func-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.func-card.highlight {
  border-color: var(--purple);
}
.func-card .fc-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.func-card .fc-icon svg { width: 24px; height: 24px; }
.func-card .fc-body { flex: 1; }
.func-card .fc-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.func-card .fc-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.func-card.logout .fc-title { color: var(--danger); }

/* ===== Forms ===== */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: none;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  -webkit-appearance: none;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-tertiary);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(28,28,30,0.08);
}
.form-group textarea {
  min-height: 80px;
  resize: vertical;
}
.form-group select {
  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='%238E8E93' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
  -webkit-appearance: none;
}
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
}
.btn-primary:hover { background: var(--btn-hover); }

.btn-outline {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--border-light); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #E0352B; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #2DB84E; }

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-xs {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px 14px;
  text-align: left;
}
th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--border-light); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-banned { background: var(--red-bg); color: var(--red); }
.badge-used { background: var(--blue-bg); color: var(--blue); }
.badge-expired { background: var(--border-light); color: var(--text-secondary); }
.badge-disabled { background: var(--red-bg); color: var(--red); }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.stat-card .stat-icon svg { width: 18px; height: 18px; }
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Charts ===== */
.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (min-width: 700px) {
  .charts-row { grid-template-columns: 2fr 1fr; }
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.chart-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}
canvas { width: 100% !important; max-height: 260px; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.toolbar input,
.toolbar select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  font-family: inherit;
  -webkit-appearance: none;
}
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--text-primary);
}
.toolbar input { flex: 1; min-width: 150px; }
.toolbar select {
  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='%238E8E93' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 4px;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.2s;
  font-family: inherit;
}
.pagination button:hover { background: var(--border-light); }
.pagination button.active {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--btn-bg);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Modals ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.modal .modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Import Area ===== */
.import-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.import-area:hover {
  border-color: var(--text-secondary);
  background: var(--border-light);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ===== Toggle group ===== */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.toggle-item {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  color: var(--text-secondary);
  background: var(--surface);
}
.toggle-item.active {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--btn-bg);
}

/* ===== List items ===== */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all 0.2s;
  background: var(--surface);
}
.list-item:hover { border-color: var(--border); }
.list-item.selected { border-color: var(--text-primary); background: var(--border-light); }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item .info .meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item .actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}

/* ===== Detail info ===== */
.detail-info {
  margin-bottom: 12px;
}
.detail-info .label {
  font-size: 12px;
  color: var(--text-secondary);
}
.detail-info .value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}
.launcher-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-primary);
  margin: 2px 4px 2px 0;
}

/* ===== Info box ===== */
.info-box {
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.info-box code {
  background: var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* ===== Login page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}
.login-card .login-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  background: var(--border-light);
  color: var(--text-primary);
}
.login-card .login-icon svg { width: 28px; height: 28px; }
.login-card h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.login-card .login-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.login-card .error-msg {
  background: var(--red-bg);
  border: 1px solid rgba(255,59,48,0.2);
  color: var(--red);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-card .error-msg.show { display: block; }
.login-card .hint {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  margin-top: 20px;
}
.login-card .hint a {
  color: var(--text-secondary);
  text-decoration: none;
}
.login-card .hint a:hover { color: var(--text-primary); }

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 8px; }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .main-content {
    padding: 28px 24px 48px;
  }
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 480px) {
  .page-header h1 { font-size: 22px; }
  .card { padding: 18px; }
  .btn { font-size: 14px; padding: 10px 18px; }
  .form-row { grid-template-columns: 1fr; }
  .top-nav .nav-link { font-size: 12px; padding: 4px 8px; }
}

/* ===== 后台管理子菜单 ===== */
.func-card--stack {
  flex-direction: column;
  align-items: stretch;
}
.func-card-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.admin-submenu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}
.admin-sub-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  cursor: pointer;
}
.admin-sub-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.admin-sub-card .fc-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-sub-card .fc-icon svg { width: 22px; height: 22px; }
.admin-sub-card .fc-body { flex: 1; }
.admin-sub-card .fc-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.admin-sub-card .fc-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}
.admin-sub-card.logout {
  border-color: transparent;
}
.admin-sub-card.logout .fc-title { color: var(--danger); }
.admin-sub-card.logout:hover { border-color: #FFCDD2; }
