:root {
  --navy: #1e3a5f;
  --navy-hover: #16304f;
  --ok: #1f8a4c;
  --ok-bg: #e9f7ef;
  --warn: #b86e00;
  --warn-bg: #fff4e5;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2433;
  --muted: #5b6576;
  --faint: #8a93a3;
  --border: #e4e8ef;
  --choice-border: #dde3ec;
  --focus: #7fa6d6;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: "Be Vietnam Pro", system-ui, -apple-system, Segoe UI, sans-serif;
  --header-h: 60px;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131a;
    --card: #151b24;
    --text: #e6eaf0;
    --muted: #9aa3b2;
    --faint: #7a8494;
    --border: #2a3340;
    --choice-border: #3a4555;
    --navy: #8eb6e8;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
@media (max-width: 640px) {
  .container { padding: 0 16px; }
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #1e3a5f;
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 16px;
}
.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e3a5f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { font-size: 12px; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .brand-title { color: #d7e6ff; }
  .brand-icon { background: #2a4a73; }
}
.header-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.chip-count {
  background: #eaf0f8;
  color: #1e3a5f;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .chip-count { background: #1a2b3d; color: #d7e6ff; }
}

.page { padding: 24px 0 40px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.block1 { max-width: 960px; margin: 0 auto 32px; overflow: hidden; }
.block2 { max-width: 1200px; margin: 0 auto; padding: 24px; }
.block2-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.chip-user, .chip-queue {
  border: 1px solid var(--border);
  background: #eaf0f8;
  color: #1e3a5f;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
}
.chip-queue { background: #fff4e5; color: #b86e00; cursor: default; }
.offline-banner {
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6c2;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.paper-date-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #f3eefb;
  border-radius: 8px;
  border: 1px solid #e4d4f5;
}
.paper-date-row label { font-weight: 600; font-size: 14px; }
.paper-date-row input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  min-height: 40px;
}
.pwd-row { display: flex; gap: 8px; align-items: center; }
.pwd-row input { flex: 1; }
.login-error { color: var(--danger); font-size: 13px; margin: 0; }
.login-dialog h3 { margin: 0 0 8px; }
.by-editor { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
@media (max-width: 640px) {
  .block2 { padding: 16px; }
  .page { padding: 16px 0 32px; }
}

body.public-mode #block2,
body.public-mode #header-right { display: none !important; }
body.public-mode .block1 { max-width: 720px; }

/* Status strip */
.status-strip {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  font-size: 13.5px;
  flex-wrap: wrap;
}
.status-strip[data-mode="new"] { background: #eaf0f8; }
.status-strip[data-mode="view"] { background: var(--ok-bg); }
.status-strip[data-mode="edit"] { background: var(--warn-bg); }
.status-strip[data-mode="paper"] { background: #f3eefb; }
.status-right { display: flex; gap: 8px; flex-wrap: wrap; }
.block1.flash-view { animation: flashView 0.6s ease; }
@keyframes flashView {
  0%, 100% { box-shadow: var(--shadow); }
  40% { box-shadow: 0 0 0 2px #1f8a4c; }
}

/* Steps */
.step-wrap { padding: 16px 20px 8px; border-bottom: 1px solid var(--border); }
.step-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.step-item {
  flex: 1;
  min-width: 64px;
  text-align: center;
  position: relative;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--faint);
}
.step-item::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-item:first-child::before { left: 50%; }
.step-item:last-child::before { right: 50%; }
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  position: relative;
  z-index: 1;
  margin: 0 auto 6px;
}
.step-label { font-size: 11px; line-height: 1.2; display: block; }
.step-item.done .step-dot { background: #1e3a5f; border-color: #1e3a5f; color: #fff; }
.step-item.on .step-dot { border-color: #1e3a5f; border-width: 3px; color: #1e3a5f; }
.step-item.on { color: var(--text); font-weight: 700; }
.step-item.skip { opacity: 0.45; }
.step-item.skip .step-dot { text-decoration: line-through; }
.step-item.locked { cursor: not-allowed; opacity: 0.4; }
.step-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
@media (max-width: 720px) {
  .step-label { display: none; }
  .step-item { min-width: 36px; }
}

.block1-body { padding: 20px 24px; }
@media (max-width: 640px) {
  .block1-body { padding: 16px; }
}
.block1-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}
.block1-nav .btn { min-width: 140px; height: 44px; }
.block1-nav .btn.primary.send { background: var(--ok); }
.block1-nav .btn.primary.send:hover { background: #18753f; }

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.btn.primary { background: #1e3a5f; color: #fff; }
.btn.primary:hover { background: var(--navy-hover); }
.btn.outline {
  background: transparent;
  color: #1e3a5f;
  border: 1px solid var(--border);
}
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
@media (prefers-color-scheme: dark) {
  .btn.outline { color: #d7e6ff; }
}

/* Survey content */
.page-header { margin-bottom: 16px; }
.part-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
  color: #2f6fed;
  font-weight: 700;
  margin: 0 0 4px;
}
.page-header h2 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.page-lead, .q-note { color: var(--muted); font-size: 13px; font-style: italic; margin: 6px 0 0; }
.q-note.prominent {
  font-style: normal;
  background: #eaf0f8;
  border-left: 3px solid #1e3a5f;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}
.intro-card { margin-bottom: 20px; }
.intro-card h1 { font-size: 20px; font-weight: 700; margin: 0 0 16px; line-height: 1.35; }
.info-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.info-pill {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 720px) {
  .info-pills { grid-template-columns: 1fr; }
}
.q-block { margin-bottom: 20px; }
.q-block.error .q-title { color: var(--danger); }
.q-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.q-code {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: #eef2f7;
  border-radius: 6px;
  padding: 2px 6px;
  margin-right: 6px;
  vertical-align: middle;
}
.q-title { margin: 0; font-size: 15px; font-weight: 600; }
.req { color: var(--danger); }
.select-hint { font-size: 12px; color: var(--muted); white-space: nowrap; }
.err-msg { color: var(--danger); font-size: 13px; margin-top: 6px; }
.q-block.error {
  outline: 1.5px solid #f5b7b1;
  outline-offset: 6px;
  border-radius: 8px;
}

.option-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 720px) {
  .option-list { grid-template-columns: 1fr; }
}
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--choice-border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  font-size: 14px;
}
.choice:hover { border-color: #1e3a5f; }
.choice:has(input:checked) {
  background: #eaf0f8;
  border: 1.5px solid #1e3a5f;
}
.choice.disabled { opacity: 0.4; cursor: not-allowed; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-mark {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--choice-border);
  border-radius: 4px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: transparent;
}
.choice:has(input[type="radio"]) .choice-mark { border-radius: 999px; }
.choice:has(input:checked) .choice-mark {
  background: #1e3a5f;
  border-color: #1e3a5f;
  color: #fff;
}
.consent-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
}
.consent-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: #1e3a5f; }

.likert-single .choice-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale-ends, .scale-legend {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.likert-block-title, .likert-group-title {
  background: #f0f3f8;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  margin: 12px 0 6px;
}
.likert-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.likert-head, .likert-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(5, 56px);
  align-items: center;
}
.likert-head {
  position: sticky;
  top: 0;
  background: #1e3a5f;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  z-index: 1;
}
.likert-row:nth-child(even) { background: #f7f9fc; }
.likert-stmt { padding: 10px; font-size: 14px; }
.likert-col { display: flex; justify-content: center; min-height: 44px; align-items: center; }
.likert-col input { width: 22px; height: 22px; accent-color: #1e3a5f; }
.answered-mark { color: var(--ok); margin-left: 4px; }
.likert-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.likert-card-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.likert-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dot {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  justify-self: center;
}
.dot.on { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.desktop-only { display: block; }
.mobile-only { display: none; }
@media (max-width: 720px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .likert-single .choice-row { grid-template-columns: 1fr; }
}

.other-wrap {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed #1e3a5f;
  border-radius: 8px;
  background: #eaf0f8;
  display: grid;
  gap: 6px;
}
.other-wrap input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: var(--card);
  color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
.char-count { text-align: right; font-size: 12px; color: var(--muted); }

.success-panel { text-align: center; padding: 40px 16px; }
.success-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 700;
}
.success-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.mode-banner {
  background: #f3eefb;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

/* Block 2 */
.block-title { margin: 0; font-size: 18px; font-weight: 700; }
.block-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0 12px;
}
@media (max-width: 800px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  position: relative;
  background: #fbfcfe;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-num { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-ico { position: absolute; right: 12px; top: 12px; opacity: 0.35; font-size: 18px; }
.target-bar { margin-bottom: 14px; }
.target-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.progress-track { height: 8px; background: #e4e8ef; border-radius: 999px; overflow: hidden; }
#mgr-target-bar { height: 100%; width: 0; background: #1e3a5f; }

.mgr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mgr-toolbar input, .mgr-toolbar select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
  min-height: 36px;
}
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 220px;
  z-index: 20;
  padding: 6px;
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.menu button:hover { background: #f7f9fc; }

.mgr-table-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
.mgr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mgr-table th, .mgr-table td {
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  height: 52px;
  text-align: left;
  vertical-align: middle;
}
.mgr-table tbody tr:hover { background: #f7f9fc; }
.mgr-table tr.row-active { background: #eaf0f8; box-shadow: inset 3px 0 0 #1e3a5f; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.orange { background: var(--warn-bg); color: var(--warn); }
.badge.gray { background: #eef0f3; color: var(--faint); }
.tag-new {
  margin-left: 6px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 800;
}
.row-new { animation: flashNew 3s ease; }
@keyframes flashNew {
  0%, 100% { background: transparent; }
  15%, 70% { background: #fef9c3; }
}
.ops { display: flex; gap: 4px; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  min-width: 34px;
  min-height: 34px;
  cursor: pointer;
  font-size: 13px;
}
.empty-msg { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-illu {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 28px;
}
.mgr-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
}
.pager-btns { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pager-btns button {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  min-height: 32px;
  min-width: 32px;
  padding: 4px 8px;
  font: inherit;
  cursor: pointer;
}
.pager-btns button.on { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.table-mobile { display: none; }
.mgr-card { border-bottom: 1px solid var(--border); padding: 12px; }
.mgr-card-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.mgr-card-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
@media (max-width: 900px) {
  .table-desktop { display: none; }
  .table-mobile { display: block; }
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 0 24px;
  color: var(--muted);
  font-size: 12px;
}
.footer-inner { display: flex; justify-content: space-between; gap: 12px; }

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  background: #1e3a5f;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.toast-action {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 16px;
}
.dialog {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 18px;
}
.dialog-actions { display: flex; gap: 8px; margin-top: 14px; }
.dialog-actions .btn { flex: 1; }
.dialog-form { display: grid; gap: 10px; margin: 12px 0; }
.dialog-form .field { display: grid; gap: 6px; }
.dialog-form input, .dialog-form select, .dialog-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: var(--card);
  color: var(--text);
}
.progress-modal .bar {
  height: 8px;
  background: #e4e8ef;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-modal .bar > span { display: block; height: 100%; background: #1e3a5f; width: 0; }

.hp { position: absolute !important; left: -9999px !important; opacity: 0 !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.print-area { display: none; }
