:root {
  --bg: transparent;
  --surface: rgba(255, 255, 255, 0.9);
  --ink: #1e293b;
  --muted: #64748b;
  --brand: #3b82f6;
  --accent: #f59e0b;
  --line: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff8ef 0%, #f5f1ec 40%, #efe9e2 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.appbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 12px;
  height: 12px;
  background: var(--brand);
  border-radius: 2px;
  transform: rotate(20deg);
}

.appbar-actions {
  display: flex;
  gap: 10px;
}

.container {
  max-width: 1100px;
  margin: 28px auto 20px;
  padding: 0 20px;
  width: 100%;
  flex: 1 0 auto;
}

.auth-shell {
  margin: 32px 0 48px;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  padding: 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(140deg, #ffffff 0%, #f8f5f2 100%);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
  position: relative;
  overflow: hidden;
}

.auth-card::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -60px;
  top: -80px;
  background: radial-gradient(circle, rgba(29, 78, 216, 0.18) 0%, rgba(29, 78, 216, 0) 70%);
  pointer-events: none;
}

.auth-visual {
  padding: 16px 18px;
  border-radius: 14px;
  background: linear-gradient(150deg, #1f2937 0%, #0f172a 100%);
  color: #f8fafc;
  display: grid;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.auth-visual::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -120px;
  bottom: -120px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.45) 0%, rgba(245, 158, 11, 0) 70%);
}

.auth-eyebrow {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
}

.auth-visual h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.auth-visual .muted {
  color: rgba(248, 250, 252, 0.72);
}

.auth-points {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 8px;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(248, 250, 252, 0.85);
}

.auth-points li::before {
  content: "◆";
  font-size: 10px;
  color: #f59e0b;
}

.auth-form {
  background: #ffffff;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid rgba(229, 231, 235, 0.9);
}

.link {
  font-size: 13px;
  color: var(--brand);
  text-decoration: none;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

.card-hd {
  font-weight: 700;
  margin-bottom: 12px;
}

.section-hd h2 {
  margin: 8px 0 6px;
}

.muted {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 12px;
}

.grid.g-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 6px;
}

.lbl {
  font-size: 14px;
  color: var(--muted);
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn.ghost {
  background: transparent;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.msg {
  min-height: 20px;
  font-size: 13px;
  color: #dc2626;
}

.is-hidden {
  display: none;
}

.site-footer {
  margin-top: auto;
  padding: 12px 20px 16px;
  text-align: center;
  font-size: 13px;
  color: #6b6b6b;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.footer-title {
  font-weight: 600;
  color: #8b5e34;
  margin-bottom: 6px;
}

.footer-line {
  line-height: 1.6;
}

@media (max-width: 760px) {
  .grid.g-2 {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
  .auth-card {
    grid-template-columns: 1fr;
  }
  .appbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .captcha-row {
    flex-direction: column;
    align-items: stretch;
  }

  .captcha-code {
    width: 100%;
    flex-basis: auto;
  }
}


/* ========================================== */
/*          Centered Premium Login UI         */
/* ========================================== */

.login-shell {
  position: relative;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

/* --- Form Area (Centered Full Screen) --- */
.login-form-area {
  width: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 10% 10%, rgba(219, 234, 254, 0.6) 0%, transparent 60%),
              radial-gradient(circle at 90% 10%, rgba(233, 213, 255, 0.55) 0%, transparent 65%),
              radial-gradient(circle at 90% 90%, rgba(254, 243, 199, 0.4) 0%, transparent 60%),
              radial-gradient(circle at 10% 90%, rgba(253, 224, 71, 0.1) 0%, transparent 55%),
              linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 40px 16px !important;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.65;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.blob-a {
  width: min(450px, 90vw);
  height: min(450px, 90vw);
  background: radial-gradient(circle, rgba(59, 130, 246, 0.28) 0%, rgba(147, 197, 253, 0.05) 70%);
  top: -80px;
  left: -80px;
  animation: blobFloatA 22s ease-in-out infinite alternate;
}

.blob-b {
  width: min(500px, 95vw);
  height: min(500px, 95vw);
  background: radial-gradient(circle, rgba(139, 92, 246, 0.22) 0%, rgba(216, 180, 254, 0.05) 70%);
  bottom: -100px;
  right: -100px;
  animation: blobFloatB 28s ease-in-out infinite alternate;
}

.login-card {
  position: relative;
  z-index: 10;
  width: min(440px, 100%);
  max-width: 100%;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 44px 32px 36px;
  box-shadow: 0 30px 70px -10px rgba(15, 23, 42, 0.16), 
              0 0 0 1px rgba(15, 23, 42, 0.02),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
  box-shadow: 0 35px 80px -10px rgba(15, 23, 42, 0.2), 
              0 0 0 1px rgba(15, 23, 42, 0.02),
              inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.login-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.login-loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(59, 130, 246, 0.18);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: loginSpin 0.8s linear infinite;
}

.login-loading-text {
  color: #1e40af;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.login-badge-container {
  display: flex;
  justify-content: center;
  margin-top: -10px;
  margin-bottom: 20px;
}

.login-badge {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4), 
              inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-badge:hover {
  transform: translateY(-4px) rotate(8deg);
}

.login-badge svg {
  width: 28px;
  height: 28px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.05em;
  overflow-wrap: anywhere;
}

.login-title-primary {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.login-subtitle {
  margin: 0 auto;
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
  max-width: 300px;
  text-align: center;
  overflow-wrap: anywhere;
}

.login-subtitle strong {
  color: #1e293b;
  font-weight: 600;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.input-wrap {
  position: relative;
  display: grid;
  align-items: center;
  min-width: 0;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: #94a3b8;
  display: flex;
  align-items: center;
}

.input-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 0 42px 0 44px;
  font-size: 14px;
  color: #1e293b;
  background: rgba(255, 255, 255, 0.8);
  transition: all 0.2s ease;
}

.login-form input:focus {
  outline: none;
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.captcha-field {
  gap: 8px;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.captcha-code {
  flex: 0 0 156px;
  width: 156px;
  height: 56px;
  border: 1px dashed #93c5fd;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.95) 0%, rgba(224, 231, 255, 0.95) 100%);
  user-select: none;
  object-fit: fill;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.captcha-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.google-signin-slot,
.google-signin-slot > div,
.login-loading-text,
.msg {
  max-width: 100%;
}

.captcha-input-wrap input {
  width: 100%;
  min-width: 0;
}

.toggle-password {
  position: absolute;
  right: 10px;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.toggle-password svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.toggle-password .eye-off {
  display: none;
}

.toggle-password.is-on .eye-on {
  display: none;
}

.toggle-password.is-on .eye-off {
  display: block;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.login-submit {
  position: relative;
  height: 48px;
  border: none;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #4f46e5 100%);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.05em;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  isolation: isolate;
}

.login-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%) skewX(-20deg);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 40%,
    transparent 75%
  );
  transition: transform 0.55s ease;
  pointer-events: none;
  z-index: -1;
}

.login-submit:hover {
  box-shadow: 0 15px 30px -5px rgba(37, 99, 235, 0.45);
  filter: brightness(1.05);
}

.login-submit:hover::after {
  transform: translateX(120%) skewX(-20deg);
}

.login-submit:active {
  box-shadow: 0 8px 16px -5px rgba(37, 99, 235, 0.35);
}

.admin-login-toggle {
  width: 100%;
  margin-top: 8px;
  height: auto;
  padding: 4px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #94a3b8;
  font-weight: 500;
  font-size: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  display: block;
}

.admin-login-toggle:hover {
  color: #64748b;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.admin-login-toggle:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
  border-radius: 6px;
}

.admin-login-section {
  margin-top: 16px;
  padding-top: 0;
  border-top: none;
}

.login-divider {
  position: relative;
  margin: 12px 0 24px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}

.login-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #e2e8f0;
}

.login-divider span {
  position: relative;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 11px;
  color: #64748b;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.02);
}

.google-signin-slot {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  margin: 8px 0;
  position: relative;
}

.google-signin-slot > div {
  width: min(384px, 100%);
  display: flex;
  justify-content: center;
}

.google-signin-slot iframe {
  display: block;
}

.google-signin-fallback {
  width: min(384px, 100%);
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px rgba(37, 99, 235, 0.55);
}

.google-signin-fallback:hover {
  background: #1d4ed8;
}

.google-signin-error {
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.google-signin-slot.is-loading {
  min-height: 48px;
}

.google-signin-placeholder {
  width: min(384px, 100%);
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(90deg, rgba(241, 245, 249, 0.82) 25%, rgba(226, 232, 240, 0.92) 50%, rgba(241, 245, 249, 0.82) 75%);
  background-size: 200% 100%;
  animation: googleSigninPulse 1.4s ease-in-out infinite;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  color: #64748b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.google-signin-placeholder-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.86);
  flex: 0 0 24px;
}

.google-signin-placeholder-text {
  height: 12px;
  width: min(160px, 48%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
}

@keyframes blobFloatA {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(60px, 80px) scale(1.15);
  }
  100% {
    transform: translate(-30px, 40px) scale(0.9);
  }
}

@keyframes blobFloatB {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(-80px, -60px) scale(1.1);
  }
  100% {
    transform: translate(40px, -20px) scale(0.95);
  }
}

@keyframes loginSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes googleSigninPulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Login-only layout overrides */
body.is-login {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  overflow-x: hidden !important;
}

body.is-login .layout {
  display: block !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
  grid-template-areas: "main" !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

body.is-login .layout-topbar,
body.is-login .layout-sidebar,
body.is-login .site-footer {
  display: none !important;
}

body.is-login .layout-main {
  display: block !important;
  padding: 0 !important;
  border-top: 0 !important;
  background: transparent !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
}

body.is-login .layout-main .container {
  display: block !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

body.is-login .login-shell {
  display: flex !important;
  margin: 0 !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  width: 100% !important;
}

@media (max-width: 900px) {
  .login-form-area {
    padding: 32px 18px !important;
  }

  .login-card {
    width: min(480px, 100%);
    padding: 36px 24px 28px;
    border-radius: 24px;
  }

  .login-header {
    margin-bottom: 28px;
  }

  .login-title-primary {
    font-size: 24px;
  }

  .captcha-row {
    align-items: stretch;
  }

  .captcha-code {
    flex: 0 0 144px;
    width: 144px;
  }
}

@media (max-width: 600px) {
  .login-shell {
    align-items: stretch !important;
  }

  .login-form-area {
    align-items: stretch !important;
    padding: 18px 12px 24px !important;
  }

  .login-blob {
    filter: blur(60px);
    opacity: 0.5;
  }

  .blob-a {
    top: -120px;
    left: -120px;
  }

  .blob-b {
    right: -140px;
    bottom: -160px;
  }

  .login-card {
    width: 100%;
    padding: 24px 16px 20px;
    border-radius: 20px;
    box-shadow: 0 20px 48px -16px rgba(15, 23, 42, 0.18);
  }

  .login-loading {
    border-radius: 20px;
    padding: 20px;
  }

  .login-badge-container {
    margin-bottom: 16px;
  }

  .login-badge {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }

  .login-badge svg {
    width: 24px;
    height: 24px;
  }

  .login-header {
    margin-bottom: 22px;
  }

  .login-header h2 {
    font-size: 17px;
  }

  .login-title-primary {
    font-size: 21px;
    margin-bottom: 12px;
  }

  .login-subtitle {
    font-size: 13px;
    max-width: none;
  }

  .login-form {
    gap: 14px;
  }

  .lbl {
    font-size: 13px;
  }

  .login-form input[type="text"],
  .login-form input[type="password"] {
    height: 50px;
    font-size: 16px;
    padding: 0 42px 0 42px;
  }

  .captcha-row {
    flex-direction: column;
    gap: 10px;
  }

  .captcha-code {
    width: 100%;
    height: 60px;
    flex-basis: auto;
  }

  .captcha-input-wrap {
    width: 100%;
  }

  .google-signin-slot {
    margin: 6px 0 2px;
  }

  .google-signin-placeholder {
    width: 100%;
    height: 46px;
    padding: 0 14px;
  }

  .admin-login-toggle {
    margin-top: 10px;
    padding: 8px 0;
    font-size: 13px;
  }

  .admin-login-section {
    margin-top: 14px;
  }

  .login-divider {
    margin: 10px 0 18px;
  }

  .login-divider span {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .login-submit {
    height: 50px;
    font-size: 16px;
  }

  .msg {
    min-height: 40px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
}

/* Language switch on the login card (the sidebar is hidden on this page). */
.login-card .login-lang {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
}

/* Icon only on the login card; the tooltip says which language it switches to. */
.login-card .login-lang .lang-label {
  display: none;
}
