/* ==========================================================
   OPENOTE - Arviointijärjestelmä
   Raikas merenvihreä teema
   ========================================================== */

/* ========= VÄRIMÄÄRITYKSET ========= */
:root {
  /* Päävärit - laivastonsininen */
  --primary: #1e3a5f;
  --primary-light: #2d4a6f;
  --primary-dark: #152a4a;
  --primary-soft: #e8eef5;

  /* Aksentti */
  --accent: #3b82f6;
  --accent-light: #60a5fa;

  /* Taustat */
  --bg: #f1f5f9;
  --bg-alt: #f8fafc;
  --card: #ffffff;

  /* Teksti */
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Reunat */
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Arvosanavärit - kirkkaammat mutta harmoniset */
  --grade-10: #22a86a;
  --grade-10-bg: #dcf5e8;
  --grade-85: #4db87a;
  --grade-85-bg: #e4f7ed;
  --grade-7: #d4a93b;
  --grade-7-bg: #faf3dc;
  --grade-55: #e8944e;
  --grade-55-bg: #fdeee0;
  --grade-4: #dc5656;
  --grade-4-bg: #fae6e6;

  /* Tila */
  --success: #22a86a;
  --warning: #d4a93b;
  --danger: #dc5656;

  /* Sarakevärit */
  --exam-bg: #e0f2fe;
  --exam-cell: #f0f9ff;
  --exam-btn: #3b82f6;
  --exam-btn-hover: #2563eb;
  --show-bg: #fae8ff;
  --show-cell: #fdf4ff;
  --show-btn: #a855f7;
  --show-btn-hover: #9333ea;
  --work-bg: #f0fdfa;
  --work-cell: #f5fffd;

  /* Vakioleveydet */
  --colw: 72px;
  --namew: 200px;
  --kaw: 100px;

  /* Harmaat */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;

  /* Apuvärit */
  --muted: #64748b;
  --danger-dark: #b91c1c;
  --bg-hover: #f1f5f9;

  /* Varjot */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);

  /* z-index kerrokset */
  --z-topbar: 100;
  --z-dropdown: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-confirm: 500;
}

/* ========= PERUSRAKENNE ========= */
*, *::before, *::after {
  box-sizing: border-box;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  font: 15px/1.5 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ========= TOPBAR / HEADER ========= */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  height: 32px;
  width: auto;
}

.brand-logo-text {
  height: 40px;
  width: auto;
}

.brand-text {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Mobiilinavigaatio - piilotettu desktopilla */
.mobile-nav {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-muted);
  transition: all 0.2s ease;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-link svg {
  width: 22px;
  height: 22px;
}

.nav-link:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Hälytys-badge */
.nav-alert {
  position: relative;
}

.alert-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--bg);
  animation: alert-pulse 2s ease-in-out infinite;
}

@keyframes alert-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

/* Ilmoitustaulu-badge - vaaleansininen */
.ilmoitus-badge {
  background: #60a5fa;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.user-name {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-link.logout:hover {
  background: var(--grade-4-bg);
  color: var(--danger);
}

/* ========= CONTAINER ========= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.flex1 { flex: 1; }

/* ========= TYPOGRAPHY ========= */
h1, h2, h3, h4 {
  color: var(--text);
  margin: 0 0 1rem;
  font-weight: 600;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--primary-dark); }

.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }

/* ========= CARD ========= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.pad { padding: 1.25rem; }

/* ========= BUTTONS ========= */
.btn, .tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover, .tab:hover {
  background: var(--bg-alt);
  border-color: var(--text-light);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  box-shadow: 0 2px 4px rgba(30, 58, 95, 0.3);
}

.btn.primary:hover {
  box-shadow: 0 4px 8px rgba(30, 58, 95, 0.4);
  transform: translateY(-1px);
}

.btn.secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--card);
  border-color: var(--primary);
  color: var(--primary);
}

.btn.accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn.danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn.warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}

.btn.exam {
  background: var(--exam-btn);
  color: white;
  border-color: var(--exam-btn);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn.exam:hover {
  background: var(--exam-btn-hover);
  border-color: var(--exam-btn-hover);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
}

.btn.show {
  background: var(--show-btn);
  color: white;
  border-color: var(--show-btn);
  box-shadow: 0 2px 4px rgba(168, 85, 247, 0.3);
}

.btn.show:hover {
  background: var(--show-btn-hover);
  border-color: var(--show-btn-hover);
  box-shadow: 0 4px 8px rgba(168, 85, 247, 0.4);
}

/* Arviointinapit - yhtä leveät */
.assessment-buttons {
  display: flex;
  gap: 0.5rem;
}

.assessment-buttons .btn {
  flex: 1 1 0;
  min-width: 6.5rem;
  padding: 0.5rem 1.5rem;
  font-size: 0.95rem;
  text-align: center;
  white-space: nowrap;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.iconbtn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Tabs */
.tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ========= JAKSO-PUDOTUSVALIKKO ========= */
.jakso-dropdown {
  position: relative;
  display: inline-block;
}

/* Tilan lisäys nappirivin alle */
.row.gap:has(.jakso-dropdown) {
  margin-bottom: 1rem;
}

.jakso-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 180px;
  justify-content: space-between;
}

.jakso-dropdown-btn:hover {
  background: var(--primary-light);
}

.jakso-dropdown.open .jakso-dropdown-btn {
  background: var(--primary-light);
  border-radius: 8px 8px 0 0;
}

.jakso-dropdown-arrow {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.jakso-dropdown.open .jakso-dropdown-arrow {
  transform: rotate(180deg);
}

.jakso-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: var(--z-dropdown);
  display: none;
  overflow: hidden;
}

.jakso-dropdown.open .jakso-dropdown-menu {
  display: block;
  animation: dropdownSlide 0.15s ease-out;
}

@keyframes dropdownSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.jakso-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease;
}

.jakso-dropdown-item:last-child {
  border-bottom: none;
}

.jakso-dropdown-item:hover {
  background: var(--bg);
}

.jakso-dropdown-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.jakso-dropdown-check {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.jakso-dropdown-check svg {
  width: 14px;
  height: 14px;
  stroke: var(--primary);
}

.jakso-dropdown-item.active .jakso-dropdown-check {
  opacity: 1;
}

/* Link-style buttons */
.linklike {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.linklike:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.tiny-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-muted);
}
.tiny-btn.danger { color: var(--danger); }
.tiny-btn:hover { opacity: 0.7; }

/* ========= MESSAGES ========= */
.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.messages li {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.messages .success {
  background: var(--grade-10-bg);
  color: var(--grade-10);
  border: 1px solid var(--grade-10);
}

.messages .error {
  background: var(--grade-4-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ========= FORMS ========= */
input, select, textarea {
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
}

/* Taulukon alla olevat toiminnot */
.table-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* Asetukset-modaalin osiot */
.settings-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--primary);
  display: flex;
  align-items: center;
}

.settings-section h4 svg {
  color: var(--primary);
  opacity: 0.8;
}

/* Jako-lista (jaetut oikeudet) */
.jako-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-alt);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  transition: background 0.15s;
}

.jako-row:hover {
  background: var(--primary-soft);
}

.jako-row span {
  flex: 1;
  font-size: 0.9rem;
}

.jako-row select {
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
}

/* Jako lisäys rivi */
.jako-add-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px dashed var(--border);
  align-items: center;
}

.jako-add-row select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.9rem;
}

.jako-add-row select:first-child {
  flex: 1;
}

.jako-add-row .btn,
.siirto-row .btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Omistajuuden siirto -osio */
.settings-section .muted.small {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.siirto-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px dashed var(--border);
  align-items: center;
  flex-wrap: wrap;
}

.siirto-row select {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.9rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ========= GRADE TABLE - 3 Column Layout ========= */
.grade-table-container {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Left column - Student names (fixed) */
.grade-col-left {
  flex: 0 0 var(--namew);
  min-width: var(--namew);
  max-width: var(--namew);
  background: var(--card);
  border-right: 1px solid rgba(226, 232, 240, 0.6);
  z-index: 10;
}

/* Middle column - Grades (scrollable) */
.grade-col-middle {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.grade-col-middle::-webkit-scrollbar {
  height: 10px;
}

.grade-col-middle::-webkit-scrollbar-track {
  background: var(--border-light);
}

.grade-col-middle::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 5px;
}

.grade-col-middle::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.grade-scroll {
  display: inline-flex;
  flex-direction: column;
  min-width: 100%;
  padding-bottom: 12px; /* Firefox scrollbar overlap fix */
}

/* Right column - Average (fixed) */
.grade-col-right {
  flex: 0 0 var(--kaw);
  min-width: var(--kaw);
  max-width: var(--kaw);
  background: var(--card);
  border-left: 1px solid rgba(226, 232, 240, 0.6);
  z-index: 10;
}

/* Headers */
.grade-header {
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  background: var(--bg-alt);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  padding: 0 0.75rem;
}

.grade-col-left .grade-header {
  justify-content: flex-start;
}

/* Header row in middle */
.grade-header-row {
  display: flex;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  background: var(--bg-alt);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.grade-header-cell {
  flex: 0 0 var(--colw);
  min-width: var(--colw);
  max-width: var(--colw);
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  overflow: hidden;
}

.grade-header-cell.empty-col {
  flex: 1;
  max-width: none;
  color: var(--text-light);
  font-style: italic;
  text-transform: none;
}

/* Grade rows */
.grade-row {
  display: flex;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
}

.grade-row:not(:last-child) {
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

/* Grade cells */
.grade-cell {
  flex: 0 0 var(--colw);
  min-width: var(--colw);
  max-width: var(--colw);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.25rem;
}

.grade-cell.empty-cell {
  flex: 1;
  max-width: none;
  color: var(--text-light);
}

/* Name cells in left column */
.grade-col-left .grade-cell {
  flex: none;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: none;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  justify-content: flex-start;
  padding: 0 0.75rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.grade-col-left .grade-cell:last-child {
  border-bottom: none;
}

.grade-name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.grade-name .table-flex-ball {
  flex-shrink: 0;
  width: 10px !important;
  height: 10px !important;
  margin-right: 0 !important;
}

.grade-name .linklike {
  text-align: left;
  white-space: normal;
  line-height: 1.3;
}

/* KA cells in right column */
.grade-col-right .grade-cell {
  flex: none;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: none;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  justify-content: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.grade-col-right .grade-cell:last-child {
  border-bottom: none;
}

.grade-ka {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}


/* Row hover - synkronoitu kaikille sarakkeille */
.row-highlight,
.row-highlight .grade-cell,
.row-highlight .grade-cell.show-grade-cell,
.row-highlight .grade-cell.show-passfail-cell,
.row-highlight .grade-cell.exam-cell,
.row-highlight .grade-cell.show-cell,
.row-highlight .grade-cell.work-cell,
.grade-col-left .row-highlight,
.grade-col-right .row-highlight {
  background: var(--primary-soft) !important;
}

/* Cell type backgrounds */
.exam-col { background: var(--exam-bg) !important; }
.exam-cell { background: var(--exam-cell); }
.show-col { background: var(--show-bg) !important; }
.show-cell { background: var(--show-cell); }
.work-col { background: var(--work-bg) !important; }
.work-cell { background: var(--work-cell); }

/* Header date buttons */
.hdr-date {
  font-size: 0.75rem;
  line-height: 1.3;
  text-align: center;
}

/* Active row */
.grade-row.active-row {
  outline: 2px solid var(--primary);
}

.grade-row.active-row .grade-cell {
  background: var(--primary-soft) !important;
}


/* ========= DOTS (Grade indicators) ========= */
.dot {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  font-weight: 600;
  font-size: 0.75rem;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Hover vain laitteilla joissa on hiiri */
@media (hover: hover) {
  .dot:hover {
    transform: scale(1.12);
    box-shadow: var(--shadow);
  }
}

.dot-empty {
  display: inline-flex !important;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: transparent;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  cursor: pointer;
}

@media (hover: hover) {
  .dot-empty:hover {
    border-color: var(--primary);
    opacity: 1;
  }
}

.dot.sel {
  transform: scale(1.15) !important;
  outline: 3px solid var(--primary) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 2px white, 0 0 0 5px var(--primary) !important;
  transition: none !important;
}

.dot:focus {
  outline: none;
}

/* Grade colors */
.dot.dot-4, .dot[data-value="4"], .dot[data-value="4.0"] {
  background: var(--grade-4) !important;
}

.dot.dot-55, .dot[data-value="5.5"] {
  background: var(--grade-55) !important;
}

.dot.dot-7, .dot[data-value="7"], .dot[data-value="7.0"] {
  background: var(--grade-7) !important;
  color: #1e293b;
}

.dot.dot-85, .dot[data-value="8.5"] {
  background: var(--grade-85) !important;
}

.dot.dot-10, .dot[data-value="10"], .dot[data-value="10.0"] {
  background: var(--grade-10) !important;
}

/* Pass/Fail ring buttons */
.dot.dot-pass {
  background: transparent !important;
  border: 3px solid #10b981 !important;
  color: #10b981 !important;
  font-size: 1.1rem;
  font-weight: bold;
  transition: all 0.2s ease;
}
.dot.dot-pass:hover {
  background: rgba(16, 185, 129, 0.1) !important;
  transform: scale(1.05);
}
.dot.dot-pass.active {
  background: #10b981 !important;
  border-color: transparent !important;
  color: white !important;
}

.dot.dot-fail {
  background: transparent !important;
  border: 3px solid #ef4444 !important;
  color: #ef4444 !important;
  font-size: 1.1rem;
  font-weight: bold;
  transition: all 0.2s ease;
}
.dot.dot-fail:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  transform: scale(1.05);
}
.dot.dot-fail.active {
  background: #ef4444 !important;
  border-color: transparent !important;
  color: white !important;
}

/* Excluded from average - gray inside */
.dot.excluded,
.exam-ball.excluded,
.show-ball.excluded,
.show-grade-badge.excluded,
.show-pallo-badge.excluded,
.show-passfail-badge.excluded {
  opacity: 0.4;
}

/* Exam number buttons (4-10) */
.dot.dot-num {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--card) !important;
  color: var(--text) !important;
  border: 2px solid var(--border);
  box-shadow: none;
}

@media (hover: hover) {
  .dot.dot-num:hover {
    border-color: var(--primary);
    background: var(--primary-soft) !important;
  }
}

.dot.dot-num.sel {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary);
  transition: none !important;
}

/* Exam extra buttons (-, +, ½) */
.dot.dot-extra {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  font-weight: 700;
  background: var(--card) !important;
  color: var(--text-muted) !important;
  border: 2px solid var(--border);
  box-shadow: none;
}

@media (hover: hover) {
  .dot.dot-extra:hover {
    border-color: var(--accent);
    background: var(--exam-cell) !important;
  }
}

.dot.dot-extra.sel {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent);
  transition: none !important;
}

/* Show (demonstration) number buttons - purple variant */
@media (hover: hover) {
  .dot.show-num:hover {
    border-color: var(--show-btn);
    background: var(--show-bg) !important;
  }
}

.dot.show-num.sel {
  background: var(--show-btn) !important;
  color: white !important;
  border-color: var(--show-btn);
  transition: none !important;
}

/* Show result cell in popup */
.show-result {
  font-weight: 700;
  color: var(--show-btn);
  min-width: 50px;
  text-align: center;
}

/* Taulukon numeronäyttö-solut (sama tausta kuin muut näyttösolut) */
.grade-cell.show-grade-cell,
.grade-cell.show-passfail-cell {
  background: var(--show-cell) !important;
}

.grade-cell.show-grade-cell .cell-grade {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--show-btn);
}

/* Exam ball - sama koko kuin muut pallot (32px) */
.exam-ball {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.exam-ball:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
}

/* Show ball - numeronäytön arvosana (lila) */
.show-ball {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
  background: linear-gradient(135deg, var(--show-btn) 0%, #a855f7 100%);
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.show-ball:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.exam-add {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.exam-add:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.05);
}

/* ========= MODALS ========= */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  animation: fadeIn 0.2s ease-out;
  padding: 1rem;
}

.modal[hidden] { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  max-width: 800px;
  width: 95%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

/* Scrollbar tyylitys */
.modal-content::-webkit-scrollbar {
  width: 8px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
  margin: 16px 0;
}
.modal-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.modal-content.wide {
  width: 900px;
  max-width: 95vw;
  height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

.modal-content.wide > h3 {
  flex-shrink: 0;
}

.modal-content.wide > .form-row,
.modal-content.wide > .flex-tabs,
.modal-content.wide > .student-card-tabs,
.modal-content.wide > .tabs {
  flex-shrink: 0;
}

.modal-content.wide > table,
.modal-content.wide > .popup-table,
.modal-content.wide > .flex-tab-content,
.modal-content.wide > .student-tab-content,
.modal-content.wide > .tab-content,
.modal-content.wide > #poytakirja-cards-container,
.modal-content.wide > #poytakirja-form {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.modal-content.wide > .actions {
  flex-shrink: 0;
  padding-top: 1rem;
}

/* Näyttö- ja koemodaalit: koko sisältö scrollaa */
#show-modal .modal-content,
#edit-show-modal .modal-content,
#exam-modal .modal-content,
#exam-edit-modal .modal-content {
  display: block;
  height: auto;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal h3 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--primary);
}

.modal .actions,
.modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Modal form groups */
.modal .form-group {
  margin-bottom: 1rem;
}

.modal .form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  color: var(--text);
}

/* Override for toggle and color picker labels */
.modal .form-group label.julkinen-toggle {
  display: inline-flex;
  margin-bottom: 0;
}

.modal .form-group .vari-picker label.vari-option {
  display: inline-flex;
  margin-bottom: 0;
}

.modal .form-group input[type="text"],
.modal .form-group input[type="date"],
.modal .form-group textarea {
  width: 100%;
  box-sizing: border-box;
}

.modal .form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.modal .actions.space-between {
  justify-content: space-between;
  align-items: center;
}

.modal .actions-btns {
  display: flex;
  gap: 0.75rem;
}

/* Toggle: Ei lasketa keskiarvoon */
.toggle-exclude {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.toggle-exclude input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-exclude input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}

.toggle-exclude input[type="checkbox"]:checked {
  background: var(--primary);
}

.toggle-exclude input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.toggle-exclude-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toggle-exclude input[type="checkbox"]:checked + .toggle-exclude-label {
  color: var(--primary);
  font-weight: 500;
}

html.modal-open, body.modal-open { overflow: hidden; }

/* Popup table */
.popup-table.modern {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.popup-table.modern th,
.popup-table.modern td {
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.popup-table.modern th:not(:first-child),
.popup-table.modern td:not(:first-child) {
  text-align: center;
}

.popup-table.modern td.oppilas-nimi {
  font-weight: 500;
  white-space: nowrap;
}

.popup-table.modern tr {
  border-bottom: 1px solid var(--border);
}

.popup-table.modern tr:last-child {
  border-bottom: none;
}

.popup-table.modern tr:hover {
  background: var(--bg-alt);
}

.popup-table.modern tr.active-row {
  background: var(--primary-soft);
}

.popup-table.modern tr.active-row:hover {
  background: var(--primary-soft);
}

/* Poista focus-kehys tr-riveiltä (black border fix) */
.popup-table.modern tr[tabindex]:focus {
  outline: none;
}

/* Manage jaksot */
#manage-jaksot-table {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  overflow: hidden;
}

#manage-jaksot-table tr {
  background: var(--card);
  transition: background 0.15s;
}

#manage-jaksot-table tr:hover {
  background: var(--primary-soft);
}

#manage-jaksot-table td {
  padding: 0.5rem;
  vertical-align: middle;
}

#manage-jaksot-table input.jakso-nimi {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#manage-jaksot-table input.jakso-nimi:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

#manage-jaksot-table td.center { text-align: center; }
#manage-jaksot-table .handle {
  cursor: grab;
  user-select: none;
  opacity: 0.4;
  transition: opacity 0.15s;
}

#manage-jaksot-table tr:hover .handle {
  opacity: 0.7;
  font-size: 1.1rem;
  color: var(--text-muted);
}
#manage-jaksot-table tr.dragging {
  opacity: 0.6;
  background: var(--primary-soft);
}

/* ========= KA CARD (bar meter) ========= */
.ka-card {
  margin: 0 0 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ka-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.ka-label strong {
  color: var(--primary);
}

/* Bar meter */
.bar-meter {
  padding: 50px 0.5rem 0;
}

.bar-track {
  position: relative;
  height: 12px;
  background: linear-gradient(to right,
    var(--grade-4) 0%,
    var(--grade-55) 25%,
    var(--grade-7) 50%,
    var(--grade-85) 75%,
    var(--grade-10) 100%
  );
  border-radius: 6px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bar-fill {
  display: none;
}

.bar-marker {
  position: absolute;
  bottom: 100%;
  margin-bottom: 4px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bar-marker::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--primary);
}

.bar-marker-value {
  background: var(--primary);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 2px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(30, 58, 95, 0.3);
}

.bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding: 0 2px;
  font-size: 0.7rem;
  color: var(--text-light);
}

.ka-jakso {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.5rem;
}

.ka-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.ka-badges .badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  font-size: 0.75rem;
  min-width: 75px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ka-badges .badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

.ka-badges .badge span {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ka-badges .badge strong {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

/* ========= SIMPLE TABLE (for lists) ========= */
.table, .modern-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}

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

.table th, .modern-table th {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  background: var(--bg-alt);
}

.table tbody tr:hover,
.modern-table tbody tr:hover {
  background: var(--primary-soft);
}

.table tbody tr:last-child td,
.modern-table tbody tr:last-child td {
  border-bottom: none;
}

/* ========= DATA TABLE (oppilasrekisteri) ========= */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
}

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

.data-table th {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
}

.data-table th:last-child {
  border-right: none;
}

.data-table td {
  border-right: 1px solid var(--border-light);
}

.data-table td:last-child {
  border-right: none;
}

.data-table tbody tr:hover {
  background: var(--primary-soft);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.inline {
  display: inline;
}

/* ========= UTILITY CLASSES ========= */
.row { display: flex; align-items: center; }
.gap { gap: 0.75rem; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }
.topspace { margin-top: 1rem; }
.right { text-align: right; }

/* Taidot-sivun lisää taito -input leveämmäksi */
.row.gap.topspace input[type="text"],
.row.gap.topspace input[name="nimi"] {
  min-width: 300px;
  flex: 1;
  max-width: 500px;
}
.center { text-align: center; }

/* Form row - kaksi kenttää vierekkäin */
.form-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.form-row input,
.form-row select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}
.form-row input:disabled {
  background: var(--bg-alt);
  color: var(--text-muted);
}
.form-row .form-group {
  flex: 1;
  min-width: 140px;
}

/* Skill display - taidon näyttö muokkausmodaalissa */
.skill-display {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
}

/* ========= PAGE HEADER ========= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  margin: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ========= GROUP CARDS ========= */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.875rem;
}

.group-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border-radius: 12px;
  padding: 1rem 1.125rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.06);
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.group-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #1e3a5f 0%, #3b82f6 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.group-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 58, 95, 0.12);
  border-color: #bfdbfe;
}

.group-card:hover::before {
  opacity: 1;
}

.group-card-header {
  margin-bottom: 0.5rem;
}

.group-name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: #1e3a5f;
}

.group-subject {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.15rem 0.5rem;
  background: #eff6ff;
  color: #3b82f6;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.jako-badge {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}

.jako-badge.jako-arviointi {
  background: #eff6ff;
  color: #3b82f6;
}

.jako-badge.jako-katselu {
  background: #faf5ff;
  color: #8b5cf6;
}

.jako-badge.shared {
  background: #8b5cf6;
  color: white;
  font-weight: 600;
}

.jako-badge.valmistunut {
  background: #22c55e;
  color: white;
  font-weight: 600;
}

/* Jaettu ryhmä (lila teema) */
.group-card.shared {
  background: #fefcff;
  border: 1px solid #e9d5ff;
}

.group-card.shared:hover {
  border-color: #d8b4fe;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

.group-card.shared .group-name {
  color: #7c3aed;
}

.group-card-stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eef2ff;
}

.group-card-stats .stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #6b7280;
}

.group-card-stats .stat svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
}

.group-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.group-card-footer .btn-icon {
  position: relative;
  z-index: 10;
}

.group-action {
  font-size: 0.8rem;
  font-weight: 600;
  color: #3b82f6;
}

.group-card:hover .group-action {
  color: #1e3a5f;
}

/* Arkistoidut ryhmät */
.group-card.archived {
  opacity: 0.7;
  border-style: dashed;
}
.group-card.archived .group-card-footer {
  justify-content: flex-end;
  gap: 0.5rem;
}

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

.delete-form {
  display: inline;
}

/* ========= EMPTY STATE ========= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  max-width: 300px;
}

/* ========= LOGIN PAGE ========= */

/* Läpinäkyvä tähtitarra (transparent starburst) */
.promo-sticker {
  display: none; /* Piilotettu toistaiseksi */
  position: absolute;
  top: 10px;
  right: -65px;
  width: 145px;
  height: 145px;
  text-decoration: none;
  z-index: 10;
  transition: transform 0.3s ease;
}

.sticker-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.circle-outline {
  fill: none;
  stroke: #667eea;
  stroke-width: 2;
  transition: stroke 0.3s ease;
}

.promo-sticker:hover .circle-outline {
  stroke: #764ba2;
}

.sticker-text {
  font-family: 'Futura', 'Century Gothic', 'Arial', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  fill: #667eea;
  transition: fill 0.3s ease;
}

.promo-sticker:hover .sticker-text {
  fill: #764ba2;
}

.sticker-arrow {
  stroke: #667eea;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease;
}

.promo-sticker:hover .sticker-arrow {
  stroke: #764ba2;
}

@keyframes sticker-wobble {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

.promo-sticker {
  animation: sticker-wobble 5s ease-in-out infinite;
}

.promo-sticker:hover {
  animation-play-state: paused;
  transform: rotate(0deg) scale(1.1);
}

/* Mobiili: piilota tarra */
@media (max-width: 500px) {
  .promo-sticker {
    display: none;
  }
}

/* Esittelysivu-pallotarra kirjautumissivulla */
.esittely-badge {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: var(--z-topbar);
  transition: all 0.2s ease;
}

.esittely-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
  background: #fff;
}

.esittely-badge svg {
  transition: transform 0.2s;
}

.esittely-badge:hover svg {
  transform: translateX(3px);
}

@media (max-width: 480px) {
  .esittely-badge {
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
  }
}

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Decorative floating shapes */
.login-container::before,
.login-container::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  animation: float 20s ease-in-out infinite;
}

.login-container::before {
  width: 400px;
  height: 400px;
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.login-container::after {
  width: 300px;
  height: 300px;
  bottom: -80px;
  right: -80px;
  animation-delay: -7s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(30px, 30px) rotate(5deg); }
  50% { transform: translate(0, 50px) rotate(0deg); }
  75% { transform: translate(-30px, 30px) rotate(-5deg); }
}

.login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  z-index: 1;
  animation: cardAppear 0.6s ease-out;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand {
  height: 56px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.login-tagline {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.login-greeting {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: #dc2626;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 240px;
  margin: 0 auto;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b7280;
}

.login-field label svg {
  width: 15px;
  height: 15px;
  color: #9ca3af;
}

.login-field input {
  padding: 0.65rem 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background: #fafafa;
}

.login-field input:hover {
  border-color: #d1d5db;
  background: #fff;
}

.login-field input:focus {
  outline: none;
  border-color: #667eea;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.login-field input::placeholder {
  color: #b0b7c3;
  font-size: 0.9rem;
}

.login-btn {
  margin-top: 0.5rem;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 12px rgba(102, 126, 234, 0.35);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(102, 126, 234, 0.45);
}

.login-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.forgot-password {
  text-align: center;
  margin-top: 1rem;
}

.forgot-password a {
  color: #667eea;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.forgot-password a:hover {
  color: #764ba2;
}

.login-footer {
  margin-top: 1.25rem;
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.login-footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ========= RESPONSIVE ========= */
/* Mobiili: Takaisin-nappi (piilotettu desktopilla) */
.mobile-back-btn {
  display: none;
}

/* Tallennettu-ilmoitus */
.save-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 2rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 1.7s forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(1rem); }
}

@media (max-width: 768px) {
  /* Estä sivuscrollaus */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* === YLÄPALKKI === */
  .topbar {
    padding: 0.5rem 0.75rem;
  }

  .brand-text {
    display: none;
  }

  /* Piilota KAIKKI navigointilinkit mobiilissa */
  .nav-links {
    display: none;
  }

  /* Näytä mobiilinavigaatio */
  .mobile-nav {
    display: flex;
  }

  /* Käyttäjänimi piiloon mobiilissa (tilansäästö) */
  .user-name {
    display: none;
  }

  /* User-menu tiiviimmin */
  .user-menu {
    gap: 0.25rem;
    padding-left: 0.5rem;
    border-left: none;
  }

  /* Varmista logout mahtuu */
  .user-menu .nav-link {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  /* Piilota raportti, vahvuudet ja tuki -ikonit mobiilissa */
  #btn-open-report,
  #btn-open-vahvuudet,
  #btn-toggle-tuki {
    display: none;
  }

  /* Näytä mobile-nav user-menun sisällä */
  .user-menu .mobile-nav {
    display: flex;
  }

  /* === CONTAINER === */
  .container {
    padding: 0.75rem;
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* === MOBIILI: TAKAISIN-NAPPI === */
  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
  }

  .mobile-back-btn:hover {
    text-decoration: underline;
  }

  /* === RYHMÄSIVU === */
  /* Piilota arviointitaulukko */
  .table-wrap {
    display: none;
  }

  /* Piilota taulukon alla oleva lisää oppilas -nappi */
  .table-actions {
    display: none;
  }

  /* Pinoa toimintorivit */
  .row.gap {
    flex-wrap: wrap;
  }

  /* Arviointinapit koko levyinen mobiilissa */
  .assessment-buttons {
    width: 100%;
  }

  /* Näytä vain Työskentely-nappi täysleveänä */
  #btn-open-work {
    flex: 1 1 100%;
    min-height: 44px;
    font-size: 0.95rem;
  }

  /* Piilota Näyttö ja Koe -napit mobiilissa */
  #btn-open-show,
  #btn-open-exam {
    display: none;
  }

  /* Jakso-dropdown ja ikonit samalle riville */
  .jakso-dropdown {
    flex: 1;
  }

  /* Piilota vähemmän tärkeät ikoninappulat mobiilissa */
  #btn-open-classroom,
  #btn-open-flex {
    display: none;
  }

  /* NÄYTÄ Openote-ikoni mobiilissa (btn-open-openote näkyy) */

  /* Flex-välitin pois */
  .flex1 {
    display: none;
  }

  /* === MODAALIT === */
  .modal-content {
    padding: 1rem;
    border-radius: 16px;
    width: calc(100% - 2rem);
    max-width: none;
    max-height: calc(100vh - 2rem);
  }

  .modal-content.wide {
    width: calc(100% - 2rem);
    height: calc(100vh - 2rem);
  }

  /* Modaalin taulukot scrollattaviksi */
  .popup-table {
    display: block;
    overflow-x: auto;
  }

  /* === LOMAKKEET === */
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  /* Isommat kosketusalueet */
  input, select, button {
    min-height: 44px;
  }

  /* Pallot pysyvät pyöreinä - ohita min-height */
  .dot {
    min-height: 32px !important;
    min-width: 32px !important;
    width: 32px !important;
    height: 32px !important;
    aspect-ratio: 1;
  }

  /* === YLÄPALKKI: Logout/asetukset oikeaan reunaan === */
  .user-menu {
    margin-left: auto;
  }

  /* === TYÖSKENTELYPOPPARI MOBIILI === */

  /* Lomakekentät pinoon ja mahtuvat ruudulle */
  #work-modal .form-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  #work-modal .form-row label {
    width: 100%;
  }

  #work-modal .form-row input,
  #work-modal .form-row select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* === WORK-MODAL (uusi työskentelyarviointi) === */
  #work-modal .modal-content {
    margin: 0.5rem !important;
    padding: 0.75rem !important;
    width: calc(100% - 1rem) !important;
    max-width: none !important;
    height: calc(100vh - 1rem) !important;
    box-sizing: border-box;
  }

  #work-modal .modal-content h3 {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
  }

  #work-modal .popup-table.modern {
    display: block !important;
    width: calc(100% + 1.5rem) !important;
    max-width: none !important;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin: 0 -0.75rem !important;
    padding: 0 !important;
  }

  #work-modal .popup-table.modern thead {
    display: none;
  }

  #work-modal .popup-table.modern tbody {
    display: block !important;
    width: 100% !important;
  }

  #work-modal .popup-table.modern tbody tr {
    display: flex !important;
    width: 100% !important;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    box-sizing: border-box;
  }

  #work-modal .popup-table.modern td {
    display: block !important;
    padding: 0 !important;
  }

  #work-modal .popup-table.modern td.oppilas-nimi {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.2;
    word-break: break-word;
    overflow: hidden;
  }

  #work-modal .popup-table.modern td:not(.oppilas-nimi) {
    flex: 0 0 auto;
  }

  #work-modal .popup-table.modern .dot {
    min-height: 40px !important;
    min-width: 40px !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem;
  }

  #work-modal .actions {
    flex-shrink: 0;
    padding-top: 0.5rem;
  }

  /* === EDIT-EVAL MODAL (työskentelyarviointi) === */
  #edit-eval-modal .modal-content {
    margin: 0.5rem !important;
    padding: 0.75rem !important;
    width: calc(100% - 1rem) !important;
    max-width: none !important;
    height: calc(100vh - 1rem) !important;
    box-sizing: border-box;
  }

  #edit-eval-modal .popup-table.modern {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
  }

  #edit-eval-modal .popup-table.modern thead {
    display: none;
  }

  #edit-eval-modal .popup-table.modern tbody {
    display: block !important;
    width: 100% !important;
  }

  #edit-eval-modal .popup-table.modern tbody tr {
    display: flex !important;
    width: 100% !important;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    box-sizing: border-box;
  }

  #edit-eval-modal .popup-table.modern td {
    display: block !important;
    padding: 0 !important;
  }

  #edit-eval-modal .popup-table.modern td.oppilas-nimi {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.2;
    word-break: break-word;
    overflow: hidden;
  }

  #edit-eval-modal .popup-table.modern td:not(.oppilas-nimi) {
    flex: 0 0 auto;
  }

  #edit-eval-modal .popup-table.modern .dot {
    min-height: 40px !important;
    min-width: 40px !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem;
  }

  #edit-eval-modal .actions {
    flex-shrink: 0;
    padding-top: 0.5rem;
  }

  /* === KORTIT === */
  .card {
    border-radius: 12px;
  }

  .card.pad {
    padding: 1rem;
  }

  /* === LISTAT === */
  .user-card,
  .group-card {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .user-actions,
  .group-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
  }

  /* === PAGE HEADER === */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  /* === STATS GRID === */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  /* === MUUT === */
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  /* Iconbtn isompi kosketusalue */
  .iconbtn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ========= ANIMATIONS ========= */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Smooth transitions for interactive elements */
a, button, input, select, textarea,
.btn, .dot, .iconbtn, .tab, .toggle-switch,
.card, .jakso-dropdown-item, .skill-dropdown-item {
  transition-property: background-color, border-color, color, box-shadow, transform;
  transition-duration: 0.15s;
  transition-timing-function: ease;
}

/* Disable transitions for layout properties */
.no-transition {
  transition: none !important;
}

/* ========= PAINOTUKSET MODAL ========= */
.weight-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-alt);
  border-radius: 10px;
  border: 1px solid var(--border-light);
}

.weight-row label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  margin-bottom: 0;
}

.weight-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.weight-dot.work {
  background: var(--primary);
}

.weight-dot.show {
  background: var(--show-btn);
}

.weight-dot.exam {
  background: var(--exam-btn);
}

.weight-input-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.weight-input-group input {
  width: 70px;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
}

.weight-suffix {
  color: var(--text-muted);
  font-weight: 500;
}

.weight-total {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border-radius: 10px;
  border: 2px solid var(--border);
  font-weight: 600;
}

#weight-total-value {
  font-size: 1.25rem;
  color: var(--primary);
}

.weight-total.invalid {
  border-color: var(--danger);
  background: var(--grade-4-bg);
}

.weight-total.invalid #weight-total-value {
  color: var(--danger);
}

.weight-warning {
  margin-left: auto;
  color: var(--danger);
  font-size: 0.85rem;
}

/* Painotukset-modaalin erikoiskoko - mahtuu ruudulle */
#weights-modal .modal-content {
  width: 450px;
  max-width: 95vw;
  height: auto;
  max-height: 90vh;
  min-height: auto;
}

/* Small icon button variant */
.iconbtn.small {
  width: 24px;
  height: 24px;
  padding: 0;
}

/* ========= SECURITY ALERT ========= */
.security-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.security-alert .alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #dc2626;
  margin-bottom: 0.5rem;
}

.security-alert .alert-header svg {
  stroke: #dc2626;
  flex-shrink: 0;
}

.security-alert .alert-desc {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: #7f1d1d;
}

.security-alert .suspicious-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.security-alert .suspicious-item {
  background: white;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
}

.security-alert .suspicious-user {
  font-weight: 600;
  color: #1e293b;
}

.security-alert .suspicious-count {
  background: #dc2626;
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.security-alert .suspicious-time,
.security-alert .suspicious-ips {
  font-size: 0.8rem;
}

.security-alert .alert-tip {
  margin: 0;
  font-size: 0.8rem;
  font-style: italic;
}

/* ========= LICENSE CARD ========= */
.license-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 16px;
  padding: 1.5rem;
  color: white;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.license-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.license-header h3 {
  margin: 0;
  color: white;
  font-size: 1.25rem;
}

.license-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.license-badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.license-badge.expired {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.license-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.license-stat {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.license-stat .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.license-stat .stat-label {
  font-size: 0.9rem;
  opacity: 0.85;
}

.license-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.license-bar-fill {
  height: 100%;
  background: white;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.license-docs {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.license-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.9rem;
}

.license-link:hover {
  color: white;
  text-decoration: underline;
}

/* ========= USER LIST ========= */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.user-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary-soft);
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-card .user-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-username {
  color: var(--primary);
}

.user-role {
  flex-shrink: 0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.role-badge.admin {
  background: var(--primary-soft);
  color: var(--primary);
}

.role-badge.teacher {
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ========= FORM GRID ========= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0;
}

.form-field input,
.form-field select {
  width: 100%;
}

/* ========= ADMIN NAV LINK ========= */
.nav-link.admin-link:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ========= SIZE SELECTOR BALLS ========= */
.size-selector {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-left: auto;
}

.size-label {
  font-size: 0.9rem;
  color: var(--text);
}

.size-balls {
  display: flex;
  gap: 0.5rem;
}

.size-ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-ball:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.size-ball.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.size-ball:focus {
  outline: none;
}

.nav-link.superadmin-link {
  color: var(--show-btn);
}

.nav-link.superadmin-link:hover {
  background: var(--show-cell);
  color: var(--show-btn-hover);
}

/* ========= SCHOOL LIST (Superadmin) ========= */
.school-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.school-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.school-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary-soft);
}

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

.school-info {
  flex: 1;
}

.school-name {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: var(--primary);
}

.school-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active {
  background: var(--grade-10-bg);
  color: var(--grade-10);
}

.status-badge.inactive {
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.status-badge.expired {
  background: var(--grade-4-bg);
  color: var(--danger);
}

.status-badge.perus {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.lukio {
  background: #fae8ff;
  color: #a21caf;
}

/* Vuositaso-badget taitosivulla */
.vuositaso-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.vt-1-2 {
  background: #dcfce7;
  color: #166534;
}

.vt-3-6 {
  background: #fef9c3;
  color: #854d0e;
}

.vt-1-6 {
  background: #d1fae5;
  color: #047857;
}

.vt-7-9 {
  background: #dbeafe;
  color: #1d4ed8;
}

.vt-lukio {
  background: #fae8ff;
  color: #a21caf;
}

/* Tavoitteet-sivu: työskentelytaidot ja oppimistavoitteet */
.tyoskentely-row {
  background-color: rgba(34, 168, 106, 0.08);
  border-left: 3px solid var(--success);
}

.tyoskentely-row:hover {
  background-color: rgba(34, 168, 106, 0.12);
}

.tyoskentely-badge {
  display: inline-block;
  background: var(--success);
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.tavoite-row {
  background-color: var(--bg);
}

.tavoite-row:hover {
  background-color: var(--border-light);
}

/* Form label - täyden leveyden kenttä */
.form-label-full {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

/* Form label - kasvava kenttä (täyttää tilan) */
.form-label-grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-label-grow input,
.form-label-grow select,
.form-label-grow .skill-dropdown {
  width: 100%;
}

/* Tavoite avattava label */
.tavoite-label {
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tavoite-toggle-icon {
  font-size: 0.65rem;
  display: inline-block;
  transition: transform 0.2s ease;
}

.tavoite-label.open .tavoite-toggle-icon {
  transform: rotate(90deg);
}

/* Tavoite-lista (openote-tyylinen) */
.tavoite-list-box {
  flex-direction: column;
  gap: 0.35rem;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.35rem 0;
  display: none;
}

.tavoite-list-box.open {
  display: flex;
}

.tavoite-card {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--gray-50, #f8fafc);
  border: none;
  border-left: 3px solid var(--border);
  border-radius: 0.4rem;
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.tavoite-card:hover {
  background: var(--bg-alt, #f1f5f9);
  border-left-color: var(--accent);
  color: var(--text);
}

.tavoite-card.active {
  background: #eef2ff;
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 500;
}

.tavoite-card:focus {
  outline: none;
}

.tavoite-card-code {
  flex-shrink: 0;
  background: var(--border);
  color: var(--text-muted);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 2rem;
  text-align: center;
}

.tavoite-card.active .tavoite-card-code {
  background: var(--accent);
  color: white;
}

/* Skill dropdown (työskentelyarviointi) */
.skill-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 280px;
}

.skill-dropdown-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
}

.skill-dropdown-btn:hover {
  border-color: var(--primary);
}

.skill-dropdown-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.skill-dropdown.open .skill-dropdown-arrow {
  transform: rotate(180deg);
}

.skill-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 450px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: var(--z-dropdown);
  margin-top: 4px;
}

.skill-dropdown.open .skill-dropdown-menu {
  display: block;
}

.skill-dropdown-group {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.skill-dropdown-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
}

.skill-dropdown-item:last-child {
  border-bottom: none;
}

.skill-dropdown-item:hover {
  background: var(--bg);
}

.skill-dropdown-item.selected {
  background: var(--primary-soft);
}

.skill-dropdown-item .skill-name {
  flex: 1;
  min-width: 0;
}

.skill-dropdown-item .vuositaso-badge {
  margin-left: 0;
}

.school-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.school-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.school-stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.school-stat svg {
  opacity: 0.6;
}

.school-stat strong {
  color: var(--text);
}

.school-progress {
  margin-top: 0.5rem;
}

.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ========= STUDENT CARD (Oppilaskortti) ========= */
.student-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.student-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.student-card-header h3 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--primary);
}

.student-card-jakso-row {
  display: flex;
  align-items: center;
}

.student-card-jakso-select {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.student-card-jakso-select:focus {
  outline: none;
  border-color: var(--accent);
}

#student-info {
  margin-bottom: 1rem;
}

/* Progress chart container */
.progress-chart-container {
  height: 220px;
  margin: 0.75rem 0 1.25rem;
  padding: 1rem 1rem 0.5rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #f0fdf4 100%);
  border-radius: 16px;
  border: 1px solid rgba(59, 130, 246, 0.15);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Student card tabs */
.student-card-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 1rem 0 0.75rem;
  padding: 0.25rem;
  background: var(--bg-alt);
  border-radius: 10px;
}

.student-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.student-tab:hover {
  color: var(--text);
  background: rgba(0,0,0,0.05);
}

.student-tab.active {
  background: var(--bg);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.student-tab-content[hidden] {
  display: none;
}

/* Tavoitteittain list */
.tavoitteittain-list {
  margin-top: 0.5rem;
}

.tavoitteittain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-alt);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.tavoitteittain-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
}

.tavoitteittain-types {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
  min-width: 5rem;
}

.tavoitteittain-ka {
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 3rem;
  text-align: center;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.tavoitteittain-ka.ka-excellent {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.tavoitteittain-ka.ka-good {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.tavoitteittain-ka.ka-ok {
  background: rgba(234, 179, 8, 0.15);
  color: #ca8a04;
}

.tavoitteittain-ka.ka-low {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

/* Pöytäkirja list (oppilaskortti) */
.poytakirja-list {
  margin-top: 0.5rem;
}

.poytakirja-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-alt);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.poytakirja-name {
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
}

.poytakirja-date {
  font-size: 0.8rem;
}

.poytakirja-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  min-width: 4rem;
  text-align: right;
}

/* Pöytäkirja modal */

/* Pöytäkirja cards (modal) */
.poytakirja-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.5rem;
  align-content: flex-start;
  background: rgba(16, 185, 129, 0.03);
  border-radius: 12px;
}

.poytakirja-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  background: white;
  border: 2px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  text-align: center;
}

.poytakirja-card:hover {
  border-color: #10b981;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.poytakirja-card.new-card {
  border-style: dashed;
  border-color: #10b981;
  background: transparent;
}

.poytakirja-card.new-card:hover {
  background: #d1fae5;
}

.poytakirja-card-icon {
  font-size: 2rem;
  color: #10b981;
  font-weight: 300;
  line-height: 1;
}

.poytakirja-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-top: 0.25rem;
}

.poytakirja-card-date {
  font-size: 0.8rem;
  color: #059669;
  margin-top: 0.25rem;
}

.poytakirja-card-unit {
  font-size: 0.75rem;
  color: white;
  background: #10b981;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.5rem;
}

.poytakirja-form {
  /* Lomake piilossa kunnes kortti valittu */
}

#poytakirja-modal .popup-table.modern tbody tr:hover {
  background: #ecfdf5;
}

/* Card list items */
.card-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  margin: 0.35rem 0;
  border-radius: 10px;
  background: var(--bg-alt);
  transition: all 0.15s ease;
}

.card-list-item:hover {
  background: var(--primary-soft);
}

.card-item-text {
  font-weight: 600;
  min-width: 75px;
  color: var(--text);
}

.card-item-detail {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

/* Arvosana + sydän wrapper oppilaskortissa */
.card-grade-wrapper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  position: relative;
}

/* Ohjaus-sydän oppilaskortin arvosanalistassa */
.card-tuki-heart {
  color: #dc2626;
  font-size: 0.7rem;
}

/* Card dot (ball) for pallo-type näytöt */
.card-dot {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

#student-body h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--primary-soft);
}

#student-body h4::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

#student-body h4:first-child {
  margin-top: 0;
}


/* ========= TAVOITE SECTION ========= */
.tavoite-section {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border: 1px solid #e9d5ff;
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.tavoite-row {
  margin-bottom: 0.75rem;
}

.tavoite-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.tavoite-row input,
.tavoite-row textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.tavoite-row input:focus,
.tavoite-row textarea:focus {
  border-color: var(--primary);
  outline: none;
}

/* Tavoite arvosanapallit */
.tavoite-balls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tavoite-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-alt);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tavoite-ball:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light, #e0e7ff);
}

.tavoite-ball.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
  min-height: 32px;
  box-sizing: border-box;
}

/* Näyttöarvioinnin badge oppilaskortilla (lila) - pillerimäinen */
.show-grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 32px;
  background: linear-gradient(145deg, #c084fc 0%, #a855f7 50%, #9333ea 100%);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

/* Pallo-tyyppisten näyttöjen värilaatikot - pillerimäinen */
.show-pallo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 32px;
  border-radius: 16px;
  flex-shrink: 0;
  color: white;
  font-weight: 700;
  font-size: 1rem;
}

/* Koe-badge oppilaskortilla (sininen laatikko) */
.exam-grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 26px;
  padding: 0 8px;
  background: linear-gradient(145deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 6px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}
.show-pallo-badge.dot-4 {
  background: var(--grade-4);
}
.show-pallo-badge.dot-55 {
  background: var(--grade-55);
}
.show-pallo-badge.dot-7 {
  background: var(--grade-7);
}
.show-pallo-badge.dot-85 {
  background: var(--grade-85);
}
.show-pallo-badge.dot-10 {
  background: var(--grade-10);
}

/* Pass/Fail badges for student cards */
.show-passfail-badge {
  width: 44px;
  height: 32px;
  border-radius: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}
.show-passfail-badge.pass {
  background: linear-gradient(145deg, #34d399 0%, #10b981 50%, #059669 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35),
              inset 0 1px 0 rgba(255,255,255,0.25);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.show-passfail-badge.fail {
  background: linear-gradient(145deg, #f87171 0%, #ef4444 50%, #dc2626 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35),
              inset 0 1px 0 rgba(255,255,255,0.25);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ========= HÄLYTYKSET SIVU ========= */
.alert-section {
  margin-bottom: 2rem;
}

.alert-section h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.alert-section .muted {
  margin-bottom: 1rem;
}

.ero-cell {
  color: #dc2626;
  font-weight: 600;
}

.ka-cell-low {
  color: #dc2626;
  font-weight: 600;
}

.tavoite-cell {
  color: var(--primary);
  font-weight: 600;
}

.jaettu-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--shared-badge-bg, #e0e7ff);
  color: var(--shared-badge-color, #4338ca);
  border-radius: 4px;
  vertical-align: middle;
}

/* Lila "Jaettu" badge ryhmäsivun otsikossa */
.jaettu-badge-lila {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #a855f7;
  color: #fff;
  border-radius: 6px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* Sähköpostinappi */
.email-btn {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.email-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.email-btn.success {
  background: #16a34a;
  border-color: #16a34a;
  color: white;
}

.email-btn.error {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

.email-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.muted.small {
  font-size: 0.8rem;
}

/* Hälytyslinkit */
.alert-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.alert-link:hover {
  text-decoration: underline;
}

.alert-link.muted-link {
  color: var(--text-muted);
  font-weight: 400;
}

.alert-link.muted-link:hover {
  color: var(--primary);
}

.no-alerts {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--bg-alt);
  border-radius: 12px;
  color: var(--text-muted);
}

.no-alerts p {
  font-size: 1.1rem;
}

/* ========= PRINT STYLES ========= */
@media print {
  body * {
    visibility: hidden;
  }

  #student-modal,
  #student-modal * {
    visibility: visible;
  }

  #student-modal {
    position: static !important;
    width: 100%;
    background: white;
    margin: 0;
    padding: 0;
    overflow: visible !important;
  }

  #student-modal .modal-content {
    box-shadow: none;
    border: none;
    max-width: 100%;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0;
    margin: 0;
  }

  /* Salli sivunvaihdot */
  #student-body {
    overflow: visible !important;
  }

  .card-list-item {
    page-break-inside: avoid;
  }

  #student-body h4 {
    page-break-after: avoid;
  }

  @page {
    margin: 0.5cm;
    size: A4;
  }

  .no-print {
    display: none !important;
  }

  /* Kompakti layout */
  .student-card-header {
    margin-top: 0;
    margin-bottom: 0.25rem;
  }

  #student-body h4 {
    margin: 0.4rem 0 0.2rem;
    font-size: 0.75rem;
  }

  .card-list-item {
    padding: 0.15rem 0;
    font-size: 0.8rem;
    gap: 0.5rem;
  }

  .list {
    margin-bottom: 0.4rem;
  }

  /* KA-kortti tulosteessa */
  .ka-card {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    box-shadow: none;
    padding: 0.5rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
    page-break-inside: avoid;
  }

  .bar-meter {
    margin-bottom: 0.25rem;
  }

  .bar-track {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    height: 10px;
  }

  .bar-labels {
    font-size: 0.65rem;
  }

  .bar-marker-value {
    background: #1e3a5f !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 0.75rem;
    padding: 0.15rem 0.35rem;
  }

  .bar-marker::after {
    border-top-color: #1e3a5f !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ka-badges {
    gap: 0.25rem;
    margin-top: 0.25rem;
  }

  .ka-badges .badge {
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
  }

  .ka-badges .badge span {
    color: #64748b !important;
  }

  .ka-badges .badge strong {
    color: #1e293b !important;
  }

  .ka-jakso {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
  }

  /* Edistymisgraafi tulosteessa */
  .progress-chart-container {
    height: 100px !important;
    min-height: 100px;
    max-height: 100px;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    box-shadow: none;
    padding: 0.4rem;
    margin: 0.3rem 0 0.5rem;
    border-radius: 8px;
    page-break-inside: avoid;
    overflow: hidden;
    display: block;
    clear: both;
  }

  .progress-chart-container canvas {
    max-height: 90px !important;
  }

  /* Tavoite-osio tulosteessa */
  .tavoite-section {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    page-break-inside: avoid;
    clear: both;
    display: block;
    position: relative;
  }

  .tavoite-section label {
    font-size: 0.75rem;
  }

  .tavoite-section textarea {
    font-size: 0.8rem;
    min-height: 2rem;
    max-height: 4rem;
  }

  .tavoite-section .btn {
    display: none !important;
  }

  .tavoite-balls {
    gap: 0.25rem;
  }

  .tavoite-ball {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  /* Dot värit tulosteessa */
  .dot {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    width: 18px;
    height: 18px;
  }

  .exam-grade-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    background: #e0e7ff !important;
    color: #4338ca !important;
  }

  .show-grade-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    background: #f3e8ff !important;
    color: #7c3aed !important;
  }

  /* Raportti-modaali tulosteessa */
  #report-modal,
  #report-modal * {
    visibility: visible;
  }

  #report-modal {
    position: static !important;
    width: 100%;
    background: white;
    margin: 0;
    padding: 0;
    overflow: visible !important;
  }

  #report-modal .modal-content {
    box-shadow: none;
    border: none;
    max-width: 100%;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 20px;
    margin: 0;
  }

  #report-modal .actions,
  #report-modal .form-row,
  #report-modal .btn-icon,
  #report-modal button {
    display: none !important;
  }

  #report-modal .settings-section {
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
  }

  #report-modal table {
    border-collapse: collapse;
    width: 100%;
  }

  #report-modal th,
  #report-modal td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
  }

  #report-modal th {
    background: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #report-modal .summary-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-around;
    gap: 0.5rem;
  }

  #report-modal .summary-item {
    text-align: center;
    flex: 1;
    min-width: 0;
    padding: 0.5rem;
  }

  #report-modal .summary-value {
    font-size: 1.5rem;
    font-weight: bold;
  }

  #report-modal .summary-label {
    font-size: 0.8rem;
    color: #666;
  }
}

/* ========= RAPORTTI ========= */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}

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

.report-table th:first-child,
.report-table td:first-child {
  width: 40%;
}

.report-table th:not(:first-child),
.report-table td:not(:first-child) {
  text-align: center;
}

.report-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report-table tbody tr:hover {
  background: var(--bg-alt);
}

.report-table tbody tr:last-child td {
  border-bottom: none;
}

.report-summary-row {
  background: var(--bg-alt);
  border-top: 2px solid var(--border);
}

.report-summary-row td {
  padding-top: 0.75rem !important;
}

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

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: var(--bg-alt);
  border-radius: 12px;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* Tuen tarve -palkki */
.support-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.support-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.support-bar {
  background: var(--gray-200);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}

.support-bar-fill {
  background: #f59e0b;
  height: 100%;
  min-width: 2px;
  border-radius: 6px;
}

/* ========= TOAST VIESTIT ========= */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  pointer-events: auto;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: #10b981;
  color: white;
}

.toast-error {
  background: #ef4444;
  color: white;
}

.toast-warning {
  background: #f59e0b;
  color: white;
}

.toast-info {
  background: var(--primary);
  color: white;
}

/* ========= VAROITUS-DIALOGI ========= */
.warning-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-confirm);
  opacity: 0;
  transition: opacity 0.2s;
}

.warning-confirm-overlay.show {
  opacity: 1;
}

.warning-confirm-box {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  transform: scale(0.9);
  transition: transform 0.2s;
}

.warning-confirm-overlay.show .warning-confirm-box {
  transform: scale(1);
}

.warning-confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.warning-confirm-message {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.warning-confirm-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.warning-confirm-buttons .btn {
  min-width: 120px;
}

.confirm-box .warning-confirm-message {
  padding-top: 0.5rem;
}

.confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  color: white;
}

.confirm-icon-question {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.confirm-icon-info {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.confirm-icon-warning {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Leveämpi dialogi (käyttäjän poisto) */
.warning-confirm-wide {
  max-width: 480px;
}

.warning-confirm-buttons-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.warning-confirm-buttons-vertical .btn {
  width: 100%;
  justify-content: center;
}

.warning-confirm-buttons-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.warning-confirm-buttons-row .btn {
  flex: 1;
  min-width: 100px;
}

/* Käyttäjän poisto - kaksipalstainen dialogi */
.delete-user-dialog {
  max-width: 560px;
  text-align: center;
  padding: 1.5rem 2rem 2rem;
}

.delete-dialog-title {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.delete-dialog-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.delete-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.delete-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.delete-stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.stat-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 0.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  font-weight: 600;
  border-radius: 6px;
  font-size: 0.85rem;
}

.delete-warning {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.delete-warning strong {
  color: var(--text);
}

.delete-warning ul {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
}

.delete-warning li {
  margin-bottom: 0.2rem;
}

.transfer-tip {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.transfer-tip strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.transfer-tip p {
  margin: 0;
  line-height: 1.4;
}

.consent-box.consent-yes {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  color: var(--primary-dark);
  border: 1px solid var(--primary);
}

.consent-box.consent-no {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  color: #c62828;
  border: 1px solid #ef5350;
}

.consent-icon {
  font-size: 1.1rem;
  font-weight: 700;
}

.delete-dialog-content {
  text-align: left;
  margin-bottom: 1.5rem;
}

.delete-dialog-content h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.delete-personal-data {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}

.delete-personal-data h4 {
  margin: 0 0 0.25rem;
}

.delete-personal-data .muted {
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.consent-box {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

.consent-warning {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.8rem;
  font-weight: normal;
}

.delete-list {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
  font-size: 0.85rem;
  font-weight: normal;
}

.delete-list li {
  margin-bottom: 0.1rem;
}

.reset-option {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 1px solid #2196f3;
  border-radius: 10px;
  padding: 1rem;
  margin-top: 1rem;
}

.reset-option strong {
  display: block;
  color: #1565c0;
  margin-bottom: 0.25rem;
}

.reset-option .muted {
  margin: 0;
  font-size: 0.85rem;
  color: #1976d2;
}

.reset-warning-box {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border: 1px solid #ff9800;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #e65100;
}

.reset-warning-box svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.delete-dialog-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.delete-dialog-buttons .btn {
  min-width: 120px;
}

/* Mobiilille yksisarakeinen */
@media (max-width: 520px) {
  .delete-user-dialog {
    max-width: 95vw;
    padding: 1.25rem 1.5rem 1.5rem;
  }
  .delete-dialog-columns {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .delete-dialog-buttons {
    flex-direction: column;
  }
  .delete-dialog-buttons .btn {
    width: 100%;
  }
}

/* ========= LUOKKAHUONE ========= */
.color-palette {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.color-dot:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.color-dot.active {
  border-color: var(--primary);
  transform: scale(1.1);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary);
}

#classroom-canvas-wrap {
  position: relative;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  border-radius: 12px;
  border: 2px dashed var(--border);
  aspect-ratio: 5 / 4;
  min-height: 500px;
  overflow: hidden;
}

#classroom-canvas {
  position: absolute;
  inset: 0;
}

.student-ball {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: white;
  font-weight: 600;
  font-size: 0.7rem;
  text-align: center;
  line-height: 1.1;
  cursor: grab;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  transform: translate(-50%, -50%);
  padding: 3px;
  word-break: break-word;
}

.student-ball:hover {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
  z-index: 10;
}

.student-ball.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 100;
  opacity: 0.9;
}

.student-ball.selected {
  box-shadow: 0 0 0 3px white, 0 0 0 6px var(--primary), 0 4px 12px rgba(0,0,0,0.25);
}

/* Opettaja-laatikko */
.teacher-ball {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 2px solid #94a3b8;
  color: #64748b;
  font-weight: 700;
  font-size: 0.75rem;
  text-align: center;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  transform: translate(-50%, -50%);
  z-index: 50;
}

.teacher-ball:hover {
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  border-color: #64748b;
}

.teacher-ball.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  z-index: 200;
}

/* Ohjeet kun luokkahuone on tyhjä */
#classroom-canvas:empty::before {
  content: "Valitse luokkahuone tai luo uusi";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Ruudukko luokkahuoneessa */
#classroom-canvas.show-grid {
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* Toggle-pallo valinta */
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  color: #64748b;
  transition: all 0.15s ease;
}

.toggle-pill:hover {
  background: #e2e8f0;
}

.toggle-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.toggle-pill .toggle-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: all 0.15s ease;
}

.toggle-pill.active .toggle-dot {
  background: white;
}

/* Checkbox inline (legacy) */
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-inline input {
  margin: 0;
}

/* ========= JOUSTAVA RYHMITTELY ========= */

/* Vanha suodatusrivi (piilotettu) */
.flex-filter {
  display: none !important;
}

/* Välilehdet */
.flex-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.flex-tab {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}

.flex-tab:hover {
  color: var(--text);
  background: var(--gray-100);
}

.flex-tab.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

/* Välilehden sisältö */
.flex-tab-content {
  display: none;
  min-height: 350px;
  max-height: 350px;
  overflow: hidden;
}

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

#flex-modal .modal-content {
  display: block;
  height: auto;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

#flex-modal .flex-tab-content {
  max-height: none;
  overflow: visible;
}

#flex-modal .flex-students {
  max-height: none;
  overflow: visible;
}

/* Suodatuslaatikot - isot kortit nimillä */
.flex-filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.flex-filter-btn {
  position: relative;
  min-width: 120px;
  min-height: 80px;
  padding: 0.5rem;
  border-radius: 12px;
  border: 3px solid var(--filter-color, var(--border));
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.flex-filter-btn:not(.no-color) {
  border-color: var(--filter-color);
}

.flex-filter-btn.no-color {
  background: white;
  border: 3px dashed #cbd5e1;
}

.flex-filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.flex-filter-btn.hidden {
  opacity: 0.4;
}

.flex-filter-btn.hidden .flex-filter-names {
  text-decoration: line-through;
}

/* Väripallo otsikkona */
.flex-filter-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.flex-filter-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--filter-color, #94a3b8);
}

.flex-filter-btn.no-color .flex-filter-dot {
  background: transparent;
  border: 2px dashed #94a3b8;
}

.flex-filter-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

/* Oppilaiden nimet */
.flex-filter-names {
  font-size: 0.7rem;
  color: #475569;
  line-height: 1.3;
  text-align: left;
  word-break: break-word;
}

/* Väripaletti */
.flex-colors {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 8px;
  margin: -8px;
  margin-bottom: 0;
}

.flex-color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--btn-color, var(--bg-alt));
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.flex-color-btn[data-color=""] {
  background: var(--card);
  border: 2px dashed var(--border);
}

.flex-color-btn:hover {
  transform: scale(1.1);
}

.flex-color-btn.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text);
}

/* Oppilaslista - 3 palstaa */
.flex-students {
  max-height: 350px;
  overflow-y: auto;
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}

.flex-student-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.flex-student-row:hover {
  background: var(--gray-100);
}

.flex-student-ball {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.flex-student-ball.has-color {
  border-style: solid;
  border-color: transparent;
}

.flex-student-name {
  font-size: 0.9rem;
}

/* Piilotettu oppilas */
.flex-student-row.filtered-out {
  opacity: 0.4;
}

.flex-student-row.filtered-out .flex-student-name {
  text-decoration: line-through;
}

/* Piilota arviointitaulukko kunnes suodatus on valmis */
.grade-table-area.flex-loading,
.popup-table.flex-loading {
  visibility: hidden;
}

/* ========================================
   OPENOTE - Muistiinpanot
   ======================================== */

.openote-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.openote-item {
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: 0.5rem;
  border-left: 4px solid var(--primary);
}

.openote-item.shared {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border-left-color: var(--show-btn);
}

.openote-shared-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--show-btn);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.openote-shared-label svg {
  width: 14px;
  height: 14px;
}

.openote-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.openote-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.openote-content {
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.openote-content-text {
  max-height: 300px;
  overflow-y: auto;
  text-align: left;
}

.openote-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-light);
}

.openote-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.openote-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.badge.shared {
  background: var(--show-bg);
  color: var(--show-btn);
}

.badge.other {
  background: var(--gray-100);
  color: var(--text-light);
}

.openote-empty {
  text-align: center;
  color: var(--text-light);
  padding: 2rem;
}

/* Openote modaali */
#openote-modal .modal-content {
  width: 900px;
  max-width: 95vw;
}

#openote-modal .flex-tab-content {
  min-height: auto;
  max-height: none;
}

#openote-modal input[type="text"],
#openote-modal textarea {
  width: 556px;  /* 900px / 1.618 (kultainen leikkaus) */
  max-width: 100%;
}

/* ========================================
   LINKIT -modaali (käyttää .wide-luokkaa = 900px)
   ======================================== */

#linkit-modal .flex-tab-content {
  min-height: auto;
  max-height: none;
}

#linkki-title,
#linkki-url {
  width: 556px;  /* 900px / 1.618 (kultainen leikkaus) - sama kuin openote */
  max-width: 100%;
}

.linkit-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.linkki-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

.linkki-item:hover {
  border-color: var(--border);
}

.linkki-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  border-radius: 8px;
  color: var(--primary);
}

.linkki-icon svg {
  width: 18px;
  height: 18px;
}

.linkki-info {
  flex: 1;
  min-width: 0;
}

.linkki-title {
  display: block;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linkki-title:hover {
  text-decoration: underline;
}

.linkki-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.linkki-item.shared {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border-left: 4px solid var(--show-btn);
}

.linkki-shared-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--show-btn);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.linkki-delete {
  flex-shrink: 0;
  padding: 0.35rem !important;
}

.linkit-empty,
.linkit-loading {
  text-align: center;
  color: var(--text-light);
  padding: 2rem;
}

/* ========================================
   Oppilaiden monivalinta (Koulusta-välilehti)
   ======================================== */

.small-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.student-pick-box {
  height: 200px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  background: var(--gray-50);
}

.student-pick-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

.student-pick-item:hover {
  background: var(--primary-light);
}

.student-pick-item:last-child {
  border-bottom: none;
}

.student-pick-item .student-name {
  font-weight: 500;
}

.student-pick-item .student-class {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-left: 0.5rem;
}

.student-pick-item .remove-btn {
  color: var(--danger);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
}

.student-pick-item .remove-btn:hover {
  color: var(--danger-dark);
}

#selected-students-list .student-pick-item {
  background: var(--primary);
  color: white;
}

#selected-students-list .student-pick-item:hover {
  background: var(--primary-light);
}

#selected-students-list .student-pick-item .student-class {
  color: rgba(255, 255, 255, 0.8);
}

#selected-students-list .student-pick-item .remove-btn {
  color: rgba(255, 255, 255, 0.8);
}

#selected-students-list .student-pick-item .remove-btn:hover {
  color: white;
}

/* ========= ILMOITUSTAULU ========= */

.ilmoitustaulu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .ilmoitustaulu-grid {
    grid-template-columns: 1fr;
  }
}

.ilmoitustaulu-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.ilmoitustaulu-col .card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ilmoitustaulu-col .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.ilmoitustaulu-col .card-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.ilmoitustaulu-col .card-body {
  padding: 1rem 1.25rem;
}

/* Ilmoituskorttilista (4 rinnakkain) */
.ilmoitus-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  align-items: start;
}

@media (max-width: 1200px) {
  .ilmoitus-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .ilmoitus-grid { grid-template-columns: repeat(2, 1fr); }
}

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

/* Ilmoituskortti */
.ilmoitus-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  aspect-ratio: 2 / 1;
  overflow: hidden;
}

.ilmoitus-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Julkinen ilmoitus */
.ilmoitus-card.julkinen {
  border: 1px solid #d8b4fe;
  border-left-width: 4px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

/* Ilmoituskortin värivaihtoehdot */
.ilmoitus-card.vari-primary { border-left-color: #60a5fa; }
.ilmoitus-card.vari-success { border-left-color: var(--success); }
.ilmoitus-card.vari-warning { border-left-color: var(--warning); }
.ilmoitus-card.vari-danger { border-left-color: var(--danger); }
.ilmoitus-card.vari-purple { border-left-color: #8b5cf6; }

.ilmoitus-card-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}

.ilmoitus-otsikko {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  line-height: 1.2;
}

.ilmoitus-card-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ilmoitus-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-light);
}

.ilmoitus-tekija {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

/* Ilmoituksen luku-modal */
.ilmoitus-read-content {
  max-width: 600px;
}

.ilmoitus-read-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ilmoitus-read-header h3 {
  margin: 0;
  flex: 1;
}

.ilmoitus-read-body {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 1rem;
  max-height: 400px;
  overflow-y: auto;
}

.ilmoitus-read-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-bottom: 1rem;
}

.julkinen-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  background: #a855f7;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 10px;
  text-transform: uppercase;
  margin-left: 0.5rem;
}

/* Muistiinpanokortti */
.muistiinpano-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.muistiinpano-card:last-child {
  margin-bottom: 0;
}

.muistiinpano-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.muistiinpano-header strong {
  font-size: 1rem;
  color: var(--text);
}

.muistiinpano-actions {
  display: flex;
  gap: 0.25rem;
}

.muistiinpano-sisalto {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.muistiinpano-sisalto p {
  margin: 0 0 0.5rem 0;
}

.muistiinpano-sisalto p:last-child {
  margin-bottom: 0;
}

.muistiinpano-meta {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Kuvitettu tyhjä tila */
.empty-state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-box .empty-icon {
  width: 48px;
  height: 48px;
  stroke: var(--text-light);
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.empty-state-box p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.empty-state-box .empty-hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* Tehtävälista */
.tehtava-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.tehtava-item:last-child {
  border-bottom: none;
}

.tehtava-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  cursor: pointer;
}

.tehtava-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.tehtava-teksti {
  flex: 1;
  color: var(--text);
}

.tehtava-item.valmis .tehtava-teksti {
  text-decoration: line-through;
  color: var(--text-light);
}

.tehtava-lisaa {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.tehtava-lisaa input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.tehtava-lisaa input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Tehtävä container */
.tehtava-container {
  max-width: 600px;
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Julkinen toggle modalissa */
.julkinen-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.julkinen-toggle input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  min-width: 44px;
  background: #ccc;
  border-radius: 24px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.julkinen-toggle input:checked + .toggle-slider {
  background: #a855f7;
}

.julkinen-toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-label {
  font-weight: 500;
  color: var(--text);
}

/* Btn-icon */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--primary);
}

.btn-icon.danger:hover {
  background: #fee2e2;
  color: var(--danger);
}

.btn-icon.btn-xs {
  width: 22px;
  height: 22px;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* ========= ILMOITUSTAULU TABS ========= */

.ilmoitustaulu-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.ilmoitustaulu-tabs .tab {
  flex: 1;
  max-width: 150px;
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  text-align: center;
}

.ilmoitustaulu-tabs .tab:hover {
  color: var(--primary);
  background: transparent;
}

.ilmoitustaulu-tabs .tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Ilmoitustaulun tab-content piilotus (vain ilmoitustaulu-sivulla) */
.ilmoitustaulu-tabs ~ .tab-content {
  display: none;
}

.ilmoitustaulu-tabs ~ .tab-content.active {
  display: block;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tab-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.tab-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* iCal import status */
.ical-status {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.ical-status.info {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.ical-status.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.ical-status.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ========= LINKIT ========= */

.linkki-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  cursor: pointer;
  align-items: center;
}

.linkki-row:hover {
  background: var(--bg-alt);
}

.linkki-row.julkinen {
  border: 2px solid #d8b4fe;
  border-left-width: 4px;
}

.linkki-row.vari-primary { border-left-color: var(--primary); }
.linkki-row.vari-success { border-left-color: var(--success); }
.linkki-row.vari-warning { border-left-color: var(--warning); }
.linkki-row.vari-danger { border-left-color: var(--danger); }
.linkki-row.vari-purple { border-left-color: #8b5cf6; }

.linkki-icon.vari-primary { background: var(--primary-soft); color: var(--primary); }
.linkki-icon.vari-success { background: #d1fae5; color: var(--success); }
.linkki-icon.vari-warning { background: #fef3c7; color: #b45309; }
.linkki-icon.vari-danger { background: #fee2e2; color: var(--danger); }
.linkki-icon.vari-purple { background: #ede9fe; color: #7c3aed; }

.linkki-content {
  flex: 1;
  min-width: 0;
}

.linkki-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.linkki-header strong {
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linkki-row.expanded .linkki-header strong {
  white-space: normal;
}

/* Piilotetut yksityiskohdat oletuksena */
.linkki-details {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.linkki-row.expanded {
  align-items: flex-start;
  padding: 0.75rem 1rem;
}

.linkki-row.expanded .linkki-details {
  display: block;
}

.linkki-url {
  font-size: 0.8rem;
  color: var(--text-light);
  word-break: break-all;
  margin-bottom: 0.25rem;
}

.linkki-kuvaus {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.linkki-actions-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.tab-body {
  min-height: 200px;
}

.tab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .tab-grid {
    grid-template-columns: 1fr;
  }
}

.tab-section {
  background: var(--bg);
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.tab-section h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ========= KALENTERI ========= */

.kalenteri-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tapahtuma-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  cursor: pointer;
  align-items: center;
}

.tapahtuma-card:hover {
  background: var(--bg-alt);
}

/* Kompakti päivämerkki */
.tapahtuma-card .tapahtuma-paiva {
  min-width: 44px;
  height: 44px;
}

.tapahtuma-card .paiva-num {
  font-size: 1.2rem;
}

/* Piilotetut yksityiskohdat oletuksena */
.tapahtuma-details {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Laajennettu kortti */
.tapahtuma-card.expanded {
  align-items: flex-start;
  padding: 0.75rem 1rem;
}

.tapahtuma-card.expanded .tapahtuma-details {
  display: block;
}

.tapahtuma-card.expanded .tapahtuma-paiva {
  min-width: 50px;
  height: 50px;
}

.tapahtuma-card.expanded .paiva-num {
  font-size: 1.4rem;
}

.tapahtuma-content {
  flex: 1;
  min-width: 0;
}

.tapahtuma-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tapahtuma-header strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tapahtuma-card.expanded .tapahtuma-header strong {
  white-space: normal;
}

.tapahtuma-card.mennyt {
  display: none;
}

.kalenteri-list.nayta-menneet .tapahtuma-card.mennyt {
  display: flex;
  opacity: 0.6;
}

.tapahtuma-card.mennyt .tapahtuma-paiva {
  background: var(--bg-hover);
}

/* Värivaihtoehdot */
.tapahtuma-card.vari-primary { border-left-color: #60a5fa; }
.tapahtuma-card.vari-success { border-left-color: var(--success); }
.tapahtuma-card.vari-warning { border-left-color: var(--warning); }
.tapahtuma-card.vari-danger { border-left-color: var(--danger); }
.tapahtuma-card.vari-purple { border-left-color: #8b5cf6; }

.tapahtuma-paiva {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  background: var(--primary-light);
  border-radius: 8px;
  flex-shrink: 0;
}

.tapahtuma-card.vari-primary .tapahtuma-paiva { background: #dbeafe; }
.tapahtuma-card.vari-success .tapahtuma-paiva { background: #d1fae5; }
.tapahtuma-card.vari-warning .tapahtuma-paiva { background: #fef3c7; }
.tapahtuma-card.vari-danger .tapahtuma-paiva { background: #fee2e2; }
.tapahtuma-card.vari-purple .tapahtuma-paiva { background: #ede9fe; }

.paiva-num {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.tapahtuma-card.vari-primary .paiva-num { color: #3b82f6; }
.tapahtuma-card.vari-success .paiva-num { color: var(--success); }
.tapahtuma-card.vari-warning .paiva-num { color: #b45309; }
.tapahtuma-card.vari-danger .paiva-num { color: var(--danger); }
.tapahtuma-card.vari-purple .paiva-num { color: #7c3aed; }

/* Julkinen tapahtuma - korostettu reunus */
.tapahtuma-card.julkinen {
  border: 2px solid #d8b4fe;
  border-left-width: 4px;
}

.paiva-kk {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}

.tapahtuma-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tapahtuma-otsikko {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.tapahtuma-kuvaus {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.tapahtuma-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin-top: 0.5rem;
}

/* Värin valitsin modalissa */
.vari-picker {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 0.5rem 0;
}

.vari-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.25rem;
  position: relative;
}

.vari-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.vari-dot {
  display: inline-block;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.15s;
  flex-shrink: 0;
  flex-grow: 0;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
}

.vari-option:hover .vari-dot {
  transform: scale(1.15);
}

.vari-option input[type="radio"]:checked + .vari-dot {
  border-color: var(--text);
  transform: scale(1.1);
}

.vari-nimi {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.vari-dot.vari-primary { background: #60a5fa; }
.vari-dot.vari-success { background: var(--success); }
.vari-dot.vari-warning { background: var(--warning); }
.vari-dot.vari-danger { background: var(--danger); }
.vari-dot.vari-purple { background: #8b5cf6; }

/* Emoji-valitsin */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.emoji-btn {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.emoji-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary);
}

/* Ilmoituskortin emoji */
.ilmoitus-emoji {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Ilmoituksen luku-modalin emoji */
.ilmoitus-read-emoji {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.empty-kalenteri {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-kalenteri svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-kalenteri p {
  margin: 0;
}

/* ========= TUKI-MERKINNÄT (sydän) ========= */

/* Sydän-nappi aktiivisena */
#btn-toggle-tuki.active {
  background: #ffe4e6;
  color: #e11d48;
  border-color: #fda4af;
}

#btn-toggle-tuki.active svg {
  fill: #e11d48;
  stroke: #e11d48;
}

/* Ohjaus-tila päällä: muuta kursori ja hover */
.grade-table-area.tuki-mode .grade-cell .dot:not(.dot-empty) {
  cursor: pointer;
}

.grade-table-area.tuki-mode .grade-cell .dot:not(.dot-empty):hover {
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.3);
}

/* Sydän-ikoni pallon sisällä (ohjattu suoritus) */
.tuki-sydän {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 10px;
  color: #e11d48;
  text-shadow: 0 0 2px white, 0 0 2px white;
  line-height: 1;
  pointer-events: none;
}

/* Varmista että pallossa/arvosanassa on position: relative */
.grade-cell .dot,
.grade-cell .exam-ball,
.grade-cell .show-ball {
  position: relative;
}

/* Ohjaus-tila päällä: myös kokeet ja näytöt klikattavia */
.grade-table-area.tuki-mode .grade-cell .exam-ball,
.grade-table-area.tuki-mode .grade-cell .show-ball {
  cursor: pointer;
}

.grade-table-area.tuki-mode .grade-cell .exam-ball:hover,
.grade-table-area.tuki-mode .grade-cell .show-ball:hover {
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.3);
}


/* ========= VAHVUUDET ========= */

.vahvuus-kategoria {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 12px;
  border-left: 4px solid var(--primary);
}

.vahvuus-kategoria-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.vahvuus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.vahvuus-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 2px solid rgba(245, 158, 11, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.9rem;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.vahvuus-item:hover {
  background: #fef3c7;
  border-color: #fbbf24;
}

.vahvuus-item.selected {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: #22c55e;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

.vahvuus-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #22c55e;
}

.vahvuus-item span {
  flex: 1;
  hyphens: auto;
  -webkit-hyphens: auto;
  line-height: 1.3;
}

/* Vahvuudet oppilaskortilla */
.vahvuudet-section {
  margin-top: 1rem;
}

.vahvuudet-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vahvuus-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  background: #dcfce7;
  color: #166534;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  word-break: break-word;
  max-width: 100%;
}

.vahvuus-badge::before {
  content: "⚡";
  font-size: 0.7rem;
}


/* ========= FEATURE TOGGLES (Asetukset) ========= */

.feature-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.feature-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.feature-toggle:hover {
  background: var(--primary-soft);
}

.feature-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.feature-toggle span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.feature-toggle span svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* Mobiili vaakatasossa (landscape) - piilota ylimääräiset ikonit */
@media (max-height: 500px) and (orientation: landscape) {
  #btn-open-vahvuudet,
  #btn-toggle-tuki,
  #btn-open-report {
    display: none;
  }

  .user-menu .mobile-nav {
    display: flex;
  }

  .nav-links {
    display: none;
  }
}
