* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Yu Gothic UI","Meiryo",sans-serif;
  background: #f4f7fb;
  color: #1f2937;
}

/* Layout */
.page {
  max-width: 960px;
  margin: 40px auto;
  padding: 0 20px;
}
.page-wide { max-width: 1680px; }

.card {
  background: #ffffff;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 32px;
}

.page-title {
  margin: 0 0 24px;
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
}

.sub-text {
  margin: 0 0 24px;
  color: #64748b;
  font-size: 14px;
}

/* Forms */
.form-group { margin-bottom: 20px; }
label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.input-text,
.input-date,
.input-time,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-text:focus,
.input-date:focus,
.input-time:focus,
textarea:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* Buttons */
.button-row {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  min-width: 140px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.02s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { opacity: 0.92; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-danger { background: #dc2626; color: #fff; }

.btn-sm {
  min-width: 0;
  padding: 8px 12px;
  font-size: 13px;
}

/* Messages */
.message {
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}
.message-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.message-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.info-box {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  color: #475569;
}

.helper-text {
  margin-top: 10px;
  font-size: 12px;
  color: #64748b;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  overflow: hidden;
}

.data-table th {
  width: 220px;
  padding: 14px 16px;
  text-align: left;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 14px;
  border-bottom: 1px solid #dbe3ee;
}

.data-table td {
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #dbe3ee;
  font-size: 14px;
}

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

/* Confirm / Complete frame */
.confirm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}
.confirm-table th,
.confirm-table td { border-bottom: 1px solid #dbe3ee; }
.confirm-table th { border-right: 1px solid #dbe3ee; }
.confirm-table tr:last-child th,
.confirm-table tr:last-child td { border-bottom: none; }

/* Links */
.link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 700;
}
.link:hover { text-decoration: underline; }

.danger-link {
  color: #dc2626;
  font-weight: 700;
  text-decoration: none;
}
.danger-link:hover { text-decoration: underline; }

.muted { color: #94a3b8; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.badge-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-green { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.badge-purple { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-amber { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.badge-gray { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.badge-role-master {
  background: #e9eef5;
  color: #334e6f;
  border-color: #c5d1df;
}
.badge-role-building-master {
  background: #e9f0ed;
  color: #3d5d53;
  border-color: #c8d8d2;
}
.badge-role-tenant-master {
  background: #f3eee8;
  color: #6b543d;
  border-color: #ddd0c1;
}
.badge-role-tenant-general {
  background: #efedf2;
  color: #5d5668;
  border-color: #d6d1dc;
}

.badge-role-security-company {
  color: #be123c;
  background: #fff1f2;
  border-color: #fecdd3;
}

/* ===== タイトル行 右上ユーザーメニュー ===== */
.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title-row .page-title {
  margin: 0;
}

.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* ★追加：トリガーとドロップダウンの間を埋める透明ブリッジ */
.user-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 10px;  /* ここで隙間を埋める */
}

.user-menu-trigger {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.user-menu-trigger:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

/* ★修正：margin-topを廃止し、見た目の間隔はtransformで作る */
.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  transform: translateY(10px); /* ブリッジと同じ値 */
  min-width: 190px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  padding: 10px 12px;
  display: none;
  z-index: 999;
}

.user-menu:hover .user-menu-dropdown,
.user-menu:focus-within .user-menu-dropdown {
  display: block;
}

.user-menu-email {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
  word-break: break-all;
}

.user-menu-name {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

/* ログアウトを赤リンクに */
.logout-link-mini {
  display: inline-block;
  color: #dc2626;
  font-weight: 700;
  text-decoration: none;
  padding: 4px 0;
}

.logout-link-mini:hover {
  text-decoration: underline;
}

.password-change-link-mini {
  display: block;
  margin-bottom: 3px;
  padding: 5px 0;
  color: #2563eb;
  font-weight: 700;
  text-decoration: none;
}

.password-change-link-mini:hover {
  text-decoration: underline;
}

/* ユーザーアイコン（丸の中に人） */
.user-menu-trigger {
  display: inline-flex;        /* アイコンと文字を横並び */
  align-items: center;
  gap: 8px;
}

.user-icon {
  width: 18px;
  height: 18px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  position: relative;
  flex: 0 0 auto;
}

/* 頭 */
.user-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  width: 6px;
  height: 6px;
  border: 1px solid #334155;
  border-radius: 999px;
  transform: translateX(-50%);
}

/* 肩（半円） */
.user-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 10px;
  height: 6px;
  border: 1px solid #334155;
  border-top: none;
  border-bottom-left-radius: 999px;
  border-bottom-right-radius: 999px;
  transform: translateX(-50%);
}

/* 右上ナビ（タイトル行内に置いて行を増やさない） */
.page-title-actions{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ナビは青文字・小さめで馴染ませる */
.nav-link-btn{
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #2563eb;
  padding: 6px 10px;      /* 小さめ */
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.nav-link-btn:hover{
  background: #f8fafc;
}

.section-title {
  margin: 0 0 14px;
  color: #0f172a;
  font-size: 17px;
}

.required-mark {
  margin-left: 4px;
  color: #dc2626;
  font-size: 11px;
  font-weight: 700;
}

.error-list {
  margin: 0;
  padding-left: 20px;
}

.error-list li + li {
  margin-top: 4px;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.page-return-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 28px;
}

.form-actions-split {
  justify-content: space-between;
}

@media (max-width: 640px) {
  .page {
    margin: 20px auto;
    padding: 0 12px;
  }

  .card {
    padding: 22px 16px;
  }

  .page-title {
    font-size: 23px;
  }

  .page-title-row {
    flex-direction: column;
  }

  .data-table th {
    width: 150px;
  }

}
