/* Chatwork 风格登录页 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body.login-page {
  --login-error: #c62828;
  /* 与背景 PDF/請求書常见的ゴシック体一致（Noto Sans JP + 系统日文字体回退） */
  font-family:
    "Noto Sans JP",
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    "Yu Gothic UI",
    YuGothic,
    Meiryo,
    "MS PGothic",
    sans-serif;
  color: #222;
  -webkit-font-smoothing: antialiased;
  /* 与参考站 datusha 全屏背景一致：浅灰底 */
  background-color: #cccccc;
}

/* 全屏背景层（对齐 mtpal：background-container 无内边距，整视口铺底图） */
.login-bg-wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  box-sizing: border-box;
  pointer-events: none;
}

/* PDF 路径：absolute 填满已 fixed 的 .login-bg-wrap，与参考站 .iframe-wrapper 逻辑一致 */
.login-bg-framed {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  margin: 0;
  overflow: hidden;
}

/* 栅格图：在整视口基础上宽度 +1200px（累计）并居中，contain 缩放 */
.login-bg-framed--cover {
  width: min(calc(100% + 1200px), calc(100vw - 24px));
  max-width: none;
  height: 100%;
  min-height: 0;
  margin-top: 0;
  margin-left: auto;
  margin-right: auto;
  flex: 1 1 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-bg-framed--cover .login-bg-card {
  display: none;
}

.login-bg-card {
  position: absolute;
  /* 比背景图区域四边各扩展 10px */
  top: -10px;
  right: -10px;
  bottom: -10px;
  left: -10px;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  z-index: 0;
}

.login-bg-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

/* 铺满红框矩形，contain 在框内缩放整页（无灰边环绕小图块） */
.login-bg-img--cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

/* 所有背景（位图 / PDF iframe）统一 blur(1.5px)，与参考站 #website-background 一致 */
.login-bg-img {
  filter: blur(1.5px) brightness(1);
}

/* PDF iframe（pdf_bg.php canvas 渲染）：absolute 填满父容器 */
.login-bg-img--pdf {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  border: none;
  pointer-events: none;
  filter: blur(1.5px) brightness(1);
}

/* login-bg-framed 是 absolute，无需媒体查询宽度覆盖 */

.login-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  /* 极轻叠层，避免把白边压成灰 */
  background: rgba(0, 0, 0, 0.06);
}

/* 登录页：对齐参考站 .background-overlay rgba(0,0,0,0.3) */
body.login-page:not(.payslip-page) .login-bg-overlay {
  background: rgba(0, 0, 0, 0.3);
}

/* 对齐参考站 .login-contents：上下留白便于表单垂直居中 */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 10px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .login-wrap {
    padding: 60px 15px 5px;
  }
}

@media (max-width: 480px) {
  .login-wrap {
    padding: 50px 10px 5px;
  }
}

/* 外层白底：略大圆角、柔和大阴影（对应 Chatwork 主容器） */
.login-modal {
  width: 100%;
  max-width: 628px;
  background: #fff;
  border-radius: 14px;
  box-shadow:
    0 12px 40px rgba(15, 23, 42, 0.1),
    0 4px 12px rgba(15, 23, 42, 0.06);
  /* 外层卡片宽度：在 448px 基础上累计加宽 */
  /* 上内边距减小可使 Logo 上移；内层卡片用等量 margin-top 顶回，避免表单跟着跑 */
  padding: 5px 36px 77px;
  transform: translateY(15px);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  margin-bottom: 28px;
}

.login-brand__img {
  display: block;
  max-width: min(260px, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
}

/* 内层登录卡片：更明显的“浮起”阴影；整体较外层缩窄、略压低高度 */
.login-card {
  width: calc(100% - 150px);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 80px;
  transform: translateY(-50px);
  position: relative;
  z-index: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow:
    0 6px 20px rgba(15, 23, 42, 0.1),
    0 2px 8px rgba(15, 23, 42, 0.05);
  /* 内边距与 Chatwork 参考图一致；底边较上一版收 10px，仅减空白不改内容区 */
  padding: 28px 32px 67px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-sizing: border-box;
}

.login-card form {
  text-align: left;
  /* 用 padding-top 避免与 .login-card__title 的 margin 折叠，确保整体下移 20px */
  padding-top: 20px;
}

@media (max-width: 520px) {
  .login-card {
    width: calc(100% - 32px);
  }
}

/* 手机端：减少留白与位移，避免“缩在中间”的观感 */
@media (max-width: 520px) {
  .login-wrap {
    padding: 18px 12px;
  }

  .login-modal {
    padding: 10px 14px 22px;
    transform: none;
    border-radius: 12px;
  }

  .login-brand {
    margin-top: 10px;
    margin-bottom: 14px;
  }

  .login-card {
    margin-top: 18px;
    transform: none;
    padding: 18px 16px 22px;
    border-radius: 10px;
  }
}

/* 超窄屏：进一步压缩间距，保证一屏可用 */
@media (max-width: 360px) {
  .login-modal {
    padding: 8px 12px 18px;
  }
  .login-card {
    width: calc(100% - 20px);
    padding: 16px 14px 18px;
  }
}

.login-card__title {
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 28px;
  color: #111111;
  letter-spacing: 0.02em;
}

.login-alert {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  background: #fdecea;
  color: #c62828;
  border: 1px solid #f5c6cb;
}

.login-field {
  margin-bottom: 18px;
}

.login-field:last-of-type {
  margin-bottom: 12px;
}

.login-field label {
  display: block;
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 8px;
  font-weight: 400;
  line-height: 1.4;
}

/* 浮动标签：与 Chatwork ULP 一致（参考站 --primary-color / --link-color） */
.login-field--float {
  position: relative;
  /* 暗蓝：标签与聚焦描边 */
  --login-accent: #0f3d7a;
}

.login-field--float .login-float-label {
  position: absolute;
  left: 15px;
  top: 50%;
  z-index: 2;
  margin: 0;
  padding: 0;
  max-width: calc(100% - 28px);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
  color: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  transform: translateY(-50%);
  transform-origin: left center;
  transition:
    top 0.2s ease,
    transform 0.2s ease,
    font-size 0.2s ease,
    color 0.2s ease,
    font-weight 0.2s ease,
    max-width 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.login-field--float .login-float-label--pw {
  max-width: calc(100% - 52px);
}

/* 邮箱格式错误：红框、红色浮动标签、下方提示（与参考 UI 一致） */
.login-field--error {
  --login-error: #c62828;
}

.login-field--error.login-field--float .login-input {
  border-width: 2px;
  border-color: var(--login-error);
  padding: 14.5px 13px;
}

.login-field--error.login-field--float .login-input:focus ~ .login-float-label,
.login-field--error.login-field--float .login-input:not(:placeholder-shown) ~ .login-float-label,
.login-field--error.login-field--float .login-input--filled ~ .login-float-label {
  color: var(--login-error);
}

.login-field--error.login-field--float .login-input:focus,
.login-field--error.login-field--float .login-input:focus-visible {
  border-color: var(--login-error);
}

.login-field--error.login-field--float .login-input:-webkit-autofill:focus {
  border-color: var(--login-error);
  box-shadow: 0 0 0 1000px #ffffff inset !important;
}

/* 認証失敗（メール/パス誤り）時：メール枠は赤のまま、ラベル「電子メールアドレス」は黒 */
.login-field--float.login-field--error.login-field--credential-fail-email .login-float-label,
.login-field--float.login-field--error.login-field--credential-fail-email .login-input:focus ~ .login-float-label,
.login-field--float.login-field--error.login-field--credential-fail-email .login-input:not(:placeholder-shown) ~ .login-float-label,
.login-field--float.login-field--error.login-field--credential-fail-email .login-input--filled ~ .login-float-label {
  color: #000000;
}

.login-field-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--login-error);
}

.login-field-error[hidden] {
  display: none !important;
}

.login-field-error__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: var(--login-error);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}

.login-field-error__text {
  flex: 1;
  min-width: 0;
}

/* 报错文案后为下一输入框预留间距，避免与浮动标签重叠（手机端更明显） */
.login-field-error + .login-field {
  margin-top: 10px;
}

@media (max-width: 520px) {
  /* 手机端统一显示通用认证提示，隐藏密码字段详细文案 */
  #passwordFieldError {
    display: none !important;
  }
}

/* 認証失敗：パスワード欄と「パスワードを忘れた」の間（図2 と同系統） */
.login-credential-inline-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 4px;
  padding: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--login-error);
}

.login-credential-inline-error[hidden] {
  display: none !important;
}

.login-credential-inline-error__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: #c62828;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}

.login-credential-inline-error__text {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
  color: var(--login-error);
}

.login-field--float .login-input:focus ~ .login-float-label,
.login-field--float .login-input:not(:placeholder-shown) ~ .login-float-label,
.login-field--float .login-input--filled ~ .login-float-label {
  top: 0;
  left: 12px;
  max-width: calc(100% - 24px);
  padding: 0 4px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--login-accent);
  background: #fff;
  transform: translateY(-50%);
  white-space: normal;
}

.login-input-wrap {
  position: relative;
}

/* 邮箱与密码框：与背景票据体一致的正文字重；占位符由 ::placeholder 控制 */
.login-input {
  box-sizing: border-box;
  width: calc(100% - 10px);
  padding: 15.5px 14px;
  margin: 0;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 400;
  color: #000000;
  -webkit-text-fill-color: #000000;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-input:-webkit-autofill,
.login-input:-webkit-autofill:hover,
.login-input:-webkit-autofill:focus,
.login-input:-webkit-autofill:active {
  -webkit-text-fill-color: #000000 !important;
  font-size: 16px;
  font-weight: 400 !important;
  caret-color: #000000;
  box-shadow: 0 0 0 1000px #ffffff inset !important;
  transition: background-color 99999s ease-out 0s;
}

.login-input::placeholder {
  color: #000000;
  -webkit-text-fill-color: #000000;
  font-size: 16px;
  font-weight: 400;
  opacity: 0.55;
}

.login-input::-webkit-input-placeholder {
  color: #000000;
  -webkit-text-fill-color: #000000;
  font-size: 16px;
  font-weight: 400;
  opacity: 0.55;
}

.login-input::-moz-placeholder {
  color: #000000;
  opacity: 0.55;
  font-size: 16px;
  font-weight: 400;
}

.login-input:focus {
  border-color: #000000;
  box-shadow: none;
}

.login-field--float .login-input {
  transition:
    border-color 0.2s ease,
    border-width 0.2s ease,
    padding 0.2s ease,
    box-shadow 0.2s ease;
}

.login-field--float .login-input::placeholder,
.login-field--float .login-input::-webkit-input-placeholder,
.login-field--float .login-input::-moz-placeholder {
  color: transparent !important;
  opacity: 0 !important;
  -webkit-text-fill-color: transparent !important;
}

.login-field--float .login-input:focus,
.login-field--float .login-input:focus-visible {
  border-width: 1px;
  border-color: #000000;
  box-shadow: none;
  padding: 15.5px 14px;
}

.login-field--float .login-input.login-input--pw:focus,
.login-field--float .login-input.login-input--pw:focus-visible {
  padding: 15.5px 44px 15.5px 14px;
}

.login-field--float .login-input:-webkit-autofill:focus {
  border-width: 1px;
  border-color: #000000;
  box-shadow: 0 0 0 1000px #ffffff inset !important;
}

/* 仅密码框右侧为眼睛按钮留空，其它与上框完全一致 */
.login-input.login-input--pw {
  padding: 15.5px 44px 15.5px 14px;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 400;
  color: #000000;
  -webkit-text-fill-color: #000000;
}

.login-toggle-pw {
  position: absolute;
  right: 9px;
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.login-toggle-pw:hover {
  background: rgba(0, 0, 0, 0.05);
}

.login-forgot {
  margin: 2px 0 22px;
  text-align: left;
}

.login-forgot a {
  font-size: 13px;
  font-weight: 400;
  color: #2563eb;
  text-decoration: none;
  display: inline-block;
}

.login-forgot a:hover {
  text-decoration: underline;
}

.login-btn {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #1e50a2;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  margin-top: 2px;
}

.login-btn:hover {
  filter: brightness(0.96);
}

.login-footer {
  margin-top: 13px;
  text-align: center;
}

.login-footer a {
  font-weight: 400;
  font-size: 14px;
}

.login-footer__row {
  margin-bottom: 16px;
}

.login-footer__row a {
  color: #2563eb;
  text-decoration: none;
}

.login-footer__row a:hover {
  text-decoration: underline;
}

/* 电脑版：底部两链接横向并排居中（与参考图一致） */
.login-footer__split {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 10px;
}

.login-footer__signup {
  margin-left: 0;
}

.login-footer__app {
  transform: none;
}

.login-footer__split a {
  display: inline-block;
  width: auto;
  text-align: center;
  color: #2563eb;
  text-decoration: none;
}

.login-footer__split a:hover {
  text-decoration: underline;
}

/* 手机版：两链接分行显示（保持现有体验） */
@media (max-width: 520px) {
  .login-footer__split {
    flex-direction: column;
    gap: 8px;
  }

  .login-footer__split a {
    display: block;
    width: 100%;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
