:root {
  color-scheme: light;
  --bg: #f6f3ff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-2: rgba(242, 247, 255, 0.88);
  --glass: rgba(255, 255, 255, 0.82);
  --line: rgba(125, 140, 168, 0.32);
  --line-strong: rgba(96, 112, 140, 0.48);
  --text: #172033;
  --muted: #475467;
  --accent: #6d5dfc;
  --accent-2: #13b8a6;
  --accent-3: #ff7a59;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #067647;
  --pending: #7a5a13;
  --radius: 8px;
  --shadow-soft: 0 18px 60px rgba(28, 35, 64, 0.12);
  --shadow-lift: 0 22px 70px rgba(75, 66, 170, 0.18);
  --aurora-speed: 14s;
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang HK", Arial, sans-serif;
}

.hidden {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 5%, rgba(109, 93, 252, 0.18), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(19, 184, 166, 0.16), transparent 28%),
    linear-gradient(135deg, #fbfaff 0%, #eef7ff 42%, #fff8f1 100%);
  color: var(--text);
  font-size: 14px;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -35%;
  z-index: -1;
  background:
    conic-gradient(from 120deg at 45% 45%, rgba(109, 93, 252, 0.22), rgba(19, 184, 166, 0.14), rgba(255, 122, 89, 0.14), rgba(109, 93, 252, 0.22));
  filter: blur(54px);
  opacity: 0.86;
  animation: ambientFlow var(--aurora-speed) ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(109, 93, 252, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(19, 184, 166, 0.045) 1px, transparent 1px),
    linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.34) 45%, transparent 70%);
  background-size: 64px 64px, 64px 64px, 180% 180%;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 72%);
  animation: gridDrift 24s linear infinite, sheenSweep 8s ease-in-out infinite;
}

@keyframes ambientFlow {
  from {
    transform: translate3d(-2%, -1%, 0) rotate(0deg) scale(1);
  }
  to {
    transform: translate3d(2%, 1%, 0) rotate(8deg) scale(1.06);
  }
}

@keyframes gridDrift {
  from {
    background-position: 0 0, 0 0, 0% 0%;
  }
  to {
    background-position: 64px 64px, -64px 64px, 100% 100%;
  }
}

@keyframes sheenSweep {
  0%, 100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.82;
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  border-radius: 6px;
  min-height: 32px;
  padding: 0 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(42, 50, 80, 0.06);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

button::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.5) 45%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 520ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(109, 93, 252, 0.45);
  box-shadow: 0 12px 32px rgba(88, 76, 190, 0.14);
}

button:hover:not(:disabled)::before {
  transform: translateX(120%);
}

button:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), #8e65ff 38%, var(--accent-2), #ff8f70);
  background-size: 220% 220%;
  color: white;
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 38px rgba(109, 93, 252, 0.28);
  animation: gradientPulse 5.5s ease infinite;
}

@keyframes gradientPulse {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

button.danger {
  background: #fff5f5;
  color: var(--danger);
  border-color: #d9aaaa;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  padding: 6px 8px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(109, 93, 252, 0.62);
  box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.12);
  background: white;
}

input[type="search"] {
  padding-right: 28px;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

textarea.json-input {
  min-height: 180px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.4;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(18px) saturate(1.2);
}

.login-copy,
.login-forms {
  padding: 24px;
}

.login-copy {
  background: linear-gradient(135deg, rgba(109, 93, 252, 0.14), rgba(19, 184, 166, 0.1));
  border-right: 1px solid rgba(125, 140, 168, 0.28);
}

.login-copy h1,
.page-title h1 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0;
}

.hint {
  color: var(--muted);
  line-height: 1.5;
}

.demo-pins {
  margin-top: 16px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.app-shell {
  display: block;
  min-height: 100vh;
}

.sidebar {
  background: #18353b;
  color: white;
  padding: 16px 12px;
}

.brand {
  padding: 0;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.segmented-nav {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 12px 38px rgba(42, 50, 80, 0.08);
  backdrop-filter: blur(18px) saturate(1.25);
}

.nav button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  background: transparent;
  color: #344054;
  border-color: transparent;
  box-shadow: none;
}

.nav button.active,
.nav button:hover {
  background: linear-gradient(135deg, rgba(109, 93, 252, 0.96), rgba(19, 184, 166, 0.9), rgba(255, 122, 89, 0.9));
  background-size: 180% 180%;
  color: white;
  box-shadow:
    0 10px 32px rgba(109, 93, 252, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
  animation: navPillFlow 4.5s ease infinite;
}

@keyframes navPillFlow {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.main {
  min-width: 0;
  display: block;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px) saturate(1.35);
  box-shadow: 0 14px 50px rgba(28, 35, 64, 0.1);
  overflow: visible;
}

.topnav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(109, 93, 252, 0.14), transparent 28%, rgba(19, 184, 166, 0.12) 58%, transparent 82%),
    linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.7) 46%, transparent 62%);
  background-size: 180% 100%, 220% 100%;
  animation: navGlow 7s ease-in-out infinite;
}

@keyframes navGlow {
  0%, 100% {
    background-position: 0% 50%, -120% 50%;
  }
  50% {
    background-position: 100% 50%, 120% 50%;
  }
}

.topnav-brand {
  min-width: 160px;
}

.topnav-brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.topnav-center {
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.topnav-center::-webkit-scrollbar {
  display: none;
}

.topnav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.nav-menu {
  position: relative;
}

.nav-menu summary {
  list-style: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
  color: #344054;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 10px 30px rgba(42, 50, 80, 0.08);
  backdrop-filter: blur(16px) saturate(1.2);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.nav-menu summary::-webkit-details-marker {
  display: none;
}

.nav-menu summary::after {
  content: "⌄";
  font-size: 12px;
  line-height: 1;
}

.nav-menu[open] summary,
.nav-menu summary.active,
.nav-menu summary:hover {
  background: linear-gradient(135deg, rgba(109, 93, 252, 0.96), rgba(19, 184, 166, 0.9), rgba(255, 122, 89, 0.9));
  background-size: 180% 180%;
  color: white;
  box-shadow:
    0 10px 32px rgba(109, 93, 252, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
  animation: navPillFlow 4.5s ease infinite;
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  min-width: 190px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: var(--shadow-lift);
  animation: menuPop 220ms cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes menuPop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nav-menu-panel button {
  justify-content: flex-start;
  text-align: left;
  border-radius: 10px;
  box-shadow: none;
}

.nav-menu-panel button.active {
  background: linear-gradient(135deg, rgba(109, 93, 252, 0.96), rgba(19, 184, 166, 0.9), rgba(255, 122, 89, 0.9));
  background-size: 180% 180%;
  color: white;
  animation: navPillFlow 4.5s ease infinite;
}

.mobile-nav-menu {
  display: none;
}

.user-chip {
  max-width: 230px;
  display: grid;
  gap: 1px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.user-chip strong,
.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip span {
  color: var(--muted);
  font-size: 11px;
}

.topbar {
  min-height: 24px;
  background: transparent;
  border-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 18px 0;
  gap: 12px;
}

.content {
  padding: 8px 18px 22px;
  display: grid;
  gap: 16px;
  align-content: start;
  animation: contentFade 220ms ease both;
}

.content > * {
  animation: surfaceRise 420ms cubic-bezier(.2, .8, .2, 1) both;
}

.content > *:nth-child(2) {
  animation-delay: 45ms;
}

.content > *:nth-child(3) {
  animation-delay: 90ms;
}

.content > *:nth-child(4) {
  animation-delay: 135ms;
}

.content > *:nth-child(n + 5) {
  animation-delay: 180ms;
}

@keyframes contentFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes surfaceRise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.page-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.page-title h1 {
  background: linear-gradient(135deg, #1d2433, var(--accent), var(--accent-2), #1d2433);
  background-size: 220% 220%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleGradient 8s ease infinite;
}

@keyframes titleGradient {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

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

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

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

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px) saturate(1.2);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(109, 93, 252, 0.42), rgba(19, 184, 166, 0.22), rgba(255, 122, 89, 0.28), rgba(109, 93, 252, 0.42));
  background-size: 220% 220%;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
  animation: borderFlow 7s ease infinite;
  transition: opacity 220ms ease;
}

.panel:hover {
  transform: translateY(-1px);
  border-color: rgba(109, 93, 252, 0.24);
  box-shadow: var(--shadow-lift);
}

.panel:hover::before {
  opacity: 1;
}

@keyframes borderFlow {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.panel-header {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(125, 140, 168, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(245, 249, 255, 0.76));
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
}

.compact-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  align-items: end;
}

.compact-form .wide {
  grid-column: span 2;
}

.checkbox-field {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
}

.checkbox-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 6px;
}

.multi-check-field {
  align-self: stretch;
}

.multi-check-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.multi-check-summary strong {
  color: var(--text);
  white-space: nowrap;
}

.multi-check-summary span {
  text-align: right;
}

.multi-check-grid {
  max-height: 168px;
  overflow: auto;
  padding-right: 2px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.checkbox-option input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.settings-form-status {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings-form-status.error,
.field-error {
  color: var(--danger);
}

.field-invalid input,
.field-invalid select,
.field-invalid .checkbox-option,
.field-invalid.checkbox-field {
  border-color: var(--danger);
}

.field-error {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.settings-tabs button {
  flex: 0 0 auto;
  background: var(--surface);
  border-radius: 999px;
}

.settings-tabs button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: rgba(255, 255, 255, 0.16);
  color: white;
}

.roster-floor-filter {
  display: inline-flex;
  gap: 5px;
  max-width: 100%;
  margin: 8px 0 10px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid rgba(118, 99, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 12px 28px rgba(70, 80, 130, 0.08);
  backdrop-filter: blur(12px);
}

.roster-floor-filter button {
  flex: 0 0 auto;
  min-width: 56px;
  padding: 7px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.roster-floor-filter button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
}

.roster-floor-filter button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 10px 24px rgba(118, 99, 255, 0.24);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.settings-editor {
  border-color: var(--accent);
}

.settings-inline-edit-row td {
  background: #f6fbfb;
  border-bottom: 1px solid var(--accent);
  white-space: normal;
}

.settings-inline-title {
  display: block;
  margin-bottom: 8px;
  color: #29474e;
}

.settings-inline-edit-row .compact-form {
  margin: 0;
}

.readonly-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.readonly-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfc;
}

.readonly-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.readonly-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.ai-plan {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.table-wrap.stacked {
  margin-top: 4px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.table-tools {
  position: sticky;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  min-width: 320px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 252, 255, 0.84);
}

.table-tools label {
  width: min(360px, 100%);
}

.table-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto !important;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-toggle input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.table-filter-reset {
  min-height: 32px;
}

.table-filter-count {
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 8px;
  white-space: nowrap;
}

.column-filter-row th {
  position: static;
  z-index: 0;
  padding: 4px;
  background: rgba(248, 251, 255, 0.92);
}

.column-filter-select {
  min-height: 30px;
  width: 100%;
  min-width: 92px;
  padding: 4px 6px;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: rgba(255, 255, 255, 0.88);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(239, 245, 255, 0.96);
  color: #344054;
  font-size: 12px;
}

th.sortable-header {
  cursor: pointer;
  user-select: none;
}

th.sortable-header::after {
  content: " ↕";
  color: var(--muted);
  font-weight: 600;
}

th.sortable-header.sorted-asc::after {
  content: " ↑";
  color: var(--accent);
}

th.sortable-header.sorted-desc::after {
  content: " ↓";
  color: var(--accent);
}

tr:hover td {
  background: rgba(235, 242, 255, 0.72);
  transition: background 140ms ease;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid;
}

.status.approved {
  color: var(--ok);
  background: #eef8f2;
  border-color: #bbdcc9;
}

.status.pending {
  color: var(--pending);
  background: #fff7df;
  border-color: #e8cf86;
}

.status.rejected {
  color: var(--danger);
  background: #fff1f1;
  border-color: #e6bbbb;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto -20% -55% -20%;
  height: 80px;
  background: linear-gradient(90deg, rgba(109, 93, 252, 0.24), rgba(19, 184, 166, 0.18), rgba(255, 122, 89, 0.2));
  filter: blur(24px);
  transform: translateX(-20%);
  animation: kpiGlow 6s ease-in-out infinite alternate;
}

@keyframes kpiGlow {
  from {
    transform: translateX(-24%);
  }
  to {
    transform: translateX(24%);
  }
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 6px;
  font-size: 24px;
  color: var(--accent);
}

.message {
  min-height: 22px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.event-marker {
  display: inline-flex;
  min-width: 18px;
  justify-content: center;
  border-radius: 4px;
  margin-left: 3px;
  font-weight: 800;
}

.event-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #c9d7d9;
  background: #eef7f7;
  color: var(--text);
}

.event-status.cancelled {
  border-color: #e3b6b6;
  background: #fff1f1;
  color: var(--danger);
}

.event-status.inactive {
  border-color: #d5d9dc;
  background: #f2f4f5;
  color: var(--muted);
}

tr.event-cancelled td {
  background: #fff6f6;
}

tr.event-cancelled:hover td {
  background: #ffecec;
}

tr.event-cancelled .event-title,
tr.event-cancelled .event-location {
  color: var(--danger);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

tr.event-inactive td {
  color: var(--muted);
  background: rgba(226, 232, 240, 0.45);
}

.selected-day-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
}

.selected-day-summary strong {
  color: var(--text);
  font-size: 15px;
}

.selected-day-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.day-cell {
  min-height: 118px;
  display: grid;
  gap: 5px;
  align-content: start;
  text-align: left;
  padding: 10px;
  border-color: var(--line);
  background: white;
}

.day-cell:hover,
.day-cell.selected {
  border-color: var(--accent);
  background: #f3fafb;
}

.day-cell.unassigned {
  background: #fbfbfb;
  border-style: dashed;
}

.day-cell.leave {
  background: #f8fbf5;
  border-color: #bed4ab;
}

.day-cell.unavailable {
  background: #fff5f5;
  border-color: #d9aaaa;
}

.day-cell-meta,
.day-cell-time,
.day-cell-status {
  color: var(--muted);
  font-size: 12px;
}

.day-cell strong,
.day-cell-shift {
  color: var(--text);
  overflow-wrap: anywhere;
}

.day-cell-shift {
  font-weight: 700;
}

.day-cell-status {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.day-cell-markers {
  display: inline-flex;
  gap: 3px;
  flex-wrap: wrap;
}

.roster-grid-table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  border-left: 1px solid var(--line-strong);
  border-top: 1px solid var(--line-strong);
}

.roster-grid-table th,
.roster-grid-table td {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  width: auto;
  min-width: 0;
  max-width: none;
  text-align: center;
  overflow: hidden;
  text-overflow: clip;
}

.roster-grid-table thead tr:first-child th:nth-child(1),
.roster-grid-table tbody td:nth-child(1) {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
}

.roster-grid-table thead tr:first-child th:nth-child(2),
.roster-grid-table tbody td:nth-child(2) {
  width: 74px;
  min-width: 74px;
  max-width: 74px;
}

.roster-grid-table thead tr:first-child th:nth-child(3),
.roster-grid-table tbody td:nth-child(3) {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

.roster-grid-table thead tr:first-child th:nth-child(4),
.roster-grid-table tbody td:nth-child(4) {
  width: 74px;
  min-width: 74px;
  max-width: 74px;
}

.roster-grid-table thead tr:first-child th:nth-child(5),
.roster-grid-table tbody td:nth-child(5),
.roster-grid-table .roster-trailing-summary {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
}

.roster-grid-table .roster-date-cell {
  width: 70px;
  min-width: 70px;
  max-width: 70px;
}

.roster-grid-table thead tr:first-child th:nth-child(1),
.roster-grid-table tbody tr:not(.roster-section-empty) td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 4;
  box-shadow: 1px 0 0 var(--line-strong);
}

.roster-grid-table thead tr:first-child th:nth-child(2),
.roster-grid-table tbody tr:not(.roster-section-empty) td:nth-child(2) {
  position: sticky;
  left: 58px;
  z-index: 4;
  box-shadow: 1px 0 0 var(--line-strong), 8px 0 14px rgba(20, 27, 43, 0.08);
}

.roster-grid-table thead tr:first-child th:nth-child(1),
.roster-grid-table thead tr:first-child th:nth-child(2) {
  z-index: 6;
  background: #e8f0f2;
}

.roster-grid-table thead th {
  border-bottom: 2px solid var(--line-strong);
  background: #e8f0f2;
}

.roster-grid-table .roster-leading-head,
.roster-grid-table .roster-summary-head {
  padding: 5px 4px;
  text-align: center;
  vertical-align: middle;
  white-space: normal;
}

.roster-grid-table .roster-head-label {
  display: inline-block;
  max-width: 100%;
  line-height: 1.12;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.roster-grid-table thead th.public-holiday-column {
  background: #ffd166;
  color: #b42318;
}

.roster-grid-table thead th.sunday-column,
.roster-grid-table thead th.sunday-column.public-holiday-column {
  background: #ffd166;
  color: #b42318;
}

.roster-grid-table td.public-holiday-column {
  background: #fff0c2;
}

.roster-grid-table td.sunday-column,
.roster-grid-table tbody tr:nth-child(even) td.public-holiday-column,
.roster-grid-table tbody tr:nth-child(even) td.sunday-column {
  background: #fff0c2;
}

.roster-grid-table .roster-event-row th {
  height: 28px;
  width: 70px;
  min-width: 70px;
  max-width: 70px;
  padding: 3px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
  white-space: normal;
}

.roster-event-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 62px;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.05;
  font-size: 9px;
}

.roster-event-chip span:last-child {
  display: -webkit-box;
  max-height: 2.2em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.roster-event-overflow {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 999px;
  background: #dfe7ea;
  color: var(--muted);
  font-size: 11px;
}

.roster-grid-table tbody tr:nth-child(even) td {
  background: #f7faf8;
}

.roster-grid-table tbody tr.roster-row-odd td {
  background: #ffffff;
}

.roster-grid-table tbody tr.roster-row-even td {
  background: #eef4f8;
}

.roster-grid-table tbody td.public-holiday-column,
.roster-grid-table tbody tr:nth-child(even) td.public-holiday-column {
  background: #fff0c2;
}

.roster-grid-table tbody td.sunday-column,
.roster-grid-table tbody tr:nth-child(even) td.sunday-column,
.roster-grid-table tbody td.sunday-column.public-holiday-column,
.roster-grid-table tbody tr:nth-child(even) td.sunday-column.public-holiday-column {
  background: #fff0c2;
}

.roster-grid-table .roster-section-header th {
  position: static;
  z-index: 0;
  width: auto;
  min-width: 0;
  max-width: none;
  padding: 8px 12px;
  color: white;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  border-top: 2px solid rgba(255, 255, 255, 0.75);
  border-bottom: 2px solid rgba(20, 27, 43, 0.16);
}

.roster-grid-table .roster-section-header span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.roster-section-none th {
  background: #6d5dfc !important;
}

.roster-section-gf th {
  background: #d28a00 !important;
}

.roster-section-ug th {
  background: #198754 !important;
}

.roster-section-1f th {
  background: #2274c9 !important;
}

.roster-section-night th {
  background: #a65f22 !important;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-none td {
  background: #f3efff;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-none.roster-row-even td {
  background: #e8e0ff;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-gf td {
  background: #fff3cf;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-gf.roster-row-even td {
  background: #ffe6a6;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-ug td {
  background: #e7f6ee;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-ug.roster-row-even td {
  background: #d1ecdc;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-1f td {
  background: #e9f3ff;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-1f.roster-row-even td {
  background: #d5e8ff;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-night td {
  background: #f8eadb;
}

.roster-grid-table tbody tr.roster-section-row.roster-section-night.roster-row-even td {
  background: #eed8c2;
}

.roster-grid-table tbody tr.roster-section-row:hover td {
  filter: brightness(0.985);
}

.roster-grid-table tbody tr.roster-section-row td.public-holiday-column {
  box-shadow: inset 0 0 0 9999px rgba(255, 193, 7, 0.18);
}

.roster-grid-table tbody tr.roster-section-row td.sunday-column,
.roster-grid-table tbody tr.roster-section-row td.sunday-column.public-holiday-column {
  box-shadow: inset 0 0 0 9999px rgba(255, 193, 7, 0.18);
}

.roster-grid-table tbody tr.roster-section-row td.changed-cell {
  box-shadow: inset 0 0 0 9999px rgba(245, 208, 111, 0.26);
}

.roster-grid-table .roster-section-empty td {
  width: auto;
  max-width: none;
  color: var(--muted);
  font-weight: 700;
}

.roster-grid-table thead tr:first-child th:nth-child(-n + 5),
.roster-grid-table tbody td:nth-child(-n + 2) {
  text-align: center;
}

.roster-grid-table .roster-title-cell,
.roster-grid-table .roster-name-cell {
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: normal;
}

.roster-grid-table .roster-title-cell {
  padding-inline: 4px;
  line-height: 1.18;
}

.roster-title-text {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  max-width: 100%;
}

.roster-title-text span {
  display: block;
  white-space: nowrap;
}

.roster-grid-table .roster-balance-cell,
.roster-grid-table .roster-summary-cell,
.roster-grid-table .roster-summary-head {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.matrix-cell-button {
  width: 100%;
  min-height: 34px;
  padding: 5px 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.matrix-cell-button:hover {
  background: #e8f4f4;
}

.auto-draft-edit-hint {
  margin-top: 10px;
}

section.panel:has(#auto-roster-patch-form.hidden) {
  display: none;
}

.auto-draft-batch-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.auto-draft-batch-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.auto-draft-batch-heading strong {
  color: var(--text);
  font-size: 14px;
}

.auto-draft-batch-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.auto-draft-batch-issues {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 12px;
  line-height: 1.35;
}

.auto-draft-batch-issues span {
  overflow-wrap: anywhere;
}

.auto-draft-editable-cell {
  padding: 0;
}

.auto-draft-cell-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 34px;
  padding: 5px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.auto-draft-cell-button:hover,
.auto-draft-cell-button:focus-visible,
.auto-draft-cell-button.active {
  outline: none;
  background: rgba(84, 112, 255, 0.14);
  box-shadow: inset 0 0 0 2px rgba(84, 112, 255, 0.28);
}

.auto-draft-empty-cell {
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.auto-draft-floating-editor {
  position: fixed;
  z-index: 3000;
  width: min(236px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid rgba(99, 102, 241, 0.34);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(20, 27, 43, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.68) inset;
  backdrop-filter: blur(18px);
  animation: floatingEditorIn 160ms ease-out;
}

.auto-draft-floating-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.auto-draft-floating-header strong,
.auto-draft-floating-header span {
  display: block;
}

.auto-draft-floating-header strong {
  color: var(--text);
  font-size: 13px;
}

.auto-draft-floating-header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.icon-button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  line-height: 1;
}

.auto-draft-cell-editor {
  display: grid;
  gap: 4px;
  min-width: 112px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 0 0 2px rgba(84, 112, 255, 0.42);
}

.auto-draft-floating-editor .auto-draft-cell-editor {
  min-width: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.auto-draft-cell-editor select {
  min-height: 28px;
  width: 100%;
  padding: 3px 5px;
  font-size: 12px;
}

.auto-draft-cell-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.auto-draft-cell-actions button {
  min-height: 26px;
  padding: 3px 5px;
  font-size: 11px;
}

.auto-draft-cell-warning {
  display: grid;
  gap: 2px;
  padding: 5px;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
}

.auto-draft-cell-warning span {
  overflow-wrap: anywhere;
}

@keyframes floatingEditorIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .auto-draft-floating-editor {
    left: 12px !important;
    right: 12px;
    top: 82px !important;
    width: auto;
  }
}

.changed-cell {
  background: #fff8e6;
}

.change-marker {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 4px;
  border-radius: 999px;
  background: #f5d06f;
  color: #3e2b05;
  font-size: 10px;
  font-weight: 700;
}

.work-floor-marker {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #e6f0ff;
  color: #18446f;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .login-panel,
  .grid.two,
  .grid.three,
  .kpis {
    grid-template-columns: 1fr;
  }

  .topnav {
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
  }

  .topnav-center,
  .management-menu {
    display: none;
  }

  .mobile-nav-menu {
    display: block;
  }

  .topnav-actions {
    gap: 6px;
  }

  .user-chip {
    max-width: 150px;
    padding: 6px 8px;
  }

  .user-chip span {
    display: none;
  }

  .nav-menu-panel {
    right: 0;
    min-width: min(260px, calc(100vw - 24px));
  }

  .topbar {
    padding-inline: 12px;
  }

  .content {
    padding: 8px 12px 18px;
  }

  .compact-form {
    grid-template-columns: 1fr;
  }

  .compact-form .wide {
    grid-column: auto;
  }

  .selected-day-summary {
    display: grid;
  }

  .readonly-grid {
    grid-template-columns: 1fr;
  }

  .row-actions {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  button:hover:not(:disabled),
  .panel:hover,
  .kpi:hover {
    transform: none;
  }
}
