:root {
  --ink: #1A1408;
  --muted: #3F3212;
  --primary: #D4A017;
  --primary-deep: #5C3D00;
  --navy: #1A1408;
  --accent: #E8B923;
  --bg: #FFF8E8;
  --card: #FFFFFF;
  --soft: #FFF1C9;
  --line: #E8D9A8;
  --success: #5A8F3C;
  --warning: #C58A00;
  --danger: #C53B3B;
  --shadow: 0 8px 22px rgba(92, 69, 16, .08);
  --radius: 12px;
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body.login-lab {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(232, 185, 35, .22), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 100%, rgba(212, 160, 23, .16), transparent 50%),
    var(--bg);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
}
a { color: var(--primary-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Top login ≈2/5 · bottom month plan ≈3/5 */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 2fr) minmax(0, 3fr);
  grid-template-areas:
    "form"
    "week";
  gap: 10px;
  padding: 10px;
  align-content: stretch;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.login-shell-manage {
  grid-template-rows: 1fr;
  grid-template-areas: "week";
}
.login-panel-form {
  grid-area: form;
  min-height: 0;
  overflow: auto;
}
.login-panel-week { grid-area: week; min-height: 0; }

.login-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.panel-body {
  padding: .45rem .75rem;
}
.form-body {
  min-width: 0;
  height: 100%;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--navy);
  font-weight: 700;
}
.brand-lockup-compact {
  margin-bottom: .25rem;
}
.brand-logo {
  display: block;
  width: clamp(56px, 5vw, 88px);
  height: auto;
}
.brand-name {
  font-size: .88rem;
  letter-spacing: .04em;
  color: var(--navy);
}

.tenant-heading {
  display: flex;
  gap: .45rem;
  align-items: flex-start;
  margin-bottom: .3rem;
}
.tenant-entry-icon {
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
}
.tenant-status-badge {
  display: inline-block;
  margin-bottom: .1rem;
  padding: .05rem .35rem;
  border-radius: 6px;
  background: var(--soft);
  color: var(--primary-deep);
  font-size: .66rem;
  font-weight: 600;
  border: 1px solid var(--line);
}
.tenant-heading h2 {
  margin: 0;
  font-size: .88rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.25;
}
.tenant-heading p {
  margin: .05rem 0 0;
  color: var(--muted);
  font-size: .74rem;
}

/* Compact horizontal login: role | user | credentials */
.login-entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(200px, .9fr);
  gap: .4rem .7rem;
  align-items: start;
}
.entry-cell { min-width: 0; }

.small-label, .form-label, .eyebrow {
  display: block;
  margin-bottom: .18rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
}
.role-selector,
.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .25rem;
  max-height: min(28vh, 12rem);
  overflow: auto;
  padding: .05rem;
}
.role-card,
.user-card {
  min-height: 1.85rem;
  padding: .25rem .35rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.role-card:hover,
.user-card:hover {
  border-color: var(--primary);
  background: var(--soft);
}
.role-card.active {
  border-color: var(--primary-deep);
  background: var(--soft);
  color: var(--navy);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px var(--primary);
}
.user-card .name { font-weight: 600; font-size: .82rem; }
.user-card .meta { color: var(--muted); font-size: .68rem; }
.selected-role {
  margin-top: .3rem;
  color: var(--muted);
  font-size: .76rem;
}

.login-alert-inline {
  margin: 0 0 .4rem;
  padding: .35rem .55rem;
  border: 1px solid #f0c2c2;
  border-radius: 8px;
  background: #fff7f7;
  color: var(--danger);
  font-size: .82rem;
  font-weight: 600;
}

.login-form,
.compact-login-form {
  display: grid;
  gap: .45rem;
  margin-top: 0;
}
.form-control {
  width: 100%;
  min-height: 2rem;
  padding: .28rem .45rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, .22);
  outline: none;
}
.password-group {
  display: flex;
  gap: .35rem;
}
.password-group .form-control { flex: 1; }
.eye-btn {
  flex: 0 0 auto;
  min-width: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--navy);
  cursor: pointer;
}
.btn-login {
  width: 100%;
  min-height: 2.15rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--primary) 100%);
  color: #1A1408;
  font-weight: 700;
  cursor: pointer;
}
.btn-login:hover {
  background: linear-gradient(180deg, #F0C53A 0%, var(--primary-deep) 100%);
  color: #fff;
}
.login-links {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .78rem;
}
.login-actions { display: grid; gap: .35rem; }

.tenant-pick-heading h2 {
  margin: .15rem 0 .3rem;
  color: var(--navy);
  font-size: 1.1rem;
}
.tenant-pick-heading p { margin: 0 0 .7rem; color: var(--muted); }
.tenant-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .55rem;
}
.tenant-entry-card {
  display: flex;
  gap: .65rem;
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: inherit;
}
.tenant-entry-card:hover {
  border-color: var(--primary);
  background: var(--soft);
  text-decoration: none;
}
.tenant-entry-copy {
  display: grid;
  gap: .12rem;
}
.tenant-entry-copy strong { color: var(--navy); }
.tenant-entry-copy small { color: var(--muted); }
.tenant-enter-button {
  margin-top: .2rem;
  color: var(--primary-deep);
  font-size: .8rem;
  font-weight: 650;
}

.login-week-head {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem .85rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .55rem;
}
.login-week-title {
  margin: 0;
  color: var(--navy);
  font-size: 1.12rem;
  font-weight: 700;
}
.login-week-range {
  margin: .2rem 0 0;
  color: var(--muted);
  font-size: .84rem;
}
.login-week-kicker {
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .74rem;
}
.login-week-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}
.login-week-nav-btn,
.login-week-today-btn,
.login-week-full-btn {
  min-height: 2rem;
  padding: .28rem .65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.login-week-today-btn {
  background: var(--soft);
  border-color: var(--primary);
}
.login-week-full-btn {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.login-week-full-btn:hover {
  background: #3D2E0A;
  color: #fff;
  text-decoration: none;
}
.login-week-status {
  margin: .5rem 0 0;
  color: var(--muted);
  font-size: .74rem;
}

.login-week-board-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  height: calc(100% - 4.5rem);
  min-height: 0;
}
.login-panel-week .panel-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.login-week-board,
.login-week-board-week,
.login-week-board-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .35rem;
  width: 100%;
}
.login-week-wd {
  text-align: center;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 650;
  padding: .1rem 0;
}
.login-week-day {
  min-height: 4.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: .3rem;
}
.login-week-board-month .login-week-day {
  min-height: 4.2rem;
}
.login-week-day.is-today {
  border-color: var(--primary-deep);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px rgba(212, 160, 23, .35);
}
.login-week-day.is-other-month { opacity: .5; }
.login-week-day-head {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem;
  margin-bottom: .22rem;
}
.login-week-day-name {
  color: var(--navy);
  font-size: .78rem;
  font-weight: 700;
}
.login-week-day-date {
  color: var(--muted);
  font-size: .68rem;
}
.login-week-day-body {
  display: grid;
  gap: .2rem;
}
.login-week-item {
  display: block;
  width: 100%;
  padding: .22rem .3rem;
  border-radius: 6px;
  border: 1px solid transparent;
  text-align: left;
  font-size: .7rem;
  line-height: 1.25;
}
.login-week-item-sampling {
  background: var(--soft);
  color: var(--navy);
  border-color: #e6d08a;
}
.login-week-item-theme {
  background: #fffaf0;
  color: var(--ink);
  border-color: var(--line);
}
.login-week-item-title { font-weight: 650; }
.login-week-item-meta {
  display: block;
  color: var(--muted);
  font-weight: 400;
}
.login-week-empty {
  margin: 0;
  color: var(--muted);
  font-size: .7rem;
}
.login-week-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .85rem;
  margin: 0 0 .45rem;
  color: var(--muted);
  font-size: .72rem;
}
.login-week-add-day {
  width: 100%;
  min-height: 1.65rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--primary-deep);
  font-size: .7rem;
  cursor: pointer;
}

/* Manage / full calendar pages reuse */
body.login-week-manage-page {
  margin: 0;
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
}
.login-week-manage-page .login-shell {
  min-height: 100vh;
}
.swc-pending {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff8e8;
  border: 1px solid #e6d2a0;
  color: #1A1408;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 1099px) and (min-width: 768px) {
  .login-entry-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(200px, .85fr);
  }
  .role-selector,
  .user-grid {
    max-height: 8.5rem;
  }
}

@media (max-width: 767px) {
  .login-shell {
    grid-template-rows: auto auto;
    padding: 10px;
    gap: 10px;
  }
  .login-panel-form {
    max-height: none;
    overflow: visible;
  }
  .login-entry-grid {
    grid-template-columns: 1fr;
  }
  .role-selector,
  .user-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
  }
  .login-week-head {
    flex-direction: column;
    align-items: stretch;
  }
  .login-week-actions {
    justify-content: flex-start;
  }
  .login-week-board-wrap {
    height: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .login-week-board,
  .login-week-board-week,
  .login-week-board-month {
    grid-template-columns: repeat(7, minmax(7.25rem, 1fr));
    min-width: 36rem;
  }
  .login-week-wd { display: block; }
}
