* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #222;
  height: 100vh;
  overflow: hidden;
}

/* ---- Login ---- */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: 40px 48px;
  width: 360px;
}

.login-card img.logo { width: 180px; display: block; margin: 0 auto 24px; }
.login-card h2 { text-align: center; margin-bottom: 24px; font-size: 16px; color: #555; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: bold; font-size: 12px; color: #555; text-transform: uppercase; letter-spacing: .5px; }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: #c04040; }

.btn-primary {
  width: 100%; padding: 11px; background: #c04040; color: #fff;
  border: none; border-radius: 4px; font-size: 14px; font-weight: bold;
  cursor: pointer; margin-top: 8px;
}
.btn-primary:hover { background: #a03030; }

.error-msg { color: #c04040; font-size: 12px; margin-top: 8px; text-align: center; min-height: 18px; }

/* ---- Search ---- */
#search-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.search-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: 40px 48px;
  width: 440px;
  text-align: center;
}

.search-card img.logo { width: 180px; display: block; margin: 0 auto 20px; }
.search-card h2 { font-size: 15px; color: #555; margin-bottom: 24px; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.search-row input:focus { outline: none; border-color: #c04040; }
.search-row button { padding: 10px 18px; background: #c04040; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
.search-row button:hover { background: #a03030; }

.search-status { margin-top: 12px; font-size: 13px; color: #777; min-height: 20px; }
.logout-link { display: block; margin-top: 20px; font-size: 12px; color: #aaa; cursor: pointer; text-decoration: underline; }

/* ---- Editor ---- */
#editor-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.editor-topbar {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 2px solid #c04040;
  padding: 8px 16px;
  gap: 12px;
  flex-shrink: 0;
}

.editor-topbar img.logo { height: 36px; }
.editor-topbar .student-label { font-weight: bold; font-size: 15px; flex: 1; }
.editor-topbar .btn-export { padding: 8px 20px; background: #c04040; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 13px; }
.editor-topbar .btn-export:hover { background: #a03030; }
.editor-topbar .btn-back { padding: 8px 14px; background: #eee; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.editor-topbar .btn-back:hover { background: #ddd; }

.editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left panel */
.left-panel {
  width: 40%;
  overflow-y: auto;
  padding: 16px;
  background: #fff;
  border-right: 1px solid #ddd;
}

.section-header {
  background: #c04040;
  color: #fff;
  padding: 6px 10px;
  font-weight: bold;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 16px 0 8px;
  border-radius: 3px;
}

.field-row { display: flex; gap: 8px; margin-bottom: 8px; }
.field-row .field { flex: 1; }
.field { margin-bottom: 8px; }
.field label { display: block; font-size: 11px; font-weight: bold; color: #666; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 6px 8px; border: 1px solid #ccc;
  border-radius: 3px; font-size: 13px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #c04040; }
.field textarea { resize: vertical; min-height: 54px; }

/* Photos */
.photo-grid-editor {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.photo-thumb {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  resize: vertical;
  height: 160px;
  min-height: 60px;
}

.photo-thumb.excluded { opacity: .35; }
.photo-thumb.included { border-color: #2a7a2a; }

.photo-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; background: #f5f5f5; }

.photo-thumb .photo-badge {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; padding: 2px 6px; border-radius: 10px;
}
.photo-thumb.included .photo-badge { background: #2a7a2a; }

/* Right panel */
.right-panel {
  width: 60%;
  overflow-y: auto;
  overflow-x: auto;
  background: #555;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  gap: 16px;
}

.preview-page {
  background: #fff;
  width: 8.5in;
  min-height: 11in;
  box-shadow: 0 2px 16px rgba(0,0,0,.4);
  padding: 0.5in 0.5in 0.75in;
  position: relative;
  font-size: 9pt;
  font-family: Arial, Helvetica, sans-serif;
  color: #111;
}

/* ── Preview: PDF-matching styles ─────────────────────────── */
.preview-page .doc-header {
  display: flex; align-items: center;
  padding-bottom: 8px; border-bottom: 3px solid #1e3a5f; margin-bottom: 8px;
}
.preview-page .doc-header img { width: 110px; margin-right: 18px; }
.preview-page .doc-header-text h1 {
  font-size: 14pt; font-weight: bold; color: #1e3a5f;
  text-transform: uppercase; letter-spacing: 0.5px; line-height: 1.1;
}
.preview-page .doc-header-text p { font-size: 8pt; color: #555; margin-top: 3px; }

.preview-page .letter {
  background: #f4f7fb; border-left: 3px solid #1e3a5f;
  padding: 6px 10px; font-size: 7.8pt; line-height: 1.4;
  margin-bottom: 8px; border-radius: 0 3px 3px 0;
}
.preview-page .letter p { margin-bottom: 3px; }

.preview-page .sec-bar {
  background: #1e3a5f; color: #fff; font-size: 8pt; font-weight: bold;
  letter-spacing: 1.2px; text-transform: uppercase;
  padding: 4px 10px; margin: 8px 0 5px; border-radius: 3px;
}
.preview-page .sub-title {
  font-size: 7.5pt; font-weight: bold; color: #1e3a5f;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #c8d4e0; padding-bottom: 2px; margin: 6px 0 3px;
}
.preview-page .info-box {
  background: #f0f4f8; border-radius: 3px; padding: 5px 10px; margin-bottom: 6px;
}
.preview-page .prow { display: flex; gap: 10px; margin-bottom: 5px; }
.preview-page .col  { flex: 1; }
.preview-page .col-2 { flex: 2; }
.preview-page .col-3 { flex: 3; }
.preview-page .lbl {
  font-size: 7pt; color: #666; text-transform: uppercase;
  letter-spacing: 0.4px; margin-bottom: 1px;
}
.preview-page .val { font-size: 9pt; font-weight: bold; color: #111; min-height: 11px; }
.preview-page .val-normal { font-size: 8.5pt; font-weight: normal; color: #111; line-height: 1.35; }

.preview-page .parent-wrap { display: flex; gap: 8px; margin-bottom: 5px; }
.preview-page .parent-box { flex: 1; border: 1px solid #c8d4e0; border-radius: 4px; overflow: hidden; }
.preview-page .parent-title {
  background: #e8eef4; padding: 3px 8px; font-size: 7.5pt; font-weight: bold;
  color: #1e3a5f; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #c8d4e0;
}
.preview-page .parent-body { padding: 5px 8px; }

.preview-page .data-row { display: flex; gap: 8px; padding: 2px 0; border-bottom: 1px solid #eef0f3; }
.preview-page .data-row:last-child { border-bottom: none; }
.preview-page .desc { margin-bottom: 5px; }

.preview-page .p-footer {
  background: #c04040; color: #fff; text-align: center;
  font-size: 7.5pt; padding: 4px 0; letter-spacing: 0.3px;
  margin-top: 20px;
  margin-left: -0.5in; margin-right: -0.5in; margin-bottom: -0.75in;
}
.preview-page .photo-page-header {
  text-align: center; border-bottom: 3px solid #1e3a5f;
  padding-bottom: 8px; margin-bottom: 12px;
}
.preview-page .photo-page-header h2 {
  font-size: 14pt; font-weight: bold; color: #1e3a5f;
  text-transform: uppercase; letter-spacing: 1px;
}
.preview-page .p-photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.preview-page .p-photo-grid img {
  width: 100%; height: 265px; object-fit: contain;
  background: #f4f7fb; border: 1px solid #c8d4e0; border-radius: 4px; display: block;
}

.hidden { display: none !important; }
