:root{
  --sp3-blue:#24517a;
  --sp3-blue-dark:#173a59;
  --sp3-blue-light:#eef4f9;
  --sp3-border:#c8d6e2;
  --sp3-text:#1c2730;
  --sp3-muted:#647380;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  background:#fff;
  color:var(--sp3-text);
  font:14px Verdana,Arial,sans-serif;
  margin:0;
  min-width:0;
}
.tabtytul{
  width:100%;
  background:var(--sp3-blue);
  border:0;
  border-bottom:2px solid var(--sp3-blue-dark);
  border-collapse:collapse;
}
.tytul{
  height:76px;
  padding:0 20px;
  background:var(--sp3-blue);
  color:#fff;
  font:bold 30px Verdana,Arial,sans-serif;
  text-align:center;
  border:0;
}
.tytul img{height:76px!important;width:1px!important}
.tytulnapis{padding:0}

/* Główny układ strony */
body > table:nth-of-type(2){
  width:min(1180px,calc(100% - 32px));
  margin:24px auto 36px!important;
  border-collapse:separate;
  border-spacing:0 18px;
}
body > table:nth-of-type(2) > tbody > tr{
  display:grid;
  grid-template-columns:150px minmax(0,1fr);
  gap:18px;
  align-items:start;
}
body > table:nth-of-type(2) > tbody > tr + tr{
  margin-top:30px;
}
body > table:nth-of-type(2) > tbody > tr > td{
  padding:0!important;
  min-width:0;
}
.ng{
  padding:11px 12px;
  background:var(--sp3-blue);
  color:#fff;
  border:1px solid var(--sp3-blue-dark);
  border-radius:8px;
  font-weight:bold;
  font-size:14px;
  text-align:center;
}

/* Stare tabele Optivum zmienione w responsywne kafelki */
table.tabela{
  display:block;
  width:100%;
  border:0;
  background:transparent;
}
table.tabela > tbody{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(170px,1fr));
  gap:8px;
  width:100%;
}
table.tabela > tbody > tr{display:contents}
table.tabela td{
  display:block;
  min-width:0;
  padding:0!important;
  border:0;
  font-size:13px;
}
table.tabela td a{
  display:flex;
  align-items:center;
  min-height:42px;
  width:100%;
  padding:9px 11px;
  border:1px solid var(--sp3-border);
  border-radius:7px;
  background:#fff;
  color:var(--sp3-blue-dark);
  text-decoration:none;
  line-height:1.25;
  overflow-wrap:anywhere;
}
table.tabela td a:visited{color:var(--sp3-blue-dark)}
@media (hover:hover) and (pointer:fine){
  table.tabela td a:hover{
    background:var(--sp3-blue-light);
    border-color:var(--sp3-blue);
    text-decoration:none;
  }
}
table.tabela td a:focus-visible{
  outline:3px solid rgba(36,81,122,.28);
  outline-offset:2px;
}

/* Oddziały: mniejsze, bardziej zwarte kafelki */
body > table:nth-of-type(2) > tbody > tr:nth-child(1) table.tabela > tbody{
  grid-template-columns:repeat(auto-fit,minmax(72px,1fr));
}
body > table:nth-of-type(2) > tbody > tr:nth-child(1) table.tabela td a{
  justify-content:center;
  min-height:44px;
  padding:8px;
  font-weight:bold;
  font-size:15px;
}

/* Nauczyciele: kolejność alfabetyczna pionowo, od góry do dołu */
body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela > tbody{
  grid-template-columns:repeat(3,minmax(0,1fr));
  grid-template-rows:repeat(14,auto);
  grid-auto-flow:column;
}

@media (max-width:980px) and (min-width:701px){
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela > tbody{
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-rows:repeat(21,auto);
    grid-auto-flow:column;
  }
}

/* Sale mogą być nieco węższe od nazwisk */
body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela > tbody{
  grid-template-columns:repeat(auto-fit,minmax(150px,1fr));
}

@media (max-width:700px){
  .tytul{height:62px;font-size:24px;padding:0 12px}
  .tytul img{height:62px!important}
  body > table:nth-of-type(2){
    width:calc(100% - 20px);
    margin:12px auto 24px!important;
    border-spacing:0 14px;
  }
  body > table:nth-of-type(2) > tbody > tr{
    display:block;
  }
  body > table:nth-of-type(2) > tbody > tr + tr{
    margin-top:24px;
  }
  body > table:nth-of-type(2) > tbody > tr > td:first-child{
    margin-bottom:8px;
  }
  .ng{
    text-align:left;
    padding:9px 11px;
    border-radius:7px;
    font-size:13px;
  }
  table.tabela > tbody{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:7px;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela > tbody{
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-rows:repeat(21,auto);
    grid-auto-flow:column;
  }
  table.tabela td a{
    min-height:44px;
    padding:9px 9px;
    font-size:12px;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(1) table.tabela > tbody{
    grid-template-columns:repeat(4,minmax(0,1fr));
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(1) table.tabela td a{
    font-size:14px;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela > tbody{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media (max-width:390px){
  table.tabela > tbody,
  body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela > tbody{
    grid-template-columns:1fr;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela > tbody{
    grid-template-columns:1fr;
    grid-template-rows:none;
    grid-auto-flow:row;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(1) table.tabela > tbody{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
}

@media print{
  .tabtytul{display:none}
  body > table:nth-of-type(2){width:100%;margin:0!important}
  body > table:nth-of-type(2) > tbody > tr{display:block;margin-bottom:15px}
  table.tabela > tbody{display:block}
  table.tabela > tbody > tr{display:table-row}
  table.tabela td{display:table-cell;padding:3px!important}
  table.tabela td a{display:inline;border:0;padding:0;min-height:0}
}

/* SP3 v8 — prawdziwy viewport mobilny + zabezpieczenie bardzo wąskich ekranów */
@media (max-width:700px){
  html,body{width:100%;max-width:100%;overflow-x:hidden}
  body > table:nth-of-type(2){max-width:100%}
  table.tabela{max-width:100%}
}

/* SP3 v10 — mobilne sekcje: nagłówek nad kafelkami, nauczyciele i sale w 2 kolumnach */
@media (max-width:700px){
  body > table:nth-of-type(2) > tbody > tr{
    display:block !important;
    width:100%;
    margin:0 0 30px !important;
  }
  body > table:nth-of-type(2) > tbody > tr > td{
    display:block !important;
    width:100% !important;
  }
  body > table:nth-of-type(2) > tbody > tr > td:first-child{
    margin:0 0 10px !important;
  }
  .ng{
    display:block;
    width:100%;
    margin:0;
    padding:10px 12px;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela > tbody,
  body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela > tbody{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    gap:7px;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela td a,
  body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela td a{
    font-size:11.5px;
    padding:8px 7px;
    min-height:42px;
  }
}
@media (max-width:390px){
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela > tbody,
  body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela > tbody{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
  body > table:nth-of-type(2) > tbody > tr:nth-child(2) table.tabela td a,
  body > table:nth-of-type(2) > tbody > tr:nth-child(3) table.tabela td a{
    font-size:10.5px;
    padding:7px 6px;
  }
}
