* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, #f8f0e6 0%, #f5ecdf 100%);
  color: #4b2f25;
  line-height: 1.45;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 28px 40px;
}

.page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top right, rgba(214, 156, 115, 0.12), transparent 30%),
    radial-gradient(circle at top left, rgba(143, 90, 68, 0.08), transparent 24%);
}

.site-credit {
  text-align: left;
  color: #9a7a67;
  font-size: 13px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.share-site-button {
  width: auto;
  min-height: 38px;
  padding: 8px 16px;
  background: #c48a5a;
  box-shadow: 0 8px 18px rgba(196, 138, 90, 0.18);
}

.hero {
  margin-bottom: 30px;
  padding: 24px 28px 18px;
  background: linear-gradient(180deg, rgba(255, 250, 244, 0.9), rgba(255, 246, 237, 0.92));
  border: 1px solid #ecd9ca;
  border-radius: 26px;
  box-shadow: 0 18px 36px rgba(124, 84, 58, 0.08);
}

.hero h1 {
  text-align: center;
  font-size: 46px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: #512f24;
}

.eyebrow {
  margin: 0 0 8px;
  color: #b06f4f;
  font-size: 14px;
}

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

.subtitle {
  max-width: none;
  color: #7a5a4c;
  font-size: 15px;
  text-align: center;
  margin: 0 auto;
}

.panel {
  background: #fffaf4;
  border: 1px solid #eedbcc;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(124, 84, 58, 0.08);
}

.class-selector-panel {
  display: flex;
  flex-direction: column;
  width: 326px;
  min-height: 120px;
  justify-content: center;
}

.class-select {
  width: 100%;
  min-height: 48px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.top-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 14px;
  background: rgba(255, 250, 244, 0.72);
  border: 1px solid #ecd8c8;
  border-radius: 24px;
  backdrop-filter: blur(6px);
}

.tabs-panel {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex: 0 0 auto;
}

.teacher-top-controls {
  display: grid;
  grid-template-columns: 154px 154px;
  gap: 18px;
  align-items: flex-start;
  flex: 0 0 auto;
  order: 3;
}

.top-controls > .class-selector-panel {
  order: 2;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 154px;
  min-height: 120px;
}

.tabs .tab-button {
  flex: 1;
}

.tab-button,
.secondary-button {
  width: 100%;
}

.tab-button {
  background: #f1dccb;
  color: #6b4333;
  min-height: 36px;
  font-size: 14px;
  border-radius: 16px;
  border: 1px solid rgba(160, 106, 78, 0.14);
  font-weight: 700;
}

.tab-button.is-active {
  background: #c9734f;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(201, 115, 79, 0.24);
}

.view-panel {
  margin-top: 20px;
}

.is-hidden {
  display: none;
}

.teacher-only-controls.is-hidden {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  margin-top: 20px;
  align-items: start;
}

.table-panel {
  margin-top: 20px;
}

.table-panel .table-container {
  max-height: 70vh;
}

.teacher-student-count-panel {
  width: 100%;
  min-width: 0;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.teacher-gender-panel {
  width: 100%;
  min-width: 0;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.teacher-gender-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.class-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.teacher-gender-tab {
  min-height: 48px;
  border-radius: 16px;
  background: #f1dccb;
  color: #6b4333;
  border: 1px solid rgba(160, 106, 78, 0.14);
  font-size: 14px;
  font-weight: 700;
}

.teacher-gender-tab.is-active {
  background: #c9734f;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(201, 115, 79, 0.24);
}

.class-tab {
  min-height: 40px;
  border-radius: 16px;
  background: #f1dccb;
  color: #6b4333;
  border: 1px solid rgba(160, 106, 78, 0.14);
  font-size: 14px;
  font-weight: 700;
}

.class-tab.is-active {
  background: #c9734f;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(201, 115, 79, 0.24);
}

.teacher-student-count-panel select,
.teacher-panel-button {
  width: 100%;
  min-height: 40px;
}

.teacher-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid #efdfd1;
}

.teacher-panel-header h2 {
  margin-bottom: 0;
}

.teacher-panel-button {
  width: auto;
  min-width: 180px;
}

.teacher-results-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.whatsapp-button {
  background: #c48a5a;
}

.teacher-layout {
  display: flex;
  flex-direction: row;
  gap: 24px;
  margin-top: 20px;
  align-items: flex-start;
}

.teacher-entry-panel {
  flex: 1.4;
  min-width: 0;
  background: linear-gradient(180deg, #fffaf4, #fff6ee);
}

.teacher-results-panel {
  flex: 1;
  min-width: 0;
  background: linear-gradient(180deg, #fffaf4, #fff7f1);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  min-height: 22px;
  color: #5a372c;
  font-size: 15px;
  text-align: center;
}

select,
input,
button {
  width: 100%;
  border: 1px solid #ddc3ae;
  border-radius: 14px;
  padding: 10px 14px;
  font: inherit;
  background: #fffdf9;
  color: #4b2f25;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

select {
  font-size: 14px;
  text-align: center;
  text-align-last: center;
}

select:focus,
input:focus {
  outline: none;
  border-color: #c9734f;
  box-shadow: 0 0 0 4px rgba(201, 115, 79, 0.14);
}

button {
  background: #c9734f;
  color: #ffffff;
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.03);
}

.secondary-button {
  background: #8f5a44;
}

.sheet-summary {
  margin-top: 12px;
  color: #8f6a58;
  font-size: 13px;
}

.form-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-content: start;
}

.metric-card {
  border: 1px solid #ecd9ca;
  border-radius: 18px;
  padding: 14px;
  background: #fff7f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.form-panel input {
  max-width: 140px;
  min-height: 44px;
  display: block;
  margin: 0 auto;
}

.form-panel button {
  grid-column: auto;
  width: 100%;
}

.metric-meta {
  margin: 10px 0 0;
  color: #8a6a5b;
  font-size: 13px;
  text-align: center;
}

.results-list {
  display: grid;
  gap: 14px;
}

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

.table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: max-content;
  background: #fffdfa;
  border-radius: 16px;
  overflow: hidden;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #ecd9ca;
  text-align: center;
}

th {
  background: #f5e5d8;
  position: sticky;
  top: 0;
  z-index: 1;
  color: #694536;
}

tbody tr:nth-child(5n + 1) {
  background: #f9ecdf;
}

.teacher-entry-panel tbody tr:nth-child(5n),
.teacher-results-panel tbody tr:nth-child(5n) {
  background: #f9ecdf;
}

.teacher-entry-panel tbody tr:nth-child(5n + 1),
.teacher-results-panel tbody tr:nth-child(5n + 1) {
  background: transparent;
}

.score-55-row {
  background: #dbeafe !important;
}

.teacher-entry-table input {
  min-width: 56px;
  width: 56px;
  padding: 6px 4px;
  border-radius: 8px;
}

.teacher-entry-panel th,
.teacher-entry-panel td,
.teacher-results-panel th,
.teacher-results-panel td {
  padding: 8px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.teacher-entry-panel th,
.teacher-results-panel th {
  border-bottom: 1px solid #e6d0bf;
}

.teacher-entry-panel th,
.teacher-results-panel th {
  min-width: 42px;
}

.student-name-cell,
.average-cell {
  min-width: 68px;
}

.teacher-entry-panel .table-container,
.teacher-results-panel .table-container {
  max-height: 70vh;
}

.student-name-cell,
.average-cell {
  font-weight: 700;
  background: #fff3e8;
}

.result-item {
  border: 1px solid #ecd9ca;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fffdfa;
  box-shadow: 0 8px 18px rgba(124, 84, 58, 0.05);
}

.result-item strong {
  display: block;
  margin-bottom: 4px;
}

.average-score {
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 18px;
  background: #8f5a44;
  color: #ffffff;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

@media (max-width: 800px) {
  .page {
    padding: 16px;
  }

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

  .top-controls,
  .tabs-panel {
    flex-direction: column;
  }

  .class-selector-panel {
    width: 100%;
  }

  .class-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .top-bar {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .hero {
    padding: 20px 18px 16px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .teacher-top-controls {
    display: flex;
    flex-direction: column;
  }

  .form-panel {
    grid-template-columns: 1fr;
  }

  .teacher-student-count-panel {
    min-width: 0;
  }

  .teacher-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .teacher-results-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .teacher-layout {
    flex-direction: column;
  }

  .results-panel {
    position: static;
  }
}
