/* ============================================================
   题答答题 Dashboard - Style
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6fa;
  color: #2d3436;
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Nav --- */
.nav {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: #2d3436;
  text-decoration: none;
}
.nav-links { display: flex; gap: 8px; }
.nav-link {
  padding: 8px 16px;
  color: #636e72;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-link:hover { background: #f0f0f0; color: #2d3436; }
.nav-link.active { background: #0984e3; color: #fff; }

/* --- Main --- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  display: block;
  background: #fff;
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid #ccc;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: #636e72; margin-top: 4px; font-weight: 500; }
.stat-blue  { border-left-color: #0984e3; }
.stat-green { border-left-color: #00b894; }
.stat-purple { border-left-color: #6c5ce7; }
.stat-orange { border-left-color: #e17055; }
.stat-teal   { border-left-color: #00cec9; }
.stat-pink   { border-left-color: #e84393; }
.stat-cyan   { border-left-color: #00b894; }
.stat-gray   { border-left-color: #636e72; }

/* --- Card --- */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 20px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}
.card-body { padding: 16px 20px; }

/* --- Grid --- */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 8px;
}
@media (max-width: 768px) { .grid-2col { grid-template-columns: 1fr; } }

/* --- Bar Chart --- */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label {
  width: 120px;
  font-size: 13px;
  color: #636e72;
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  height: 26px;
  background: #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: #0984e3;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  min-width: 28px;
  transition: width 0.3s;
}
.bar-fill-diff { background: #e17055; }
.bar-fill-sub { background: #6c5ce7; }

/* --- KP List --- */
.kp-list { list-style: none; }
.kp-list li {
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}
.kp-list li:last-child { border-bottom: none; }
.badge {
  display: inline-block;
  background: #dfe6e9;
  color: #636e72;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

/* --- Table --- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.table th { background: #fafafa; font-weight: 600; color: #636e72; font-size: 12px; text-transform: uppercase; position: sticky; top: 0; }
.table tbody tr:hover { background: #f8f9fe; }
.table-full { min-width: 100%; }
.col-type { font-size: 10px; color: #b2bec3; font-weight: 400; margin-left: 4px; }
.th-action { width: 120px; text-align: center; }
.cell-action { text-align: center; white-space: nowrap; }
.cell-stem { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.null { color: #b2bec3; font-style: italic; font-size: 11px; }
.fk-link { color: #0984e3; text-decoration: none; }
.fk-link:hover { text-decoration: underline; }
.tag-type {
  display: inline-block;
  background: #dfe6e9;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: #636e72;
}
.diff-dot { color: #e17055; font-size: 14px; }
.empty-cell { text-align: center; color: #b2bec3; padding: 32px 0 !important; }
.kp-tags { margin-top: 6px; line-height: 1.8; }
.kp-tag {
  display: inline-block;
  background: #e8f4fd;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 11px;
  color: #0984e3;
  margin-right: 4px;
}
.table-wrapper { overflow-x: auto; }

/* --- Page Header --- */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.subtitle { font-size: 13px; color: #636e72; margin-top: 4px; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; }

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0;
  font-size: 13px;
  color: #636e72;
  flex-wrap: wrap;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e0e0e0;
  text-decoration: none;
  color: #2d3436;
  font-size: 13px;
  transition: all 0.1s;
}
.page-link:hover { background: #f0f0f0; }
.page-link.active { background: #0984e3; color: #fff; border-color: #0984e3; }

/* --- Table Grid (tables list) --- */
.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.table-card {
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e8e8e8;
  transition: all 0.15s;
}
.table-card:hover { border-color: #0984e3; box-shadow: 0 2px 8px rgba(9,132,227,0.12); }
.table-card-name { font-size: 15px; font-weight: 600; color: #2d3436; word-break: break-all; font-family: monospace; }
.table-card-count { font-size: 12px; color: #636e72; margin-top: 6px; }
.table-card-desc { font-size: 12px; color: #b2bec3; margin-top: 4px; line-height: 1.4; }

/* --- Form --- */
.form-wrapper { max-width: 720px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #2d3436;
}
.form-group label code { background: #f0f0f0; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.form-group .required { color: #e17055; margin-left: 2px; }
.form-group .default { font-size: 11px; color: #b2bec3; margin-left: 8px; font-weight: 400; }
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: #fff;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #0984e3;
  box-shadow: 0 0 0 3px rgba(9,132,227,0.1);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-hint { font-size: 11px; color: #b2bec3; margin-top: 2px; }
.form-actions { margin-top: 24px; display: flex; gap: 8px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid #ddd;
  background: #fff;
  color: #2d3436;
  cursor: pointer;
  transition: all 0.1s;
}
.btn:hover { background: #f5f5f5; }
.btn-primary { background: #0984e3; color: #fff; border-color: #0984e3; }
.btn-primary:hover { background: #0773c5; }
.btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  color: #2d3436;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.1s;
}
.btn-sm:hover { background: #f0f0f0; }
.btn-danger { color: #e17055; border-color: #e17055; }
.btn-danger:hover { background: #fff5f5; }
.inline-form { display: inline; }

/* --- Misc --- */
.empty { color: #b2bec3; text-align: center; padding: 20px 0; font-size: 14px; }
.empty p { margin: 0; }

/* --- Filter Bar --- */
.filter-bar { display: flex; align-items: center; gap: 8px; }
.filter-bar form { display: flex; align-items: center; gap: 6px; }
.filter-bar label { font-size: 13px; color: #636e72; white-space: nowrap; }
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}
.filter-bar select:focus { outline: none; border-color: #0984e3; }

/* --- Color Dot --- */
.color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.1);
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.pack-card {
  display: block;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}
.pack-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.pack-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }

.pack-selectable {
  position: relative;
  cursor: pointer;
}
.pack-selectable:hover {
  border-color: #0984e3;
}
.pack-selectable:has(.pack-checkbox:checked) {
  border-color: #0984e3;
  background: #f8fbff;
  box-shadow: 0 2px 8px rgba(9,132,227,0.12);
}
.pack-selectable:has(.pack-checkbox[style*="inline"]) {
  padding-left: 44px;
}
.pack-checkbox {
  position: absolute;
  top: 20px;
  left: 16px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.merge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
}
.pack-meta { font-size: 13px; color: #636e72; margin-bottom: 8px; }
.pack-desc { font-size: 13px; color: #636e72; line-height: 1.5; }

.kp-row input[type="number"] {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.form-actions .btn { display: inline-flex; align-items: center; }
.total-summary { font-size: 15px; color: #2d3436; margin-right: auto; }
.total-summary strong { color: #0984e3; font-size: 18px; }

.batch-set-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}
.batch-set-bar label { font-size: 14px; color: #2d3436; }
.batch-set-bar input[type="number"] {
  width: 70px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

.number-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}
.number-stepper input[type="number"] {
  width: 60px;
  padding: 6px 4px;
  border: none;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  text-align: center;
  font-size: 14px;
  -moz-appearance: textfield;
}
.number-stepper input[type="number"]::-webkit-outer-spin-button,
.number-stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: #fff;
  color: #2d3436;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.stepper-btn:hover { background: #f0f0f0; }
