:root {
  --primary-color: #3498db;
  --secondary-color: #2ecc71;
  --accent-color: #e74c3c;
  --light-color: #f5f5f5;
  --dark-color: #333;
  --border-color: #ddd;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--dark-color);
  background-color: var(--light-color);
  padding: 10px;
  max-width: 100%;
  margin: 0 auto;
}

h1,
h2,
h3 {
  margin-bottom: 16px;
  color: var(--dark-color);
}

h1 {
  text-align: center;
  margin-top: 10px;
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 10px;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.section {
  background-color: white;
  padding: 15px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  width: 100%;
  overflow: hidden;
}

.row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

input,
select,
button {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 16px;
  min-height: 44px;
}

button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s;
  min-width: 44px;
  font-weight: bold;
}

button:hover {
  background-color: #2980b9;
}

button.secondary {
  background-color: var(--secondary-color);
}

button.secondary:hover {
  background-color: #27ae60;
}

button.danger {
  background-color: var(--accent-color);
}

button.danger:hover {
  background-color: #c0392b;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  font-size: 14px;
  white-space: nowrap;
}

table,
th,
td {
  border: 1px solid var(--border-color);
}

th,
td {
  padding: 10px;
  text-align: center;
}

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

.absense-table-container table thead tr th,
.results-container table thead tr th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #f0f0f0;
}

.absense-table-container table thead tr:first-child th,
.results-container table thead tr:first-child th {
  top: 0;
  z-index: 3;
}

.absense-table-container table thead tr:nth-child(2) th,
.results-container table thead tr:nth-child(2) th {
  top: 30px;
}

.absense-table-container table th:first-child,
.absense-table-container table td:first-child,
.results-container table th:first-child,
.results-container table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: #f0f0f0;
}

.absense-table-container table thead th:first-child,
.results-container table thead th:first-child {
  z-index: 4;
}

.results-container table th:nth-child(1),
.results-container table td:nth-child(1) {
  width: 70px;
}

.results-container table th:nth-child(2),
.results-container table td:nth-child(2) {
  width: 50px;
}

.results-container table th:nth-child(3),
.results-container table th:nth-child(4),
.results-container table th:nth-child(5),
.results-container table td:nth-child(3),
.results-container table td:nth-child(4),
.results-container table td:nth-child(5) {
  width: auto;
}

td.weekend {
  background-color: #f9eaea;
}

.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background-color: #f9f9f9;
  border-radius: 4px;
  margin-bottom: 5px;
}

.checkbox-container {
  position: relative;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.absense-table-container {
  max-height: 600px;
  overflow-y: auto;
  overflow-x: auto;
  margin-top: 10px;
  -webkit-overflow-scrolling: touch;
}

.results-container {
  max-height: 600px;
  overflow-y: auto;
  overflow-x: auto;
  margin-top: 10px;
  -webkit-overflow-scrolling: touch;
}

.member-list {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 10px;
  -webkit-overflow-scrolling: touch;
}

.rank-indicator {
  display: inline-block;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  text-align: center;
  line-height: 25px;
  margin-right: 8px;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.rank-1 {
  background-color: #ff5733;
}
.rank-2 {
  background-color: #ff9933;
}
.rank-3 {
  background-color: #ffcc33;
}
.rank-4 {
  background-color: #33cc33;
}
.rank-5 {
  background-color: #33cccc;
}
.rank-6 {
  background-color: #3366cc;
}
.rank-7 {
  background-color: #9933cc;
}

.tab-container {
  display: flex;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.tab {
  padding: 12px 15px;
  cursor: pointer;
  background-color: #f0f0f0;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  margin-right: 5px;
  margin-bottom: 5px;
  font-size: 14px;
}

.tab.active {
  background-color: white;
  border-bottom: 1px solid white;
  margin-bottom: -1px;
  font-weight: bold;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.loader {
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
  display: none;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.result-member {
  padding: 5px;
  border-radius: 3px;
  margin: 4px 0;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-right: 15px;
  margin-bottom: 5px;
}

#notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 15px;
  background-color: #2ecc71;
  color: white;
  border-radius: 5px;
  display: none;
  z-index: 1000;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  max-width: 90%;
}

.day-label {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  text-align: center;
  white-space: nowrap;
  padding: 5px;
  font-weight: bold;
}

.meal-label {
  text-align: center;
  font-weight: bold;
}

.participation-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.stats-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

@media (max-width: 768px) {
  body {
    padding: 5px;
  }

  .row {
    flex-direction: column;
    margin-bottom: 10px;
  }

  .section {
    padding: 12px;
    margin-bottom: 15px;
  }

  input,
  select,
  button {
    width: 100%;
    margin-bottom: 5px;
    font-size: 16px;
    padding: 12px;
  }

  table {
    font-size: 13px;
  }

  th,
  td {
    padding: 8px 5px;
  }

  .tab {
    padding: 10px;
    font-size: 13px;
    flex-grow: 1;
    text-align: center;
  }

  .member-row {
    padding: 10px;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  .legend {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .tab-container {
    flex-direction: column;
    border-bottom: none;
  }

  .tab {
    margin-right: 0;
    border-radius: 4px;
    margin-bottom: 5px;
    border: 1px solid var(--border-color);
  }

  .tab.active {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 5px;
  }

  h1 {
    font-size: clamp(1.3rem, 5vw, 1.8rem);
  }

  .legend-item {
    margin-right: 5px;
    font-size: 13px;
  }

  .rank-indicator {
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-size: 12px;
  }

  .toggle-all-absense {
    padding: 3px 5px !important;
    font-size: 11px !important;
    min-height: auto !important;
  }
}
