:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #617085;
  --line: #d9e1ea;
  --soft: #f4f7fa;
  --paper: #ffffff;
  --blue: #2454c6;
  --green: #1f8a62;
  --red: #bf3347;
  --brand-red: #731305;
  --footer-bg: #25282b;
  --footer-text: #a7adb4;
  --shadow: 0 18px 45px rgba(26, 37, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: #ffffff;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 76px;
  align-items: center;
  gap: 18px;
  min-height: 78px;
  padding: 14px 28px;
  background: var(--brand-red);
}

.site-header img {
  width: 64px;
  max-height: 48px;
  object-fit: contain;
  justify-self: end;
}

.site-title {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--brand-red);
  padding: 8px 14px;
  font-size: 23px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
  text-decoration: none;
}

.public-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.public-nav a,
.public-nav button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.public-nav a:hover,
.public-nav button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.public-nav span {
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  margin-left: 4px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--brand-red);
}

main {
  min-height: calc(100vh - 138px);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-height: 60px;
  padding: 18px 28px;
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 14px;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.footer-links a {
  color: var(--footer-text);
  text-decoration: none;
  font-weight: 700;
}

.footer-links a:hover {
  color: #ffffff;
}

.page-view[hidden],
.admin-section[hidden],
.login-screen[hidden] {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(244, 247, 250, 0.96);
}

.login-card,
.dialog-card {
  display: grid;
  gap: 16px;
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

dialog {
  width: min(1080px, calc(100vw - 32px));
  border: 0;
  border-radius: 14px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(24, 33, 47, 0.44);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 138px);
}

.workspace {
  min-width: 0;
  padding: 28px;
  background: #ffffff;
}

.public-workspace {
  background: var(--soft);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: rgb(37, 40, 43);
  color: #f7fbff;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c8d3e3;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: #3a3f44;
  color: #ffffff;
}

.side-panel {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.side-panel.compact {
  margin-top: auto;
}

.mini-label {
  color: #aebbd0;
  font-size: 13px;
  font-weight: 700;
}

.user-chip {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: #33383d;
}

.user-chip span,
.status-row {
  color: #aebbd0;
  font-size: 13px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #61d394;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-red);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.panel,
.course-card,
.stat-card,
.calendar-day {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

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

.filter-row,
.form-grid,
.form-section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.form-grid .wide,
.form-section-grid .wide {
  grid-column: 1 / -1;
}

.form-section {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.form-section legend {
  padding: 0 8px;
  color: var(--brand-red);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.form-section-grid {
  margin-bottom: 0;
  padding-top: 4px;
}

label {
  display: grid;
  gap: 6px;
  color: #314052;
  font-size: 14px;
  font-weight: 800;
}

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

input[type="file"] {
  padding: 8px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.primary,
.secondary,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
}

.primary {
  background: var(--brand-red);
  color: #ffffff;
}

.secondary {
  background: #eef2f6;
  color: var(--ink);
}

.danger {
  background: #bf3347;
  color: #ffffff;
}

.full {
  width: 100%;
}

.form-actions,
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.stacked-form {
  display: grid;
  gap: 16px;
}

.image-upload-field {
  display: grid;
  gap: 8px;
}

.image-upload-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f8faf9;
}

.image-preview {
  width: 180px;
  height: 108px;
  border-radius: 8px;
  object-fit: cover;
  background: #e8eeec;
}

.image-upload-controls {
  display: grid;
  gap: 8px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.term-date-row {
  display: grid;
  grid-template-columns: 1fr 130px 130px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkline input {
  width: auto;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.course-card {
  overflow: hidden;
}

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

.course-row-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.course-row-card img,
.thumb {
  width: 92px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
}

.course-row-card h2 {
  margin-bottom: 4px;
}

.course-row-card p {
  margin: 0;
  color: var(--muted);
}

.course-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.course-body {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.course-body h2 a {
  color: var(--ink);
  text-decoration-color: rgba(115, 19, 5, 0.35);
  text-underline-offset: 4px;
}

.course-body p,
.empty,
.panel p {
  color: var(--muted);
  line-height: 1.5;
}

.status-pill,
.tag {
  width: max-content;
  border-radius: 999px;
  background: #eaf1ec;
  color: var(--green);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.tag {
  background: #eef2f6;
  color: var(--muted);
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-row span {
  border-radius: 8px;
  background: #f0f3f7;
  color: #445365;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 700;
}

.hero-image {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.term-list,
.basket-list {
  display: grid;
  gap: 12px;
}

.term-item,
.basket-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #ffffff;
}

.term-item {
  display: grid;
  gap: 7px;
}

.term-item.disabled {
  opacity: 0.62;
}

.basket-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

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

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.calendar-day {
  min-height: 128px;
  padding: 10px;
}

.calendar-day strong {
  display: block;
  margin-bottom: 7px;
}

.muted-day {
  opacity: 0.42;
}

.calendar-event {
  display: block;
  border-radius: 7px;
  background: var(--brand-red);
  color: #ffffff;
  padding: 7px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f3f7;
  color: #4d5b6a;
  font-size: 13px;
  text-transform: uppercase;
}

.action-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 34px;
}

.bar-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

.bar {
  height: 14px;
  border-radius: 999px;
  background: #dfe6ee;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--brand-red);
}

@media (max-width: 1100px) {
  .site-header {
    grid-template-columns: 1fr 64px;
  }

  .public-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .course-grid,
  .stats-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .site-header,
  .site-footer,
  .topbar,
  .calendar-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header {
    display: flex;
  }

  .public-nav {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace,
  .sidebar {
    padding: 18px;
  }

  .course-grid,
  .stats-grid,
  .detail-grid,
  .filter-row,
  .form-grid,
  .form-section-grid,
  .image-upload-row,
  .term-date-row,
  .calendar {
    grid-template-columns: 1fr;
  }

  .image-preview {
    width: 100%;
    height: 160px;
  }

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