:root {
  --md-primary: #1a73e8;
  --md-primary-dark: #1558b0;
  --md-accent: #f6a623;
  --md-surface: #ffffff;
  --md-bg: #f5f7fb;
  --md-border: #e0e6ef;
  --md-text: #1f2933;
  --md-muted: #6b7785;
  --md-radius: 10px;
  --md-shadow: 0 6px 18px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", "Helvetica Neue", Arial, sans-serif;
  background: var(--md-bg);
  color: var(--md-text);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

header {
  background: var(--md-surface);
  box-shadow: var(--md-shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-title h1 {
  margin: 0;
  font-size: 1.5rem;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  list-style: none;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: #eef2f7;
  color: var(--md-text);
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  margin-top: 0.5rem;
  min-width: 180px;
  background: var(--md-surface);
  border: 1px solid var(--md-border);
  border-radius: 8px;
  box-shadow: var(--md-shadow);
  padding: 0.75rem;
  display: none;
  z-index: 20;
}

.user-menu[open] .user-menu-panel {
  display: grid;
  gap: 0.5rem;
}

.user-menu-panel a {
  color: var(--md-primary);
  text-decoration: none;
}

.user-menu-name {
  margin: 0 0 0.25rem;
  font-weight: 600;
  color: var(--md-text);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.nav-links a {
  color: var(--md-primary);
  text-decoration: none;
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--md-primary-dark);
}

.card {
  background: var(--md-surface);
  border-radius: var(--md-radius);
  box-shadow: var(--md-shadow);
  padding: 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--md-surface);
  border-radius: var(--md-radius);
  box-shadow: var(--md-shadow);
  padding: 1rem 1.25rem;
}

.kpi-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--md-muted);
  margin: 0 0 0.25rem;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.chart {
  margin-top: 1rem;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
  align-items: end;
  height: 180px;
  padding: 0 0.25rem;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
}

.bar-stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f7;
}

.bar-segment {
  display: block;
  width: 100%;
}

.bar-segment.present {
  background: #1a73e8;
}

.bar-segment.absent {
  background: #d93025;
}

.bar-segment.late {
  background: #f6a623;
}

.bar-label {
  font-size: 0.8rem;
  color: var(--md-muted);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--md-muted);
}

.legend {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0.35rem;
}

.legend.present {
  background: #1a73e8;
}

.legend.absent {
  background: #d93025;
}

.legend.late {
  background: #f6a623;
}

h2 {
  margin-top: 0;
}

p {
  color: var(--md-muted);
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

table {
  width: min(70vw, 100%);
  border-collapse: collapse;
  margin: 1rem auto 0;
  background: var(--md-surface);
  border-radius: var(--md-radius);
  overflow: hidden;
  box-shadow: var(--md-shadow);
}

th,
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--md-border);
  text-align: left;
}

th {
  background: #f0f4ff;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.actions a {
  margin-right: 0.5rem;
  color: var(--md-primary);
  text-decoration: none;
}

.actions a:hover {
  color: var(--md-primary-dark);
}

form {
  display: grid;
  gap: 1rem;
}

form p {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.75rem;
  align-items: center;
  margin: 0;
}

form p label {
  font-weight: 600;
  color: var(--md-text);
}

form input,
form select,
form textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--md-border);
  border-radius: 6px;
  font: inherit;
}

form .errorlist {
  grid-column: 2 / 3;
  margin: 0.25rem 0 0;
  padding: 0;
  color: #b00020;
  list-style: none;
}

@media (max-width: 720px) {
  form p {
    grid-template-columns: 1fr;
  }
}

button,
.button {
  background: var(--md-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--md-primary-dark);
}

.notice {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--md-accent);
  background: #fff7e6;
  border-radius: 6px;
  color: var(--md-text);
}

.note {
  color: var(--md-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0.75rem;
}

.student-picker select {
  height: 260px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--md-surface);
  border-top: 1px solid var(--md-border);
  box-shadow: 0 -6px 18px rgba(31, 41, 51, 0.08);
  padding: 1rem 1.5rem;
  z-index: 30;
}

.site-footer {
  margin-top: 2rem;
  padding: 1.5rem;
  border-top: 1px solid var(--md-border);
  background: var(--md-surface);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--md-muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--md-primary);
  text-decoration: none;
}

.cookie-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

.cookie-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.button-secondary {
  background: #eef2f7;
  color: var(--md-text);
}

.calendar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.calendar-header h2 {
  margin: 0;
}

.calendar-subtitle {
  margin: 0.25rem 0 0;
  color: var(--md-muted);
}

.calendar-nav {
  display: flex;
  gap: 0.5rem;
}

.calendar-toggle {
  display: flex;
  gap: 0.5rem;
}

.calendar-toggle a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--md-muted);
  background: #eef2f7;
}

.calendar-toggle a.active {
  color: #fff;
  background: var(--md-primary);
}

.calendar-grid {
  display: grid;
  gap: 0.75rem;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--md-muted);
  padding: 0 0.5rem;
}

.calendar-weekdays span {
  text-align: center;
}

.calendar-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
}

.calendar-cell {
  background: var(--md-surface);
  border: 1px solid var(--md-border);
  border-radius: 10px;
  padding: 0.75rem;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calendar-cell.today {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.calendar-cell.outside {
  opacity: 0.5;
}

.calendar-date {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--md-text);
}

.calendar-day {
  font-size: 1.1rem;
}

.calendar-month {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--md-muted);
}

.calendar-events {
  display: grid;
  gap: 0.5rem;
}

.calendar-event {
  border: 1px solid var(--md-border);
  border-left: 4px solid var(--md-primary);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: #f7f9fc;
}

.calendar-event.canceled {
  border-left-color: #d93025;
  opacity: 0.75;
}

.event-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.event-actions {
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.event-actions a {
  color: var(--md-primary);
  text-decoration: none;
}

.calendar-empty {
  color: var(--md-muted);
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .calendar-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .calendar-weekdays {
    display: none;
  }
}

@media (max-width: 600px) {
  .calendar-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .header-inner {
    padding: 1rem;
  }

  main {
    padding: 1.5rem 1rem 2.5rem;
  }
}
