:root {
  --ink: #18202a;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --brand: #0f5367;
  --brand-strong: #0b4558;
  --accent: #157c76;
  --danger: #b42318;
  --warning: #a15c00;
  --shadow: 0 18px 50px rgba(22, 34, 51, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef3f8;
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.app-frame {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  min-height: 72px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.home-quick-access {
  position: relative;
  z-index: 18;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: #f8fbfe;
  border-bottom: 1px solid var(--line);
}

.user-session-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.user-session-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  background: #e1ebf4;
  border: 1px solid #c2d5e5;
  border-radius: 50%;
}

.user-session-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brand);
  background: #e2eff5;
  padding: 1px 8px;
  border-radius: 999px;
  align-self: flex-start;
}

.user-display-name {
  font-size: 0.92rem;
  color: var(--ink);
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: #fca5a5;
  background: #fff5f5;
}

.logout-btn svg {
  width: 14px;
  height: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.context-label,
.rail-header span,
.period-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.quick-access {
  position: relative;
}

.quick-access[hidden] {
  display: none !important;
}

.quick-access-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 83, 103, 0.16);
}

.quick-access-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 6px;
  width: 260px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-access-menu[hidden] {
  display: none;
}

.quick-access-option {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.quick-access-option span {
  color: var(--muted);
  font-size: 0.82rem;
}

.quick-access-option:hover,
.quick-access-option.active {
  border-color: rgba(15, 83, 103, 0.2);
  background: #edf7f8;
}

.week-chip {
  display: grid;
  grid-template-columns: 146px 210px 230px;
  align-items: end;
  gap: 18px;
  min-width: 0;
}

.period-mode, .period-month, .period-week {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.week-chip [hidden] { display: none; }
body[data-planning-mode="month"] .period-week { display: none !important; }
.period-label { font-weight: 600; }
.mode-segments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 40px;
  padding: 3px;
  background: #eef2f5;
  border: 1px solid #e0e6ec;
  border-radius: 6px;
}
.mode-segments button { border: 0; border-radius: 4px; background: transparent; color: #526172; font-size: 13px; font-weight: 600; }
.mode-segments button[aria-pressed="true"] { background: #fff; color: var(--brand); box-shadow: 0 1px 3px #18202a22; }
.period-month { position: relative; }
.month-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}
.month-trigger span { flex: 1; text-align: left; }
.month-trigger svg, .period-icon svg { width: 16px; height: 16px; flex-shrink: 0; }
.month-trigger > svg:first-child { color: var(--muted); }
.month-trigger[aria-expanded="true"] { border-color: var(--brand); }
.period-icon { display: grid; place-items: center; width: 34px; height: 36px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #47586a; }
.period-icon:hover:not(:disabled), .month-trigger:hover { background: #f1f6f8; }
.week-chip button:disabled { opacity: 0.3; cursor: default; }
.week-chip button:focus-visible, .week-chip select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.week-navigation { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.week-navigation select { padding: 0 4px; height: 36px; border: 0; border-radius: 0; font-size: 13px; text-align: center; background: transparent; }
.month-picker-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; width: 300px; padding: 12px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px #18202a24; }
.month-picker-heading { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; }
.month-picker-heading strong { font-size: 16px; }
.month-picker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.month-picker-grid button { height: 36px; padding: 0 3px; border: 1px solid transparent; border-radius: 4px; background: white; color: #425264; font-size: 12px; }
.month-picker-grid button:hover { background: #eef4f6; }
.month-picker-grid button[aria-pressed="true"] { border-color: var(--brand); background: #e8f3f4; color: var(--brand); font-weight: 700; }

select,
input,
textarea {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.35;
}

.portal {
  display: none;
  min-height: calc(100vh - 130px);
}

.portal.active {
  display: grid;
  grid-template-columns: minmax(240px, 284px) minmax(0, 1fr);
}

.left-rail {
  padding: 18px;
  background: #142536;
  color: #fff;
}

.rail-header {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.rail-header select,
.filter-label select {
  background: #20364a;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
}

.course-list {
  display: grid;
  gap: 10px;
}

.course-card {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  color: #dbe7f2;
  background: #1a3044;
}

.course-card strong {
  font-size: 1.35rem;
}

.course-card span {
  color: #fff;
  font-weight: 700;
}

.course-card small {
  color: #9fb4c8;
}

.course-card.active {
  border-color: #65d7ce;
  background: #0f5367;
}

.filter-label {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  color: #dbe7f2;
  font-size: 0.92rem;
}

.workbench,
.coordinator-main {
  min-width: 0;
  padding: 18px;
}

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

.workbench-toolbar h1 {
  margin: 2px 0 0;
  font-size: 1.45rem;
}

.month-planner {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(22, 34, 51, 0.08);
}

.month-planner[hidden] {
  display: none;
}

.month-planner h2 {
  margin: 2px 0 0;
  font-size: 1.05rem;
}

.month-week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.month-week-card {
  display: grid;
  gap: 5px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #f8fbfe;
  text-align: left;
}

.month-week-card.active {
  border-color: var(--brand);
  background: #e8f5f7;
  box-shadow: inset 0 0 0 1px var(--brand);
}

.month-week-card span,
.month-week-card small {
  color: var(--muted);
}

.context-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.toolbar-actions,
.status-counters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.primary-button,
.ghost-button,
.danger-button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.ghost-button {
  color: var(--brand);
  background: #fff;
  border-color: var(--line);
}

.danger-button {
  width: 100%;
  color: var(--danger);
  background: #fff4f2;
  border-color: #ffcbc4;
}

.primary-button.full {
  width: 100%;
  margin-top: 8px;
}

.save-state,
.status-counters span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  color: var(--warning);
  background: #fff8eb;
  border: 1px solid #fedf89;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 800;
}

.save-state.saved,
.status-counters span:first-child {
  color: #027a48;
  background: #ecfdf3;
  border-color: #abefc6;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 326px);
  gap: 18px;
  align-items: start;
}

.official-editor {
  min-width: 0;
}

.report-editor {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.editor-heading span {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 5px 9px;
  color: #fff;
  background: var(--brand);
  border-radius: 7px;
  font-weight: 800;
}

.editor-heading h2 {
  margin: 0;
  font-size: 1.3rem;
}

.editor-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.editor-status {
  white-space: nowrap;
  padding: 8px 10px;
  color: #027a48;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.85rem;
}

.unit-editor {
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.unit-editor label,
.activity-card label {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.86rem;
}

.spellcheck-feedback {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 7px 9px;
  color: #92400e;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 7px;
  font-size: 0.78rem;
  line-height: 1.25;
}

.spellcheck-feedback[hidden] {
  display: none;
}

.spellcheck-feedback span {
  color: #7c2d12;
}

.spellcheck-feedback[data-state="complete"] {
  color: #24543c;
  background: #f0f8f3;
  border-color: #bbd8c7;
}

.spellcheck-feedback[data-state="pending"] {
  color: #526070;
  background: #f4f6f8;
  border-color: #d6dde5;
}

.spelling-issues { width: 100%; max-height: 230px; overflow-y: auto; }
.spelling-issue { padding: 8px 0; border-top: 1px solid #ecd4b6; }
.spelling-issue > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.spelling-actions { margin-top: 6px; }
.spelling-issue button {
  padding: 5px 8px;
  background: white;
  color: #234e63;
  border: 1px solid #c5ced6;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.spelling-issue button:hover { background: #eaf2f7; }
.spelling-issue button:focus-visible { outline: 2px solid #17667c; outline-offset: 2px; }
.spelling-issue .spelling-word { color: #9d2727; text-decoration: underline wavy; border: none; background: none; font-weight: 800; padding-left: 0; }

.activity-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.activity-section > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.activity-section h3 {
  margin: 0;
  font-size: 1rem;
}

.activity-section.work {
  background: #f7d2ee;
}

.activity-section.workshop {
  background: #c8f4d0;
}

.activity-section.exam {
  background: #f7d2ee;
}

.mini-add {
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 8px 11px;
  color: #fff;
  background: var(--brand);
  font-size: 0.9rem;
  font-weight: 800;
}

.activity-cards {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.activity-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
}

.activity-card-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.remove-link {
  border: 0;
  color: var(--danger);
  background: transparent;
  font-weight: 800;
}

.activity-fields {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 96px;
  gap: 10px;
}

.activity-date-field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.date-control { position: relative; min-width: 0; }
.date-control .date-entry { width: 100%; padding-right: 40px; font-weight: 800; }
.date-control .date-calendar {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  width: 34px;
  min-width: 0;
  height: auto;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  color: transparent;
  cursor: pointer;
  font-size: 0;
}
.date-calendar::-webkit-datetime-edit { display: none; }
.date-calendar::-webkit-calendar-picker-indicator { width: 20px; height: 20px; margin: 0; padding: 0; opacity: 1; cursor: pointer; }
.date-control .date-calendar:hover { background-color: #edf4f7; }
.date-control .date-calendar:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.section-empty {
  padding: 16px;
  color: rgba(0, 0, 0, 0.55);
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed rgba(0, 0, 0, 0.18);
  border-radius: 8px;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.template-page {
  position: relative;
  width: min(100%, 920px);
  min-height: 1310px;
  margin: 0 auto 18px;
  overflow: hidden;
  color: #000;
  background: #fff;
  box-shadow: var(--shadow);
}

.preview-stack .template-page {
  width: min(100%, 760px);
  min-height: 1082px;
}

.native-template {
  padding: 48px 42px 62px;
  font-family: Arial, Helvetica, sans-serif;
}

.pdf-letterhead {
  position: relative;
  display: grid;
  justify-items: center;
  min-height: 178px;
  margin-bottom: 26px;
}

.pdf-brand {
  position: absolute;
  left: 0;
  top: 26px;
  width: 198px;
}

.pdf-logo {
  display: block;
  width: 100%;
  height: auto;
}

.pdf-title {
  width: 100%;
  max-width: 620px;
  padding-top: 8px;
  text-align: center;
  font-weight: 800;
  line-height: 1.12;
}

.pdf-title h2,
.pdf-title h3 {
  margin: 0;
  font-size: 21px;
}

.pdf-title strong,
.pdf-title span {
  display: block;
  font-size: 18px;
}

.pdf-process {
  display: grid;
  gap: 4px;
  justify-self: end;
  justify-items: end;
  width: 100%;
  padding-right: 16px;
  font-size: 15px;
  font-weight: 800;
}

.official-table {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  border: 2px solid #000;
}

.pdf-side-cell {
  position: relative;
  min-height: 780px;
  border-right: 2px solid #000;
  background: #fff;
}

.side-vertical {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 720px;
  height: 56px;
  transform: translate(-50%, -50%) rotate(-90deg);
  color: #e30000;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.side-stack {
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 100%;
}

.side-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  max-width: 100%;
  min-width: 0;
}

.side-label-main {
  font-size: 26px;
  line-height: 1;
}

.side-label-small {
  font-size: 18px;
  line-height: 1;
}

.pdf-main-grid {
  min-width: 0;
}

.pdf-band {
  display: grid;
  min-height: 86px;
  place-items: center;
  color: #fff;
  background: #164f64;
  border-bottom: 2px solid #000;
  font-size: 21px;
  font-weight: 800;
  text-align: center;
}

.pdf-unit-row {
  display: grid;
  grid-template-columns: auto 68px minmax(180px, 1fr) auto minmax(150px, 0.8fr);
  gap: 16px;
  align-items: center;
  min-height: 114px;
  padding: 18px 20px;
  border-bottom: 1px solid #000;
  font-size: 20px;
  font-weight: 800;
}

.unit-number-box {
  display: grid;
  width: 62px;
  height: 50px;
  place-items: center;
  border: 3px solid #164f64;
  border-radius: 8px;
  font-size: 21px;
}

.unit-name-line,
.topic-line {
  min-height: 28px;
  border-bottom: 1px solid #000;
  font-size: 15px;
  line-height: 1.2;
}

.pdf-section-block {
  display: grid;
  grid-template-columns: 146px minmax(0, 1fr);
  border-bottom: 1px solid #000;
}

.pdf-section-block:last-child {
  border-bottom: 0;
}

.pdf-section-block.work,
.pdf-section-block.exam {
  background: #f0caea;
}

.pdf-section-block.workshop {
  background: #c5f0ca;
}

.pdf-section-title {
  min-width: 0;
  overflow: visible;
  padding: 28px 10px 12px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: normal;
  text-align: left;
  text-overflow: clip;
  white-space: nowrap;
}

.pdf-section-rows {
  display: grid;
  min-width: 0;
}

.activity-subrow {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 170px;
  min-height: 136px;
  border-left: 1px solid #000;
  border-bottom: 1px solid #000;
}

.activity-subrow:last-child {
  border-bottom: 0;
}

.activity-subrow.empty {
  min-height: 178px;
}

.activity-description-cell {
  min-width: 0;
  padding: 46px 12px 12px;
  font-size: 13.5px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.activity-mode-cell {
  display: grid;
  grid-template-columns: auto 30px;
  gap: 9px 8px;
  align-content: start;
  align-items: center;
  justify-content: start;
  padding: 28px 10px 10px;
  font-size: 16px;
}

.check-square {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  background: #fff;
  border: 1px solid #000;
  font-size: 14px;
  line-height: 1;
}

.activity-date-cell {
  display: grid;
  align-content: start;
  border-left: 1px solid #000;
}

.date-box-clean {
  display: grid;
  gap: 7px;
  min-height: 78px;
  padding: 6px 9px 9px;
  border-bottom: 1px solid #000;
  font-size: 12px;
  line-height: 1;
}

.date-box-clean strong {
  font-size: 13px;
}

.date-clean-label {
  width: 100%;
  padding: 8px 10px 6px;
  background: #fff;
  border: 1px solid #000;
  border-bottom: 0;
  font-size: 12px;
  white-space: nowrap;
}

.date-clean-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.25fr);
  align-items: center;
  justify-content: center;
  column-gap: 3px;
  text-align: center;
}

.date-clean-values {
  min-height: 27px;
  margin-top: -7px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid #000;
  border-top: 0;
  font-size: 11px;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 14px 8px 9px;
  font-size: 13px;
}

.score-box {
  display: grid;
  width: 48px;
  height: 34px;
  place-items: center;
  background: #fff;
  border: 1px solid #000;
  font-size: 13px;
}

.detail-panel {
  display: grid;
  gap: 14px;
}

.panel-card,
.review-panel,
.preview-stack {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(22, 34, 51, 0.08);
}

.panel-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.panel-card.compact {
  gap: 10px;
}

.panel-title {
  display: grid;
  gap: 2px;
}

.panel-title span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: var(--soft);
  border-radius: 7px;
}

.coordinator-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-bottom: 16px;
}

.review-panel {
  padding: 16px;
}

.review-panel h2,
.preview-header h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.report-list,
.missing-list {
  display: grid;
  gap: 10px;
}

.report-card,
.missing-card,
.empty-state {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.report-card strong,
.missing-card strong {
  font-size: 0.95rem;
}

.report-card span,
.missing-card span,
.report-card small {
  color: var(--muted);
  font-size: 0.86rem;
}

.missing-card {
  border-color: #fedf89;
  background: #fff8eb;
}

.empty-state.good {
  color: #027a48;
  background: #ecfdf3;
  border-color: #abefc6;
}

.preview-stack {
  padding: 16px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.preview-header span,
.consolidated-preview-item span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.consolidated-preview-list {
  display: grid;
  gap: 10px;
}

.consolidated-preview-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.consolidated-preview-item > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.consolidated-preview-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-counts span {
  padding: 6px 8px;
  color: var(--brand);
  background: #eef8fb;
  border: 1px solid #ccecf3;
  border-radius: 7px;
  font-size: 0.78rem;
}

.print-area {
  display: none;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  padding: 22px;
  background: rgba(15, 29, 43, 0.68);
}

.preview-modal.open {
  display: block;
}

.preview-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  max-height: calc(100vh - 44px);
  margin: 0 auto;
  overflow: hidden;
  background: #f7fafc;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.close-preview-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #344054;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.close-preview-icon:hover,
.close-preview-icon:focus {
  color: #fff;
  background: var(--brand);
  outline: 0;
}

.preview-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 16px 56px 16px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.preview-dialog-header > div:first-child {
  flex: 1 1 auto;
}

.preview-dialog-header h2 {
  margin: 2px 0 0;
  line-height: 1.3;
}

.preview-dialog-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.preview-dialog-body .template-page {
  width: 1000px;
  max-width: none;
}

@media (max-width: 1180px) {
  .app-header { grid-template-columns: 1fr; gap: 14px; }
  .week-chip { grid-template-columns: 146px minmax(180px, 1fr) minmax(210px, 1fr); }
  .portal.active {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    grid-template-columns: 1fr 1fr;
  }

  .activity-fields,
  .unit-editor {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .app-header,
  .portal.active,
  .coordinator-grid,
  .detail-panel {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions button {
    flex: 1;
  }

  .quick-access,
  .quick-access-button,
  .quick-access-menu {
    width: 100%;
    min-width: 0; /* Override any min-width from base styles */
  }

  .quick-access-menu {
    position: static;
    margin-top: 8px;
  }

  .workbench-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .left-rail {
    padding: 14px;
  }

  .activity-fields,
  .unit-editor {
    grid-template-columns: 1fr;
  }

  .preview-dialog-header {
    align-items: stretch;
    flex-direction: column;
  }

  .consolidated-preview-item {
    grid-template-columns: 1fr;
  }

  .section-counts {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .app-header { position: relative; padding: 14px 16px; }
  .week-chip { grid-template-columns: 106px minmax(0, 1fr); gap: 12px; }
  .period-week { grid-column: 1 / -1; }
  .month-trigger { font-size: 12px; padding: 0 7px; gap: 5px; }
  .month-trigger > svg:first-child { display: none; }
  .mode-segments button { font-size: 12px; }
  .month-picker-panel { width: min(300px, calc(100vw - 32px)); }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .app-header,
  main {
    display: none !important;
  }

  .print-area {
    display: block;
  }

  .template-page {
    width: 210mm;
    height: 297mm;
    min-height: 0;
    margin: 0;
    box-shadow: none;
    overflow: hidden;
    page-break-after: always;
  }

  .template-page:last-child {
    page-break-after: auto;
  }

  .native-template {
    padding: 10mm 11mm;
  }

  .pdf-letterhead {
    min-height: 41mm;
    margin-bottom: 6mm;
  }

  .pdf-brand {
    top: 6mm;
    width: 43mm;
  }

  .pdf-title h2,
  .pdf-title h3 {
    font-size: 13.5pt;
  }

  .pdf-title strong,
  .pdf-title span {
    font-size: 12pt;
  }

  .pdf-process {
    padding-right: 4mm;
    font-size: 9.5pt;
  }

  .official-table {
    grid-template-columns: 21mm minmax(0, 1fr);
  }

  .pdf-side-cell {
    min-height: 198mm;
  }

  .side-vertical {
    width: 182mm;
    height: 14mm;
  }

  .side-line {
    gap: 1.4mm;
  }

  .side-label-main {
    font-size: 14pt;
  }

  .side-label-small {
    font-size: 8.5pt;
  }

  .pdf-band {
    min-height: 19mm;
    font-size: 14pt;
  }

  .pdf-unit-row {
    grid-template-columns: auto 15mm minmax(38mm, 1fr) auto minmax(34mm, 0.8fr);
    gap: 4mm;
    min-height: 28mm;
    padding: 4mm;
    font-size: 13pt;
  }

  .unit-number-box {
    width: 14mm;
    height: 12mm;
    font-size: 13pt;
  }

  .unit-name-line,
  .topic-line {
    min-height: 7mm;
    font-size: 10pt;
  }

  .pdf-section-block {
    grid-template-columns: 38mm minmax(0, 1fr);
  }

  .pdf-section-title {
    padding: 8mm 2mm 3mm;
    font-size: 10.5pt;
  }

  .activity-subrow {
    grid-template-columns: minmax(52mm, 1fr) 36mm 38mm;
    min-height: 26mm;
  }

  .activity-subrow.empty {
    min-height: 30mm;
  }

  .activity-description-cell {
    padding: 11mm 3mm 3mm;
    font-size: 10pt;
  }

  .activity-mode-cell {
    grid-template-columns: auto 7mm;
    gap: 2.2mm 2mm;
    padding: 7mm 2mm 2mm;
    font-size: 10.5pt;
  }

  .check-square {
    width: 7mm;
    height: 7mm;
    font-size: 9pt;
  }

  .date-box-clean {
    gap: 1mm;
    min-height: 12mm;
    padding: 1mm 2mm 1.2mm;
    font-size: 8pt;
  }

  .date-box-clean strong {
    font-size: 8.5pt;
  }

  .date-clean-label {
    padding: 1mm 2mm 0.6mm;
    font-size: 7.4pt;
  }

  .date-clean-values {
    min-height: 4.5mm;
    margin-top: -1mm;
    padding: 0 2mm;
    font-size: 7.2pt;
  }

  .date-clean-grid {
    column-gap: 0.6mm;
  }

  .score-row {
    grid-template-columns: minmax(0, 1fr) 11mm;
    gap: 2mm;
    min-height: 8.5mm;
    padding: 1mm 4mm 1mm 2mm;
    font-size: 8pt;
  }

  .score-box {
    width: 10mm;
    height: 8mm;
    font-size: 8pt;
  }
}

/* ==========================================================================
   Pantalla de Ingreso Institucional (Login)
   ========================================================================== */
.login-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #0b3c4b 0%, #0f5367 40%, #177180 80%, #0c4355 100%);
  overflow-y: auto;
}

.login-screen[hidden] {
  display: none !important;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.login-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 490px;
  margin: auto;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 30px 24px;
  box-shadow: 0 24px 60px rgba(7, 30, 40, 0.35), 0 4px 16px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand-wrapper {
  margin-bottom: 12px;
}

.login-logo {
  height: 54px;
  max-width: 100%;
  object-fit: contain;
}

.login-badge {
  display: inline-block;
  padding: 3px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--brand);
  background: #e8f3f8;
  border-radius: 999px;
  margin-bottom: 8px;
}

.login-title {
  margin: 0 0 4px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #0b3c4b;
  line-height: 1.3;
}

.login-subtitle {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--accent);
}

.login-tagline {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #edf2f7;
  border-radius: 10px;
  margin-bottom: 22px;
}

.login-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.login-tab svg {
  width: 18px;
  height: 18px;
}

.login-tab:hover {
  color: var(--ink);
}

.login-tab.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.login-panels {
  min-height: 240px;
}

.login-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-panel[hidden] {
  display: none !important;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-hint {
  font-size: 0.76rem;
  color: var(--muted);
}

.field-hint code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--brand);
  font-weight: 600;
}

.login-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-wrapper .field-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: #94a3b8;
  pointer-events: none;
}

.login-select,
.login-input {
  width: 100%;
  height: 44px;
  padding: 8px 12px 8px 38px;
  font-size: 0.92rem;
  color: var(--ink);
  background: #f8fafc;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: all 0.15s ease;
}

.login-input-wrapper:focus-within .field-icon {
  color: var(--brand);
}

.login-select:focus,
.login-input:focus {
  background: #ffffff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 83, 103, 0.14);
}

.toggle-password-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.toggle-password-btn:hover {
  color: var(--ink);
}

.toggle-password-btn svg {
  width: 16px;
  height: 16px;
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
}

.login-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.login-error-message {
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
}

.login-submit-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 46px;
  font-size: 0.96rem;
  font-weight: 800;
  color: #ffffff;
  background: var(--brand);
  border: none;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 83, 103, 0.28);
  transition: all 0.2s ease;
  margin-top: 4px;
}

.login-submit-button:hover {
  background: var(--brand-strong);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 83, 103, 0.35);
}

.login-submit-button.coordinator {
  background: #0d625d;
  box-shadow: 0 8px 20px rgba(13, 98, 93, 0.28);
}

.login-submit-button.coordinator:hover {
  background: #094743;
}

.login-submit-button svg {
  width: 18px;
  height: 18px;
  transition: transform 0.15s ease;
}

.login-submit-button:hover svg {
  transform: translateX(3px);
}

.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #edf2f7;
  text-align: center;
}

.login-quick-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 10px;
}

.login-quick-pills {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.login-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand);
  background: #f0f6fa;
  border: 1px solid #d0e2ec;
  border-radius: 999px;
  transition: all 0.15s ease;
}

.login-pill svg {
  width: 14px;
  height: 14px;
  color: #f59e0b;
}

.login-pill:hover {
  background: #e2eff5;
  border-color: var(--brand);
  transform: translateY(-1px);
}

.login-legal-note {
  margin: 0;
  font-size: 0.74rem;
  color: #94a3b8;
}

@media (max-width: 480px) {
  .login-card {
    padding: 24px 18px 20px;
  }
  .login-title {
    font-size: 1.05rem;
  }
  /* Prevent tabs from overflowing the screen on very small devices */
  .login-tabs {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .login-tab {
    padding: 10px;
  }
  .login-submit-button {
    height: auto;
    padding: 12px;
    white-space: normal;
  }
}

/* Cover Page */
.cover-page {
  background-color: #ffffff !important;
  color: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}
.cover-content {
  max-width: 600px;
}
.cover-logo {
  max-width: 250px;
  margin-bottom: 20px;
}
.cover-page h1 {
  font-size: 14pt;
  margin-bottom: 10px;
  color: #000;
}
.cover-page h2 {
  font-size: 12pt;
  margin-bottom: 10px;
  color: #000;
}
.cover-page h3 {
  font-size: 12pt;
  margin-bottom: 20px;
  color: #000;
}
.cover-week {
  font-size: 11pt;
  margin-bottom: 30px;
  font-weight: bold;
}
.cover-page h4 {
  font-size: 12pt;
  margin-bottom: 20px;
  text-transform: uppercase;
  color: #000;
}
.cover-course-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.course-link {
  color: #0056b3;
  text-decoration: underline;
  font-size: 11pt;
  font-weight: bold;
}
.back-to-top-link {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 24px;
  right: 42px;
  color: #0056b3;
  text-decoration: underline;
  font-size: 9pt;
  z-index: 10;
}
.pdf-course-header {
  font-size: 11pt;
  margin-bottom: 10px;
  color: #000;
  display: flex;
  gap: 10px;
}


/* Status Badges for Month Cards */
.month-week-card small {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.8rem;
  margin-top: 4px;
}
/* Coordinator Statuses */
.month-week-card small.status-sin-asignaturas {
  color: var(--muted);
  background: #f1f3f5;
  border: 1px solid #dee2e6;
}
.month-week-card small.status-sin-informes,
.month-week-card small.status-sin-llenar {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fec8cb;
}
.month-week-card small.status-en-progreso,
.month-week-card small.status-borrador {
  color: var(--warning);
  background: #fff8eb;
  border: 1px solid #fedf89;
}
.month-week-card small.status-completado,
.month-week-card small.status-enviado {
  color: #027a48;
  background: #ecfdf3;
  border: 1px solid #abefc6;
}
/* User Profile Menu */
.user-profile-menu {
  position: relative;
}

.user-profile-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 500;
  transition: all 0.2s;
}

.user-profile-btn:hover {
  background: var(--soft);
  border-color: var(--brand);
}

.user-avatar-small {
  font-size: 1.2rem;
}

.user-profile-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  z-index: 100;
  overflow: hidden;
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.user-avatar-large {
  font-size: 2.5rem;
  background: var(--panel);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.user-dropdown-info {
  display: flex;
  flex-direction: column;
}

.user-dropdown-info strong {
  font-size: 1rem;
  color: var(--ink);
}

.user-dropdown-info span {
  font-size: 0.85rem;
  color: var(--muted);
}

.user-dropdown-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.user-dropdown-list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.95rem;
  text-align: left;
  transition: background 0.1s;
}

.user-dropdown-list button:hover {
  background: var(--soft);
}

.user-dropdown-list button i {
  color: var(--muted);
  width: 18px;
  height: 18px;
}

.user-dropdown-footer {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.user-dropdown-footer button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--danger);
  font-weight: 500;
  font-size: 0.95rem;
  text-align: left;
  transition: background 0.1s;
}

.user-dropdown-footer button:hover {
  background: #fef2f2;
}

.user-dropdown-footer button i {
  width: 18px;
  height: 18px;
}
