:root {
  color-scheme: light;
  --bg: #eef2ef;
  --card: #ffffff;
  --text: #101a14;
  --text-2: #2c3a32;
  --muted: #55645b;
  --line: #d3dcd6;
  --brand: #14532d;
  --brand-2: #1f7a3f;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe1;
  --brand-text: #14532d;
  --para-bg: #a9d8b8;
  --para-text: #0d3f21;
  --chip: #e7ece9;
  --accent: #b45309;
  --accent-soft: #fdf0d8;
  --accent-text: #7c3a06;
  --shadow: 0 1px 2px rgba(16, 40, 25, .08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1411;
  --card: #1a221e;
  --text: #f4f8f5;
  --text-2: #d5e0d9;
  --muted: #a6b5ac;
  --line: #36423b;
  --brand: #14532d;
  --brand-2: #1f7a3f;
  --brand-ink: #ffffff;
  --brand-soft: #1f3a2a;
  --brand-text: #9fe3ad;
  --para-bg: #2f6b47;
  --para-text: #e6f7ea;
  --chip: #2b3530;
  --accent: #f59e0b;
  --accent-soft: #44330f;
  --accent-text: #ffd98a;
  --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-text); }
[hidden] { display: none !important; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }

.top { background: linear-gradient(120deg, #14532d, #1f7a3f); color: var(--brand-ink); }
.top-in, .filters-in, .content, .foot { max-width: 1140px; margin: 0 auto; padding-left: 14px; padding-right: 14px; }
.top-in { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 18px; padding-top: 7px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding-bottom: 7px; color: inherit; text-decoration: none; }
.logo { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #fff; }
.logo img { max-width: 31px; max-height: 31px; display: block; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 1.14rem; line-height: 1.15; font-weight: 700; white-space: nowrap; }
.brand-text small { display: block; font-size: .72rem; opacity: .9; white-space: nowrap; }
.tabs { display: flex; gap: 2px; align-self: flex-end; }
.tabs a { padding: 7px 18px; border-radius: 10px 10px 0 0; color: inherit; font-weight: 600; text-decoration: none; }
.tabs a:hover { background: rgba(255, 255, 255, .14); }
.tabs a[aria-current="page"] { background: var(--card); color: var(--brand-text); }
.top-tools { display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto; padding-bottom: 7px; align-self: center; }
.tool { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .4); border-radius: 8px; background: rgba(255, 255, 255, .1); color: inherit; font-size: .82rem; text-decoration: none; cursor: pointer; }
.tool:hover { background: rgba(255, 255, 255, .22); }
.theme { padding: 0 7px; }

.filters { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.filters-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-top: 6px; padding-bottom: 6px; }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--chip); border-radius: 9px; }
.seg button { border: 0; background: none; height: 30px; padding: 0 11px; border-radius: 7px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); font-weight: 650; }
.dates { display: flex; gap: 8px; }
.dates label { display: flex; align-items: center; gap: 5px; font-size: .86rem; color: var(--muted); }
.dates input { height: 34px; padding: 0 8px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.fields { display: flex; gap: 8px; margin-left: auto; min-width: 0; }

.pick { position: relative; min-width: 0; width: 180px; }
.pick-wide { width: 260px; }
.pick-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pick-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; height: 34px; padding: 0 9px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; text-align: left; cursor: pointer; }
.pick-btn:hover { border-color: var(--brand-2); }
.pick-btn[aria-expanded="true"] { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-soft); }
.pick-value { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pick-value.none { color: var(--muted); }
.pick.has-value .pick-btn { border-color: var(--brand-2); background: var(--brand-soft); font-weight: 650; padding-right: 32px; }
.pick.has-value .chev { display: none; }
.chev { flex: none; width: 16px; height: 16px; color: var(--muted); transition: transform .12s; }
.pick-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.pick-clear { position: absolute; right: 2px; top: 2px; width: 30px; height: 30px; border: 0; border-radius: 7px; background: none; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.pop { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; display: flex; flex-direction: column; width: 100%; min-width: 240px; max-height: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .22); overflow: hidden; }
.pop-head { display: none; }
.pop-search { flex: none; padding: 6px; border-bottom: 1px solid var(--line); }
.pop-search input { width: 100%; height: 32px; padding: 0 8px; font-size: 15px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 7px; }
.pop-list { flex: 1 1 auto; margin: 0; padding: 3px; list-style: none; overflow-y: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.pop-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.pop-list li:hover, .pop-list li.active { background: var(--chip); }
.pop-list li[aria-selected="true"] { background: var(--brand-soft); color: var(--brand-text); font-weight: 650; }
.pop-list li[aria-selected="true"]::after { content: "✓"; }
.pop-empty { padding: 12px 8px; text-align: center; color: var(--muted); cursor: default !important; }
.pop-bg { display: none; }
.view-tasks .pick[data-key="room"] { display: none; }

.content { padding-top: 10px; padding-bottom: 14px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.side { display: none; }
.side-all, .side-list button { border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: pointer; }
.side-all { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 5px; padding: 4px 8px; font-weight: 600; }
.side-all .n { font-size: .78rem; font-weight: 500; }
.side-list { display: flex; flex-wrap: wrap; gap: 3px; }
.side-list button { flex: 1 0 auto; min-width: 46px; padding: 3px 5px; font-weight: 500; font-size: .86rem; line-height: 1.25; }
.side-all:hover, .side-list button:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.side [aria-pressed="true"], .side [aria-pressed="true"]:hover { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }

.day { margin-bottom: 14px; }
.day:last-child { margin-bottom: 0; }
.day-head { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 8px; margin: 0 0 5px; font-size: 1.04rem; font-weight: 600; }
.badge { font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--brand); color: var(--brand-ink); }
.count { font-size: .8rem; font-weight: 400; color: var(--muted); }
.list, .tlist { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.thead { display: none; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 3px 10px; border: 0; border-top: 1px solid var(--line); background: var(--para-bg); color: var(--para-text); font-size: .92rem; font-weight: 600; text-align: left; cursor: pointer; }
.group-head:hover { background: var(--brand-2); color: var(--brand-ink); }
.group-head .n { font-size: .76rem; font-weight: 500; white-space: nowrap; }
.row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 1px 8px; align-items: start; padding: 5px 10px; border-top: 1px solid var(--line); }
.list > .row:first-child, .thead + .row, .thead + .group-head { border-top: 0; }
.group-head + .row { border-top: 0; }
.para { grid-row: 1 / span 3; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--para-bg); color: var(--para-text); font-weight: 600; font-size: .86rem; }
.time { grid-column: 2; color: var(--brand-text); font-size: .84rem; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.time:empty { display: none; }
.time.est { color: var(--muted); font-weight: 400; cursor: help; }
.subj { grid-column: 2; font-weight: 400; overflow-wrap: anywhere; }
.meta { grid-column: 2 / 4; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; color: var(--text-2); font-size: .88rem; }
.meta > :empty { display: none; }
.c-kind { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.chip { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--chip); color: var(--text); font-size: .78rem; font-weight: 500; line-height: 1.5; white-space: nowrap; }
.chip.g { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.c-act { grid-column: 3; grid-row: 1 / span 2; }
.c-act:empty { display: none; }
.task-btn { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent); font-size: .78rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.task-btn:hover { background: var(--accent); color: #fff; }
.task-btn.add { border-style: dashed; background: none; color: var(--muted); border-color: var(--muted); font-weight: 500; }

.trow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 5px 10px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.trow:hover { background: var(--brand-soft); }
.tlist .thead + .trow { border-top: 0; }
.t-open { display: none; }
.t-subj { grid-column: 1; grid-row: 1; font-weight: 400; overflow-wrap: anywhere; }
.t-srok { grid-column: 2; grid-row: 1; color: var(--accent-text); font-size: .86rem; font-weight: 500; white-space: nowrap; }
.t-line { grid-column: 1 / -1; color: var(--text-2); font-size: .88rem; }
.t-group { font-weight: 500; margin-right: 6px; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 196px minmax(0, 1fr); }
  .side { display: block; position: sticky; top: 56px; max-height: calc(100vh - 66px); overflow-y: auto; scrollbar-width: none; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
  .side::-webkit-scrollbar { display: none; }
  .pick[data-key="gruppa"] { display: none; }
  .list.report .thead { display: grid; grid-template-columns: 60px 340px 170px 50px; gap: 8px; padding: 4px 10px; background: var(--brand-soft); color: var(--brand-text); font-size: .78rem; font-weight: 700; }
  .list.report .thead > :last-child { text-align: right; }

  .list.wide { --cols: 24px 90px 250px 140px 58px minmax(0, 1fr) 68px; }
  .list.wide.with-group { --cols: 24px 90px 230px 54px 140px 58px minmax(0, 1fr) 68px; }
  .list.wide.no-act { --cols: 24px 90px 250px 140px 58px minmax(0, 1fr); }
  .list.wide.with-group.no-act { --cols: 24px 90px 230px 54px 140px 58px minmax(0, 1fr); }
  .list.wide .row, .list.wide .thead { grid-template-columns: var(--cols); gap: 8px; align-items: center; }
  .list.wide .row { padding-top: 3px; padding-bottom: 3px; }
  .list.wide .thead, .tlist .thead { display: grid; padding: 4px 10px; background: var(--brand-soft); color: var(--brand-text); font-size: .78rem; font-weight: 700; }
  .list.wide .thead > :first-child { margin-left: -2px; }
  .list.wide .para { grid-row: auto; }
  .list.wide .time, .list.wide .subj { grid-column: auto; }
  .list.wide .time:empty { display: block; }
  .list.wide .meta { display: contents; font-size: .88rem; }
  .list.wide .meta > :empty, .list.wide .c-act:empty { display: block; }
  .list.wide .c-teacher { color: var(--text-2); font-size: .88rem; }
  .list.wide .c-act { grid-column: auto; grid-row: auto; }
  .list.wide .room-pre { display: none; }

  .tlist { --tcols: 122px 230px 54px 140px minmax(0, 1fr); }
  .tlist.no-group { --tcols: 122px 250px 140px minmax(0, 1fr); }
  .tlist .thead, .tlist .trow { grid-template-columns: var(--tcols); gap: 8px; align-items: center; }
  .tlist .trow { padding-top: 5px; padding-bottom: 5px; }
  .tlist .t-line { display: contents; }
  .tlist .t-group { margin: 0; }
  .tlist .t-subj { grid-column: auto; grid-row: auto; }
  .tlist .t-srok { grid-column: auto; grid-row: auto; white-space: normal; overflow-wrap: anywhere; }
  .tlist .t-srok:empty::before { content: "—"; color: var(--muted); }
  .t-open { display: block; justify-self: end; color: var(--brand-text); font-size: .84rem; font-weight: 500; }
  .trow:not(:hover) .t-open { opacity: .65; }
}

.note { padding: 22px 14px; text-align: center; color: var(--text-2); }
.note button { display: block; margin: 8px auto 0; height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 600; cursor: pointer; }
.skel { height: 40px; margin-bottom: 5px; border-radius: 8px; background: var(--chip); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } .chev { transition: none; } }
.foot { padding-bottom: 14px; text-align: center; font-size: .82rem; }

.task-page { max-width: 760px; }
.back { display: inline-block; margin-bottom: 7px; font-weight: 600; text-decoration: none; }
.back:hover { text-decoration: underline; }
.task-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.task-head { padding: 11px 14px 10px; background: var(--brand-soft); }
.task-date { margin: 0 0 1px; color: var(--brand-text); font-weight: 600; font-size: .86rem; }
.task-head h1 { margin: 0; font-size: 1.24rem; line-height: 1.2; overflow-wrap: anywhere; }
.deadline { display: inline-block; margin: 6px 0 0; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent); font-size: .86rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin: 0; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.facts dt { font-size: .74rem; font-weight: 600; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.task-text { padding: 10px 14px 0; }
.task-text h2 { margin: 0 0 3px; font-size: .94rem; }
.task-text div { padding: 8px 10px; border-radius: 8px; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.42; }
.task-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; }
.btn { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font-weight: 600; font-size: .86rem; text-decoration: none; cursor: pointer; }
.btn.main { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.task-id { margin: 0; padding: 8px 14px 10px; font-size: .76rem; color: var(--muted); }
.saved, .form-error { margin: 0 0 8px; padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.saved { background: var(--brand-soft); color: var(--brand-text); }
.form-error { background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent); }

.form-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 0; }
.form-field { display: block; min-width: 0; }
.form-field > span { display: block; margin-bottom: 3px; font-size: .9rem; font-weight: 600; }
.form-field > small { display: block; margin: -2px 0 3px; color: var(--muted); font-size: .78rem; }
.form-field textarea, .form-field input, .form-field select, .report-teacher select { display: block; width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.form-field textarea { padding: 8px 10px; line-height: 1.42; resize: vertical; }
.form-field input, .form-field select { height: 36px; padding: 0 9px; }
.form-field textarea:focus, .form-field input:focus, .form-field select:focus, .report-teacher select:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { padding-bottom: 14px; }

.report-teacher { display: block; width: 260px; min-width: 0; }
.report-teacher select { height: 34px; padding: 0 8px; }
.report-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.report-sum div { padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.report-sum b { display: block; font-size: 1.3rem; font-weight: 600; line-height: 1.2; color: var(--brand-text); }
.report-sum span { font-size: .8rem; color: var(--muted); }
.report-row { display: grid; grid-template-columns: 60px 340px 170px 50px; gap: 8px; padding: 4px 10px; border-top: 1px solid var(--line); }
.report .thead + .report-row { border-top: 0; }
.report-row > :last-child { text-align: right; font-variant-numeric: tabular-nums; }
.report-total { padding: 3px 10px; background: var(--chip); font-size: .84rem; }
.report-total b { font-weight: 600; }

@media (max-width: 899px) {

  .trow { grid-template-columns: 62px auto minmax(0, 1fr); gap: 3px 8px; padding: 8px 10px; align-items: center; }
  .tlist.no-group .trow { grid-template-columns: auto minmax(0, 1fr); }
  .trow .t-line { display: contents; }
  .trow .t-group { grid-column: 1; grid-row: 1 / span 2; align-self: start; margin: 0; padding: 3px 2px; border-radius: 6px; background: var(--para-bg); color: var(--para-text); font-size: .82rem; font-weight: 600; line-height: 1.25; text-align: center; white-space: nowrap; }
  .trow .t-subj { grid-column: 2 / -1; grid-row: 1; font-weight: 500; line-height: 1.25; }
  .tlist.no-group .trow .t-subj { grid-column: 1 / -1; }
  .trow .t-teacher { grid-column: 2; grid-row: 2; color: var(--muted); font-size: .84rem; white-space: nowrap; }
  .tlist.no-group .trow .t-teacher { grid-column: 1; }
  .trow .t-srok { grid-column: 3; grid-row: 2; justify-self: end; padding: 0 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-text); font-size: .78rem; font-weight: 500; line-height: 1.5; text-align: right; white-space: normal; }
  .tlist.no-group .trow .t-srok { grid-column: 2; }
  .trow .t-srok::before { content: "Срок: "; font-weight: 400; }
  .trow .t-srok:empty { display: none; }
  .fields { width: 100%; margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .pick, .pick-wide { width: auto; }
  .pick-wide { grid-column: 1 / -1; grid-row: 2; }
  .view-tasks .pick-wide { grid-column: auto; grid-row: auto; }
}
@media (max-width: 720px) {
  .top-in { padding-top: 6px; align-items: center; }
  .brand, .top-tools { padding-bottom: 4px; }
  .logo { width: 32px; height: 32px; border-radius: 8px; }
  .logo img { max-width: 26px; max-height: 26px; }
  .brand { gap: 8px; }
  .brand-text strong { font-size: 1.04rem; }
  .brand-text small { display: none; }
  .tool:not(.theme) { display: none; }
  .tabs { order: 9; width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 6px; }
  .filters { position: static; }
  .seg { width: 100%; }
  .seg button { flex: 1 1 0; padding: 0 2px; font-size: .88rem; }
  .dates { width: 100%; }
  .dates label { flex: 1 1 0; min-width: 0; }
  .dates input { flex: 1 1 0; width: 100%; font-size: 15px; }
  .pick-btn { font-size: 15px; }
  .pop-bg:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 19; background: rgba(0, 0, 0, .5); }
  .pop { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 72vh; max-height: 72dvh; border: 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .pop-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px 2px; font-size: 1.04rem; font-weight: 700; }
  .pop-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--chip); font-size: 1.15rem; cursor: pointer; }
  .pop-search input { height: 38px; font-size: 16px; }
  .pop-list li { min-height: 44px; padding: 6px 10px; font-size: 1rem; }
  .facts { grid-template-columns: 1fr 1fr; }
  .form-field textarea, .form-field input, .form-field select { font-size: 16px; }
  .report-teacher { flex: 1 1 auto; width: auto; }
  .report-teacher select { font-size: 15px; }
  .filters .fields:has(.report-teacher) { display: flex; }
  .report-sum { grid-template-columns: 1fr 1fr; }
  .report-row { grid-template-columns: 54px minmax(0, 1fr) 34px; }
  .report-row > :nth-child(3) { grid-column: 2; grid-row: 2; color: var(--muted); font-size: .84rem; }
  .report-row > :last-child { grid-column: 3; grid-row: 1; }
}
@media (min-width: 721px) and (max-width: 899px) {
  .report-row { grid-template-columns: 60px minmax(0, 1fr) 150px 44px; }
}
