.grade-shell {
  width: min(1080px, calc(100% - 32px));
}

.grade-shell .mort-layout {
  gap: 16px;
}

.grade-shell .grade-form {
  display: grid;
  gap: 14px;
}

.grade-shell .grade-table-wrap {
  border: 1px solid #dbe5f4;
  border-radius: 12px;
  background: #ffffff;
  overflow-x: auto;
  padding: 10px;
}

.grade-shell .grade-course-table {
  width: 100%;
  min-width: 660px;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.grade-shell .grade-course-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 4px 8px;
}

.grade-shell .grade-course-table td {
  padding: 0 8px;
  vertical-align: middle;
}

.grade-shell .grade-course-table input,
.grade-shell .grade-inline-affix {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid #c8d3e7;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  box-sizing: border-box;
}

.grade-shell .grade-course-table input {
  padding: 0 10px;
}

.grade-shell .grade-course-table input:focus,
.grade-shell .grade-plan-grid input:focus,
.grade-shell .grade-final-form input:focus {
  outline: none;
  border-color: #2f6fdf;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.grade-shell .grade-inline-affix {
  display: grid;
  grid-template-columns: 1fr auto;
  overflow: hidden;
  padding: 0;
}

.grade-shell .grade-inline-affix input {
  border: 0;
  border-radius: 0;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  min-width: 0;
  padding: 0 10px;
}

.grade-shell .grade-inline-affix span {
  min-width: 38px;
  border-left: 1px solid #c8d3e7;
  background: #f4f7fd;
  color: #0f2454;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.grade-shell .grade-actions-col {
  width: 1%;
  white-space: nowrap;
}

.grade-shell .grade-remove-row {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid #c8d3e7;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
}

.grade-shell .grade-remove-row:hover,
.grade-shell .grade-remove-row:focus-visible {
  border-color: #2f6fdf;
  color: #1f5cc9;
}

.grade-shell .grade-optional {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: #94a3b8;
}

.grade-shell .grade-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.grade-shell .grade-link-btn {
  border: 0;
  background: transparent;
  color: #1f5cc9;
  font-size: 14px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.grade-shell .grade-link-btn:hover,
.grade-shell .grade-link-btn:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.grade-shell .grade-action-btns {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.grade-shell .grade-btn {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid #c8d3e7;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}

.grade-shell .grade-btn:hover,
.grade-shell .grade-btn:focus-visible {
  border-color: #2f6fdf;
}

.grade-shell .grade-plan-inline {
  border: 1px solid #dbe5f4;
  border-radius: 12px;
  background: #fcfdff;
  padding: 10px 12px;
}

.grade-shell .grade-plan-inline h2 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}

.grade-shell .grade-plan-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grade-shell .grade-plan-grid label,
.grade-shell .grade-final-form label {
  display: grid;
  gap: 6px;
}

.grade-shell .grade-plan-grid label span,
.grade-shell .grade-final-form label span {
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}

.grade-shell .grade-plan-grid input,
.grade-shell .grade-final-form input {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid #c8d3e7;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  padding: 0 10px;
  box-sizing: border-box;
}

.grade-shell .grade-settings {
  border: 1px solid #dbe5f4;
  border-radius: 12px;
  background: #fcfdff;
  padding: 10px 12px;
}

.grade-shell .grade-settings > summary {
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.grade-shell .grade-settings > summary::-webkit-details-marker {
  display: none;
}

.grade-shell .grade-settings > summary::after {
  content: '▾';
  color: #64748b;
  font-size: 13px;
  transition: transform 0.16s ease;
}

.grade-shell .grade-settings[open] > summary::after {
  transform: rotate(180deg);
}

.grade-shell .grade-settings p {
  margin: 10px 0 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
}

.grade-shell .grade-result-note {
  margin: 12px 0 0;
  color: #475569;
  font-size: 14px;
}

.grade-shell .grade-plan-result-card {
  margin-top: 12px;
  border: 1px solid #dbe5f4;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px 12px;
}

.grade-shell .grade-plan-result-card h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #667085;
}

.grade-shell .grade-plan-result-card p {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
}

.grade-shell .grade-breakdown-wrap {
  margin-top: 12px;
  border: 1px solid #dbe5f4;
  border-radius: 10px;
  background: #ffffff;
  overflow-x: auto;
}

.grade-shell .grade-breakdown-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.grade-shell .grade-breakdown-table th,
.grade-shell .grade-breakdown-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  font-size: 13px;
}

.grade-shell .grade-breakdown-table th {
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.grade-shell .grade-breakdown-table tbody tr:last-child td {
  border-bottom: 0;
}

.grade-shell .grade-final-card > p {
  margin: 0 0 12px;
  font-size: 14px;
  color: #475569;
}

.grade-shell .grade-final-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.grade-shell .grade-final-result-card {
  grid-column: 1 / -1;
  border: 1px solid #dbe5f4;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px 12px;
}

.grade-shell .grade-final-result-card h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #667085;
}

.grade-shell .grade-final-result-card p {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .grade-shell .grade-plan-grid,
  .grade-shell .grade-final-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .grade-shell {
    width: calc(100% - 22px);
    margin: 20px auto 42px;
  }

  .grade-shell .mort-card {
    padding: 14px;
  }

  .grade-shell .grade-table-wrap {
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .grade-shell .grade-course-table {
    min-width: 0;
    border-spacing: 0;
  }

  .grade-shell .grade-course-table thead {
    display: none;
  }

  .grade-shell .grade-course-table tbody {
    display: grid;
    gap: 10px;
  }

  .grade-shell .grade-course-table tr[data-grade-row] {
    display: block;
    border: 1px solid #dbe5f4;
    border-radius: 12px;
    background: #ffffff;
    padding: 10px;
  }

  .grade-shell .grade-course-table td {
    display: block;
    margin: 0 0 12px;
    padding: 0;
  }

  .grade-shell .grade-course-table td:last-child {
    margin-bottom: 0;
  }

  .grade-shell .grade-course-table td::before {
    display: block;
    margin: 0 0 4px;
    font-size: 11px;
    line-height: 1.3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    color: #64748b;
    content: '';
  }

  .grade-shell .grade-course-table td:nth-child(1)::before {
    content: 'Assignment / exam';
  }

  .grade-shell .grade-course-table td:nth-child(2)::before {
    content: 'Grade';
  }

  .grade-shell .grade-course-table td:nth-child(3)::before {
    content: 'Weight';
  }

  .grade-shell .grade-course-table td.grade-actions-col::before {
    display: none;
  }

  .grade-shell .grade-remove-row {
    display: inline-block;
    width: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
    padding: 0;
    text-transform: lowercase;
  }

  .grade-shell .grade-remove-row::before {
    content: '- ';
  }

  .grade-shell .grade-remove-row:hover,
  .grade-shell .grade-remove-row:focus-visible {
    border: 0;
    color: #334155;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .grade-shell .grade-breakdown-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .grade-shell .grade-breakdown-table {
    min-width: 0;
  }

  .grade-shell .grade-breakdown-table thead {
    display: none;
  }

  .grade-shell .grade-breakdown-table tbody {
    display: grid;
    gap: 10px;
  }

  .grade-shell .grade-breakdown-table tbody tr {
    display: block;
    border: 1px solid #dbe5f4;
    border-radius: 12px;
    background: #ffffff;
    padding: 10px;
  }

  .grade-shell .grade-breakdown-table td {
    display: block;
    border: 0;
    margin: 0 0 8px;
    padding: 0;
    font-size: 15px;
  }

  .grade-shell .grade-breakdown-table td:last-child {
    margin-bottom: 0;
  }

  .grade-shell .grade-breakdown-table td::before {
    display: block;
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    color: #64748b;
    content: '';
  }

  .grade-shell .grade-breakdown-table td:nth-child(1)::before {
    content: 'Assignment';
  }

  .grade-shell .grade-breakdown-table td:nth-child(2)::before {
    content: 'Grade input';
  }

  .grade-shell .grade-breakdown-table td:nth-child(3)::before {
    content: 'Normalized grade';
  }

  .grade-shell .grade-breakdown-table td:nth-child(4)::before {
    content: 'Weight';
  }

  .grade-shell .grade-breakdown-table td:nth-child(5)::before {
    content: 'Weighted contribution';
  }

  .grade-shell .grade-breakdown-table td[colspan] {
    margin: 0;
    color: #64748b;
  }

  .grade-shell .grade-breakdown-table td[colspan]::before {
    display: none;
  }

  .grade-shell .grade-actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .grade-shell .grade-action-btns {
    width: 100%;
  }

  .grade-shell .grade-btn {
    width: 100%;
    flex: 1 1 auto;
  }

  .grade-shell .grade-link-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .grade-shell .grade-plan-grid,
  .grade-shell .grade-final-form {
    grid-template-columns: 1fr;
  }
}
