:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --ink: #162b22;
  --muted: #5f746a;
  --line: #d7e2db;
  --accent: #0f6a4f;
  --accent-soft: #dff1ea;
  --warn: #9a4f10;
  --good: #16693f;
  --bad: #8f2f2f;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  background: radial-gradient(circle at top right, #eef8f3 0%, #f4f7f5 55%);
  color: var(--ink);
}

.landing-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing-card {
  width: min(560px, 100%);
  background: #ffffff;
  border: 1px solid #d8e4dd;
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.landing-card h1 {
  margin: 0;
}

.landing-subtitle {
  margin: 6px 0 18px;
  color: var(--muted);
}

.login-section {
  border: 1px solid #d7e3dc;
  border-radius: 12px;
  padding: 14px;
  background: #f9fcfa;
  margin-bottom: 12px;
}

.login-section h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.login-section p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-section form {
  display: grid;
  gap: 8px;
}

.password-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.password-field input {
  flex: 1;
}

.password-toggle {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #c8d9d0;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: #f0f5f1;
}

#student-login-btn {
  background: #0d4fba;
  color: #ffffff;
  border: 2px solid #083378;
}

#student-login-btn:hover,
#student-login-btn:focus-visible {
  background: #ffe600;
  color: #000000;
  border-color: #000000;
}

.landing-footnote {
  margin-top: 10px;
  font-size: 0.92rem;
  color: var(--muted);
}

.landing-footnote a {
  color: #1b5d46;
  font-weight: 600;
  text-decoration: none;
}

.landing-footnote a:hover {
  text-decoration: underline;
}

.auth-message {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.auth-message.is-error {
  color: var(--bad);
}

.auth-message.is-success {
  color: var(--good);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

.left-pane {
  background: linear-gradient(160deg, #123d2f 0%, #0f2d22 100%);
  color: #eff8f4;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  overflow: hidden;
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.03em;
}

.brand-home-link {
  color: inherit;
  text-decoration: none;
}

.brand-home-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.brand p {
  margin: 6px 0 0;
  color: #c0ddd2;
  font-size: 0.9rem;
}

.menu h2,
.status-bar h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu li {
  margin-bottom: 6px;
}

.menu-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: #c8e0d6;
  background: transparent;
  font-weight: 600;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.menu-btn.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.menu-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dev-panel {
  margin-top: -6px;
}

.dev-panel h2 {
  margin: 0 0 10px;
  color: #d6ebe2;
}

.dev-actions {
  display: grid;
  gap: 8px;
}

.dev-btn {
  text-align: left;
}

.status-bar {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 14px;
  box-shadow: none;
}

.status-side {
  margin-top: 12px;
  padding: 10px;
}

.status-side h2 {
  margin: 0 0 8px;
  color: #d6ebe2;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 9px 10px;
}

.status-side .status-item {
  margin-bottom: 6px;
  padding: 6px 8px;
  border-radius: 8px;
}

.status-item:last-child {
  margin-bottom: 0;
}

.status-item span {
  color: #cce3d9;
  font-size: 0.9rem;
}

.status-item strong {
  color: #ffffff;
}

.status-side .status-item span {
  font-size: 0.78rem;
}

.status-side .status-item strong {
  font-size: 0.86rem;
}

.right-pane {
  padding: 0 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  overflow-y: auto;
}

.top-status-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #d6e3dc;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(20, 53, 41, 0.08);
  backdrop-filter: blur(3px);
}

.top-status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.top-status-item {
  border: 1px solid #dce8e2;
  border-radius: 8px;
  background: #f8fbf9;
  padding: 4px 6px;
}

.top-status-item span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.1;
}

.top-status-item strong {
  display: block;
  margin-top: 2px;
  color: #183e31;
  font-size: 0.84rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-status-actions {
  flex: 0 0 auto;
}

.exercise-header .chapter {
  margin: 0;
  color: var(--muted);
}

.exercise-header h2 {
  margin: 6px 0 0;
  font-size: 1.8rem;
}

.question-card,
.form-card,
.results-card,
.solution-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.start-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}

.start-card h3 {
  margin: 0 0 8px;
}

.start-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.hint-card {
  background: #f8fcfa;
  border: 1px solid #d5e5dc;
  border-left: 4px solid #3f8c6b;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.hint-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.back-btn {
  background: #e8f0ec;
  color: #184536;
  border: 1px solid #bcd2c7;
}

.hint-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.hint-card li {
  margin-bottom: 8px;
}

.hint-card li:last-child {
  margin-bottom: 0;
}

h3 {
  margin-top: 0;
}

.question-card ol {
  margin-top: 8px;
  padding-left: 20px;
}

.question-card li {
  margin-bottom: 8px;
}

.form-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.form-head-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.admin-btn {
  background: #e8f0ec;
  color: #184536;
  border: 1px solid #bcd2c7;
}

.task-group {
  border: 1px solid #d5e4dc;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbf9 0%, #ffffff 70%);
  padding: 12px;
  margin-top: 12px;
}

.task-group:first-child {
  margin-top: 8px;
}

.task-group-b {
  border-color: #d5dee6;
  background: linear-gradient(180deg, #f7fafc 0%, #ffffff 70%);
}

.task-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #d7e2db;
}

.task-group-head h4 {
  margin: 0;
  font-size: 1rem;
  color: #1f4b3b;
}

.task-group-b .task-group-head h4 {
  color: #2a4a66;
}

.task-group-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.entry-block {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.task-group-body .entry-block:first-child {
  margin-top: 10px;
}

.entry-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.entry-title-row.has-hint .entry-title {
  cursor: help;
  text-decoration: underline dotted;
  text-decoration-color: #8ea79b;
  text-underline-offset: 3px;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.entry-block h4 {
  margin: 0;
  font-size: 1rem;
}

.points-badge {
  background: #e3f1ea;
  color: #1e5a43;
  border: 1px solid #b8d7c8;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.entry-score-badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid #cfd8d3;
  background: #f3f6f4;
  color: #5a6d63;
}

.entry-score-badge.is-pending {
  border-color: #d8dcd8;
  background: #f3f5f3;
  color: #627068;
}

.entry-score-badge.is-ok {
  border-color: #8fbfa5;
  background: #e7f6ee;
  color: #1f6645;
}

.entry-score-badge.is-partial {
  border-color: #f0d29a;
  background: #fff8e7;
  color: #9a4f10;
}

.entry-score-badge.is-bad {
  border-color: #d8a2a2;
  background: #fdeeee;
  color: #8f2f2f;
}

.consistency-badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid #cfd8d3;
  background: #f3f6f4;
  color: #5a6d63;
}

.consistency-badge.is-pending {
  border-color: #d8dcd8;
  background: #f3f5f3;
  color: #627068;
}

.consistency-badge.is-ok {
  border-color: #8fbfa5;
  background: #e7f6ee;
  color: #1f6645;
}

.consistency-badge.is-bad {
  border-color: #d8a2a2;
  background: #fdeeee;
  color: #8f2f2f;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.side-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfefd;
}

.side-box h5 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.line-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 8px;
  margin-bottom: 8px;
}

.line-row:last-child {
  margin-bottom: 0;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #b8ccc2;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95rem;
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid #9fd4bf;
  border-color: #6fb598;
}

.line-row.evaluated select,
.line-row.evaluated input[type="text"] {
  cursor: help;
}

.line-row.evaluated.field-ok select,
.line-row.evaluated.field-ok input[type="text"] {
  background: #ecf9f0;
  border-color: #7fbe95;
}

.line-row.evaluated.field-partial select,
.line-row.evaluated.field-partial input[type="text"] {
  background: #fff8e7;
  border-color: #e4be70;
}

.line-row.evaluated.field-bad select,
.line-row.evaluated.field-bad input[type="text"] {
  background: #fdeeee;
  border-color: #d39191;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

button#submit-btn {
  background: var(--accent);
  color: #ffffff;
}

button.secondary {
  background: #eaf1ed;
  color: #264338;
}

.admin-card {
  background: #f9fcfa;
  border: 1px solid #cddfd4;
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

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

.admin-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.admin-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

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

.admin-attempts-table th,
.admin-attempts-table td {
  border: 1px solid #d8e4dd;
  padding: 5px 6px;
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.25;
  vertical-align: top;
}

.admin-attempts-table th {
  background: #eaf3ee;
  color: #1f4b3b;
}

.admin-sort-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 650;
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: pointer;
}

.admin-sort-btn:hover {
  color: #0f6a4f;
}

.admin-sort-indicator {
  min-width: 1.2em;
  text-align: right;
  color: #426659;
}

.admin-filter-row th {
  background: #f5faf7;
}

.admin-filter-row input {
  width: 100%;
  font-size: 0.74rem;
  padding: 4px 6px;
  border: 1px solid #c8d9d0;
  border-radius: 5px;
}

.admin-empty-row {
  text-align: center;
  color: var(--muted);
  background: #fbfdfc;
}

.admin-detail-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.admin-export-archive {
  margin-top: 14px;
}

.admin-export-archive h4 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: #1f4b3b;
}

.admin-archive-table {
  min-width: 860px;
}

.admin-attempt-detail {
  border: 1px solid #d7e3dc;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 10px;
}

.admin-attempt-detail summary {
  cursor: pointer;
  font-weight: 600;
  color: #1f4b3b;
}

.admin-doc-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.admin-readonly-doc {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.admin-doc-section {
  border: 1px solid #dce8e2;
  border-radius: 8px;
  background: #f9fcfa;
  padding: 10px;
}

.admin-doc-section h5 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #1f4b3b;
}

.admin-doc-section p,
.admin-doc-section li {
  font-size: 0.84rem;
  line-height: 1.35;
}

.admin-doc-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-doc-meta-grid span {
  display: block;
  color: #5a6f65;
  font-size: 0.76rem;
}

.admin-doc-meta-grid strong {
  color: #183e31;
  font-size: 0.84rem;
}

.admin-doc-entry {
  margin-top: 8px;
}

.admin-doc-entry:first-of-type {
  margin-top: 0;
}

.admin-doc-entry h6 {
  margin: 0 0 6px;
  color: #2a4a66;
  font-size: 0.86rem;
}

.admin-doc-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-doc-side {
  border: 1px solid #d8e5de;
  border-radius: 7px;
  background: #ffffff;
  padding: 8px;
}

.admin-doc-side-title {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1f4b3b;
}

.admin-doc-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-doc-table th,
.admin-doc-table td {
  border: 1px solid #dce7e1;
  padding: 4px 5px;
  text-align: left;
  font-size: 0.76rem;
}

.admin-doc-table th {
  background: #edf5f1;
}

.admin-detail-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-detail-entry {
  margin-top: 10px;
  border: 1px solid #e0e9e4;
  border-radius: 8px;
  padding: 8px;
  background: #f9fcfa;
}

.admin-detail-entry h5 {
  margin: 0;
  font-size: 0.92rem;
}

.admin-row-finding {
  margin: 6px 0 0;
  font-size: 0.85rem;
}

.admin-row-finding.ok {
  color: var(--good);
}

.admin-row-finding.partial {
  color: var(--warn);
}

.admin-row-finding.bad {
  color: var(--bad);
}

.admin-entry {
  margin-top: 12px;
  border: 1px solid #d5e2db;
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.admin-entry h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-side {
  border: 1px solid #d7e2db;
  border-radius: 8px;
  padding: 8px;
}

.admin-side h5 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-row:last-child {
  margin-bottom: 0;
}

.admin-row input[type="text"],
.admin-row select {
  font-size: 0.9rem;
}

#overall-result {
  font-size: 1.05rem;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.result-kpi {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #f7fbf9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.result-kpi span {
  color: var(--muted);
  font-size: 0.9rem;
}

.result-kpi strong {
  color: var(--ink);
}

.result-line {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
  font-size: 0.93rem;
}

.result-line.ok {
  background: #ecf9f0;
  border-color: #aad3b8;
  color: var(--good);
}

.result-line.partial {
  background: #fff8e7;
  border-color: #f0d29a;
  color: var(--warn);
}

.result-line.bad {
  background: #fdeeee;
  border-color: #e5b0b0;
  color: var(--bad);
}

.solution-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.solution-table th,
.solution-table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  font-size: 0.92rem;
}

.solution-table th {
  background: var(--accent-soft);
}

.completion-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 180px);
}

.completion-card {
  width: min(620px, 100%);
  border: 1px solid #d5e3db;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9f6 100%);
  box-shadow: var(--shadow);
  padding: 30px 28px;
}

.completion-eyebrow {
  margin: 0 0 8px;
  color: #1a6148;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.82rem;
  font-weight: 700;
}

.completion-card h3 {
  margin: 0 0 10px;
  font-size: 1.9rem;
}

.completion-card p {
  margin: 0 0 8px;
  color: #385649;
}

#completion-timestamp {
  font-weight: 600;
  color: #1f4b3b;
}

@media (max-width: 1050px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .left-pane {
    gap: 12px;
    height: auto;
    overflow: visible;
  }

  .status-side {
    margin-top: 0;
  }

  .right-pane {
    height: auto;
    overflow: visible;
  }

  .top-status-bar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .top-status-grid {
    grid-template-columns: 1fr;
  }

  .top-status-actions {
    width: 100%;
  }

  .top-status-actions button {
    width: 100%;
  }

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

  .task-group-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hint-head {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

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

  .result-summary {
    grid-template-columns: 1fr;
  }

  .completion-view {
    min-height: auto;
  }

  .completion-card {
    padding: 20px 18px;
  }
}
