:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-strong: #f9fbfd;
  --text: #17212b;
  --muted: #66788a;
  --line: #dfe7ef;
  --accent: #1677a3;
  --accent-dark: #0d5d82;
  --accent-soft: #e8f5fa;
  --danger: #c2413a;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 48px rgba(30, 51, 70, 0.12);
  --radius: 8px;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.survey-page {
  background:
    linear-gradient(180deg, #eef7fb 0, rgba(245, 248, 251, 0) 320px),
    var(--bg);
}

.survey-shell {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 28px 16px 120px;
}

.survey-hero {
  padding: 20px 0 8px;
}

.survey-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.survey-hero h1,
.thanks-shell h1,
.login-card h1,
.admin-topbar h1 {
  max-width: 100%;
  margin: 16px 0 8px;
  font-size: clamp(26px, 5vw, 36px);
  line-height: 1.18;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.survey-hero p,
.thanks-shell p,
.login-card p,
.admin-topbar p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.survey-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.form-section,
.table-panel,
.login-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(30, 51, 70, 0.06);
}

.form-section {
  min-width: 0;
  padding: 20px;
}

.section-title {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-title span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 800;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.login-form label span,
.filters label span {
  color: #33485a;
  font-size: 13px;
  font-weight: 700;
}

.required {
  margin-left: 3px;
  color: var(--danger);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  min-height: 124px;
  resize: vertical;
  padding: 10px 11px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 163, 0.14);
}

.question {
  padding: 18px 0 0;
}

.question + .question {
  margin-top: 18px;
  border-top: 1px dashed var(--line);
}

.question-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.question-number {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

.question h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
}

.question-note {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.choice input {
  width: 18px;
  min-height: auto;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.choice span {
  flex: 1;
}

.other-field {
  margin-top: 12px;
}

.rating-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.rating-option {
  position: relative;
}

.rating-option input {
  position: absolute;
  opacity: 0;
}

.rating-option span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  font-weight: 800;
}

.rating-option input:checked + span {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.form-errors {
  padding: 12px 14px;
  border: 1px solid #f0b5af;
  border-radius: 8px;
  color: #8d211a;
  background: var(--danger-soft);
}

.submit-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  margin: 8px -16px -120px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(245, 248, 251, 0.92);
  backdrop-filter: blur(12px);
}

.primary-button,
.ghost-button,
.export-button,
.text-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  min-height: 44px;
  padding: 0 20px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.primary-button.compact,
.ghost-button.compact {
  min-height: 38px;
  padding: 0 14px;
}

.ghost-button,
.export-button {
  min-height: 38px;
  padding: 0 13px;
  border-color: var(--line);
  color: var(--text);
  background: #ffffff;
  font-weight: 700;
}

.export-button {
  color: var(--accent-dark);
  border-color: #b7dce9;
  background: var(--accent-soft);
}

.thanks-shell {
  width: min(100% - 32px, 520px);
  margin: 12vh auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  text-align: center;
  box-shadow: var(--shadow);
}

.success-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin: 0 auto 8px;
  border-radius: 50%;
  color: #ffffff;
  background: #178b5f;
  font-size: 34px;
  font-weight: 900;
}

.secondary-link {
  display: inline-flex;
  margin-top: 20px;
  color: var(--accent-dark);
  font-weight: 800;
}

.admin-page {
  background: #eef3f7;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-form label,
.filters label {
  display: grid;
  gap: 6px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.admin-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.admin-brand strong,
.admin-brand span {
  display: block;
}

.admin-brand span {
  color: var(--muted);
  font-size: 12px;
}

.admin-nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.admin-nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.admin-nav a.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.admin-main {
  min-width: 0;
  padding: 24px;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

.admin-topbar h1 {
  margin-top: 0;
  font-size: 28px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(220px, 1.4fr) auto auto auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.table-panel {
  overflow: hidden;
}

.table-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-summary span {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #405466;
  background: #f7fafc;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.muted-cell {
  max-width: 260px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.text-button,
.danger-button {
  min-height: 32px;
  padding: 0 9px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.text-button {
  color: var(--accent-dark);
  border-color: #b7dce9;
}

.danger-button {
  color: var(--danger);
  border-color: #efc0ba;
}

.detail-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(15, 29, 43, 0.44);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2,
.dialog-head p {
  margin: 0;
}

.dialog-head p {
  color: var(--muted);
  margin-top: 4px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 22px;
}

.detail-content {
  display: grid;
  gap: 16px;
  max-height: calc(min(760px, 100vh - 28px) - 82px);
  padding: 20px;
  overflow-y: auto;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-section h3 {
  margin: 0;
  padding: 10px 12px;
  background: #f7fafc;
  font-size: 15px;
}

dl {
  display: grid;
  gap: 0;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: minmax(140px, 0.32fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-text {
  color: var(--muted);
}

@media (max-width: 1060px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .survey-shell {
    padding-top: 18px;
  }

  .survey-hero h1,
  .thanks-shell h1 {
    font-size: 24px;
    line-height: 1.25;
    word-break: break-all;
  }

  .form-section {
    padding: 16px;
  }

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

  .submit-bar {
    justify-content: stretch;
  }

  .submit-bar .primary-button {
    width: 100%;
  }

  .admin-main {
    padding: 16px;
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .keyword-filter {
    grid-column: auto;
  }

  dl div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
