:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5d6b7a;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #b45309;
  --bad: #b91c1c;
  --good: #047857;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

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

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #111827;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 700;
}

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

.brand h1 {
  font-size: 20px;
}

.brand p,
.toolbar p,
.field span,
.status-box small {
  color: var(--muted);
}

.sidebar .brand p,
.sidebar .field span,
.sidebar .status-box small {
  color: #cbd5e1;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.sidebar input {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

.exam-part-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}

.exam-part-box > span {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}

.exam-part-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.exam-part-option {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 9px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f9fafb;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.exam-part-option.active {
  border-color: #99f6e4;
  background: #0f766e;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab,
.primary,
.danger,
.link-button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

button:not(.tab):not(.primary):not(.danger):not(.candidate-item) {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

button:not(.tab):not(.primary):not(.danger):not(.candidate-item):hover {
  background: #f8fafc;
}

.tab {
  background: #1f2937;
  color: #d1d5db;
}

.tab.active {
  background: #e5f4f2;
  color: #0f766e;
  font-weight: 700;
}

.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.primary:hover {
  background: #0b5f59;
}

.danger {
  background: #fee2e2;
  color: #991b1b;
  font-weight: 700;
  text-align: center;
}

.danger:hover {
  background: #fecaca;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button-row.left {
  justify-content: flex-start;
}

.status-box {
  margin-top: auto;
  padding: 16px;
  border: 1px solid #374151;
  border-radius: 8px;
  display: grid;
  gap: 10px;
}

.year-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #1f2937;
}

.year-box > span,
.year-box .field span {
  color: #cbd5e1;
  font-size: 12px;
}

.year-box > strong {
  font-size: 24px;
}

.year-box select {
  background: #111827;
  border-color: #4b5563;
  color: #fff;
}

.status-box span {
  display: block;
  font-size: 32px;
  font-weight: 700;
}

.logout-button {
  text-align: center;
  padding: 8px;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar h2 {
  font-size: 26px;
  margin-bottom: 5px;
}

.exam-mode-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -12px -12px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.exam-mode-title {
  display: grid;
  gap: 2px;
  white-space: nowrap;
}

.exam-mode-title span {
  color: var(--muted);
  font-size: 12px;
}

.exam-mode-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.work-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.candidate-list {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.candidate-panel {
  position: sticky;
  top: 18px;
}

.candidate-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 13px 16px;
  text-align: left;
  cursor: pointer;
}

.candidate-item.active {
  background: #e8f5f4;
}

.candidate-item strong {
  font-size: 15px;
}

.candidate-item span {
  color: var(--muted);
  font-size: 13px;
}

.candidate-status {
  display: inline-block;
  margin-top: 5px;
  font-style: normal;
  font-weight: 700;
}

.candidate-status.good {
  color: var(--good);
}

.candidate-status.open,
.candidate-status.warn {
  color: var(--warn);
}

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

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

.task-navigator {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(6, minmax(68px, 1fr));
  gap: 7px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.task-nav-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px;
  align-items: center;
  min-width: 0;
  padding: 7px 8px !important;
  border-width: 1px !important;
}

.task-nav-item strong {
  font-size: 14px;
}

.task-nav-item span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.task-nav-item.good {
  border-color: #86efac !important;
  background: #f0fdf4 !important;
}

.task-nav-item.warn,
.task-nav-item.open {
  border-color: #fcd34d !important;
  background: #fffbeb !important;
}

.task-nav-item.bad {
  border-color: #fca5a5 !important;
  background: #fef2f2 !important;
}

.task-nav-item.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.task-list {
  display: grid;
  gap: 0;
}

.task {
  border-bottom: 1px solid var(--line);
  padding: 0;
}

.task:last-child {
  border-bottom: 0;
}

.task-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  padding: 14px 18px;
  list-style-position: inside;
}

.task-summary strong {
  font-size: 17px;
}

.task-summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.task[open] .task-summary {
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.task-body {
  display: grid;
  gap: 12px;
  padding: 14px 18px 16px;
}

.task-score {
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
}

.task-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.task-actions button,
.criterion-control button {
  padding: 7px 9px !important;
  font-size: 13px;
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.criterion {
  display: grid;
  gap: 6px;
}

.criterion span {
  color: var(--muted);
  font-size: 13px;
}

.criterion input {
  max-width: 140px;
}

.criterion-control {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.criterion input.invalid {
  border-color: var(--bad);
  background: #fff1f2;
}

.criterion-error {
  min-height: 16px;
  color: var(--bad);
  font-size: 12px;
}

#scoreProblemPanel {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.problem-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.problem-link {
  width: 100%;
  text-align: left !important;
  padding: 7px 9px !important;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  background: #f8fafc;
  font-size: 13px;
  color: var(--muted);
}

#summaryTable {
  min-width: 980px;
}

#summaryTable td {
  vertical-align: top;
}

.summary-name {
  display: block;
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reviewer-chip-list,
.summary-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.reviewer-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.reviewer-chip.good {
  background: #dcfce7;
  color: var(--good);
}

.reviewer-chip.open {
  background: #fef3c7;
  color: var(--warn);
}

.summary-details summary {
  cursor: pointer;
  list-style: none;
}

.summary-details summary::-webkit-details-marker {
  display: none;
}

.summary-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
  min-width: 240px;
  white-space: normal;
}

.compact-button {
  padding: 7px 9px !important;
  font-size: 12px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.sync-status.good {
  background: #dcfce7;
  color: var(--good);
}

.sync-status.warn {
  background: #fef3c7;
  color: var(--warn);
}

tr.difference-warning td {
  background: #fff7ed;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.good {
  background: #dcfce7;
  color: var(--good);
}

.badge.bad {
  background: #fee2e2;
  color: var(--bad);
}

.badge.open {
  background: #fef3c7;
  color: var(--warn);
}

.import-panel,
.admin-panel,
.audit-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.import-panel {
  max-width: 620px;
}

.gp1-import-panel {
  margin-top: 18px;
  border-top: 4px solid #0f766e;
}

.gp2-panel {
  max-width: 760px;
  border-top: 4px solid #1d4ed8;
}

.gp1-panel {
  max-width: 760px;
  padding: 18px;
  display: grid;
  gap: 14px;
  border-top: 4px solid #0f766e;
}

.gp2-hint-grid,
.gp1-hint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.import-section-title {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.import-section-title h3,
.import-section-title p {
  margin: 0;
}

.import-section-title p {
  margin-top: 5px;
  color: var(--muted);
}

.import-block,
.admin-block {
  display: grid;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.import-block:last-child,
.admin-block:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.admin-detail {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-detail summary {
  cursor: pointer;
  padding: 13px 14px;
  font-size: 16px;
  font-weight: 700;
  list-style-position: inside;
}

.admin-detail[open] {
  padding-bottom: 14px;
}

.admin-detail[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.admin-detail > :not(summary) {
  margin-left: 14px;
  margin-right: 14px;
}

.admin-detail h4 {
  margin-top: 2px;
  font-size: 15px;
}

#factorTable input {
  max-width: 110px;
}

.audit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.audit-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.audit-card strong {
  display: block;
  font-size: 20px;
  margin-top: 5px;
}

.preparation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 14px;
}

.preparation-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.preparation-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.preparation-card-head h3,
.preparation-card-head p {
  margin: 0;
}

.preparation-card-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

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

.preparation-check {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.preparation-check.checked {
  border-color: #86b9a9;
  background: #edf8f4;
}

.preparation-check strong,
.preparation-check small {
  display: block;
}

.preparation-check small {
  margin-top: 3px;
  color: var(--muted);
}

.preparation-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.preparation-check.checked .preparation-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#preparationItemsInput {
  min-height: 280px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.audit-overview {
  display: grid;
  gap: 10px;
}

.audit-overview h3,
.audit-detail summary {
  font-size: 16px;
  font-weight: 700;
}

.audit-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.audit-detail summary {
  cursor: pointer;
  list-style-position: inside;
  padding: 12px;
}

.audit-detail[open] summary {
  border-bottom: 1px solid var(--line);
}

.audit-detail > .table-wrap,
.audit-detail > .score-header,
.audit-detail > .audit-detail {
  margin: 12px;
}

.audit-detail .audit-detail {
  background: #f8fafc;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.check-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.check-head {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 12px;
}

.check-head.ready {
  border-color: #86efac;
  background: #f0fdf4;
}

.check-head.blocked {
  border-color: #fecaca;
  background: #fef2f2;
}

.check-row {
  display: grid;
  grid-template-columns: auto 180px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.notice {
  min-height: 24px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

body.exam-mode .app-shell {
  grid-template-columns: 1fr;
}

body.exam-mode .sidebar,
body.exam-mode #view-bewerten > .toolbar {
  display: none;
}

body.exam-mode .main {
  padding: 12px;
}

body.exam-mode .work-grid {
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 12px;
}

body.exam-mode .candidate-panel {
  top: 72px;
}

body.exam-mode .candidate-list {
  max-height: calc(100vh - 155px);
}

body.exam-mode .score-header {
  padding: 12px 14px;
}

body.exam-mode .task-navigator {
  top: 68px;
}

body.exam-mode .task-body {
  padding: 12px 14px 14px;
}

body.exam-mode .criterion input {
  min-height: 48px;
  max-width: 120px;
  border-width: 2px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

body.exam-mode .criterion-control button {
  min-height: 42px;
}

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

  .sidebar {
    position: static;
  }

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

  .candidate-list {
    max-height: 280px;
  }

  .candidate-panel {
    position: static;
  }

  .task-navigator {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }

  body.exam-mode .work-grid {
    grid-template-columns: minmax(230px, 32vw) minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .toolbar,
  .score-header,
  .task-summary {
    flex-direction: column;
  }

  .check-row {
    grid-template-columns: 1fr;
  }

  #view-bewerten > .toolbar .button-row {
    position: sticky;
    bottom: 0;
    z-index: 4;
    justify-content: stretch;
    padding: 10px;
    margin: 0 -10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  #view-bewerten > .toolbar .button-row button {
    flex: 1 1 140px;
    text-align: center;
  }

  .criterion input {
    max-width: none;
    min-height: 46px;
    font-size: 18px;
  }

  .criterion-control button {
    min-height: 46px;
  }

  .exam-mode-bar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    margin: -6px -6px 10px;
  }

  .exam-mode-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exam-mode-actions .sync-status {
    grid-column: 1 / -1;
    justify-content: center;
  }

  body.exam-mode .work-grid {
    grid-template-columns: 1fr;
  }

  body.exam-mode .candidate-panel {
    position: static;
  }

  body.exam-mode .candidate-list {
    max-height: 230px;
  }

  body.exam-mode .task-navigator {
    top: 0;
  }

  body.exam-mode .criterion input {
    max-width: none;
  }
}

@media print {
  .internal-only {
    display: none !important;
  }
}
