/*
 * Rirekisho Japan Admin Portal
 * Visual language intentionally aligned with the public student form.
 */
.rpg-jp-portal {
  --rpg-jp-primary: #2563eb;
  --rpg-jp-primary-dark: #1d4ed8;
  --rpg-jp-primary-soft: #eff6ff;
  --rpg-jp-heading: #111827;
  --rpg-jp-text: #1f2937;
  --rpg-jp-muted: #6b7280;
  --rpg-jp-border: #e5e7eb;
  --rpg-jp-border-strong: #d1d5db;
  --rpg-jp-surface: #ffffff;
  --rpg-jp-page: #f3f4f6;
  --rpg-jp-success: #15803d;
  --rpg-jp-danger: #b91c1c;
  width: min(100%, 1180px);
  margin: 24px auto;
  padding: 38px;
  border: 1px solid #e8ebef;
  border-radius: 24px;
  background: var(--rpg-jp-page);
  color: var(--rpg-jp-text);
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans JP", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.rpg-jp-portal *,
.rpg-jp-portal *::before,
.rpg-jp-portal *::after { box-sizing: border-box; }
.rpg-jp-portal [hidden] { display: none !important; }

/* Hero */
.rpg-jp-header {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: 100%;
  margin: 0 0 24px;
  padding: 4px 2px 24px;
  border-bottom: 1px solid var(--rpg-jp-border);
  background: transparent;
  color: var(--rpg-jp-text);
}
.rpg-jp-header__copy { min-width: 0; }
.rpg-jp-hero__badge,
.rpg-jp-login__badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 12px;
  padding: 5px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: var(--rpg-jp-primary-soft);
  color: var(--rpg-jp-primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.rpg-jp-header h1 {
  margin: 0 0 7px;
  color: var(--rpg-jp-heading);
  font-size: clamp(27px, 4vw, 38px);
  font-weight: 750;
  letter-spacing: -.035em;
  line-height: 1.15;
}
.rpg-jp-header p {
  margin: 0;
  color: var(--rpg-jp-muted);
  font-size: 15px;
}

/* Login */
.rpg-jp-login {
  width: min(100%, 620px);
  margin: 18px auto;
  padding: 34px;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 20px;
  background: var(--rpg-jp-surface);
  box-shadow: 0 10px 32px rgba(17, 24, 39, .07);
}
.rpg-jp-login__head { margin-bottom: 24px; text-align: center; }
.rpg-jp-login h2 {
  margin: 0 0 8px;
  color: var(--rpg-jp-heading);
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -.025em;
}
.rpg-jp-login p { margin: 0; color: var(--rpg-jp-muted); }
.rpg-jp-login form { margin-top: 24px; }
.rpg-jp-login form > p { margin: 0 0 16px; }
.rpg-jp-login label { display: block; margin: 0 0 7px; color: #374151; font-size: 14px; font-weight: 650; }
.rpg-jp-login input[type=text],
.rpg-jp-login input[type=password] {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--rpg-jp-border-strong);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--rpg-jp-text);
  font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.rpg-jp-login input[type=text]:focus,
.rpg-jp-login input[type=password]:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.rpg-jp-login .login-remember label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.rpg-jp-login input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--rpg-jp-primary); }
.rpg-jp-login input[type=submit] {
  width: 100%;
  min-height: 46px;
  margin-top: 2px;
  padding: 10px 18px;
  border: 1px solid var(--rpg-jp-primary);
  border-radius: 10px;
  background: var(--rpg-jp-primary);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 7px 17px rgba(37, 99, 235, .2);
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.rpg-jp-login input[type=submit]:hover { background: var(--rpg-jp-primary-dark); box-shadow: 0 9px 20px rgba(37,99,235,.26); transform: translateY(-1px); }

/* Toolbar and summary */
.rpg-jp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 18px;
  padding: 18px;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 16px;
  background: var(--rpg-jp-surface);
  box-shadow: 0 5px 18px rgba(17,24,39,.045);
}
.rpg-jp-search { display: flex; gap: 9px; flex: 1; max-width: 600px; }
.rpg-jp-search input {
  flex: 1;
  min-width: 180px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--rpg-jp-border-strong);
  border-radius: 10px;
  outline: none;
  background: #fff;
  font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.rpg-jp-search input:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(37,99,235,.1); }
.rpg-jp-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: #374151;
  font-weight: 750;
}
.rpg-jp-count strong { color: var(--rpg-jp-primary-dark); font-size: 20px; }

/* Buttons */
.rpg-jp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--rpg-jp-border-strong);
  border-radius: 10px;
  background: #fff;
  color: #374151 !important;
  text-decoration: none !important;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.rpg-jp-button:hover { border-color: #bfdbfe; background: #f8fbff; color: var(--rpg-jp-primary-dark) !important; transform: translateY(-1px); }
.rpg-jp-button--primary { border-color: var(--rpg-jp-primary); background: var(--rpg-jp-primary); color: #fff !important; box-shadow: 0 6px 14px rgba(37,99,235,.18); }
.rpg-jp-button--primary:hover { border-color: var(--rpg-jp-primary-dark); background: var(--rpg-jp-primary-dark); color: #fff !important; }
.rpg-jp-button--danger { border-color: #fecaca; background: #fff; color: var(--rpg-jp-danger) !important; }

/* Notices */
.rpg-jp-notice {
  position: relative;
  margin: 0 0 18px;
  padding: 14px 16px 14px 46px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  background: #f0fdf4;
  color: #166534;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(21,128,61,.05);
}
.rpg-jp-notice::before {
  content: "✓";
  position: absolute;
  top: 13px;
  left: 16px;
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

/* List */
.rpg-jp-table-wrap {
  /* Keep the list visually contained, but do not create an internal vertical
     scroll container. The download popup must be able to escape the table. */
  position: relative;
  overflow: visible;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 16px;
  background: var(--rpg-jp-surface);
  box-shadow: 0 5px 18px rgba(17,24,39,.045);
}
.rpg-jp-table { width: 100%; min-width: 900px; border-collapse: separate; border-spacing: 0; }
.rpg-jp-table th,
.rpg-jp-table td { padding: 15px 16px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: middle; }
.rpg-jp-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .025em;
}
.rpg-jp-table tbody tr { transition: background .16s ease; }
.rpg-jp-table tbody tr:hover { background: #fbfdff; }
.rpg-jp-table tbody tr:last-child td { border-bottom: 0; }
.rpg-jp-table td code {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: var(--rpg-jp-primary-soft);
  color: var(--rpg-jp-primary-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}
.rpg-jp-student-name { color: var(--rpg-jp-heading); font-size: 15px; }
.rpg-jp-actions { display: flex; gap: 7px; align-items: center; flex-wrap: nowrap; }
.rpg-jp-badge { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.rpg-jp-badge--ok { background: #dcfce7; color: #166534; }
.rpg-jp-badge--pending { background: #fef3c7; color: #92400e; }
.rpg-jp-empty { padding: 40px 24px !important; text-align: center !important; color: var(--rpg-jp-muted); }

/* Download menu */
.rpg-download-menu { display: inline-block; position: relative; z-index: 20; }
.rpg-download-menu[open] { z-index: 200; }
.rpg-download-menu summary { list-style: none; }
.rpg-download-menu summary::-webkit-details-marker { display: none; }
.rpg-download-menu__items {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 7px);
  right: 0;
  min-width: 205px;
  padding: 7px;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15,23,42,.16);
}
.rpg-download-menu__items a,
.rpg-download-menu__items button {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--rpg-jp-text);
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.rpg-download-menu__items a:hover,
.rpg-download-menu__items button:hover { background: var(--rpg-jp-primary-soft); color: var(--rpg-jp-primary-dark); }
.rpg-download-menu__items button:disabled { color: #9ca3af; background: #f8fafc; cursor: not-allowed; }
.rpg-download-menu__items button:disabled:hover { color: #9ca3af; background: #f8fafc; }

/* Edit form */
.rpg-jp-edit {
  display: grid;
  gap: 20px;
  padding: 0;
  border: 0;
  background: transparent;
}
.rpg-jp-edit > h2 {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 58px;
  margin: 0;
  padding: 16px 22px;
  border: 1px solid var(--rpg-jp-border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: #f8fafc;
  color: var(--rpg-jp-heading);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.35;
  box-shadow: 0 5px 18px rgba(17,24,39,.035);
}
.rpg-jp-edit > h2::before {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-right: 12px;
  border-radius: 50%;
  background: var(--rpg-jp-primary);
  box-shadow: 0 0 0 5px #dbeafe;
}
.rpg-jp-edit > h2 + .rpg-admin-grid,
.rpg-jp-edit > h2 + .rpg-admin-table-scroll,
.rpg-jp-edit > h2 + p + .rpg-admin-table-scroll {
  margin-top: -20px;
  padding: 24px;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 0 0 16px 16px;
  background: var(--rpg-jp-surface);
  box-shadow: 0 5px 18px rgba(17,24,39,.045);
}
.rpg-jp-edit > h2 + p {
  margin: -20px 0 0;
  padding: 18px 24px 34px;
  border-right: 1px solid var(--rpg-jp-border);
  border-left: 1px solid var(--rpg-jp-border);
  background: var(--rpg-jp-surface);
  color: var(--rpg-jp-muted);
}
.rpg-admin-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.rpg-jp-edit label { display: grid; align-content: start; gap: 7px; min-width: 0; color: #374151; font-size: 14px; font-weight: 650; }
.rpg-jp-edit label strong { font-weight: 650; }
.rpg-jp-edit input[type=text],
.rpg-jp-edit input[type=email],
.rpg-jp-edit input[type=date],
.rpg-jp-edit input[type=number],
.rpg-jp-edit input[type=file],
.rpg-jp-edit textarea,
.rpg-jp-edit select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--rpg-jp-border-strong);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--rpg-jp-text);
  font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.rpg-jp-edit input[type=text],
.rpg-jp-edit input[type=email],
.rpg-jp-edit input[type=date],
.rpg-jp-edit input[type=number],
.rpg-jp-edit select { min-height: 43px; }
.rpg-jp-edit textarea { min-height: 126px; resize: vertical; }
.rpg-jp-edit input:focus,
.rpg-jp-edit textarea:focus,
.rpg-jp-edit select:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(37,99,235,.1); }
.rpg-jp-edit input[readonly] { background: #f8fafc; color: #64748b; }
.rpg-jp-edit small { color: var(--rpg-jp-muted); font-size: 12px; font-weight: 400; }
.rpg-admin-full {
  margin: 0;
  padding: 20px 22px;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 14px;
  background: var(--rpg-jp-surface);
  box-shadow: 0 5px 18px rgba(17,24,39,.035);
}
.rpg-admin-table-scroll { overflow: auto; }
.rpg-admin-table-scroll table { width: 100%; min-width: 880px; border-collapse: separate; border-spacing: 0; }
.rpg-admin-table-scroll th,
.rpg-admin-table-scroll td { padding: 10px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
.rpg-admin-table-scroll th { background: #f8fafc; color: #64748b; text-align: left; font-size: 12px; font-weight: 800; }
.rpg-admin-table-scroll tbody tr:last-child td { border-bottom: 0; }
.rpg-admin-history-table { min-width: 1160px !important; }
.rpg-admin-history-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.rpg-admin-history-actions label { display: inline-flex; }
.rpg-admin-history-actions input { position: absolute; opacity: 0; pointer-events: none; }
.rpg-admin-history-actions span { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; }
.rpg-admin-history-actions input:checked + span { border-color: var(--rpg-jp-primary); background: var(--rpg-jp-primary); color: #fff; }
.rpg-admin-history-actions label.is-disabled { opacity: .35; }
.rpg-admin-family-occupation { display: grid; gap: 7px; }
.rpg-admin-generation-status { margin: -6px 0 0; color: var(--rpg-jp-muted); font-weight: 700; }
.rpg-admin-generation-status.is-error { color: var(--rpg-jp-danger); }
.rpg-admin-generation-status.is-success { color: var(--rpg-jp-success); }
.rpg-jp-submit {
  position: sticky;
  z-index: 10;
  bottom: 14px;
  display: flex;
  justify-content: flex-end;
  margin: 4px 0 0;
  padding: 14px;
  border: 1px solid var(--rpg-jp-border);
  border-radius: 14px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 28px rgba(17,24,39,.11);
  backdrop-filter: blur(10px);
}
.rpg-jp-submit .rpg-jp-button { min-height: 46px; padding-inline: 22px; }

/* Pagination */
.rpg-jp-pagination { display: flex; justify-content: center; gap: 6px; margin: 18px 0 0; }
.rpg-jp-pagination .page-numbers { display: inline-flex; min-width: 38px; min-height: 38px; align-items: center; justify-content: center; padding: 7px 10px; border: 1px solid var(--rpg-jp-border-strong); border-radius: 9px; background: #fff; color: #374151; text-decoration: none; font-weight: 700; }
.rpg-jp-pagination .page-numbers.current { border-color: var(--rpg-jp-primary); background: var(--rpg-jp-primary); color: #fff; }

/* On narrower screens the table may extend wider than the viewport. Let the
   page itself scroll horizontally instead of trapping the download menu in a
   nested scroll frame. */
@media (max-width: 1040px) {
  .rpg-jp-table-wrap { overflow: visible; }
  .rpg-jp-table { min-width: 900px; }
  .rpg-jp-portal { overflow: visible; }
}

@media (max-width: 900px) {
  .rpg-jp-portal { margin: 14px auto; padding: 22px; border-radius: 20px; }
  .rpg-jp-header { align-items: flex-start; flex-direction: column; }
  .rpg-admin-grid { grid-template-columns: 1fr; }
  .rpg-jp-toolbar { align-items: stretch; flex-direction: column; }
  .rpg-jp-search { max-width: none; }
  .rpg-jp-count { justify-content: flex-end; }
}

@media (max-width: 620px) {
  .rpg-jp-portal { width: 100%; margin: 0; padding: 16px; border: 0; border-radius: 0; box-shadow: none; }
  .rpg-jp-login { padding: 24px 18px; }
  .rpg-jp-header h1 { font-size: 29px; }
  .rpg-jp-search { flex-direction: column; }
  .rpg-jp-search .rpg-jp-button { width: 100%; }
  .rpg-jp-button { min-height: 42px; }
  .rpg-jp-submit { bottom: 8px; }
  .rpg-jp-submit .rpg-jp-button { width: 100%; }
}
