/* ============================================================
   Matikan korotus -modaali (näkyy Symmathin kautta käytettäessä)
   ============================================================ */

/* --- Kelluva avausnappi --- */
.korotus-fab {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 14px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(99, 102, 241, .38);
  transition: transform .18s ease, box-shadow .18s ease;
}
.korotus-fab:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(99,102,241,.45); }
.korotus-fab:active { transform: translateY(0); }
.korotus-fab .korotus-fab-icon {
  display: inline-flex;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  align-items: center; justify-content: center;
  font-size: 16px;
}
.korotus-fab .korotus-fab-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  opacity: .85;
  margin-top: -2px;
}

/* --- Modaalin sisältö --- */
.korotus-scope { font-family: 'Nunito', sans-serif; color: #1f2937; }
.korotus-scope * { box-sizing: border-box; }

/* Nollataan sovelluksen yleiset button-tehosteet (padding, hehku, hover-kallistus)
   modaalin sisällä — muuten pikkunapit venyvät ja "leijuvat" vinossa. */
.korotus-scope button,
.korotus-scope button:hover,
.korotus-scope button:active {
  transform: none;
  box-shadow: none;
  font-family: 'Nunito', sans-serif;
}
.korotus-scope .korotus-btn-primary { box-shadow: 0 6px 14px rgba(99,102,241,.3); }
.korotus-scope .korotus-icon-btn,
.korotus-scope .korotus-target-btn,
.korotus-scope .korotus-cal-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.korotus-shell { width: 100%; max-width: 980px; margin: 0 auto; padding: 6px 8px 28px; overflow-x: hidden; }

/* Yläkortti */
.korotus-hero {
  border-radius: 20px;
  padding: 20px 22px;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 55%, #fdf4ff 100%);
  border: 1px solid rgba(129, 140, 248, .35);
  margin-bottom: 16px;
}
.korotus-hero-top { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.korotus-hero h2 { margin: 0; font-size: 20px; font-weight: 900; color: #312e81; }
.korotus-hero .korotus-hero-user { font-size: 13px; color: #6d6a8f; font-weight: 700; }
.korotus-hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.korotus-stat {
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(129,140,248,.25);
  border-radius: 14px;
  padding: 10px 14px;
}
.korotus-stat .k-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: #8187a8; }
.korotus-stat .k-value { font-size: 21px; font-weight: 900; color: #312e81; line-height: 1.25; }
.korotus-stat .k-value small { font-size: 12px; font-weight: 700; color: #8187a8; }
.korotus-stat.k-good .k-value { color: #047857; }
.korotus-stat.k-warn .k-value { color: #b45309; }

/* Tavoitearvosana */
.korotus-target-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.korotus-target-row .k-label { font-size: 12.5px; font-weight: 800; color: #4b5563; margin-right: 2px; }
.korotus-target-btn {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  border: 2px solid #d7d9f2;
  background: #fff;
  font-family: inherit;
  font-size: 16px; font-weight: 900; color: #4f46e5;
  cursor: pointer;
  transition: all .15s ease;
}
.korotus-target-btn:hover { border-color: #818cf8; transform: translateY(-1px); }
.korotus-target-btn.is-active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(99,102,241,.35);
}
.korotus-target-hint { font-size: 12px; color: #6b7280; font-weight: 700; }

/* Edistymispalkki rajoineen */
.korotus-progressbar { position: relative; height: 46px; margin: 22px 6px 8px; }
.korotus-progress-track {
  position: absolute; top: 24px; left: 0; right: 0; height: 10px;
  border-radius: 999px; background: #e5e7f5; overflow: hidden;
}
.korotus-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #6366f1);
  transition: width .5s ease;
}
.korotus-progress-tick { position: absolute; top: 18px; width: 2px; height: 22px; background: #c3c6e6; }
.korotus-progress-tick.is-target { background: #f59e0b; width: 3px; }
.korotus-progress-tick span {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 900; color: #8187a8;
}
.korotus-progress-tick.is-target span { color: #b45309; }
.korotus-progress-tick.is-passed span { color: #047857; }

/* Välilehdet */
.korotus-tabs { display: flex; gap: 6px; margin: 4px 0 16px; flex-wrap: wrap; }
.korotus-tab {
  border: 1px solid #e2e4f0;
  background: #fff;
  border-radius: 999px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13.5px; font-weight: 800; color: #4b5563;
  cursor: pointer;
  transition: all .15s ease;
}
.korotus-tab:hover { border-color: #a5b4fc; color: #4338ca; }
.korotus-tab.is-active {
  background: #312e81; border-color: #312e81; color: #fff;
  box-shadow: 0 6px 14px rgba(49,46,129,.25);
}

/* --- Listanäkymä --- */
.korotus-course-block { margin-bottom: 18px; }
.korotus-course-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; margin-bottom: 6px;
}
.korotus-course-head h3 { margin: 0; font-size: 14.5px; font-weight: 900; color: #374151; }
.korotus-course-head .k-course-pts { font-size: 12.5px; font-weight: 800; color: #6b7280; }
.korotus-table { display: flex; flex-direction: column; gap: 8px; }
.korotus-row {
  display: grid;
  grid-template-columns: 26px minmax(150px, 1.6fr) auto minmax(120px, .9fr) 92px auto;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid #ecedf5;
  border-radius: 14px;
  padding: 10px 14px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.korotus-row:hover { border-color: #c7d2fe; box-shadow: 0 6px 16px rgba(49,46,129,.08); }
.korotus-row.is-done { background: #f6fdf9; border-color: #bbe9d2; }

.korotus-status {
  position: relative;
  width: 16px; height: 16px; border-radius: 50%;
  justify-self: center;
  cursor: help;
}
.korotus-status.k-ready { background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,.16); }
.korotus-status.k-not-ready { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,.14); }
.korotus-status.k-none { background: #d1d5db; box-shadow: 0 0 0 4px rgba(209,213,219,.25); cursor: default; }
.korotus-status .korotus-tooltip {
  display: none;
  position: absolute; z-index: 40;
  left: 20px; top: -6px;
  min-width: 230px;
  background: #1f2937; color: #f9fafb;
  border-radius: 10px; padding: 10px 12px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}
.korotus-status:hover .korotus-tooltip { display: block; }
.korotus-tooltip .kt-ok { color: #6ee7b7; }
.korotus-tooltip .kt-no { color: #fca5a5; }

.korotus-row .k-title { font-size: 14px; font-weight: 800; color: #1f2937; }
.korotus-row .k-title small { display: block; font-size: 11px; font-weight: 700; color: #9ca3af; }

.korotus-badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .4px;
  border-radius: 999px; padding: 3px 10px;
  background: #eef2ff; color: #4338ca;
}
.korotus-badge.k-esitelma { background: #fef3c7; color: #92400e; }
.korotus-badge.k-lisatehtava { background: #ecfdf5; color: #065f46; }

.korotus-date-input {
  font-family: inherit;
  font-size: 12.5px; font-weight: 700; color: #374151;
  border: 1px solid #e2e4f0; border-radius: 10px;
  padding: 7px 9px;
  background: #fafaff;
  width: 100%;
  max-width: 150px;
}
.korotus-date-input:focus { outline: none; border-color: #818cf8; }

.korotus-points { text-align: right; font-size: 15px; font-weight: 900; color: #4b5563; white-space: nowrap; }
.korotus-points .k-max { font-size: 11.5px; color: #9ca3af; font-weight: 800; }
.korotus-points.k-has { color: #047857; }
.korotus-points-input {
  width: 58px;
  font-family: inherit; font-size: 14px; font-weight: 900; color: #047857;
  text-align: center;
  border: 1px solid #d3ded8; border-radius: 10px;
  padding: 7px 4px;
  background: #fbfefc;
}
.korotus-points-input:focus { outline: none; border-color: #10b981; }

.korotus-row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.korotus-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #e2e4f0; background: #fff;
  width: 32px; height: 32px; padding: 0; border-radius: 9px;
  font-size: 13px; line-height: 1; cursor: pointer; color: #6b7280;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.korotus-icon-btn svg { display: block; }
.korotus-icon-btn:hover { border-color: #a5b4fc; color: #4338ca; }
.korotus-icon-btn.k-danger:hover { border-color: #fca5a5; color: #b91c1c; background: #fef2f2; }

/* --- Kalenteri --- */
.korotus-cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.korotus-cal-head h3 { margin: 0; font-size: 16px; font-weight: 900; color: #312e81; text-transform: capitalize; }
.korotus-cal-nav { display: flex; gap: 6px; }
.korotus-cal-nav button {
  border: 1px solid #e2e4f0; background: #fff;
  border-radius: 10px; width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900; color: #4b5563; cursor: pointer;
}
.korotus-cal-nav button:hover { border-color: #a5b4fc; color: #4338ca; }
.korotus-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
}
.korotus-cal-dow {
  text-align: center; font-size: 11px; font-weight: 900; color: #9ca3af;
  text-transform: uppercase; padding: 4px 0;
}
.korotus-cal-day {
  min-height: 72px;
  border: 1px solid #eef0f7;
  border-radius: 12px;
  padding: 5px 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.korotus-cal-day:hover { border-color: #a5b4fc; background: #fafaff; }
.korotus-cal-day.k-other { opacity: .38; }
.korotus-cal-day.k-today { border-color: #6366f1; box-shadow: inset 0 0 0 1px #6366f1; }
.korotus-cal-day.k-selected { background: #eef2ff; border-color: #6366f1; }
.korotus-cal-day .k-num { font-size: 11.5px; font-weight: 900; color: #6b7280; }
.korotus-cal-day.k-today .k-num { color: #4338ca; }
.korotus-cal-chip {
  display: block;
  margin-top: 3px;
  font-size: 10.5px; font-weight: 800;
  border-radius: 7px; padding: 2px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: #e0e7ff; color: #3730a3;
}
.korotus-cal-chip.k-scored { background: #d1fae5; color: #065f46; }
.korotus-cal-chip.k-late { background: #fef3c7; color: #92400e; }

.korotus-cal-detail {
  margin-top: 12px;
  border: 1px solid #e2e4f0;
  border-radius: 14px;
  background: #fafaff;
  padding: 14px 16px;
}
.korotus-cal-detail h4 { margin: 0 0 8px; font-size: 14px; font-weight: 900; color: #312e81; }
.korotus-cal-detail .k-empty { font-size: 13px; color: #6b7280; font-weight: 600; }
.korotus-cal-detail-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed #e5e7f0;
  font-size: 13px; font-weight: 700; color: #374151;
}
.korotus-cal-detail-row:last-child { border-bottom: none; }
.korotus-mini-btn {
  border: 1px solid #e2e4f0; background: #fff;
  border-radius: 999px; padding: 5px 12px;
  font-family: inherit; font-size: 11.5px; font-weight: 800; color: #4338ca;
  cursor: pointer;
}
.korotus-mini-btn:hover { border-color: #a5b4fc; background: #eef2ff; }
.korotus-mini-btn.k-danger { color: #b91c1c; }
.korotus-mini-btn.k-danger:hover { border-color: #fca5a5; background: #fef2f2; }

/* --- Kuvaajanäkymä --- */
.korotus-chart-wrap {
  background: #fff; border: 1px solid #ecedf5; border-radius: 16px;
  padding: 16px; margin-bottom: 14px;
}
.korotus-chart-wrap h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 900; color: #374151; }
.korotus-chart-canvas { position: relative; height: 300px; }
.korotus-chart-canvas.k-small { height: 240px; }

/* --- Opettajanäkymä --- */
.korotus-crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.korotus-crumb {
  border: none; background: none; padding: 0;
  font-family: inherit; font-size: 13px; font-weight: 800; color: #4f46e5; cursor: pointer;
}
.korotus-crumb:hover { text-decoration: underline; }
.korotus-crumb-sep { color: #9ca3af; font-weight: 800; }
.korotus-crumb-current { font-size: 13px; font-weight: 800; color: #374151; }

.korotus-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.korotus-group-card {
  border: 1px solid #ecedf5; border-radius: 16px; background: #fff;
  padding: 16px 18px; cursor: pointer; text-align: left;
  font-family: inherit;
  transition: all .15s ease;
}
.korotus-group-card:hover { border-color: #a5b4fc; box-shadow: 0 8px 20px rgba(49,46,129,.10); transform: translateY(-2px); }
.korotus-group-card .k-code { font-size: 15px; font-weight: 900; color: #312e81; }
.korotus-group-card .k-name { font-size: 12.5px; font-weight: 700; color: #6b7280; margin-top: 2px; }
.korotus-group-card .k-count { margin-top: 10px; font-size: 12px; font-weight: 800; color: #4f46e5; }

.korotus-table-scroll { overflow-x: auto; }
.korotus-studenttable { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0 6px; }
.korotus-studenttable th {
  text-align: left; font-size: 11px; font-weight: 900; text-transform: uppercase;
  letter-spacing: .4px; color: #9ca3af; padding: 0 12px 2px;
}
.korotus-studenttable td {
  background: #fff; border-top: 1px solid #ecedf5; border-bottom: 1px solid #ecedf5;
  padding: 11px 12px; font-size: 13.5px; font-weight: 700; color: #374151;
}
.korotus-studenttable tr td:first-child { border-left: 1px solid #ecedf5; border-radius: 12px 0 0 12px; }
.korotus-studenttable tr td:last-child { border-right: 1px solid #ecedf5; border-radius: 0 12px 12px 0; }
.korotus-studenttable tbody tr { cursor: pointer; transition: transform .1s ease; }
.korotus-studenttable tbody tr:hover td { border-color: #c7d2fe; background: #fafaff; }
.korotus-grade-chip {
  display: inline-block; min-width: 30px; text-align: center;
  border-radius: 8px; padding: 3px 8px;
  background: #eef2ff; color: #4338ca; font-weight: 900; font-size: 13px;
}
.korotus-grade-chip.k-none { background: #f3f4f6; color: #9ca3af; }

/* Lisää kenttä -lomake */
.korotus-addform {
  border: 1px dashed #c7d2fe; border-radius: 14px;
  background: #fafaff; padding: 14px 16px; margin-top: 14px;
}
.korotus-addform h4 { margin: 0 0 10px; font-size: 13.5px; font-weight: 900; color: #4338ca; }
.korotus-addform .k-form-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.korotus-addform input[type="text"],
.korotus-addform input[type="number"],
.korotus-addform input[type="date"],
.korotus-addform select {
  font-family: inherit; font-size: 13px; font-weight: 700; color: #374151;
  border: 1px solid #e2e4f0; border-radius: 10px; padding: 8px 10px; background: #fff;
}
.korotus-addform input[type="text"] { flex: 1 1 180px; }
.korotus-btn-primary {
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-family: inherit; font-size: 13px; font-weight: 800;
  padding: 9px 20px; cursor: pointer;
  box-shadow: 0 6px 14px rgba(99,102,241,.3);
}
.korotus-btn-primary:hover { filter: brightness(1.06); }

.korotus-note { font-size: 12px; color: #6b7280; font-weight: 600; margin-top: 8px; }
.korotus-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 700;
  margin: 8px 0;
}
.korotus-loader { text-align: center; padding: 40px 0; color: #6b7280; font-weight: 700; }

@media (max-width: 720px) {
  .korotus-row { grid-template-columns: 22px 1fr auto; grid-auto-rows: auto; row-gap: 6px; }
  .korotus-row .k-cell-date, .korotus-row .korotus-points, .korotus-row .korotus-row-actions { grid-column: 2 / -1; justify-self: start; text-align: left; }
  .korotus-cal-day { min-height: 54px; }
  .korotus-fab { right: 14px; bottom: 16px; padding: 10px 16px 10px 12px; }
}
