:root {
  --bg-1: #f2f5ff;
  --bg-2: #f8fffb;
  --ink: #1a1d2d;
  --muted: #59607a;
  --accent: #0c6a57;
  --accent-soft: #d4f3eb;
  --border: #dbe0ef;
  --white: #ffffff;
  --danger: #a12b3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(120deg, var(--bg-1), var(--bg-2));
}

.bg-shape {
  position: fixed;
  width: 46vw;
  height: 46vw;
  border-radius: 50%;
  background: radial-gradient(circle, #b8e6db 0%, rgba(184, 230, 219, 0) 72%);
  top: -10vw;
  right: -10vw;
  z-index: -1;
}

.container {
  max-width: 1600px;
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

.hero h1 {
  margin: 0 0 0.4rem;
  font-family: "Merriweather", Georgia, serif;
  font-size: clamp(1.4rem, 1rem + 1.5vw, 2.2rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero .meta {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.inline-form {
  margin: 0;
}

.logout-btn {
  background: #29426d;
}

.refresh-note {
  color: var(--accent);
  margin: 0.45rem 0 0;
}

.hero a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.05);
}

.upload-form,
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

input,
select,
button,
textarea {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  font: inherit;
}

button {
  background: var(--accent);
  color: var(--white);
  border: none;
  cursor: pointer;
}

button:hover {
  opacity: 0.92;
}

.actions-inline {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 0.7rem;
}

.admin-card h2,
.admin-card h3 {
  margin-top: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1rem;
}

.admin-form,
.admin-form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.user-list {
  display: grid;
  gap: 0.8rem;
}

.user-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fbfdff;
  display: grid;
  gap: 0.35rem;
}

.danger-btn {
  background: #8b2339;
}

.edit-row td {
  background: #fbfcff;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.admin-form textarea {
  min-height: 80px;
  width: min(700px, 100%);
}

.delete-remark {
  background: #6e1f31;
  margin-top: 0.4rem;
}

.actions-inline a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1320px;
  table-layout: auto;
}

th,
td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

th {
  background: #f8fbff;
}

.sort-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.sort-link:hover {
  color: var(--accent);
}

.summary-cell {
  line-height: 1.45;
  font-size: 1.02rem;
  min-width: 360px;
}

th:nth-child(1), td:nth-child(1) { width: 120px; }
th:nth-child(2), td:nth-child(2) { width: 240px; }
th:nth-child(3), td:nth-child(3) { width: 260px; }
th:nth-child(4), td:nth-child(4) { width: 120px; }
th:nth-child(5), td:nth-child(5) { width: 280px; }
th:nth-child(6), td:nth-child(6) { width: 520px; }
th:nth-child(7), td:nth-child(7) { width: 320px; }
th:nth-child(8), td:nth-child(8) { width: 120px; }

td:nth-child(1) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.open-link {
  display: inline-block;
  white-space: nowrap;
}

.agency-hint {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.save-remark,
.copy-row {
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

.copy-row {
  white-space: nowrap;
}

.comment-list {
  width: 100%;
  margin-bottom: 0.5rem;
}

.comment-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  background: #fcfdff;
}

.comment-item p {
  margin: 0.4rem 0;
}

.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.revoke-remark {
  background: #8d2f43;
}

.comment-item.revoked {
  opacity: 0.62;
  background: #f5f7fb;
}

.empty-note {
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.remark-input {
  min-height: 64px;
  width: 100%;
  margin-bottom: 0.4rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
  max-width: 100%;
}

.tag-chip-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 100%;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #e8f4f0;
  color: #12463a;
  border: 1px solid #b8ddd2;
  border-radius: 999px;
  padding: 0.22rem 0.62rem;
  font-size: 0.82rem;
  line-height: 1.2;
  text-decoration: none;
  max-width: 210px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tag-chip:hover {
  background: #d5eee6;
  border-color: #93cab9;
}

.tag-chip.active {
  background: #0c6a57;
  color: #fff;
  border-color: #0c6a57;
}

.tag-remove {
  background: #7a2b3d;
  border-radius: 999px;
  padding: 0.06rem 0.35rem;
  font-size: 0.78rem;
  min-width: auto;
}

.tag-editor {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.tag-input {
  width: 220px;
  padding: 0.35rem 0.55rem;
}

.tag-add,
.save-remark,
.modal-copy-btn {
  min-width: 76px;
  white-space: nowrap;
}

.full-view-btn {
  margin-right: 0.35rem;
  background: #29426d;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal.open {
  display: flex;
}

.modal-panel {
  width: min(900px, 96vw);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-close {
  float: right;
  background: #334b70;
}

.full-card h3 {
  margin: 0.3rem 0 0.8rem;
}

.full-card p {
  margin: 0.45rem 0;
}

.full-summary {
  white-space: pre-wrap;
  line-height: 1.5;
}

.modal-copy-btn {
  margin-top: 0.4rem;
  background: #0f5b4b;
}

.full-remarks {
  margin-top: 0.4rem;
}

.flash-wrap {
  margin-top: 1rem;
}

.flash {
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.5rem;
}

.flash.ok {
  background: var(--accent-soft);
  border: 1px solid #9bdecb;
}

.flash.error {
  background: #ffe7ec;
  border: 1px solid #efb5c0;
  color: var(--danger);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(460px, 100%);
}

.login-card h1 {
  margin-top: 0;
}

.login-form {
  display: grid;
  gap: 0.8rem;
}

.login-form label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.pager {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.pager-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

@media (max-width: 768px) {
  .container {
    margin-top: 1rem;
  }

  .hero .meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}
