* {
  box-sizing: border-box;
}

:root {
  --qr-code-size: 5.3cm;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f2f4f7;
  color: #1f2937;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

main[role="main"] {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-header {
  flex-shrink: 0;
  background: #0b1b4e;
  color: #ffffff;
  min-height: 90px;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.top-header__brand {
  display: flex;
  align-items: center;
  min-height: 60px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  padding: 3px;
}

.su-navbar__logo {
  width: 180px;
  height: 60px;
  object-fit: contain;
  display: block;
}

.page-content {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 12px 24px 12px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 440px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px 22px;
  align-items: stretch;
  overflow: visible;
}

.page-content > .search-panel {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  position: relative;
  z-index: 30;
}

.page-content > .sidebar-menu {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  align-self: stretch;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-content > .content-grid {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  align-self: stretch;
}

.page-content > .qr-grid {
  grid-column: 3;
  grid-row: 2;
  min-height: 0;
  align-self: stretch;
}

.page-announcement {
  flex-shrink: 0;
  margin-top: auto;
  background: #ffffff;
  border-top: 2px solid #1c458b;
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
}

.page-announcement__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px 14px;
}

.page-announcement__title {
  margin: 0 0 5px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1c4d97;
}

.page-announcement__list {
  margin: 0;
  padding-left: 1.1rem;
  color: #334155;
  font-size: 0.8rem;
  line-height: 1.35;
}

.page-announcement__list li + li {
  margin-top: 3px;
}

.page-announcement a {
  color: #1c4d97;
  font-weight: 600;
  text-decoration: underline;
}

.page-announcement a:hover {
  color: #163f7d;
}

.search-panel {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #ffffff;
  border: 1px solid #d6deea;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.06);
  transition: background-color 0.18s ease, opacity 0.18s ease;
}

.search-panel:focus-within {
  background: rgba(255, 255, 255, 0.86);
  opacity: 0.86;
}

.search-input-wrap {
  flex: 1;
  position: relative;
  z-index: 35;
}

.search-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bfccdd;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 0.94rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-panel input:focus {
  outline: none;
  border-color: #1c4d97;
  box-shadow: 0 0 0 3px rgba(28, 77, 151, 0.12);
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.15);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  display: none;
  z-index: 40;
  max-height: 240px;
  overflow-y: auto;
}

.search-suggestions.is-visible {
  display: block;
}

.search-suggestions li {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.92rem;
  color: #1f2937;
}

.search-suggestions li:hover {
  background: #eff6ff;
}

.search-panel button {
  min-height: 42px;
  padding: 0 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, #2459a7 0%, #1c4d97 100%);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.search-panel button:hover {
  background: linear-gradient(180deg, #1f5299 0%, #184686 100%);
  box-shadow: 0 6px 14px rgba(28, 77, 151, 0.22);
  transform: translateY(-1px);
}

.sidebar-menu {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  padding: 12px;
}

.sidebar-menu h2 {
  margin: 0 0 8px;
  background: #1c4d97;
  color: #ffffff;
  font-size: 1rem;
  border-radius: 8px;
  padding: 10px 12px;
}

.sidebar-menu details {
  border-bottom: 1px solid #e8edf3;
}

.sidebar-menu details:last-child {
  border-bottom: none;
}

.sidebar-menu summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: #1e293b;
  padding: 10px 4px;
  border-radius: 6px;
}

.sidebar-menu details.is-active-group summary {
  background: #dbeafe;
  color: #1e3a8a;
}

.sidebar-menu summary::-webkit-details-marker {
  display: none;
}

.sidebar-menu summary::before {
  content: ">";
  margin-right: 8px;
  color: #64748b;
}

.sidebar-menu details[open] summary::before {
  content: "v";
}

.sidebar-menu ul {
  display: none;
}

.sidebar-menu li {
  margin: 8px 0;
  border-radius: 6px;
  padding: 4px 6px;
}

.sidebar-menu a {
  text-decoration: none;
  color: #334155;
  font-size: 0.92rem;
}

.sidebar-menu a:hover {
  color: #1c4d97;
}

.content-grid {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.qr-grid {
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-reveal {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.panel-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.qr-card__content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
}

.qr-card__label {
  font-weight: 600;
  color: #1e3a8a;
  text-align: center;
}

.qr-print-header {
  display: none;
}

.qr-card__image {
  width: 220px;
  height: 220px;
  border: 1px dashed #cfd8e3;
  border-radius: 8px;
  background: #f8fafc;
  display: none;
}

.qr-count-message {
  margin: 0;
  padding: 8px 12px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e3a8a;
  background: #eff6ff;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
}

.qr-carousel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.qr-carousel__viewport {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  max-height: calc(var(--qr-code-size) + 5.5rem);
  display: flex;
  justify-content: center;
  align-items: center;
}

.qr-carousel__btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  background: #ffffff;
  color: #1c4d97;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.qr-carousel__btn:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #94a3b8;
}

.qr-carousel__btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  color: #334155;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.qr-carousel-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
}

.qr-carousel-index {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
}

.qr-print-btn {
  min-height: 36px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.qr-print-btn:hover {
  background: #0d9488;
}

.qr-preview-list {
  width: 100%;
  display: flex;
  justify-content: center;
}

.qr-preview-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 100%;
}

.qr-preview-item img {
  width: min(var(--qr-code-size), 100%);
  max-width: var(--qr-code-size);
  aspect-ratio: 1;
  height: auto;
  object-fit: contain;
  border: 1px dashed #cfd8e3;
  border-radius: 6px;
  background: #f8fafc;
}

.qr-preview-item .meta {
  font-size: 0.85rem;
  color: #334155;
  text-align: center;
  word-break: break-word;
  white-space: pre-line;
}

.qr-card__text {
  text-align: center;
  font-size: 0.9rem;
  color: #475569;
}

@media print {
  @page {
    margin: 0;
    size: auto;
  }

  html,
  body {
    height: auto !important;
    overflow: visible !important;
  }

  body {
    display: block !important;
  }

  main[role="main"],
  .page-shell {
    flex: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .page-content {
    overflow: visible !important;
  }

  .page-announcement {
    display: none;
  }

  body * {
    visibility: hidden;
  }

  #qr-print-header,
  #qr-print-header *,
  #qr-count-message,
  #qr-print-region,
  #qr-print-region * {
    visibility: visible;
  }

  #qr-print-header {
    position: absolute;
    left: 0;
    right: 0;
    top: 8mm;
    display: block;
    text-align: center;
    color: #000000 !important;
  }

  .qr-print-header__university {
    font-size: 14pt;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 2mm;
  }

  .qr-print-header__group {
    font-size: 11pt;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1mm;
  }

  .qr-print-header__unit {
    font-size: 10pt;
    line-height: 1.2;
    margin-bottom: 1mm;
  }

  #qr-selected-label {
    display: none !important;
  }

  #qr-carousel,
  #qr-carousel-footer,
  #qr-preview-text {
    display: none !important;
  }

  #qr-count-message {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 34mm;
    width: 90%;
    max-width: 420px;
    border: none !important;
    background: transparent !important;
    font-size: 9pt;
    color: #000000 !important;
  }

  #qr-print-region {
    position: absolute;
    left: 50%;
    top: 44mm;
    transform: translateX(-50%);
    width: min(100%, var(--qr-code-size));
  }

  .qr-preview-item {
    border: none;
    padding: 0;
    box-shadow: none;
  }

  .qr-preview-item img {
    width: var(--qr-code-size) !important;
    height: var(--qr-code-size) !important;
    max-width: var(--qr-code-size) !important;
    aspect-ratio: 1;
    border: none !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .qr-preview-item .meta {
    font-size: 9pt;
    color: #000000 !important;
    margin-top: 8px;
  }
}

.info-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.info-card h2 {
  flex-shrink: 0;
  margin: 0;
  padding: 13px 18px;
  text-align: center;
  font-size: 1.03rem;
  color: #ffffff;
  background: #1c4d97;
}

.info-card ul {
  list-style: none;
  margin: 0;
  padding: 14px 18px 18px;
}

.info-card li {
  padding: 10px 0;
  font-size: 0.95rem;
  color: #334155;
  border-bottom: 1px solid #edf1f6;
}

.info-card li::before {
  content: ">";
  margin-right: 8px;
  color: #64748b;
  font-size: 0.75rem;
}

.info-card li:last-child {
  border-bottom: none;
}

#content-panel .unit-content-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: auto;
  align-content: start;
  justify-content: stretch;
  gap: 0 28px;
  list-style: none;
  counter-reset: unit-item;
  padding: 12px 12px 18px;
}

#content-panel .unit-content-list > li:not(.unit-content-list__message) {
  counter-increment: unit-item;
  margin: 0;
  padding: 12px 6px;
  border-bottom: 1px solid #e8edf3;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 4px;
}

#content-panel .unit-content-list > li:not(.unit-content-list__message)::before {
  content: counter(unit-item) ". ";
  flex-shrink: 0;
  min-width: 1.85em;
  font-weight: 600;
  font-size: 0.92rem;
  color: #1c4d97;
}

#content-panel .unit-content-list > li.unit-content-list__message {
  grid-column: 1 / -1;
  cursor: default;
  border-bottom: none;
  padding: 14px 8px;
}

#content-panel .unit-content-list > li.unit-content-list__message::before {
  content: none;
}

#unit-content-list li:not(.unit-content-list__message) {
  cursor: pointer;
}

#unit-content-list li:not(.unit-content-list__message):hover,
#unit-content-list li:not(.unit-content-list__message):focus-visible {
  background: #eef3fb;
}

@media (max-width: 640px) {
  #content-panel .unit-content-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .page-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
  }

  .page-content > .search-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .page-content > .sidebar-menu {
    grid-column: 1;
    grid-row: 2;
    max-height: 32vh;
  }

  .page-content > .content-grid {
    grid-column: 1;
    grid-row: 3;
  }

  .page-content > .qr-grid {
    grid-column: 1;
    grid-row: 4;
  }
}

@media (max-width: 640px) {
  .top-header {
    min-height: 56px;
    padding: 8px 14px;
  }

  .page-content {
    padding: 10px 14px 10px;
  }

  .page-announcement__inner {
    padding: 8px 12px 10px;
  }

  .search-panel {
    flex-direction: column;
    align-items: stretch;
  }
}