:root {
  --burgundy: #28307c;
  --burgundy-dark: #1d245f;
  --burgundy-soft: #eef0fa;
  --ink: #1c2530;
  --muted: #66717d;
  --line: #dfe3e7;
  --surface: #ffffff;
  --background: #f5f6f7;
  --success: #176b4d;
  --success-soft: #e9f6f0;
  --danger: #a12b2b;
  --danger-soft: #fff0f0;
  --shadow: 0 14px 40px rgba(28, 37, 48, 0.08);
}

* { box-sizing: border-box; }
html { min-height: 100%; font-size: 16px; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}
a { color: var(--burgundy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.main-content { min-height: calc(100vh - 190px); padding-top: 44px; padding-bottom: 70px; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-accent { height: 5px; background: linear-gradient(90deg, var(--burgundy-dark), var(--burgundy), #4654a4); }
.header-inner { min-height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.brand { display: flex; align-items: center; gap: 16px; color: var(--ink); text-decoration: none; }
.brand-logo {
  display: block;
  width: 56px;
  flex: 0 0 56px;
  line-height: 0;
}
.brand-logo img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.06rem; }
.brand-copy small { margin-top: 5px; color: var(--muted); letter-spacing: 0.04em; }
nav { display: flex; align-items: center; gap: 24px; }
nav a, .link-button { color: var(--ink); font-weight: 600; text-decoration: none; font-size: 0.92rem; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; padding: 0; background: transparent; cursor: pointer; font-family: inherit; }
nav a:hover, .link-button:hover { color: var(--burgundy); }

h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; line-height: 1.18; }
h1 { font-size: clamp(2rem, 5vw, 3.35rem); margin-bottom: 18px; letter-spacing: -0.025em; }
h2 { font-size: clamp(1.45rem, 3vw, 2.1rem); margin-bottom: 12px; }
h3 { line-height: 1.28; }
.hero { max-width: 850px; padding: 34px 0 62px; }
.hero p { max-width: 760px; color: var(--muted); font-size: 1.12rem; }
.eyebrow, .section-kicker {
  display: block;
  margin-bottom: 10px;
  color: var(--burgundy);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.section-heading, .admin-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.section-heading h2, .admin-heading h1 { margin-bottom: 0; }
.count-badge, .status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 800;
}
.count-badge { background: #e9ecef; color: #49525d; }
.status-badge.published { background: var(--success-soft); color: var(--success); }
.status-badge.draft { background: #f0f1f2; color: #59636d; }
.exam-list { display: grid; gap: 16px; }
.exam-card {
  display: grid;
  grid-template-columns: 105px 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(28, 37, 48, 0.035);
}
.exam-card-date { min-height: 70px; padding-right: 22px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.exam-card-date span { color: var(--burgundy); font-family: Georgia, serif; font-size: 2rem; font-weight: 700; line-height: 1; }
.exam-card-date small { color: var(--muted); margin-top: 6px; }
.exam-card-body h3 { margin-bottom: 8px; font-size: 1.15rem; }
.exam-card-body p { margin-bottom: 8px; color: var(--muted); }
.meta { color: var(--muted); font-size: 0.82rem; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.91rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--burgundy); color: white; }
.button-primary:hover { background: var(--burgundy-dark); color: white; }
.button-secondary { background: white; color: var(--ink); border-color: #cbd1d7; }
.button-secondary:hover { border-color: var(--burgundy); color: var(--burgundy); }
.button-danger { background: white; border-color: #e0a2a2; color: var(--danger); }
.button-danger:hover { background: var(--danger-soft); }
.button-small { min-height: 36px; padding: 7px 13px; font-size: 0.82rem; }
.button-full { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.empty-state { padding: 64px 30px; text-align: center; background: var(--surface); border: 1px dashed #c6ccd2; border-radius: 12px; }
.empty-state h1, .empty-state h2, .empty-state h3 { margin-bottom: 10px; }
.empty-state p { color: var(--muted); }
.empty-state.narrow { max-width: 700px; margin: 60px auto; }
.breadcrumb { display: flex; gap: 10px; margin-bottom: 32px; color: var(--muted); font-size: .86rem; }
.query-layout, .editor-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .75fr); gap: 70px; align-items: start; }
.query-intro { padding-top: 20px; }
.query-intro h1 { font-size: clamp(2rem, 4vw, 3rem); }
.query-intro > p { max-width: 660px; color: var(--muted); }
.exam-date { color: var(--burgundy) !important; font-weight: 700; }
.privacy-note { max-width: 620px; margin-top: 36px; padding: 18px 20px; border-left: 3px solid var(--burgundy); background: var(--burgundy-soft); }
.privacy-note p { margin: 5px 0 0; color: #535c66; font-size: .9rem; }
.form-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.form-card { padding: clamp(24px, 5vw, 38px); }
.form-card h1 { font-size: 2rem; }
.form-card h2 { font-size: 1.6rem; }
.form-help, .muted { color: var(--muted); }
.form-group { margin-top: 22px; }
.form-group label, .upload-form label { display: block; margin-bottom: 7px; font-size: .88rem; font-weight: 750; }
input, textarea {
  width: 100%;
  border: 1px solid #bfc6ce;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
  font: inherit;
}
input:focus, textarea:focus { outline: 3px solid rgba(40, 48, 124, .16); border-color: var(--burgundy); }
input[type="file"] { padding: 9px; background: #fafafa; }
.form-group small { display: block; margin-top: 6px; color: var(--muted); }
.field-error { display: block; min-height: 1em; margin-top: 5px; color: var(--danger); font-size: .84rem; }
.validation-summary { margin-bottom: 18px; color: var(--danger); font-size: .9rem; }
.validation-summary:empty { display: none; }
.validation-summary ul { margin: 0; padding-left: 20px; }
.captcha-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.captcha-question { display: grid; place-items: center; min-height: 50px; border: 1px dashed #b7bec6; border-radius: 6px; background: repeating-linear-gradient(-35deg, #f3f4f5, #f3f4f5 6px, white 6px, white 12px); font-family: Georgia, serif; font-size: 1.2rem; font-weight: 700; letter-spacing: .08em; }
.login-shell { display: grid; place-items: center; min-height: 570px; }
.login-card { width: min(100%, 480px); }

.alert { margin-bottom: 24px; border: 1px solid; border-radius: 8px; padding: 14px 16px; }
.alert-success { background: var(--success-soft); border-color: #a9d7c5; color: #155a42; }
.alert-error { background: var(--danger-soft); border-color: #e4b3b3; color: #812525; }
.alert pre { margin: 10px 0 0; white-space: pre-wrap; font-family: inherit; font-size: .88rem; }
.admin-heading { align-items: center; }
.admin-heading > div:first-child { max-width: 780px; }
.admin-heading p { margin-bottom: 0; color: var(--muted); }
.table-shell { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 10px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 16px 18px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { background: #f8f9fa; color: #58626d; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
.admin-table td small { display: block; margin-top: 4px; color: var(--muted); }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.editor-layout > section:first-child { padding-top: 25px; }
.editor-layout > section:first-child p { max-width: 590px; color: var(--muted); }
.details-heading { align-items: end; }
.details-heading h1 { margin: 12px 0; font-size: clamp(2rem, 4vw, 3rem); }
.title-status { display: flex; gap: 12px; align-items: center; }
.admin-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.panel { padding: 26px; box-shadow: 0 5px 20px rgba(28, 37, 48, .04); }
.panel-heading > div { display: flex; align-items: center; gap: 12px; }
.panel-heading h2 { margin: 0; font-family: inherit; font-size: 1.1rem; }
.step-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--burgundy); color: white; font-weight: 800; font-size: .82rem; }
.panel > p { margin: 18px 0; color: var(--muted); font-size: .92rem; }
.upload-form { display: grid; gap: 12px; margin-top: 20px; }
.import-summary { display: flex; flex-direction: column; margin-top: 18px; padding: 13px; background: var(--success-soft); border-radius: 6px; color: var(--success); font-size: .86rem; }
.field-list { display: grid; margin-top: 16px; max-height: 330px; overflow-y: auto; }
.field-list div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field-list small { color: var(--muted); }
.publish-panel { grid-column: 1 / -1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.compact-actions { justify-content: flex-end; flex-wrap: nowrap; }
.admin-note { margin-top: 24px; }

.document-toolbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 20px; }
.result-document { width: min(100%, 900px); margin: 0 auto; padding: clamp(28px, 6vw, 62px); background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.document-header { display: flex; align-items: center; justify-content: center; gap: 24px; padding-bottom: 28px; text-align: center; border-bottom: 3px double var(--ink); }
.document-logo { display: block; width: 72px; flex: 0 0 72px; line-height: 0; }
.document-logo img { display: block; width: 100%; height: auto; max-width: 100%; }
.document-header p { margin: 0 0 4px; font-weight: 700; }
.document-header h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.75rem); text-transform: uppercase; letter-spacing: .02em; }
.document-header h2 { margin: 7px 0 0; font-family: inherit; font-size: 1rem; letter-spacing: .12em; text-transform: uppercase; }
.document-exam { padding: 28px 0; text-align: center; border-bottom: 1px solid var(--line); }
.document-exam span { color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.document-exam h3 { margin: 0 0 4px; font-size: 1.2rem; }
.document-exam p { margin: 0; color: var(--muted); }
.document-section { padding-top: 30px; }
.document-section > h3 { padding-bottom: 8px; border-bottom: 1px solid var(--ink); font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.result-grid div { min-width: 0; padding: 13px 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-grid dt { margin-bottom: 4px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.result-grid dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.final-result { margin-top: 30px; padding: 20px 24px; background: var(--burgundy-soft); border: 1px solid #c8cdea; text-align: center; }
.final-result span { display: block; color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.final-result strong { display: block; margin-top: 5px; color: var(--burgundy-dark); font-family: Georgia, serif; font-size: 1.25rem; }
.document-footer { margin-top: 42px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .74rem; text-align: center; }
.document-footer p { margin: 3px 0; }
.site-footer { padding: 24px 0; background: #202832; color: #d6dae0; font-size: .8rem; }
.site-footer .container { display: flex; justify-content: space-between; gap: 25px; }

@media (max-width: 820px) {
  .header-inner { align-items: flex-start; flex-direction: column; padding: 18px 0; }
  nav { width: 100%; flex-wrap: wrap; gap: 16px; }
  .query-layout, .editor-layout { grid-template-columns: 1fr; gap: 30px; }
  .exam-card { grid-template-columns: 78px 1fr; }
  .exam-card .button { grid-column: 1 / -1; width: 100%; }
  .admin-grid { grid-template-columns: 1fr; }
  .publish-panel { grid-column: auto; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .container { width: min(100% - 24px, 1180px); }
  .main-content { padding-top: 28px; }
  .brand-logo { width: 48px; flex-basis: 48px; }
  .brand-copy strong { font-size: .9rem; }
  .brand-copy small { font-size: .75rem; }
  h1 { font-size: 2rem; }
  .hero { padding: 18px 0 40px; }
  .exam-card { grid-template-columns: 1fr; gap: 16px; padding: 19px; }
  .exam-card-date { min-height: auto; padding: 0 0 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .exam-card-date span { font-size: 1.35rem; }
  .captcha-row { grid-template-columns: 1fr 90px; }
  .result-document { padding: 22px 16px; }
  .document-header { align-items: center; flex-direction: column; gap: 13px; }
  .result-grid { grid-template-columns: 1fr; }
  .document-toolbar { align-items: stretch; flex-direction: column; }
  .site-footer .container { flex-direction: column; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: white; color: black; font-size: 10pt; }
  .no-print, .site-header, .site-footer { display: none !important; }
  .main-content, .container { width: 100%; min-height: 0; padding: 0; margin: 0; }
  .result-document { width: 100%; padding: 0; border: 0; box-shadow: none; }
  .result-document, .document-logo, .final-result { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .document-header h1 { font-size: 15pt; }
  .document-header h2 { font-size: 10pt; }
  .document-section, .final-result { break-inside: avoid; }
  .result-grid div { padding: 8px 10px; }
  .document-footer { margin-top: 24px; }
}
