:root {
  --main-color: #0f91d6;
  --main-dark: #0874ad;
  --paper: #ffffff;
  --page: #f4f2f2;
  --line: #e2e6ea;
  --ink: #20252a;
  --muted: #747b83;
  --soft-blue: #eaf6fd;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--page);
  color: var(--ink);
  display: flex;
  font-family: "Rubik", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.sidebar {
  background: var(--main-color);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 34px 26px 24px;
  width: 292px;
}

.brand {
  align-items: center;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 92px;
  padding: 18px;
}

.brand img {
  max-width: 210px;
  width: 100%;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 34px;
}

.nav-link {
  border-radius: 7px;
  color: #fff;
  opacity: 0.72;
  padding: 12px 14px;
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover {
  background: #ffffff1f;
  opacity: 1;
}

.sidebar-footer {
  border-top: 1px solid #ffffff38;
  color: #ffffffc9;
  font-size: 12px;
  line-height: 1.45;
  margin-top: auto;
  padding-top: 18px;
}

.page {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 28px;
}

.topbar {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--main-dark);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 7px;
}

h1 {
  color: #4d545a;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}

h2 {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}

.icon-button,
.button {
  align-items: center;
  background: var(--main-color);
  border: 0;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 500;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
  white-space: nowrap;
}

.icon-button {
  aspect-ratio: 1;
  font-size: 22px;
  padding: 0;
  width: 44px;
}

.button:hover,
.icon-button:hover {
  background: var(--main-dark);
}

.button:disabled,
.icon-button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button.ghost {
  background: #edf3f7;
  color: #26323a;
}

.toolbar {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 520px) 1fr;
  margin-bottom: 18px;
}

.search {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px 14px;
}

.search span {
  color: var(--muted);
  font-size: 12px;
}

.search input {
  border: 0;
  color: var(--ink);
  outline: 0;
  width: 100%;
}

.status {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.layout {
  display: grid;
  flex: 1;
  gap: 18px;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 0;
}

.tree-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
}

.panel-title {
  color: #5b626a;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.tree {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.filters {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
}

.filter-control {
  display: grid;
  gap: 5px;
}

.filter-control span {
  color: var(--muted);
  font-size: 12px;
}

.filter-control select {
  appearance: none;
  background: #f8fbfd;
  border: 1px solid #dce6ed;
  border-radius: 7px;
  color: #27323a;
  cursor: pointer;
  min-height: 40px;
  outline: 0;
  padding: 0 34px 0 12px;
  width: 100%;
}

.filter-control {
  position: relative;
}

.filter-control::after {
  color: var(--main-dark);
  content: "▾";
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 31px;
}

.reset-filters {
  background: transparent;
  border: 1px solid #dce6ed;
  border-radius: 7px;
  color: #34434d;
  cursor: pointer;
  min-height: 36px;
}

.reset-filters:hover {
  background: var(--soft-blue);
}

.file-count {
  color: var(--muted);
  font-size: 12px;
  padding: 12px 0 8px;
}

.file-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.file-row {
  background: #fff;
  border: 1px solid #e0e7ec;
  border-radius: 7px;
  color: #27323a;
  cursor: pointer;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  position: relative;
  text-align: left;
  width: 100%;
}

.file-row:hover,
.file-row.active {
  background: var(--soft-blue);
  border-color: #b7daee;
}

.file-name {
  font-weight: 500;
  overflow-wrap: anywhere;
  padding-right: 58px;
}

.file-original {
  color: #788692;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.file-badge {
  background: #eef3f6;
  border: 1px solid #dce6ed;
  border-radius: 999px;
  color: #52616d;
  display: inline-flex;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  margin-left: 6px;
  padding: 4px 6px;
  vertical-align: middle;
}

.file-path {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.file-date {
  color: var(--main-dark);
  font-size: 11px;
  position: absolute;
  right: 12px;
  top: 12px;
}

.schedule-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  padding: 34px;
  text-align: center;
}

.empty-state strong {
  color: #4d545a;
  font-size: 22px;
  font-weight: 500;
}

.file-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.hidden {
  display: none;
}

.file-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 18px;
}

.tabs:empty {
  border-bottom: 0;
  padding: 0;
}

.week-controls {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 18px;
}

.week-controls.hidden {
  display: none;
}

.week-summary {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 3px;
}

.week-summary strong {
  color: #26323a;
  font-size: 13px;
  font-weight: 600;
}

.week-tabs {
  background: #eef3f6;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  padding: 4px;
  width: 100%;
}

.week-tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #44515b;
  cursor: pointer;
  min-height: 34px;
  min-width: 0;
  padding: 0 8px;
  white-space: nowrap;
}

.week-tab.active {
  background: var(--main-color);
  color: #ffffff;
  font-weight: 600;
}

.tab {
  background: #eef2f5;
  border: 0;
  border-radius: 999px;
  color: #34434d;
  cursor: pointer;
  min-height: 34px;
  padding: 0 14px;
}

.tab.active {
  background: var(--main-color);
  color: #fff;
}

.schedule-content {
  flex: 1;
  overflow: auto;
  padding: 18px;
}

.schedule-view {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.schedule-title {
  background: linear-gradient(90deg, #f2f9fd, #ffffff);
  border: 1px solid #d8e9f3;
  border-left: 5px solid var(--main-color);
  border-radius: 8px;
  color: #26323a;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  padding: 14px 16px;
}

.cards-view {
  padding-bottom: 8px;
}

.days-list {
  display: grid;
  gap: 14px;
}

.week-note {
  color: #5c6872;
  font-size: 13px;
  margin-top: -4px;
}

.day-card {
  background: #ffffff;
  border: 1px solid #d8e3ea;
  border-radius: 8px;
  overflow: hidden;
}

.day-card h3 {
  background: #f0f7fb;
  border-bottom: 1px solid #d8e3ea;
  color: #25313a;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  padding: 13px 16px;
  white-space: pre-line;
}

.day-slots {
  display: grid;
}

.time-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 118px minmax(0, 1fr);
  padding: 14px 16px;
}

.time-row + .time-row {
  border-top: 1px solid #edf1f4;
}

.time-cell {
  align-self: start;
  background: #f7fafc;
  border: 1px solid #dce7ee;
  border-radius: 7px;
  color: #26323a;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 8px;
  text-align: center;
}

.lesson-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  min-width: 0;
}

.lesson-card {
  background: #fbfdff;
  border: 1px solid #dbe8f0;
  border-left: 4px solid var(--main-color);
  border-radius: 7px;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 11px 12px;
}

.lesson-topline {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.lesson-week {
  border-radius: 999px;
  color: #fff;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 8px;
}

.lesson-week.numerator {
  background: #1594d2;
}

.lesson-week.denominator {
  background: #64748b;
}

.lesson-group {
  color: var(--main-dark);
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  min-width: 120px;
  overflow-wrap: anywhere;
}

.lesson-subject {
  color: #222b33;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.lesson-teacher,
.lesson-place {
  color: #59656f;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.lesson-place {
  color: #3f4b54;
}

.lesson-card.match {
  box-shadow: inset 0 0 0 2px #0f91d6;
}

.schedule-scroll {
  border: 1px solid #d6dee5;
  border-radius: 8px;
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.sheet-table {
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
  width: max-content;
}

.sheet-table td {
  background: #ffffff;
  border: 1px solid #d9dde1;
  line-height: 1.35;
  max-width: 260px;
  min-width: 92px;
  padding: 9px;
  vertical-align: top;
  white-space: pre-wrap;
}

.sheet-table td.axis-cell {
  background: #f5f9fc;
  font-weight: 500;
  z-index: 2;
}

.sheet-table td[data-col="1"].axis-cell {
  min-width: 118px;
  text-align: center;
}

.sheet-table td[data-col="2"].axis-cell {
  min-width: 110px;
  text-align: center;
}

.sheet-table td.has-value {
  color: #26323a;
}

.sheet-table td.header-cell {
  background: #f0f6fa;
  color: #25313a;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
}

.sheet-table td.lesson-cell {
  background: #fbfdff;
  border-left: 4px solid var(--main-color);
  box-shadow: inset 0 0 0 1px #eaf4fa;
  font-size: 12px;
  min-width: 190px;
}

.sheet-table td.lesson-cell:hover {
  background: #eef8fe;
}

.sheet-table td.match {
  box-shadow: inset 0 0 0 2px #0f91d6;
}

.notice {
  background: #f8fbfd;
  border: 1px solid #d9e7ef;
  border-radius: 8px;
  color: #44515b;
  padding: 16px;
}

.notice.compact {
  font-size: 13px;
  padding: 12px;
}

.file-preview {
  display: grid;
  gap: 12px;
}

.preview-head {
  align-items: center;
  background: #f8fbfd;
  border: 1px solid #d9e7ef;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.preview-head strong {
  color: #26323a;
  overflow-wrap: anywhere;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.preview-frame {
  background: #ffffff;
  border: 1px solid #d6dee5;
  border-radius: 8px;
  height: calc(100vh - 300px);
  min-height: 560px;
  width: 100%;
}

.image-preview {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d6dee5;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 320px;
  overflow: auto;
  padding: 16px;
}

.image-preview img {
  height: auto;
  max-height: calc(100vh - 320px);
  max-width: 100%;
  object-fit: contain;
}

@media (max-width: 980px) {
  body {
    display: block;
  }

  .sidebar {
    min-height: auto;
    width: 100%;
  }

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

  .status {
    text-align: left;
  }

  .file-head {
    display: grid;
  }

  .preview-head {
    align-items: stretch;
    display: grid;
  }

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

  .preview-actions .button {
    width: 100%;
  }

  .preview-frame {
    height: 70vh;
    min-height: 420px;
  }

  .week-controls {
    align-items: stretch;
    display: grid;
  }

  .week-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .time-row {
    grid-template-columns: 1fr;
  }

  .lesson-list {
    grid-template-columns: 1fr;
  }
}
