* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  margin: 0;
  background: #f7f8fa;
  color: #222;
  line-height: 1.5;
}

header {
  background: #fff;
  border-bottom: 1px solid #e1e4e8;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 20px;
  color: #333;
}

header .badge {
  background: #4682B4;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: normal;
}

header .user-info {
  margin-left: auto;
  font-size: 13px;
  color: #666;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar label {
  font-weight: 500;
  font-size: 14px;
}

.toolbar select,
.toolbar input[type="text"] {
  padding: 8px 12px;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

.toolbar input[type="text"] {
  flex: 1;
  min-width: 200px;
}

button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background: #4682B4;
  color: white;
  font-weight: 500;
}

button:hover { background: #365e84; }

button.secondary {
  background: #e1e4e8;
  color: #333;
}
button.secondary:hover { background: #c8cdd2; }

button.danger {
  background: #d73a49;
}
button.danger:hover { background: #a5252f; }

button.icon {
  padding: 4px 8px;
  background: transparent;
  color: #666;
}
button.icon:hover { background: #eef0f3; color: #222; }

.term-table {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: #4682B4;
  color: white;
}

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

th { font-weight: 500; }

tbody tr:hover { background: #f7f8fa; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: #888;
}

.notes { color: #888; font-size: 13px; }
.muted { color: #999; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-draft  { background: #FFE8E0; color: #B85C00; border: 1px solid #FFB066; }
.status-review { background: #FFF3D6; color: #8B6914; border: 1px solid #DAA520; }
.status-active { background: #DEFBE0; color: #1B5E20; border: 1px solid #66BB6A; }

/* 可點擊的內嵌狀態下拉（管理頁用） */
.status-select {
  padding: 3px 22px 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='currentColor'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 5px center;
  background-size: 12px;
  outline: none;
  transition: filter 0.1s;
}
.status-select:hover { filter: brightness(0.96); }
.status-select.status-draft  { background-color: #FFE8E0; color: #B85C00; border: 1px solid #FFB066; }
.status-select.status-review { background-color: #FFF3D6; color: #8B6914; border: 1px solid #DAA520; }
.status-select.status-active { background-color: #DEFBE0; color: #1B5E20; border: 1px solid #66BB6A; }

/* checkbox 列 */
.row-check, .head-check {
  width: 36px;
  text-align: center;
}

/* 浮動批量動作條 */
.bulk-action-bar {
  display: none;
  position: sticky;
  top: 0;
  background: #4682B4;
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  z-index: 50;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.bulk-action-bar.show { display: flex; }
.bulk-action-bar .count {
  font-weight: 600;
}
.bulk-action-bar select,
.bulk-action-bar button {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: none;
  cursor: pointer;
}
.bulk-action-bar select { background: white; color: #333; }
.bulk-action-bar .btn-clear { background: rgba(255,255,255,0.2); color: white; }
.bulk-action-bar .btn-delete { background: #d73a49; color: white; }
.bulk-action-bar .btn-delete:hover { background: #a5252f; }

.changelog-list {
  max-height: 60vh;
  overflow-y: auto;
}
.changelog-item {
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f3;
  font-size: 14px;
}
.changelog-item:last-child { border-bottom: none; }
.changelog-time {
  font-size: 12px;
  color: #888;
  margin-bottom: 2px;
}
.changelog-action {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-right: 6px;
}
.action-create { background: #DEFBE0; color: #1B5E20; }
.action-update { background: #E0F0FF; color: #1A4480; }
.action-delete { background: #FFE0E0; color: #82071e; }
.action-bulk_insert { background: #F0E0FF; color: #4B0082; }
.action-status_change { background: #FFF3D6; color: #8B6914; }

footer {
  text-align: center;
  padding: 24px;
  color: #888;
  font-size: 13px;
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.open {
  display: flex;
}

.modal {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eef0f3;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
}
.modal-close {
  background: transparent;
  color: #888;
  font-size: 20px;
  padding: 0 8px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #eef0f3;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-row {
  margin-bottom: 14px;
}
.form-row label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
  font-weight: 500;
}
.form-row input[type="text"],
.form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.form-row textarea { min-height: 60px; }

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.checkbox-group label {
  font-weight: normal;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.error-banner {
  background: #ffebe9;
  border: 1px solid #ff8182;
  color: #82071e;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 14px;
  display: none;
}
.error-banner.show { display: block; }
