/* Public funding application form */

:root {
  --navy: #0b3d5c;
  --navy-dark: #072a40;
  --teal: #1a7a6d;
  --bg: #e8eef2;
  --card: #ffffff;
  --text: #1f2a33;
  --muted: #5c6b76;
  --border: #d0dae2;
  --danger: #b42318;
  --required: #b42318;
}

* { box-sizing: border-box; }

body.apply-body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(160deg, #d5e3ec 0%, var(--bg) 50%, #dce8e6 100%);
  color: var(--text);
  min-height: 100vh;
}

.apply-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.apply-banner {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: #f5f8fa;
}

.apply-header {
  background: linear-gradient(135deg, var(--navy) 0%, #145a78 55%, var(--teal) 100%);
  color: #fff;
  padding: 24px 28px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(7, 42, 64, 0.2);
}

.apply-header h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  font-weight: 600;
}

.apply-header .zh {
  opacity: 0.92;
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.apply-header .meta {
  opacity: 0.85;
  font-size: 0.92rem;
}

.apply-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(7, 42, 64, 0.06);
}

.apply-card h2 {
  margin: 0 0 16px;
  color: var(--navy);
  font-size: 1.2rem;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2eaf0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-group { margin-bottom: 4px; }

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--navy-dark);
}
.form-label .req { color: var(--required); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
.form-textarea { min-height: 140px; resize: vertical; }

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 122, 109, 0.15);
}

.help-text { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.note-box {
  background: #f0f7f6;
  border: 1px solid #c5ddd8;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.92rem;
  color: var(--navy-dark);
  margin: 10px 0 14px;
}

.radio-row, .check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: center;
  margin-top: 4px;
}
.radio-row label, .check-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  cursor: pointer;
}

.check-stack label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  cursor: pointer;
}
.check-stack input { margin-top: 3px; flex-shrink: 0; }

.repeat-block {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafcfd;
}
.repeat-block .row-title {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.btn-add-row {
  background: #edf3f7;
  border: 1px solid var(--border);
  color: var(--navy);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-remove-row {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 6px;
}

.html-doc {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafb;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.msg {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.msg.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c2c0; }
.msg.success { background: #e7f6ef; color: #0f6b4c; border: 1px solid #b7e1cd; }
.msg.info { background: #eef5fa; color: var(--navy); border: 1px solid #c9dae8; }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.btn-submit {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-submit:hover { background: var(--navy-dark); }

.fund-pick-list { list-style: none; padding: 0; margin: 0; }
.fund-pick-list li { margin-bottom: 10px; }
.fund-pick-list a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--navy);
  font-weight: 600;
  background: #fff;
}
.fund-pick-list a:hover { border-color: var(--teal); background: #f4faf9; }
.fund-pick-list .zh { display: block; font-weight: 500; color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.word-count { font-size: 0.85rem; color: var(--muted); text-align: right; margin-top: 4px; }
.word-count.over, .word-count.under { color: var(--danger); font-weight: 600; }

.placeholder-api {
  background: #fff8e6;
  border: 1px dashed #e0c56e;
  color: #6b5a1e;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.prog-catalog {
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fafcfd;
}
.prog-group + .prog-group {
  border-top: 1px solid var(--border);
}
.prog-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  background: #edf3f7;
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.prog-group-title::-webkit-details-marker { display: none; }
.prog-group-title::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--teal);
  flex-shrink: 0;
}
.prog-group[open] > .prog-group-title::before { content: "▾"; }
.prog-group-title:hover { background: #e3edf4; }
.prog-group-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.prog-group-label { display: block; }
.prog-group-sublabel {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}
.prog-group-count {
  flex-shrink: 0;
  min-width: 1.75rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}
.prog-group-body {
  border-top: 1px solid #e4ebf0;
  padding: 4px 0 8px;
}
.prog-inst-block + .prog-inst-block {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e4ebf0;
}
.prog-inst-name {
  padding: 8px 14px 2px;
  color: var(--navy);
  font-weight: 700;
  font-size: 0.9rem;
}
.prog-list {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
}
.prog-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 6px 14px 6px 2em;
  border-bottom: 1px solid #eef2f5;
  font-size: 0.92rem;
  line-height: 1.45;
}
.prog-inst-block .prog-list li:last-child { border-bottom: none; }
.prog-list a.prog-detail-link,
.prog-list .prog-text {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  position: relative;
}
.prog-list a.prog-detail-link:hover .prog-name {
  text-decoration: underline;
  color: var(--navy);
}
.prog-list a.prog-detail-link:hover .prog-reg,
.prog-list a.prog-detail-link:hover .prog-date { text-decoration: none; }
.prog-hover-hint {
  display: none;
  margin-left: 8px;
  font-size: 0.75em;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.prog-list a.prog-detail-link:hover .prog-hover-hint,
.prog-list a.prog-detail-link:focus-visible .prog-hover-hint {
  display: inline;
}
.prog-reg {
  font-size: 0.78em;
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
}
.prog-date {
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
  font-size: 0.92em;
}
.prog-code {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  padding-top: 2px;
}

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .apply-header h1 { font-size: 1.25rem; }
  .prog-list li { flex-direction: column; gap: 4px; }
}
