/* 邻推 · 公共样式 */
:root {
  --primary: #0f4c4a;
  --primary-dark: #0a2b3f;
  --accent: #f97316;
  --bg: #f0f4f9;
  --card: #fff;
  --border: #e2edf2;
  --text: #1f2a44;
  --muted: #6c7a91;
  --success: #22c55e;
  --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: linear-gradient(180deg, var(--primary-dark), #1c5d7a);
  color: #fff;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.sidebar .logo {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.sidebar .sub {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 1.5rem;
}

.sidebar nav a {
  display: block;
  color: rgba(255,255,255,0.85);
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow: auto;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.header-bar h1 {
  font-size: 1.5rem;
  color: var(--primary);
  border-left: 4px solid var(--accent);
  padding-left: 0.8rem;
}

.card {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--card);
  border-radius: 16px;
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat .num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

.stat .label { font-size: 0.85rem; color: var(--muted); }

.btn {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #0d3d3b; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #ea580c; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; text-decoration: underline; padding: 0 0.15rem; font-size: inherit; }
.dept-tree { max-height: 280px; overflow-y: auto; padding: 0.5rem; background: var(--bg); border-radius: 8px; border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}
.form-group textarea { min-height: 100px; resize: vertical; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.6rem;
  text-align: left;
}
th { background: #eef2ff; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

.alert {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-info { background: #eff6ff; border-left: 4px solid #3b82f6; }
.alert-warn { background: #fff7ed; border-left: 4px solid var(--accent); }
.alert-success { background: #f0fdf4; border-left: 4px solid var(--success); }
.alert-error { background: #fef2f2; border-left: 4px solid var(--danger); }

.auth-page {
  max-width: 420px;
  margin: 4rem auto;
  padding: 0 1rem;
}
.auth-box {
  background: var(--card);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 25px 45px -12px rgba(0,0,0,0.15);
}
.auth-box h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.auth-box .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.hidden { display: none !important; }

.qr-box {
  text-align: center;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 16px;
  margin: 1rem 0;
}
.qr-box img {
  max-width: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.qr-placeholder {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  background: #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.timer-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
}
.timer-fill {
  height: 100%;
  background: var(--success);
  width: 0%;
  transition: width 0.3s;
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .main { padding: 1rem; }
}

/* 自建应用 · 微信内 H5 */
.mobile-app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 4.5rem;
}
.mobile-app .app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 1rem 1rem 1.2rem;
}
.mobile-app .app-header h1 { font-size: 1.1rem; font-weight: 600; }
.mobile-app .app-header p { font-size: 0.8rem; opacity: 0.85; margin-top: 0.25rem; }
.mobile-app .app-body { padding: 1rem; }
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 100;
}
.app-tabbar a {
  flex: 1;
  text-align: center;
  padding: 0.65rem 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.app-tabbar a.active { color: var(--primary); font-weight: 600; }
.region-select { font-size: 0.9rem; }
.region-select optgroup { font-weight: 600; color: var(--primary); }
.tag-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin: 0.15rem;
  background: #e0f2f1;
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
}
.portal-switch-bar {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: rgba(255,255,255,0.85);
  font-size: 0.75rem;
}
.portal-switch-bar a { color: rgba(255,255,255,0.9); text-decoration: none; }
.portal-switch-bar a:hover { text-decoration: underline; }
.portal-switch-bar .active { color: #fff; font-weight: 600; }
.portal-switch-bar .sep { opacity: 0.45; }
.mobile-app .app-header + .portal-switch-bar,
.mobile-app .portal-switch-bar + .app-header { margin-top: 0; }
.mobile-app .portal-switch-bar + .app-header { padding-top: 0.65rem; }
