html, body {
  min-height: 100%;
}

body {
  margin: 0;
  color: #0e3a52;
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.login-body {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(255, 255, 255, 0.85), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(159, 216, 245, 0.9), transparent 50%),
    linear-gradient(180deg, #9fd4ea 0%, #5eb3d6 46%, #1d6f9a 100%);
}

.sky-scene {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 32px 16px 90px;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 40px;
  filter: blur(0.2px);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-a {
  width: 140px;
  height: 36px;
  top: 12%;
  left: 14%;
}

.cloud-a::before {
  width: 54px;
  height: 54px;
  top: -28px;
  left: 22px;
}

.cloud-a::after {
  width: 36px;
  height: 36px;
  top: -16px;
  left: 68px;
}

.cloud-b {
  width: 100px;
  height: 28px;
  top: 18%;
  right: 16%;
}

.cloud-b::before {
  width: 40px;
  height: 40px;
  top: -20px;
  left: 18px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 22px;
  padding: 32px 28px 28px;
  box-shadow: 0 18px 50px rgba(8, 54, 82, 0.18);
  position: relative;
  z-index: 1;
}

.brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #7ec8e3, #1d6f9a);
  display: grid;
  place-items: center;
}

.yacht-icon {
  width: 42px;
  height: 42px;
}

.login-card h1,
.sidebar-brand strong {
  letter-spacing: 0.08em;
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 1.8rem;
  color: #0e4d73;
}

.brand-sub {
  text-align: center;
  color: #4f7f99;
  margin: 4px 0 22px;
}

.form-label {
  color: #0e4d73;
  font-weight: 600;
}

.form-control {
  border-color: #b7d7e8;
  border-radius: 10px;
  min-height: 44px;
}

.form-control:focus {
  border-color: #1d6f9a;
  box-shadow: 0 0 0 0.2rem rgba(29, 111, 154, 0.18);
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#captchaImage {
  border-radius: 8px;
  cursor: pointer;
  background: #d7f1fb;
}

.captcha-refresh {
  color: #1d6f9a;
  text-decoration: none;
  font-weight: 600;
}

.btn-login {
  margin-top: 8px;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #2f8fbe, #0e4d73);
  color: #fff;
  font-weight: 700;
}

.btn-login:hover {
  background: #0b3f5e;
  color: #fff;
}

.sea {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 120px;
  z-index: 0;
}

.sea svg {
  width: 100%;
  height: 100%;
  display: block;
}

.admin-body {
  background: #e7f5fb;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0e4d73 0%, #083652 100%);
  color: #e7f6fc;
  padding: 22px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  margin-bottom: 28px;
}

.sidebar-brand .yacht-icon {
  width: 40px;
  height: 40px;
}

.sidebar-brand strong {
  display: block;
  font-size: 1.2rem;
}

.sidebar-brand small {
  color: #b7d7e8;
}

.side-link,
.side-label {
  display: block;
  border-radius: 10px;
  margin-bottom: 6px;
}

.side-link {
  padding: 10px 12px;
  color: #e7f6fc;
}

.side-link.active {
  background: rgba(255, 255, 255, 0.16);
  font-weight: 700;
}

.side-link.muted {
  color: rgba(231, 246, 252, 0.62);
}

.side-label {
  margin-top: 18px;
  padding: 0 12px;
  color: #8ecae6;
  font-size: 0.78rem;
}

.perm-tree {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.perm-tree .perm-tree {
  margin: 0 0 8px 12px;
  padding-left: 10px;
  border-left: 1px solid rgba(182, 220, 236, 0.35);
}

.perm-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.perm-row .side-link {
  flex: 1;
  margin-bottom: 2px;
}

.perm-main {
  font-weight: 700;
}

.perm-child {
  color: rgba(231, 246, 252, 0.88);
  font-size: 0.95rem;
}

.perm-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: #9fd4ea;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.perm-icon svg,
.perm-icon img {
  width: 18px;
  height: 18px;
  display: block;
}

.perm-icon-text {
  font-size: 0.85rem;
  line-height: 1;
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid #d3ebf5;
}

.topbar-title {
  font-weight: 700;
  color: #0e4d73;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-logout {
  border: 1px solid #0e4d73;
  color: #0e4d73;
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
}

.btn-logout:hover {
  background: #0e4d73;
  color: #fff;
}

.admin-content {
  padding: 28px;
}

.welcome-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  border-radius: 18px;
  background: linear-gradient(120deg, #ffffff 0%, #d7f1fb 55%, #8ecae6 100%);
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #1d6f9a;
  font-weight: 700;
}

.welcome-banner h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  color: #0e4d73;
}

.welcome-banner p {
  margin: 0;
  color: #3d6d84;
}

.banner-yacht {
  width: 120px;
  height: 72px;
  flex: none;
}

.stat-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card,
.module-grid article {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(14, 77, 115, 0.06);
}

.stat-card span,
.module-grid p {
  color: #5d8498;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  color: #0e4d73;
}

.panel {
  margin-top: 22px;
}

.panel h2,
.module-grid h3 {
  color: #0e4d73;
}

.module-grid h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.module-grid p {
  margin: 0;
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar nav {
    display: block;
  }

  .side-label {
    display: none;
  }

  .side-link {
    white-space: nowrap;
  }

  .stat-grid,
  .module-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cloud-a,
  .cloud-b {
    display: none;
  }
}

@media (max-width: 560px) {
  .stat-grid,
  .module-grid {
    grid-template-columns: 1fr;
  }

  .welcome-banner {
    align-items: flex-start;
  }

  .banner-yacht {
    width: 84px;
  }

  .admin-content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  color: #0e4d73;
  font-size: 1.6rem;
}

.data-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(14, 77, 115, 0.06);
}

.form-card {
  max-width: 640px;
}

.staff-card,
.cohort-card {
  max-width: 920px;
}

.staff-form,
.cohort-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}

.staff-form .span-2,
.cohort-form .span-2 {
  grid-column: 1 / -1;
}

@media (max-width: 720px) {
  .staff-form,
  .cohort-form {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #d3ebf5;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: #0e4d73;
  font-weight: 700;
}

.data-table tr.audit-matched td {
  background: #fde8ef;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.row-actions form {
  margin: 0;
}

.btn-sea,
.btn-line,
.btn-danger-line {
  border-radius: 10px;
  padding: 6px 12px;
  text-decoration: none;
}

.btn-sea {
  background: #0e4d73;
  color: #fff;
  border: 0;
}

.btn-sea:hover {
  background: #0b3f5e;
  color: #fff;
}

.btn-line {
  border: 1px solid #0e4d73;
  color: #0e4d73;
  background: #fff;
}

.btn-danger-line {
  border: 1px solid #b42318;
  color: #b42318;
  background: #fff;
}

.empty-note {
  margin: 0;
  color: #5d8498;
}

.status-options {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.status-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #0e4d73;
}

.dept-sort-note {
  margin-bottom: 12px;
}

.dept-head,
.dept-row {
  display: grid;
  grid-template-columns: 36px minmax(90px, 140px) minmax(140px, 1.4fr) minmax(80px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.dept-head {
  padding: 0 8px 8px;
  color: #0e4d73;
  font-weight: 700;
}

.dept-group {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dept-row {
  padding: 10px 8px;
  border-top: 1px solid #d3ebf5;
  background: #fff;
}

.dept-drag {
  cursor: grab;
  color: #5d8498;
  letter-spacing: -2px;
  user-select: none;
}

.dept-node.is-dragging > .dept-row,
.dept-node.dept-drop > .dept-row {
  background: #e7f6fd;
}

.dept-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #e7f4fb;
}

.dept-switch-btn {
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  background: transparent;
  color: #5d8498;
}

.dept-switch-btn.is-active[data-status="1"] {
  background: #0e4d73;
  color: #fff;
}

.dept-switch-btn.is-active[data-status="X"] {
  background: #b42318;
  color: #fff;
}

.avatar-preview {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid #d3ebf5;
}

.avatar-preview[hidden] {
  display: none;
}

.avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px dashed #9fd4ea;
  background: #f4fbfe;
}

.role-card {
  max-width: 920px;
}

.perm-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d3ebf5;
  border-radius: 12px;
}

.perm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0e4d73;
}

.scope-box {
  margin-bottom: 16px;
}

.scope-box[hidden] {
  display: none;
}

.assign-line {
  display: flex;
  gap: 8px;
  align-items: center;
}

.assign-line .form-select {
  max-width: 420px;
}

.assign-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assign-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid #d3ebf5;
  border-radius: 10px;
}

@media (max-width: 900px) {
  .dept-head {
    display: none;
  }

  .dept-row {
    grid-template-columns: 28px minmax(72px, 110px) 1fr auto auto;
  }

  .dept-row > span:nth-child(4) {
    display: none;
  }
}
