@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #F5F6FA;
  --paper: #FFFFFF;
  --ink: #232842;
  --ink-soft: #6B7089;
  --line: #E4E6F0;
  --primary: #35408E;
  --primary-soft: #EEF0FA;
  --accent-mint: #2BA98A;
  --accent-amber: #D98032;
  --ring-track: #E7E9F3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 40, 66, 0.04), 0 8px 24px -12px rgba(35, 40, 66, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 32px;
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.no-lines { background-image: none; }

a { color: inherit; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.topbar .who {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.topbar .who small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.btn-logout {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  padding: 9px 16px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-logout:hover { border-color: var(--primary); color: var(--primary); }
.btn-logout:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Announcements ---------- */

.announcements {
  margin: 18px 0 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--accent-amber);
  padding: 16px 18px 14px;
}

.announcements-head {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-amber);
  margin-bottom: 10px;
}

.announcements-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.announcements-list li {
  position: relative;
  padding: 10px 12px 10px 14px;
  background: #FBF6EE;
  border: 1px solid #F0E1C4;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

/* ---------- Module grid ---------- */

.modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.module-card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
  padding-left: 28px;
  overflow: hidden;
}

.module-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--tab-color, var(--primary));
}

.module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.module-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
}

/* SVG ring */
.ring-wrap { position: relative; width: 58px; height: 58px; flex: none; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 6; }
.ring-value { fill: none; stroke: var(--tab-color, var(--primary)); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}

/* Topics */
.topics { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.topic-row { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center; }

.topic-name { font-size: 13.5px; color: var(--ink); line-height: 1.35; }

.topic-percent {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  min-width: 34px;
  text-align: right;
}

.topic-bar-track {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 4px;
  background: var(--ring-track);
  overflow: hidden;
}
.topic-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--tab-color, var(--primary));
  transition: width .6s ease;
}

/* Toggle buttons — только «смотреть» */
.actions-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
}
.actions-row .toggle-btn {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
}

.toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.toggle-btn:hover { background: #E3E7FA; }
.toggle-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle-btn .chev { transition: transform .25s ease; flex-shrink: 0; }
.toggle-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.toggle-btn .toggle-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cl-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.cl-header .hw-label { margin-bottom: 0; }

.pdf-link {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.pdf-link:hover { text-decoration: underline; }
.pdf-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.details {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.details.open { grid-template-rows: 1fr; }
.details-inner { overflow: hidden; }

.hw-block {
  margin-top: 14px;
  padding: 14px 14px;
  background: #FBF6EE;
  border: 1px solid #F0E1C4;
  border-radius: 10px;
}
.hw-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-amber);
  margin-bottom: 6px;
}
.hw-text { font-size: 13.5px; line-height: 1.5; color: var(--ink); }

.checklist { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  line-height: 1.4;
}
.check-mark {
  flex: none;
  width: 17px; height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.checklist li.done .check-mark { background: var(--accent-mint); border-color: var(--accent-mint); }
.checklist li.done .check-mark::after { content: "✓"; color: #fff; font-size: 11px; font-weight: 700; }
.checklist li.done span { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--line); }

.empty-note { font-size: 13px; color: var(--ink-soft); font-style: italic; }

/* Архив (прошлые периоды) */
.archive-section { margin-top: 24px; }

.archive-btn {
  max-width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.archive-btn:hover { background: var(--primary-soft); }
.archive-btn:disabled { opacity: .6; cursor: default; }

#archive-container.modules { margin-top: 18px; }
/* .modules { display:grid } иначе перебивает атрибут hidden */
#archive-container[hidden] {
  display: none !important;
  margin-top: 0;
}

.module-card.archived { opacity: .88; }
.archived-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  background: var(--ring-track);
  padding: 3px 9px;
  border-radius: 20px;
  margin-left: 8px;
  vertical-align: middle;
}

/* Checklist panel (Содержание / Критерии / Материалы по каждой теме) */
.cl-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.cl-topic {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.cl-topic-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 6px;
}
.cl-field { font-size: 12.5px; line-height: 1.55; margin-top: 5px; color: var(--ink); }
.cl-field-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 1px;
}

/* ---------- Login page ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px 32px;
}

.login-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 8px;
}

.login-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  transition: border-color .15s ease;
}
.field input:focus { outline: none; border-color: var(--primary); background: var(--paper); }

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  transition: background .15s ease;
}
.btn-primary:hover { background: #2A337A; }
.btn-primary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.error-msg {
  background: #FDEEEE;
  border: 1px solid #F3CACA;
  color: #B23A3A;
  font-size: 13px;
  padding: 10px 13px;
  border-radius: 9px;
  margin-bottom: 16px;
}

.demo-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .wrap { padding: 20px 14px 60px; }
  .topbar { padding: 16px 18px; }
  .modules { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
