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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #333;
}

.hidden { display: none !important; }

.page { min-height: 100vh; }

.login-box {
  max-width: 420px;
  margin: 100px auto;
  background: #fff;
  padding: 36px 40px 32px;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.08);
}

.login-tip {
  color: #888;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}

.login-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.login-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

.login-actions .btn-secondary {
  background: #fff;
  color: #1890ff;
  border: 1px solid #91caff;
}

.login-actions .btn-secondary:hover:not(:disabled) {
  background: #e6f4ff;
}

.login-actions .btn-secondary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.login-actions #login-btn {
  background: #1890ff;
  color: #fff;
  border: none;
}

.login-actions #login-btn:hover {
  background: #40a9ff;
}

.code-group {
  margin-bottom: 4px;
}

.code-tip {
  color: #1890ff;
  font-size: 12px;
  line-height: 1.5;
  margin: -6px 0 10px;
}

.login-extra {
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
}

.login-extra a {
  color: #1890ff;
  text-decoration: none;
}

.login-extra a:hover {
  text-decoration: underline;
}

#reset-panel h1 {
  text-align: center;
  margin-bottom: 16px;
  color: #1890ff;
}

.security-banner {
  background: #fff7e6;
  color: #ad6800;
  border-bottom: 1px solid #ffd591;
  padding: 12px 24px;
  font-size: 14px;
  line-height: 1.6;
}

.settings-section-title {
  margin: 28px 0 16px;
  padding-top: 8px;
  border-top: 1px dashed #e8e8e8;
  font-size: 16px;
  color: #333;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 16px;
  color: #1890ff;
}

#main-page {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

#security-banner {
  grid-column: 1 / -1;
}

.main-wrap {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.admin-user-label {
  color: #666;
  font-size: 14px;
}

.logout-top {
  background: #fff;
  color: #666;
  border: 1px solid #d9d9d9;
}

.logout-top:hover {
  color: #1890ff;
  border-color: #91caff;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
  width: 220px;
  background: #001529;
  color: #fff;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.logo {
  padding: 20px;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 1px solid #002140;
}

.sidebar nav { flex: 1; padding: 10px 0; }

.sidebar nav a {
  display: block;
  padding: 12px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  transition: all 0.3s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: #fff;
  background: #1890ff;
}

.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #f0f2f5;
}

.tab { display: none; }
.tab.active { display: block; }

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.tab-header h2 { font-size: 20px; }

.actions { display: flex; gap: 10px; align-items: center; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-card {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.stat-card span {
  display: block;
  font-size: 36px;
  font-weight: bold;
  color: #1890ff;
}

.stat-card label {
  color: #999;
  font-size: 14px;
  margin-top: 8px;
  display: block;
}

.btn {
  padding: 8px 16px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn-primary {
  background: #1890ff;
  color: #fff;
  border-color: #1890ff;
}

.btn-danger {
  background: #ff4d4f;
  color: #fff;
  border-color: #ff4d4f;
}

.btn-sm { padding: 4px 8px; font-size: 12px; margin-right: 4px; }

.table-wrap {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

th { background: #fafafa; font-weight: 600; }

.province-group {
  margin-bottom: 20px;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
}

.province-header {
  background: #fafafa;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.city-tags {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.city-tag {
  background: #e6f7ff;
  color: #1890ff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.city-tag .edit, .city-tag .del {
  cursor: pointer;
  font-size: 12px;
}

.city-tag .del { color: #ff4d4f; }

select {
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
}

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 520px;
  max-width: 92%;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.modal-content.modal-wide {
  width: 680px;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

.close-btn:hover {
  color: #666;
}

.modal-body,
#modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid #f0f0f0;
  text-align: right;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-shrink: 0;
  background: #fafafa;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}

.form-group-compact {
  margin-bottom: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-section {
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px dashed #e8e8e8;
}

.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.newspaper-form .form-group label {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.newspaper-form input,
.newspaper-form textarea,
.newspaper-form select {
  border-radius: 8px;
  border-color: #e3e3e3;
  padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.newspaper-form input:focus,
.newspaper-form textarea:focus,
.newspaper-form select:focus {
  outline: none;
  border-color: #1890ff;
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.12);
}

.province-panel {
  background: #f7f9fc;
  border: 1px solid #e8edf5;
  border-radius: 12px;
  padding: 16px 18px 18px;
}

.province-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.province-actions {
  display: flex;
  gap: 8px;
}

.chip-action {
  border: none;
  background: #1890ff;
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.chip-action:hover {
  background: #40a9ff;
}

.chip-action-light {
  background: #fff;
  color: #666;
  border: 1px solid #d9d9d9;
}

.chip-action-light:hover {
  background: #f5f5f5;
  color: #333;
}

.province-count-badge {
  font-size: 13px;
  color: #1890ff;
  background: #e6f4ff;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 500;
}

.province-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  max-height: 200px;
  overflow-y: auto;
  padding: 6px 4px 10px;
  margin: 0 -2px;
}

.province-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #dfe3ea;
  color: #555;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
}

.province-chip:hover {
  border-color: #91caff;
  color: #1890ff;
}

.province-chip.active {
  background: linear-gradient(135deg, #1890ff, #36a3ff);
  border-color: #1890ff;
  color: #fff;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.28);
}

.province-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.province-chip span {
  white-space: nowrap;
}

.region-cell {
  max-width: 240px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-content.modal-wide {
    width: 92%;
  }

  .province-chip {
    min-width: calc(33% - 10px);
  }
}

.form-group small {
  color: #999;
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.settings-form {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  max-width: 600px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
}

.radio-label input {
  width: auto;
  margin: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

.form-tip {
  color: #666;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.display-row {
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fafafa;
}

.display-row-title {
  font-weight: bold;
  margin-bottom: 12px;
  color: #1a6dcc;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.badge-hot { background: #fff1f0; color: #ff4d4f; }
.badge-active { background: #f6ffed; color: #52c41a; }
.badge-inactive { background: #f5f5f5; color: #999; }

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 60px; }
  .logo, .sidebar nav a { font-size: 0; }
  .sidebar nav a { padding: 16px; text-align: center; }
}
