:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --border: #e0e2e7;
  --text: #1f2430;
  --text-dim: #6b7280;
  --primary: #3b5bdb;
  --primary-dark: #2f47ad;
  --danger: #d64545;
  --ok: #2f9e44;
  --warn: #f08c00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.25rem; margin: 0; }

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

.filters {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

select, input, textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:hover { background: #f0f1f3; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.status-msg { font-size: 0.85rem; color: var(--text-dim); }

.issue-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.issue-table th, .issue-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.issue-table th { background: #fafbfc; color: var(--text-dim); font-weight: 600; }
.issue-table tbody tr { cursor: pointer; }
.issue-table tbody tr:hover { background: #f4f6fb; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #fff;
}
.badge-待處理 { background: var(--danger); }
.badge-處理中 { background: var(--warn); }
.badge-已解決 { background: var(--ok); }
.badge-低 { background: #868e96; }
.badge-中 { background: #4263eb; }
.badge-高 { background: #f08c00; }
.badge-緊急 { background: #d64545; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal.hidden { display: none; }

.modal-card {
  background: var(--card-bg);
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  padding: 20px 24px 24px;
}

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

.modal-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-dim);
}

#newIssueForm { display: flex; flex-direction: column; gap: 12px; }
#newIssueForm label { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; color: var(--text-dim); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-actions { display: flex; justify-content: flex-end; margin-top: 4px; }

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  background: #fdeeee;
  border: 1px solid #f3c8c8;
  padding: 8px 10px;
  border-radius: 6px;
}
.hidden { display: none; }

.detail-body dl {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  font-size: 0.9rem;
}
.detail-body dt { color: var(--text-dim); }
.detail-body dd { margin: 0; }

.detail-images { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.detail-images img {
  width: 140px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.status-update {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}
