:root {
  --primary: #1B4332;
  --primary-soft: #2D6A4F;
  --primary-light: #74C69D;
  --bg: #F8F4EE;
  --surface: #FFFFFF;
  --border: rgba(27, 67, 50, 0.12);
  --text: #1A1A18;
  --muted: #5B635D;
  --shadow: 0 18px 50px rgba(27, 67, 50, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
body {
  display: flex;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}
a { color: inherit; text-decoration: none; }

.page-shell {
  flex: 1;
  width: 100%;
}
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 24px;
}
.brand-name { font-family: Arial, Helvetica, sans-serif; font-size: 20px; color: var(--primary); }
.brand-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.header-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.text-link { font-size: 13px; color: var(--primary); font-weight: 500; }
.btn-secondary, .btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; border: none; cursor: pointer; font-family: Arial, Helvetica, sans-serif; font-weight: 600; }
.btn-primary { background: var(--primary); color: #fff; padding: 12px 20px; }
.btn-primary:hover { background: var(--primary-soft); }
.btn-secondary { background: transparent; color: var(--primary); padding: 12px 20px; border: 1.5px solid var(--primary); }
.btn-secondary:hover { background: rgba(27, 67, 50, 0.08); }

.content-panel { display: flex; justify-content: center; }
.panel-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 32px; box-shadow: var(--shadow); }
.panel-wide { max-width: 900px; }
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.panel-copy { margin-top: 10px; color: var(--muted); max-width: 680px; line-height: 1.7; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.form-group label { font-size: 13px; color: var(--text); font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input,
.form-group select {
  min-height: 48px;
  line-height: 1.2;
}

.form-group select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 44px;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B635D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 4px rgba(116, 198, 157, 0.12);
}


.form-group select:hover {
  border-color: var(--primary-soft);
}

.form-group select:focus {
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 4px rgba(116, 198, 157, 0.12);
}



.location-dropdown { position:relative; display:block; }
.location-dropdown input { padding-right:44px; }
.location-dropdown::after {
  content:'⌄'; position:absolute; right:16px; top:50%; transform:translateY(-55%);
  color:var(--muted); font-size:18px; line-height:1; pointer-events:none;
}

#barangay_name,
#barangay_name:invalid {
  border-color: var(--border) !important;
  box-shadow: none;
}

#barangay_name:focus,
#barangay_name:focus:invalid {
  border-color: var(--primary-soft) !important;
  box-shadow: 0 0 0 4px rgba(116, 198, 157, 0.12);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary-soft); box-shadow: 0 0 0 4px rgba(116, 198, 157, 0.12); }
.form-group textarea { min-height: 120px; resize: vertical; }

input[type="date"]:valid {
  border-color: #10b981;
}

input[type="date"]:invalid {
  border-color: var(--border);
}

#sex:invalid,
#civil_status:invalid {
  border-color: var(--border);
}

form.validation-visible input[type="date"]:invalid,
input[type="date"].validation-touched:invalid {
  border-color: #ef4444;
}

input[data-ph-mobile]:not(:placeholder-shown):valid {
  border-color: #10b981;
}

input[data-ph-mobile]:not(:placeholder-shown):invalid {
  border-color: #ef4444;
}

#contact:not(:placeholder-shown):valid {
  border-color: #10b981;
}

#contact:not(:placeholder-shown):invalid {
  border-color: #ef4444;
}

#contact,
#barangay_name,
#sitio {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #fff;
  outline: none;
}

#contact:focus,
#barangay_name:focus,
#sitio:focus {
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 4px rgba(116, 198, 157, 0.12);
}

.alert { border-radius: 14px; padding: 14px 18px; margin-bottom: 20px; font-size: 14px; }
.alert-error { background: #FEE2E2; color: #7F1D1D; border: 1px solid rgba(253, 186, 116, 0.4); }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid rgba(16, 185, 129, 0.4); }

.auth-panel { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.auth-card { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 36px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0; font-size: 28px; line-height: 1.1; color: var(--primary); }
.auth-copy { margin: 12px 0 24px; color: var(--muted); line-height: 1.7; }
.auth-note { margin-top: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.table-wrapper { overflow-x: auto; }
.status-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.status-table th,
.status-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.status-table th { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.status-table td a { color: var(--primary); font-weight: 600; }

.empty-state { padding: 52px 0; text-align: center; color: var(--muted); }
.empty-state p { font-size: 15px; margin-bottom: 18px; }

.detail-card { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 24px; }
.detail-card h2 { margin: 0 0 16px; font-size: 20px; color: var(--primary); }
.detail-row { margin-bottom: 14px; font-size: 14px; color: var(--text); }
.detail-row strong { color: var(--primary); }
.detail-row p { margin: 6px 0 0; color: var(--muted); line-height: 1.7; }

.process-section {
  margin-top: 32px;
  padding: 24px;
  background: #F7FFF7;
  border: 1px solid rgba(27, 67, 50, 0.08);
  border-radius: 22px;
}
.process-section h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: var(--primary);
}
.process-section p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.75;
}
.process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.process-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}
.process-step {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  font-weight: 700;
  margin-bottom: 12px;
}
.process-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--text);
}
.process-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; }
.badge-submitted { background: #E5E7EB; color: #374151; }
.badge-processing { background: #FEF3C7; color: #92400E; }
.badge-approved { background: #D1FAE5; color: #065F46; }
.badge-rejected, .badge-disqualified { background: #FEE2E2; color: #991B1B; }

@media (max-width: 900px) {
  .page-shell { padding: 0 12px; }
  .portal-header {
    flex-direction: column;
    align-items: stretch;
  }
  .portal-header, .panel-card { padding: 20px; }
  .header-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .header-actions a {
    min-width: 0;
  }
  .panel-top { flex-direction: column; align-items: stretch; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { padding: 10px; }
  .portal-header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 12px; }
  .header-actions a { width: 100%; }
  .btn-primary, .btn-secondary { width: 100%; justify-content: center; }
  .auth-card { padding: 28px; }
}

@media (max-width: 480px) {
  .page-shell { padding: 0 8px; }
  .panel-card, .auth-card { padding: 18px 14px; border-radius: 16px; }
  .page-header h1, .auth-card h1 { font-size: 24px; }
  .process-section { padding: 16px; border-radius: 16px; }
  .process-grid { grid-template-columns: 1fr; }
  .form-row { gap: 0; }
}

html, body { width: 100%; min-width: 0; overflow-x: hidden; }
img, video, iframe, svg { max-width: 100%; }
input, select, textarea, button { max-width: 100%; min-width: 0; }
.page-shell, .content-panel, .panel-card, .auth-card, .form-container, .form-group, .form-row { min-width: 0; max-width: 100%; }
.panel-card h1, .panel-copy, .auth-card h1, .auth-copy, .alert, .form-group label { overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .page-shell { padding: 0 8px; }
  .panel-card, .auth-card { width: 100%; padding: 20px 14px; border-radius: 16px; }
  .panel-top, .portal-header, .header-actions, .location-actions { width: 100%; min-width: 0; }
  .panel-top, .portal-header { align-items: stretch; }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .btn-primary, .btn-secondary, .location-actions button { width: 100%; }
}
/* Scroll-in reveal for portal content cards. */
.scroll-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 450ms ease, transform 450ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}

.scroll-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.registration-captcha {
  max-width: 100%;
  margin: 0 0 18px;
  overflow-x: auto;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-reveal,
  .scroll-reveal.is-revealed {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
