:root {
  --ink: #1f2937;
  --muted: #66758a;
  --line: #d6e0ea;
  --teal: #0f766e;
  --blue: #1e5268;
  --paper: #f5f8f7;
  --white: #ffffff;
  --danger: #b42318;
  --ok: #1a7f37;
  --warn: #a16207;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 41, 55, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(31, 41, 55, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 51px 31px;
  font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.side-menu {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: #18323c;
  color: #ffffff;
}

.brand-block {
  display: grid;
  gap: 8px;
  margin-bottom: 34px;
}

.brand-block strong {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #e9f4f1;
  color: #18323c;
  font-size: 23px;
}

.brand-block span {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 900;
}

.menu-stack {
  display: grid;
  gap: 10px;
}

.menu-button {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  min-height: 58px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  text-align: left;
}

.menu-button span {
  color: rgba(255, 255, 255, 0.46);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 900;
}

.menu-button b {
  font-size: 18px;
}

.menu-button.is-active,
.menu-button:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.assignment-card {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0;
  padding: 36px;
  border: 0;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.page-head,
.box-head,
.action-row,
.progress-meta,
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.1;
}

.outline-button,
.primary-button,
.danger-button {
  min-height: 62px;
  padding: 0 24px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--blue);
  font-size: 25px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.language-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: #f7fafc;
}

.lang-button {
  min-width: 82px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.lang-button.is-active {
  background: var(--teal);
  color: #ffffff;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 25px;
  font-weight: 900;
}

.login-strip {
  margin-top: 26px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 18px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr) 148px;
  gap: 20px;
  margin-top: 28px;
}

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

label > span,
.field > span,
.email-area > span {
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 64px;
  padding: 0 24px;
  font-size: 24px;
}

textarea {
  height: 250px;
  padding: 20px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.status-text {
  margin-top: 12px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.status-text.error {
  color: var(--danger);
}

.status-text.ok {
  color: var(--ok);
}

.product-box,
.progress-panel,
.result-panel {
  margin-top: 24px;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.box-head {
  min-height: 70px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.box-head strong {
  color: var(--blue);
  font-size: 22px;
}

.product-list {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  min-height: 110px;
  padding: 22px;
}

.product-item {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 0 18px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 23px;
  font-weight: 900;
}

.product-item.muted {
  color: var(--muted);
}

.product-item input {
  width: 20px;
  height: 20px;
}

.email-area {
  margin-top: 24px;
}

.correction-panel {
  margin-top: 18px;
  border: 1px solid #f1c27d;
  background: #fffaf0;
}

.correction-head {
  align-items: flex-start;
  background: #fff7e6;
}

.correction-head p {
  margin: 6px 0 0;
  color: var(--warn);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.correction-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.correction-compare {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.correction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid #ecd4a7;
  background: #ffffff;
}

.correction-row.is-unfixed {
  border-color: #f0b4ac;
  background: #fff6f5;
}

.correction-row span,
.correction-output span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.correction-row code {
  display: block;
  min-height: 38px;
  padding: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid #edf1f4;
  background: #f8fafc;
  color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 15px;
  line-height: 1.45;
}

.correction-output textarea {
  height: 170px;
  background: #ffffff;
  font-size: 17px;
}

.correction-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.action-row {
  margin-top: 18px;
}

.button-group {
  display: flex;
  gap: 12px;
}

.progress-panel {
  padding: 22px;
}

.progress-meta strong {
  font-size: 22px;
}

.progress-meta span {
  color: var(--muted);
  font-size: 17px;
}

.progress-track {
  height: 14px;
  margin: 18px 0;
  border: 1px solid var(--line);
  background: #eef3f6;
  overflow: hidden;
}

.progress-track > div {
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 0.2s ease;
}

.summary-row {
  justify-content: flex-start;
  gap: 28px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.summary-row b {
  color: var(--ink);
}

.team-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
  gap: 18px;
  align-items: stretch;
  margin-top: 28px;
}

.metric-tile {
  min-height: 110px;
  padding: 20px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  color: var(--blue);
  font-size: 38px;
  line-height: 1;
}

.team-workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 22px;
  margin-top: 24px;
  align-items: start;
}

.team-list-panel,
.team-detail-panel,
.delete-progress-panel {
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.compact-head {
  min-height: 58px;
}

.team-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.search-input {
  height: 56px;
  width: 100%;
  font-size: 18px;
}

.sort-field {
  gap: 5px;
}

.sort-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.sort-field select {
  height: 56px;
  padding: 0 10px;
  font-size: 16px;
  font-weight: 900;
}

.team-list {
  max-height: 670px;
  overflow: auto;
}

.team-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-bottom: 1px solid #edf1f4;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.team-item.is-active,
.team-item:hover {
  background: #edf7f4;
}

.team-item strong,
.team-item small {
  display: block;
}

.team-item strong {
  margin-bottom: 7px;
  font-size: 17px;
}

.team-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.team-item b {
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 48px;
  background: var(--blue);
  color: #ffffff;
  font-size: 20px;
}

.team-detail-panel {
  padding: 22px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: flex-start;
}

.detail-head h2 {
  margin: 0;
  font-size: 30px;
}

.team-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.team-count {
  min-width: 130px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #ffffff;
  text-align: center;
}

.team-count span,
.delete-confirm span,
.select-all-row span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.team-count strong {
  display: block;
  margin-top: 6px;
  color: var(--blue);
  font-size: 34px;
}

.team-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin-top: 20px;
}

.select-all-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 240px;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.copy-button {
  flex: 0 0 auto;
}

.select-all-row input,
.team-user-row input {
  width: 18px;
  height: 18px;
}

.delete-confirm {
  flex: 1 1 260px;
  gap: 6px;
}

.delete-confirm input {
  height: 56px;
  font-size: 20px;
  font-weight: 900;
}

.team-user-list {
  max-height: 430px;
  overflow: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.team-user-row {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 190px 92px;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  padding: 12px 16px;
  border-bottom: 1px solid #edf1f4;
}

.team-user-row label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.team-user-row strong,
.team-user-row small {
  display: block;
}

.team-user-row strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.team-user-row small,
.team-user-row > span {
  color: var(--muted);
  font-size: 12px;
}

.row-delete-button {
  font-size: 15px;
}

.delete-progress-panel {
  margin-top: 18px;
  padding: 18px;
}

.danger-track > div {
  background: var(--danger);
}

.delete-progress-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
}

.delete-progress-actions a {
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.remaining-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.remaining-box strong {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--blue);
}

.remaining-list {
  min-height: 54px;
  max-height: 150px;
  overflow: auto;
  padding: 12px 14px;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.delete-results {
  max-height: 230px;
  margin-top: 16px;
  border: 1px solid var(--line);
}

.result-panel a {
  color: var(--blue);
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
}

.result-list {
  max-height: 270px;
  overflow: auto;
  background: #ffffff;
}

.result-row,
.empty-row {
  display: grid;
  grid-template-columns: 72px minmax(240px, 1fr) 110px minmax(180px, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid #edf1f4;
  font-size: 16px;
}

.empty-row {
  display: block;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  justify-content: center;
  min-width: 72px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.badge.success {
  background: #e7f7ef;
  color: var(--ok);
}

.badge.failed {
  background: #fff1e0;
  color: var(--warn);
}

.badge.already_imported {
  background: #eaf1ff;
  color: #2563eb;
}

.badge.processed {
  background: #e7f7ef;
  color: var(--ok);
}

@media (max-width: 900px) {
  .app-layout {
    display: block;
  }

  .side-menu {
    position: static;
    height: auto;
    padding: 16px;
  }

  .brand-block {
    margin-bottom: 16px;
  }

  .menu-stack {
    grid-template-columns: 1fr 1fr;
  }

  .assignment-card {
    width: 100%;
    min-height: 100vh;
    padding: 22px;
    border-left: 0;
  }

  .page-head,
  .action-row,
  .head-actions,
  .detail-head,
  .delete-progress-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-form,
  .form-grid,
  .team-metrics,
  .team-workspace,
  .team-actions {
    grid-template-columns: 1fr;
  }

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

  .team-list {
    max-height: 360px;
  }

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

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

  .correction-actions {
    justify-content: stretch;
  }

  .correction-actions button {
    width: 100%;
  }

  .result-row {
    grid-template-columns: 48px 1fr;
  }
}
