* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font:
    16px/1.5 Arial,
    sans-serif;
  color: #303a35;
  background: #f4f1eb;
}

main {
  width: 100%;
  margin: 0;
}

/* hidden screens */
[hidden] {
  display: none !important;
}

section {
  padding: 24px;
  background: white;
  border: 1px solid #d9d5cc;
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(30, 45, 37, 0.08);
}

h1 {
  margin: 0 0 14px;
  font-size: 29px;
  color: #285247;
}

h2 {
  margin: 10px 0;
  font-size: 21px;
  color: #396357;
}

p {
  margin: 8px 0 14px;
}

/* login */
#loginScreen {
  position: relative;
  max-width: 1120px;
  min-height: calc(100vh - 90px);
  margin: 16px auto;
  padding: 60px 54% 60px 55px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(to right, #285247 45%, white 45%);
}

#loginScreen h1 {
  color: white;
  font-size: 38px;
  line-height: 1.2;
  margin-bottom: 22px;
}

#loginScreen h2 {
  color: #e4eee7;
  font-size: 24px;
}

#loginScreen > p {
  color: #e0eae4;
  font-size: 15px;
}

#loginForm {
  position: absolute;
  top: 50%;
  right: 6%;
  width: 42%;
  transform: translateY(-50%);
}

#loginForm button {
  width: 100%;
  margin: 20px 0 0;
}

label {
  display: block;
  margin: 12px 0 5px;
  font-weight: bold;
  color: #285247;
}

input:not([type="radio"]),
select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font:
    16px Arial,
    sans-serif;
  color: #303a35;
  background: white;
  border: 1px solid #929f96;
  border-radius: 6px;
}

button {
  min-height: 46px;
  padding: 10px 18px;
  margin: 8px 8px 8px 0;
  font:
    bold 16px Arial,
    sans-serif;
  color: white;
  background: #356b5a;
  border: 2px solid #356b5a;
  border-radius: 7px;
  cursor: pointer;
}

button:hover {
  background: #285247;
  border-color: #285247;
}

button:disabled {
  background: #737d77;
  border-color: #737d77;
  cursor: not-allowed;
}

#backFromAddBtn,
#backFromViewBtn,
#signOutBtn,
button[name="edit"] {
  background: white;
  color: #285247;
  border-color: #809b89;
}

#backFromAddBtn:hover,
#backFromViewBtn:hover,
#signOutBtn:hover,
button[name="edit"]:hover {
  background: #e6eee7;
}

button[name="delete"] {
  background: #a43d36;
  border-color: #a43d36;
}

button[name="delete"]:hover {
  background: #802c27;
  border-color: #802c27;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
h1:focus,
h2:focus {
  outline: 3px solid #b34d13;
  outline-offset: 3px;
}

/* full pages */
#dashboardScreen,
#addStudentScreen,
#viewStudentsScreen {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 22px 30px;
  background: white;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

#dashboardScreen > h1,
#addStudentScreen > h1 {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #d9d5cc;
}

/* dashboard */
#dashboardScreen > p {
  margin: 6px 0;
  color: #59645d;
}

#dashboardScreen nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  margin: 12px 0;
}

#addStudentBtn,
#viewStudentsBtn {
  width: 100%;
  height: 58px;
  min-height: 58px;
  margin: 0;
  padding: 10px;
  font-size: 17px;
}

#addStudentBtn {
  background: #285247;
  border-color: #285247;
}

#viewStudentsBtn {
  background: #e8ece1;
  border-color: #8aa28c;
  color: #285247;
}

#viewStudentsBtn:hover {
  background: #d5e3d4;
}

#dashboardScreen section {
  margin: 8px 0;
  padding: 8px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

#studentCount {
  display: block;
  font-size: 26px;
  font-weight: bold;
  line-height: 1.2;
  color: #285247;
}

#signOutBtn {
  margin-top: 8px;
}

/* form layout */
#studentForm {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 10px 18px;
  width: 100%;
  max-width: none;
  margin: 12px 0;
  padding: 22px;
  background: #faf9f6;
  border: 1px solid #dfdbd1;
  border-radius: 8px;
}

#studentForm > label {
  margin: 0;
}

#studentForm > input,
#studentForm > select {
  margin: 0;
}

#studentForm > fieldset,
#specializationGroup,
#studentForm > p,
#studentForm > div {
  grid-column: 1 / -1;
}

fieldset {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #a9b3a9;
  border-radius: 7px;
}

legend {
  padding: 0 6px;
  color: #285247;
  font-weight: bold;
}

input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-right: 6px;
  vertical-align: middle;
  accent-color: #356b5a;
}

fieldset label {
  display: inline-block;
  margin: 6px 16px 6px 0;
  font-weight: normal;
}

#specializationGroup {
  margin-top: 10px;
}

#saveStudentBtn {
  grid-column: 2;
  justify-self: start;
  margin: 8px 0 0;
}

#backFromAddBtn {
  margin-top: 6px;
}

/* records */
#viewStudentsScreen {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  column-gap: 14px;
  row-gap: 8px;
  overflow-x: auto;
}

#viewStudentsScreen > h1,
#viewStudentsScreen > h2 {
  grid-column: 1 / -1;
  margin: 0 0 8px;
}

#viewStudentsScreen > label[for="searchStudent"] {
  grid-column: 1;
  grid-row: 2;
}

#viewStudentsScreen > label[for="sortStudents"] {
  grid-column: 2;
  grid-row: 2;
}

#searchStudent {
  grid-column: 1;
  grid-row: 3;
}

#sortStudents {
  grid-column: 2;
  grid-row: 3;
}

#viewStudentsScreen > label {
  margin: 0;
}

#resultsCount,
#loadingMessage,
#noStudentsMessage,
#viewStudentsScreen > table,
#backFromViewBtn {
  grid-column: 1 / -1;
}

#resultsCount {
  margin: 4px 0;
  padding: 8px 12px;
  background: #edf3ec;
  border-radius: 5px;
  color: #285247;
}

#backFromViewBtn {
  justify-self: start;
  margin-top: 10px;
}

/* table */
table {
  width: 100%;
  min-width: 740px;
  margin-top: 6px;
  border-collapse: collapse;
  font-size: 15px;
}

caption {
  padding: 8px 0;
  text-align: left;
  font-weight: bold;
  color: #285247;
}

th,
td {
  padding: 9px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #dddcd5;
}

th {
  background: #285247;
  color: white;
}

tbody tr:nth-child(even) {
  background: #f5f3ee;
}

tbody tr:hover {
  background: #e6eee4;
}

td {
  overflow-wrap: anywhere;
}

td button {
  min-height: 40px;
  padding: 6px 10px;
  margin: 2px;
}

#loginMessage,
#studentMessage,
#loadingMessage,
#noStudentsMessage,
#resultsCount {
  font-weight: bold;
  overflow-wrap: anywhere;
}

/* mobile */
@media (max-width: 800px) {
  #loginScreen {
    position: static;
    display: block;
    min-height: 0;
    margin: 10px;
    padding: 26px;
    background: white;
    border-top: 5px solid #285247;
  }

  #loginScreen h1 {
    color: #285247;
  }

  #loginScreen h2 {
    color: #396357;
  }

  #loginScreen > p {
    color: #59645d;
  }

  #loginForm {
    position: static;
    width: 100%;
    margin-top: 20px;
    transform: none;
  }
}

@media (max-width: 600px) {
  #dashboardScreen,
  #addStudentScreen,
  #viewStudentsScreen {
    padding: 16px;
  }

  #dashboardScreen nav,
  #studentForm,
  #viewStudentsScreen {
    grid-template-columns: 1fr;
  }

  #studentForm {
    padding: 16px;
    gap: 6px;
  }

  #studentForm > label {
    margin-top: 8px;
  }

  #studentForm > fieldset,
  #specializationGroup,
  #studentForm > p,
  #studentForm > div,
  #saveStudentBtn {
    grid-column: 1;
  }

  #viewStudentsScreen > label[for="searchStudent"] {
    grid-column: 1;
    grid-row: 2;
  }

  #searchStudent {
    grid-column: 1;
    grid-row: 3;
  }

  #viewStudentsScreen > label[for="sortStudents"] {
    grid-column: 1;
    grid-row: 4;
  }

  #sortStudents {
    grid-column: 1;
    grid-row: 5;
  }
}
