:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-soft: #eef5f7;
  --line: #d8e1e5;
  --line-strong: #aebdc5;
  --text: #18242c;
  --muted: #63717a;
  --navy: #153c63;
  --blue: #2f6ea5;
  --teal: #007f86;
  --green: #1f7a4d;
  --amber: #a56414;
  --red: #b42318;
  --shadow: 0 14px 34px rgba(31, 45, 56, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "Noto Sans", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  font-size: 24px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--navy);
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.35;
}

.topbar-actions,
.section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.select-control {
  min-height: 38px;
  max-width: 190px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  max-width: 190px;
  padding: 0 10px;
  border: 1px solid rgba(21, 60, 99, 0.16);
  border-radius: var(--radius);
  color: var(--navy);
  background: #eef5f7;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  white-space: nowrap;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: #f9fbfc;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button:focus-visible,
.choice-button:focus-visible,
.section-link:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 127, 134, 0.22);
  outline-offset: 2px;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.icon-button.compact {
  width: 38px;
  padding: 0;
}

.icon-button.compact span {
  display: none;
}

.icon-button.danger {
  color: var(--red);
}

.project-strip {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin: 18px 24px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-panel {
  display: grid;
  gap: 16px;
  margin: 18px 24px 28px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.admin-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bd-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
}

.bd-stat {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.bd-stat strong {
  color: var(--navy);
  font-size: 26px;
  line-height: 1;
}

.bd-stat span {
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.bd-stat small,
.admin-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.admin-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

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

.admin-table th {
  color: var(--muted);
  background: #f7fafb;
  font-size: 12px;
  font-weight: 850;
}

.admin-table td {
  font-size: 13px;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.mini-button:hover {
  border-color: var(--line-strong);
  background: #f7fafb;
}

.mini-button.danger {
  color: var(--red);
}

.empty-cell {
  height: 72px;
  color: var(--muted);
  text-align: center !important;
}

.strip-title,
.summary-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
  font-weight: 800;
}

.strip-title svg,
.summary-heading svg {
  width: 17px;
  height: 17px;
  color: var(--teal);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.meta-field {
  display: grid;
  gap: 5px;
}

.meta-field label,
.field-note label,
.text-field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta-field input,
.search-box input,
.field-note textarea,
.text-field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
}

.meta-field input {
  height: 38px;
  padding: 0 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  align-items: start;
  padding: 18px 24px 28px;
}

.sidebar,
.form-panel,
.summary-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar,
.summary-panel {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.sidebar {
  padding: 14px;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

#sidebar-progress {
  display: block;
  color: var(--navy);
  font-size: 28px;
  line-height: 1;
}

.save-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(31, 122, 77, 0.28);
  border-radius: 999px;
  color: var(--green);
  background: rgba(31, 122, 77, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin: 14px 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex: 0 0 16px;
}

.search-box input {
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
}

.section-list {
  display: grid;
  gap: 7px;
}

.section-link {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
  text-align: left;
}

.section-link:hover {
  background: var(--surface-soft);
}

.section-link.is-active {
  border-color: rgba(0, 127, 134, 0.34);
  background: rgba(0, 127, 134, 0.08);
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--navy);
  background: #e5eef5;
  font-size: 12px;
  font-weight: 800;
}

.section-link.is-active .section-number {
  color: #ffffff;
  background: var(--teal);
}

.section-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 750;
}

.section-percent {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.form-panel {
  min-width: 0;
}

.section-toolbar {
  position: sticky;
  top: 86px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.field-list {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.field-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: #ffffff;
}

.field-card.is-complete {
  border-left-color: var(--green);
}

.field-card.is-risk {
  border-left-color: var(--red);
}

.field-title-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.field-status {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f4f6;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.field-status.status-a {
  color: var(--green);
  background: rgba(31, 122, 77, 0.1);
}

.field-status.status-b {
  color: var(--amber);
  background: rgba(165, 100, 20, 0.1);
}

.field-status.status-c {
  color: var(--red);
  background: rgba(180, 35, 24, 0.1);
}

.choice-grid {
  display: grid;
  gap: 9px;
}

.choice-button {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fbfcfd;
  text-align: left;
}

.choice-button:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.choice-button.is-selected {
  border-color: rgba(0, 127, 134, 0.55);
  background: rgba(0, 127, 134, 0.07);
}

.choice-button[data-value="C"].is-selected {
  border-color: rgba(180, 35, 24, 0.42);
  background: rgba(180, 35, 24, 0.07);
}

.choice-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--navy);
  background: #e6edf3;
  font-weight: 900;
}

.choice-button.is-selected .choice-letter {
  color: #ffffff;
  background: var(--teal);
}

.choice-button[data-value="B"].is-selected .choice-letter {
  background: var(--amber);
}

.choice-button[data-value="C"].is-selected .choice-letter {
  background: var(--red);
}

.choice-text {
  line-height: 1.55;
}

.field-note,
.text-field {
  display: grid;
  gap: 6px;
}

.field-note textarea,
.text-field textarea {
  min-height: 82px;
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

.text-field textarea.long {
  min-height: 132px;
}

.summary-panel {
  padding: 16px;
}

.score-block {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.score-ring {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 57%, transparent 58%),
    conic-gradient(var(--teal) 0deg, var(--teal) 0deg, #e3e9ec 0deg);
}

.score-ring span {
  margin-top: 8px;
  color: var(--navy);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.score-ring small {
  margin-top: -22px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#risk-label {
  margin: 0 0 6px;
  color: var(--navy);
}

.summary-line {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px 0;
}

.metric-grid div {
  min-width: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.metric-grid span {
  color: var(--navy);
  font-size: 22px;
  font-weight: 900;
}

.metric-grid small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.summary-section {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.section-scores {
  display: grid;
  gap: 9px;
}

.score-row {
  display: grid;
  gap: 5px;
}

.score-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.score-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e9ec;
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.score-bar span.low {
  background: var(--red);
}

.score-bar span.mid {
  background: var(--amber);
}

.risk-list {
  display: grid;
  gap: 8px;
}

.risk-item,
.empty-state {
  padding: 10px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
}

.risk-item {
  border: 1px solid rgba(180, 35, 24, 0.2);
  background: rgba(180, 35, 24, 0.06);
}

.risk-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--red);
}

.empty-state {
  color: var(--muted);
  background: #f7fafb;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: #20313b;
  box-shadow: var(--shadow);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(15, 28, 36, 0.42);
  backdrop-filter: blur(6px);
}

.login-modal.is-open {
  display: grid;
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 28, 36, 0.18);
}

.login-logo {
  width: 48px;
  height: 48px;
}

.login-box h2 {
  margin-bottom: 6px;
  color: var(--navy);
}

.login-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-box input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
  color: #ffffff;
  border-color: transparent;
  background: var(--navy);
}

.login-submit:hover {
  border-color: transparent;
  background: #0d2f50;
}

.login-hint {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  }

  .summary-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }

  .summary-panel {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(260px, 1fr) minmax(260px, 1fr);
    gap: 16px;
  }

  .score-block,
  .metric-grid,
  .summary-section {
    padding: 0;
    border-top: 0;
    border-bottom: 0;
  }

}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .project-strip,
  .admin-panel,
  .workspace {
    margin-left: 14px;
    margin-right: 14px;
  }

  .project-strip,
  .workspace,
  .summary-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 14px 0 24px;
  }

  .sidebar,
  .section-toolbar {
    position: static;
  }

  .sidebar {
    max-height: none;
  }

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

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

  .admin-head {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 19px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .topbar,
  .project-strip,
  .field-list,
  .section-toolbar,
  .summary-panel,
  .sidebar {
    padding: 12px;
  }

  .topbar-actions .icon-button span {
    display: none;
  }

  .topbar-actions .icon-button {
    width: 38px;
    padding: 0;
  }

  .select-control {
    max-width: none;
    flex: 1 1 150px;
  }

  .user-pill {
    max-width: none;
    flex: 1 1 130px;
  }

  .admin-panel,
  .login-box {
    padding: 12px;
  }

  .bd-stats {
    grid-template-columns: 1fr;
  }

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

  .field-title-row,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .field-status {
    width: fit-content;
  }

  .choice-button {
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 10px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar-actions,
  .sidebar,
  .section-controls,
  .toast {
    display: none !important;
  }

  .topbar,
  .project-strip,
  .workspace,
  .summary-panel,
  .form-panel {
    position: static;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .field-card {
    break-inside: avoid;
  }
}
