*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --navy: #0f2d4a;
  --navy-dark: #0a2036;
  --blue: #1a4f82;
  --blue-hover: #133d66;
  --blue-soft: #eef5fc;
  --gold: #c8963e;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #d8e0e8;
  --border-strong: #b8c4d0;
  --ink: #1e293b;
  --slate: #475569;
  --muted: #64748b;
  --green: #166534;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --amber: #92400e;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --red: #991b1b;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.container {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
}

/* Header */
.site-header {
  background: var(--navy);
  color: #ffffff;
  border-bottom: 3px solid var(--gold);
}

.header-inner {
  min-height: 64px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.site-name {
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.site-name:hover {
  color: #ffffff;
  text-decoration: none;
}

.site-name img {
  width: 48px;
  height: 36px;
  object-fit: contain;
  background: #ffffff;
  padding: 2px 4px;
  border-radius: 3px;
  flex-shrink: 0;
}

.site-name b {
  background: #ffffff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.site-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.site-brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: #cbd5e1;
  letter-spacing: 0.1px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.site-nav a {
  color: #dbe7f3;
  font-size: 13.5px;
  font-weight: 500;
  padding: 4px 0;
  text-decoration: none;
}

.site-nav a:hover {
  color: #ffffff;
}

.site-nav .current {
  color: #ffffff;
  font-weight: 700;
  border-bottom: 2px solid var(--gold);
}

/* Breadcrumb & Page Headings */
.breadcrumb {
  color: var(--muted);
  font-size: 12.5px;
  padding: 16px 0 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--slate);
  font-weight: 500;
}

.breadcrumb a:hover {
  color: var(--blue);
}

.page-header-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: 4px;
  padding: 20px 24px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.main-title {
  font-size: 22px;
  line-height: 1.3;
  margin: 0 0 6px;
  color: var(--navy);
  font-weight: 700;
}

.page-intro {
  color: var(--slate);
  margin: 0;
  font-size: 13.5px;
  max-width: 780px;
}

/* Summary Strip */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 18px;
}

.summary-strip > div {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
}

.summary-strip > div:last-child {
  border-right: 0;
}

.summary-strip strong {
  display: block;
  font-size: 21px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.summary-strip span {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: block;
}

/* Filter & Search Bar */
.catalog-Controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 13.5px;
  color: var(--ink);
  background: #ffffff;
}

.search-box input:focus {
  border-color: var(--blue);
  outline: none;
}

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cat-tab {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--slate);
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.12s;
}

.cat-tab:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.cat-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #ffffff;
}

/* Sections & Tables */
.section {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  margin-bottom: 20px;
}

.section-head {
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 700;
  margin: 0;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-head small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.section-content {
  padding: 0 18px 8px;
}

.exam-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.exam-table th {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
}

.exam-table td {
  padding: 14px 10px;
  border-bottom: 1px solid #edf1f5;
  vertical-align: middle;
  font-size: 13.5px;
}

.exam-table tbody tr:hover td {
  background: #fafbfc;
}

.exam-table tbody tr:last-child td {
  border-bottom: none;
}

.exam-table .name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  display: block;
}

.exam-table .small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
}

.exam-top3-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.top3-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--ink);
}

.top3-pill.rank-1 {
  background: #fefce8;
  border-color: #fde047;
  color: #854d0e;
}

.top3-pill.rank-2 {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.top3-pill.rank-3 {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.top3-empty {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 5px;
  display: inline-block;
}

.exam-table .seq {
  color: var(--slate);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.code-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  background: #e8eff7;
  border: 1px solid #cbd9e8;
  padding: 2px 7px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.cat-label {
  display: inline-block;
  font-size: 11.5px;
  color: var(--slate);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 3px;
}

/* Subject Grid */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 18px;
}

.subject-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.subject-card:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(15, 45, 74, 0.06);
}

.subject-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subject-code {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  background: #e8eff7;
  border: 1px solid #cbd9e8;
  padding: 2px 8px;
  border-radius: 3px;
}

.subject-cat {
  font-size: 11px;
  color: var(--muted);
}

.subject-card h3 {
  margin: 6px 0 6px;
  font-size: 15.5px;
  color: var(--navy);
  line-height: 1.35;
}

.subject-card h3 a {
  color: inherit;
  text-decoration: none;
}

.subject-card h3 a:hover {
  color: var(--blue);
}

.subject-card p {
  margin: 0;
  color: var(--slate);
  font-size: 12.5px;
  line-height: 1.5;
}

.subject-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 11px;
  border-top: 1px solid #edf1f5;
  font-size: 12px;
  color: var(--muted);
}

/* Status Pill */
.status-pill {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--green-border);
  background: var(--green-bg);
  color: var(--green);
  border-radius: 3px;
  white-space: nowrap;
}

.status-pill.pending {
  border-color: var(--border);
  background: var(--surface-alt);
  color: var(--muted);
}

.status-pill.locked {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber);
}

/* Buttons */
.button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 4px;
  line-height: 1.4;
  white-space: nowrap;
  display: inline-block;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.button:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
  text-decoration: none;
  color: #ffffff;
}

.button.outline {
  color: var(--blue);
  background: #ffffff;
  border-color: var(--border-strong);
}

.button.outline:hover {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--navy);
}

.button:disabled {
  background: #cbd5e1;
  border-color: #cbd5e1;
  cursor: default;
  color: #ffffff;
}

.note {
  border-left: 3px solid var(--blue);
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 0 4px 4px 0;
  color: var(--slate);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}

.note strong {
  color: var(--navy);
}

.empty-box {
  padding: 28px 20px;
  color: var(--slate);
  font-size: 13.5px;
  text-align: center;
}

.footer {
  font-size: 12.5px;
  color: var(--muted);
  padding: 18px 0 36px;
  border-top: 1px solid var(--border);
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 920px) {
  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .summary-strip > div:nth-child(2) {
    border-right: 0;
  }
  .summary-strip > div:nth-child(1),
  .summary-strip > div:nth-child(2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 650px) {
  .container {
    width: calc(100% - 24px);
  }
  .subject-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .page-header-box {
    padding: 16px;
  }
  .main-title {
    font-size: 19px;
  }
  .section-content {
    padding: 0 10px 8px;
  }
  .exam-table thead {
    display: none;
  }
  .exam-table, .exam-table tbody, .exam-table tr, .exam-table td {
    display: block;
  }
  .exam-table tr {
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
  }
  .exam-table tr:last-child {
    border-bottom: 0;
  }
  .exam-table td {
    border: 0;
    padding: 3px 6px;
  }
  .exam-table td:last-child {
    padding-top: 10px;
    text-align: left !important;
  }
}
