:root {
  color-scheme: light;
  --red: #a3161c;          /* table header / frame */
  --red-dark: #7d1015;
  --alert: #d9534f;
  --gold-1: #f7df98;
  --gold-2: #d6a832;
  --gold-3: #9a7016;
  --gold: #d4a234;
  --green: #5cb85c;
  --green-dark: #449d44;
  --green-brand: #12a57a;
  --ink: #111;
  --muted: #666;
  --focus: #1a73e8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: Arial, Helvetica, sans-serif; color: var(--ink); background: #fff; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------------- Brand (emblem + stacked wordmark, our own artwork) ---------------- */
.brand { display: inline-flex; align-items: center; gap: 6px; }
.brand-emblem { width: 72px; height: 72px; flex: none; }
.wordmark { display: inline-flex; flex-direction: column; font-family: Oswald, "Arial Narrow", Arial, sans-serif; font-weight: 700; line-height: .92; text-transform: uppercase; letter-spacing: .5px; text-align: left; }
.wm-1 { color: var(--red); }
.wm-2 { color: var(--green-brand); }
.wm-3 { color: var(--gold-2); }

/* ---------------- Search page ---------------- */
.search-body { min-height: 100vh; font-family: Poppins, Arial, sans-serif; background: #e9e1d2; }
.search-bg { position: fixed; inset: 0; z-index: 0; background: url("/public/campus.svg") center / cover no-repeat; }
.search-bg::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.45); }
.search-wrap { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 100px 16px 32px; }
.search-card {
  width: 100%; max-width: 560px; background: #fff; border-radius: 4px;
  padding: 30px 40px 40px; box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.search-brand { margin: 0 0 22px; text-align: center; font-size: inherit; line-height: 1; }
.brand--search .brand-emblem { width: 76px; height: 76px; }
.brand--search .wordmark { font-size: 27px; }
.released { color: var(--alert); font-size: 13px; font-weight: 700; margin: 0 0 4px; letter-spacing: .2px; font-family: Arial, sans-serif; }
.search-card label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; color: #222; }
.search-card input, .search-card select {
  display: block; width: 100%; height: 34px; font: 14px Poppins, Arial, sans-serif; color: #333;
  padding: 6px 7px; border: 1px solid #ccc; border-radius: 4px; background: #fff;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075); transition: border-color .15s, box-shadow .15s;
}
.search-card select { padding-left: 12px; }
.search-card input::placeholder { color: #999; }
.search-card input:focus, .search-card select:focus { outline: none; border-color: #66afe9; box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 0 3px rgba(102,175,233,.35); }
.search-card input[aria-invalid="true"] { border-color: var(--alert); }
.field-error { color: var(--alert); font-size: 13px; margin: 6px 0 0; }
.field-error:empty { display: none; }
.actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.btn-search {
  display: inline-flex; align-items: stretch; padding: 0; overflow: hidden; cursor: pointer;
  background: var(--green); color: #fff; border: 1px solid #4cae4c; border-radius: 4px;
  font: 500 14px Poppins, Arial, sans-serif; min-height: 34px;
}
.btn-search .btn-text { padding: 6px 12px; display: flex; align-items: center; }
.btn-search .btn-icon { display: flex; align-items: center; padding: 0 12px; background: rgba(0,0,0,.15); }
.btn-search:hover { background: var(--green-dark); }
.btn-search:disabled { opacity: .75; cursor: progress; }
.search-card hr { border: 0; border-top: 1px solid #eee; margin: 20px 0 0; }
.copyright { color: #fff; font-size: 13px; font-weight: 500; margin: 24px 0 0; text-align: center; text-shadow: 0 0 2px rgba(0,0,0,.9), 0 1px 4px rgba(0,0,0,.7); }

/* ---------------- Result page ---------------- */
.result-body { background: #f1f1f1; padding: 16px 12px 32px; }
.toolbar { max-width: 1040px; margin: 0 auto 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn-back { color: var(--red); text-decoration: none; font-weight: 700; font-size: 14px; padding: 6px 0; }
.btn-back:hover { text-decoration: underline; }
.btn-print { background: var(--red); color: #fff; border: 0; border-radius: 4px; padding: 8px 22px; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn-print:hover { background: var(--red-dark); }

.card { max-width: 1040px; margin: 0 auto; background: #fff; padding: 12px 20px 24px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.banner { display: flex; align-items: center; gap: 12px; padding: 0 0 6px; }
.banner-emblem { width: 88px; height: 88px; flex: none; }
.banner-text {
  font-family: Oswald, "Arial Narrow", Arial, sans-serif; font-weight: 700; letter-spacing: 1px;
  font-size: clamp(22px, 5.4vw, 54px); line-height: 1;
  background: linear-gradient(90deg, #a57414 0%, var(--gold-2) 30%, var(--gold-1) 55%, var(--gold-2) 75%, #a57414 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  display: inline-block; padding-right: .08em; background-size: calc(100% - .08em) 100%; background-repeat: no-repeat;
}

/* Red rounded frame; the title box straddles its top edge. */
.frame { position: relative; border: 1px solid var(--red); border-radius: 12px; margin-top: 48px; padding: 0 10px 0; overflow: visible; }
.frame > *:not(.watermark) { position: relative; z-index: 1; }
.watermark { position: absolute; z-index: 0; left: 50%; top: 20px; transform: translateX(-50%); opacity: .1; pointer-events: none; white-space: nowrap; }
.brand--watermark .brand-emblem { width: 220px; height: 220px; }
.brand--watermark .wordmark { font-size: 76px; }

.title-block { display: flex; flex-direction: column; width: 220px; margin: -28px auto 18px; border: 1px solid var(--red); border-radius: 6px; overflow: hidden; background: #fff; font-size: inherit; text-align: center; }
.title-gold { background: var(--gold); color: #fff; font-weight: 700; font-size: 18px; padding: 5px 6px 3px; }
.title-sub { background: #fff; color: #000; font-weight: 400; font-size: 16px; padding: 5px 6px 6px; border-top: 2px solid #fff; }

.info-box { border: 2px solid #000; padding: 12px 14px 44px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 14px; }
.info-field { display: flex; align-items: flex-end; gap: 10px; flex: 1 1 300px; min-width: 0; }
.info-field--roll { flex: 0 1 330px; }
.info-label { white-space: nowrap; min-width: 4.5em; }
.info-value { flex: 1; min-width: 0; border-bottom: 1px solid #000; padding: 0 6px 1px; overflow-wrap: anywhere; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 14px;
  /* scroll-shadow hint on the right edge when the table overflows */
  background: linear-gradient(90deg, #fff 30%, rgba(255,255,255,0)) left / 24px 100% no-repeat local,
              linear-gradient(270deg, #fff 30%, rgba(255,255,255,0)) right / 24px 100% no-repeat local,
              radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.18), transparent) left / 10px 100% no-repeat scroll,
              radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.18), transparent) right / 10px 100% no-repeat scroll; }
table.marks { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
table.marks thead th { padding: 0 1px; vertical-align: bottom; font-weight: 700; }
table.marks thead th:first-child { padding-left: 0; }
table.marks thead th:last-child { padding-right: 0; }
table.marks .tab { display: block; background: var(--red); color: #fff; text-align: center; padding: 10px 8px 9px; border-radius: 10px 10px 0 0; white-space: nowrap; }
table.marks thead th.label { width: 51%; }
table.marks thead th.label .tab { padding-bottom: 14px; padding-top: 12px; }
table.marks tbody th, table.marks tbody td {
  font-weight: 700; text-align: center; padding: 1px 8px; line-height: 1.35;
  border-right: 1px solid #000; border-bottom: 1px solid #000; background: transparent;
}
table.marks tbody tr:first-child > * { border-top: 1px solid #000; }
table.marks tbody th:first-child, table.marks tbody td:first-child { border-left: 1px solid #000; }
table.marks tbody .label { text-align: left; padding-left: 13px; white-space: nowrap; }

.result-footer { text-align: center; font-weight: 700; font-size: 13px; padding: 8px 8px 14px; }
.result-footer p { margin: 3px 0; }
.bottom-bar { height: 16px; background: var(--red); margin: 0 -10px; border-radius: 0 0 11px 11px; }

/* ---------------- Admin ---------------- */
.admin-body { background: #f6f6f6; }
.admin { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
.admin h1 { color: var(--maroon); }
.admin section { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 12px 16px; margin: 14px 0; }
.admin .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.admin label { display: flex; flex-direction: column; font-size: 13px; font-weight: 600; gap: 4px; }
.admin input, .admin select, .admin textarea { font: inherit; padding: 6px 8px; border: 1px solid #bbb; border-radius: 5px; }
.admin textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 13px; margin-bottom: 8px; }
.admin details { border-top: 1px solid #eee; padding: 8px 0; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 8px; }
.admin-table th, .admin-table td { border: 1px solid #ccc; padding: 4px 6px; text-align: left; }
.flash { background: #fff6d6; border: 1px solid #e6c25a; padding: 8px 12px; border-radius: 6px; }
.btn-small { font-size: 12px; padding: 3px 8px; border-radius: 4px; border: 1px solid #999; background: #fff; cursor: pointer; }
.btn-small.danger { color: var(--red); border-color: var(--red); }

/* ---------------- Phone ---------------- */
@media (max-width: 600px) {
  .search-wrap { padding-top: 32px; }
  .search-card { padding: 22px 18px 24px; }
  .brand--search .brand-emblem { width: 60px; height: 60px; }
  .brand--search .wordmark { font-size: 22px; }
  .result-body { padding: 10px 8px 24px; }
  .card { padding: 10px 10px 16px; }
  .banner-emblem { width: 52px; height: 52px; }
  .frame { margin-top: 40px; padding: 0 8px; }
  .brand--watermark .brand-emblem { width: 120px; height: 120px; }
  .brand--watermark .wordmark { font-size: 40px; }
  .info-box { padding-bottom: 28px; }
  .info-field--roll { flex: 1 1 300px; }
  .bottom-bar { margin: 0 -8px; }
  /* Fit more of the table on screen: wrap the long label, tighter type. Still scrolls inside .table-wrap if needed. */
  table.marks { min-width: 500px; font-size: 12.5px; }
  table.marks tbody .label { white-space: normal; padding-left: 8px; min-width: 170px; }
  table.marks .tab { padding: 8px 4px 7px; white-space: normal; }
  table.marks thead th.label { width: 40%; }
}

/* ---------------- Print (A4) ---------------- */
@page { size: A4 portrait; margin: 8mm; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .no-print { display: none !important; }
  .result-body { background: #fff; padding: 0; }
  .card { max-width: none; width: 100%; margin: 0; padding: 0; box-shadow: none; }
  .table-wrap { overflow: visible; background: none; }
  table.marks { min-width: 0; font-size: 12px; }
  table.marks tbody tr { break-inside: avoid; }
  .banner-emblem { width: 72px; height: 72px; }
  .banner-text { font-size: 44px; background: none; color: var(--gold-2); -webkit-text-fill-color: var(--gold-2); }
}
