* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f5f6f8;
  color: #222;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #111827;
  color: #f9fafb;
  padding: 24px;
}

.sidebar h1 {
  font-size: 18px;
  margin-bottom: 20px;
}

.sidebar nav a {
  display: block;
  color: #d1d5db;
  text-decoration: none;
  padding: 10px 0;
}

.sidebar nav a.active {
  color: #ffffff;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 32px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.charts {
  margin-top: 20px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.chart {
  min-height: 180px;
  border-radius: 6px;
  background: #f9fafb;
  padding: 12px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: #ffffff;
}

thead {
  background: #f3f4f6;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

button {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
}

button.secondary {
  background: #6b7280;
}

.hidden {
  display: none;
}

/* 登录门控：未登录时全屏显示，登录后隐藏 */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  color: #f9fafb;
}

.login-screen.hidden {
  display: none;
}

.login-box {
  background: #1f2937;
  padding: 28px;
  border-radius: 12px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.login-box h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

.login-box .hint {
  color: #9ca3af;
  font-size: 13px;
  margin: 0 0 20px 0;
}

.login-box label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
}

.login-box input {
  margin-top: 4px;
  width: 100%;
}

.login-box button[type="submit"] {
  margin-top: 8px;
  width: 100%;
}

.logout-btn {
  margin-top: 24px;
  background: transparent;
  color: #9ca3af;
  border: 1px solid #374151;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  text-align: left;
}

.logout-btn:hover {
  color: #fff;
  border-color: #6b7280;
}

.settings-card .hint {
  color: #6b7280;
  font-size: 13px;
  margin: 0 0 4px 0;
}

.settings-card {
  background: #ffffff;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
textarea,
select {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 必须覆盖 .modal 的 display:flex，否则添加 .hidden 后弹窗仍可见、无法关闭 */
.modal.hidden {
  display: none;
}

.modal-content {
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  width: 420px;
  max-width: 90vw;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
