:root {
  --page: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-header: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #1e40af;
  --primary-hover: #1d3557;
  --primary-light: #eff6ff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --focus: #2563eb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --radius: 12px;
  --shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.header-inner {
  width: min(100% - 48px, 980px);
  padding: 16px 0;
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.institution {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}

.institution-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.institution-copy {
  min-width: 0;
}

.institution-name {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}

.institution-subtitle {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.academic-year {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}

/* Main Layout */
main {
  width: min(100% - 48px, 980px);
  margin: 36px auto 60px;
}

.page-intro {
  margin-bottom: 24px;
}

.page-intro h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.6rem, 2.8vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-intro-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.required-note {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.required-marker {
  color: var(--danger);
  font-weight: 700;
}

/* Form Container */
.registration-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
}

fieldset:last-of-type {
  border-bottom: none;
}

legend {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 20px 32px;
  margin: 0;
  background: var(--surface-header);
  border-bottom: 1px solid var(--border);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.section-number {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--surface);
  font-size: 0.76rem;
  font-weight: 700;
}

.form-grid {
  padding: 28px 32px 32px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
}

.form-field {
  min-width: 0;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

label,
.group-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input,
select {
  min-height: 44px;
  padding: 9px 12px;
}

select {
  cursor: pointer;
}

textarea {
  min-height: 108px;
  padding: 10px 12px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Error States */
.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: var(--danger);
  background-color: #fffbfa;
}

.field-error-msg {
  display: block;
  margin-top: 5px;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
}

/* File Upload */
input[type="file"] {
  min-height: 44px;
  padding: 6px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease;
}

input[type="file"]::file-selector-button:hover {
  background: #e2e8f0;
}

.helper-text {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

/* Declaration */
.declaration {
  padding: 24px 32px 28px;
}

.declaration-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.declaration.has-error .declaration-card {
  border-color: var(--danger);
  background-color: #fffbfa;
}

.checkbox-label {
  margin: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

/* Form Actions */
.form-actions {
  padding: 20px 32px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
}

.button {
  min-height: 42px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 140ms ease, border-color 140ms ease, transform 100ms ease;
}

.button:active {
  transform: scale(0.98);
}

.button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover {
  background: #f1f5f9;
}

.button-primary {
  background: var(--primary);
  color: var(--surface);
}

.button-primary:hover {
  background: var(--primary-hover);
}

.button-danger {
  background: var(--danger);
  color: #ffffff;
}

.button-danger:hover {
  background: #dc2626;
}

.button-sm {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 6px;
}

/* QR Code Top Banner */
.qr-top-banner {
  margin-bottom: 26px;
}

.qr-top-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 26px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-left: 4px solid var(--primary);
}

.qr-top-code {
  flex: 0 0 148px;
  width: 148px;
  height: 148px;
  background: #ffffff;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-top-code svg,
.qr-top-code img {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-top-info {
  flex: 1;
  min-width: 0;
}

.qr-top-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.qr-top-info h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.qr-top-info p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.qr-top-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  word-break: break-all;
}

.qr-top-link a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.qr-top-link a:hover {
  text-decoration: underline;
}

/* Banner Alerts */
.alert {
  padding: 14px 18px;
  margin-bottom: 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.4;
}

.alert-danger {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #991b1b;
}

.alert-success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #166534;
}

.alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

/* Success Card */
.success-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 40px;
  text-align: center;
}

.success-icon-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: #dcfce7;
  color: #16a34a;
  display: grid;
  place-items: center;
  font-size: 2rem;
}

.success-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin: 16px 0 24px;
}

.details-table-wrap {
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-align: left;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
}

.details-table th,
.details-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.details-table tr:last-child th,
.details-table tr:last-child td {
  border-bottom: none;
}

.details-table th {
  width: 35%;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.details-table td {
  color: var(--text);
  font-weight: 500;
}

/* Admin Dashboard Elements */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.search-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}

.search-input {
  flex: 1;
  min-width: 220px;
}

.filter-select {
  min-width: 160px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 4px;
}

.data-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--surface-subtle);
  padding: 14px 16px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.action-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Responsive Styles */
@media (max-width: 720px) {
  .header-inner,
  main {
    width: min(100% - 32px, 980px);
  }

  legend {
    padding: 16px 20px;
  }

  .form-grid {
    padding: 20px;
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .form-field.full-width {
    grid-column: auto;
  }

  .declaration {
    padding: 18px 20px;
  }

  .form-actions {
    padding: 18px 20px;
  }

  main {
    margin-block: 24px 40px;
  }

  .page-intro-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .success-card {
    padding: 24px 18px;
  }

  .qr-top-card {
    flex-direction: column;
    text-align: center;
    padding: 20px 18px;
  }

  .qr-top-code {
    margin: 0 auto;
  }

  .details-table th {
    width: 45%;
  }
}

@media (max-width: 480px) {
  .header-inner {
    width: calc(100% - 24px);
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .institution {
    gap: 12px;
  }

  .institution-logo {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .institution-name {
    font-size: 1.1rem;
  }

  main {
    width: calc(100% - 24px);
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .button {
    width: 100%;
  }

  .search-filter-form {
    flex-direction: column;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .site-header,
  .form-actions,
  .print-hide {
    display: none !important;
  }

  .success-card {
    box-shadow: none;
    border: none;
    padding: 0;
  }
}
