:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: #0f172a;
  background-color: #f5f6fb;
  --card-bg: #ffffff;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --border: #e2e8f0;
  --shadow: 0 15px 35px rgba(15, 27, 40, 0.09);
  --muted: #475569;
  --eyebrow: #64748b;
  --body-bg: #f5f6fb;
  --chip-bg: rgba(100, 116, 139, 0.08);
  --control-bg: #ffffff;
  --control-border: #d0d7e6;
  --control-arrow: #0f172a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--body-bg);
  color: inherit;
}

.hidden {
  display: none !important;
}

.gate {
  position: fixed;
  inset: 0;
  background: rgba(5, 11, 22, 0.85);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 999;
}

.gate-card {
  width: min(360px, 100%);
  background: var(--card-bg);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: 0 20px 45px rgba(5, 11, 22, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: center;
}

.gate-card input {
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 2px solid var(--control-border);
  font-size: 1rem;
  background: var(--control-bg);
  color: inherit;
}

.gate-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-error {
  font-size: 0.9rem;
  color: #f87171;
  margin: 0;
}

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0.5rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  margin: 0 0 0.5rem;
  color: var(--eyebrow);
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 2.4rem);
}

.lead {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.domain-hint {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: var(--eyebrow);
}

.onboarding {
  background: var(--card-bg);
  border-radius: 1.25rem;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
}

.onboarding h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.onboarding ol {
  margin: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.onboarding li {
  list-style: none;
  display: flex;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.onboarding li strong {
  font-size: 1rem;
  color: var(--accent);
}

.onboarding .tip {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.refresh-top {
  display: inline-flex;
  justify-content: center;
  align-self: center;
  width: min(240px, 100%);
}


.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
  min-width: 185px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.refresh-visual {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(6px) scale(0.5);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.refresh-ring {
  width: 2.4rem;
  height: 2.4rem;
}

.refresh-ring__spinner {
  transform: rotate(-90deg);
  transform-origin: center;
}

.refresh-ring__bg,
.refresh-ring__fg {
  fill: none;
  stroke-width: 4;
}

.refresh-ring__bg {
  stroke: rgba(255, 255, 255, 0.22);
}

.refresh-ring__fg {
  stroke: #fff;
  stroke-linecap: round;
  stroke-dasharray: 188;
  stroke-dashoffset: 188;
  transform-origin: center;
}

.refresh-check {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  opacity: 0;
  transform-origin: center;
  transition: stroke-dashoffset 0.35s ease 0.08s, opacity 0.2s ease 0.05s, transform 0.25s ease;
}

.refresh-button .refresh-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: opacity 0.18s ease, transform 0.2s ease;
}

.refresh-button.is-loading .refresh-visual,
.refresh-button.is-success .refresh-visual {
  opacity: 1;
  transform: translateY(0) scale(1);
}


.refresh-button.is-loading .refresh-ring__spinner {
  animation: ring-spin 0.32s linear infinite;
}

.refresh-button.is-loading .refresh-ring__fg {
  animation: ring-dash 0.9s ease-in-out infinite;
}

.refresh-button.is-success .refresh-ring__spinner {
  animation: ring-settle 0.45s ease forwards;
}

.refresh-button.is-success .refresh-ring__fg {
  animation: none;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s ease;
}

.refresh-button.is-success .refresh-check {
  opacity: 1;
  stroke-dashoffset: 0;
  transform: scale(1.02);
}

.refresh-button.is-loading .refresh-label,
.refresh-button.is-success .refresh-label {
  opacity: 0;
  transform: translateY(-10px);
}

.refresh-button:disabled {
  cursor: not-allowed;
  filter: brightness(0.95);
}

@keyframes ring-spin {
  0% {
    transform: rotate(-90deg);
  }
  100% {
    transform: rotate(270deg);
  }
}

@keyframes ring-dash {
  0% {
    stroke-dashoffset: 188;
  }
  50% {
    stroke-dashoffset: 58;
  }
  100% {
    stroke-dashoffset: 188;
  }
}

@keyframes ring-settle {
  0% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(-90deg);
  }
}

.card {
  background: var(--card-bg);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 1.4rem;
}

.card p {
  margin: 0 0 0.6rem;
  color: var(--muted);
}

.dataset-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.2rem;
}

.admin-note {
  margin-top: 0.75rem;
}

.upload-card .file-input {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: fit-content;
  border-radius: 999px;
  background-color: var(--accent);
  color: #fff;
  padding: 0.8rem 1.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.upload-card .file-input:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.upload-card input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: #cbd5f5;
  flex: 1;
}

.link-loader {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.link-loader input {
  width: 100%;
  border-radius: 0.9rem;
  border: 2px solid var(--border);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.link-loader input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  border: none;
  border-radius: 0.9rem;
  padding: 0.85rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.25);
}

button.ghost {
  background: rgba(15, 23, 42, 0.05);
  color: #0f172a;
}

button.ghost:hover {
  box-shadow: none;
}

.small {
  font-size: 0.85rem;
  color: #64748b;
}

.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.9rem;
  background: rgba(100, 116, 139, 0.08);
  font-weight: 600;
  color: #334155;
}

.summary {
  margin-top: 0.65rem;
  font-size: 0.95rem;
  color: #0f172a;
}

.actions {
  margin-top: 1rem;
}

.selection-card .selectors {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.selection-card label {
  font-weight: 600;
  color: inherit;
}

.selection-card select {
  margin-top: 0.35rem;
  padding: 0.95rem 2.75rem 0.95rem 1.1rem;
  border-radius: 1rem;
  border: 2px solid var(--control-border);
  font-size: 1rem;
  width: 100%;
  background: var(--control-bg);
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--control-arrow) 50%),
    linear-gradient(-45deg, transparent 50%, var(--control-arrow) 50%),
    linear-gradient(var(--control-border), var(--control-border));
  background-position: calc(100% - 1.2rem) center, calc(100% - 0.8rem) center, calc(100% - 2.2rem) center;
  background-size: 8px 8px, 8px 8px, 1px 60%;
  background-repeat: no-repeat;
}

.roster-card select {
  min-width: 220px;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  border-radius: 999px;
  border: 2px solid var(--control-border);
  background: var(--control-bg);
  color: inherit;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--control-arrow) 50%),
    linear-gradient(-45deg, transparent 50%, var(--control-arrow) 50%),
    linear-gradient(var(--control-border), var(--control-border));
  background-position: calc(100% - 1rem) center, calc(100% - 0.6rem) center, calc(100% - 1.6rem) center;
  background-size: 7px 7px, 7px 7px, 1px 50%;
  background-repeat: no-repeat;
}

.roster-card select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.selection-card select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toggle {
  margin-top: 1.2rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.toggle .switch {
  flex: 0 0 auto;
  min-width: 56px;
}

.quick-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ghost.danger {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
}

.ghost.danger:hover {
  box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.2);
}

.switch {
  position: relative;
  width: 56px;
  height: 32px;
  display: inline-flex;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: linear-gradient(135deg, #cbd5f5, #b4c5f3);
  transition: 0.25s ease;
  border-radius: 30px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  background-color: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
  transition: transform 0.25s ease;
}

.switch input:checked + .slider {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.switch input:checked + .slider::before {
  transform: translateX(24px);
}

.info {
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.shift-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.roster-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.roster-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.roster-controls select {
  min-width: 200px;
}

.shift-list {
  margin-top: 1rem;
  max-height: min(65vh, 650px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.shift-list.empty {
  min-height: 120px;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--eyebrow);
}

.week-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--eyebrow);
  margin-top: 0.6rem;
}

.shift-item {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: #fff;
}

.shift-item.today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.shift-item__date {
  font-size: 1.05rem;
  font-weight: 600;
}

.shift-item__time {
  color: #0f172a;
  font-weight: 600;
}

.shift-item__meta {
  font-size: 0.85rem;
  color: var(--eyebrow);
}

.roster-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.roster-list.empty {
  min-height: 120px;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--eyebrow);
}

.roster-item {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--control-bg);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.03);
}

.roster-item__name {
  margin: 0;
  font-weight: 600;
  color: inherit;
}

.roster-item__department {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--eyebrow);
}

.roster-item__detail {
  font-weight: 600;
  color: inherit;
}

@media (min-width: 768px) {
  .app-header {
    flex-direction: row;
    align-items: stretch;
  }

  .app-header > div {
    flex: 1;
  }

  .selection-card .selectors {
    flex-direction: row;
  }

  .selection-card label {
    flex: 1;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color: #e2e8f0;
    background-color: #050b16;
    --body-bg: #050b16;
    --card-bg: #0f172a;
    --border: rgba(148, 163, 184, 0.25);
    --shadow: 0 15px 30px rgba(1, 5, 15, 0.75);
    --accent-soft: rgba(96, 165, 250, 0.35);
    --muted: rgba(226, 232, 240, 0.8);
    --eyebrow: #94a3b8;
    --chip-bg: rgba(148, 163, 184, 0.15);
    --control-bg: rgba(15, 23, 42, 0.9);
    --control-border: rgba(148, 163, 184, 0.35);
    --control-arrow: #e2e8f0;
  }

  body {
    background-color: var(--body-bg);
  }

  .shift-item {
    background: rgba(15, 23, 42, 0.8);
  }

  .shift-item__time {
    color: #e2e8f0;
  }

  .roster-item {
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
  }

  .roster-item__detail {
    color: #e2e8f0;
  }

  .slider {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  .switch input:checked + .slider {
    background: linear-gradient(135deg, #818cf8, #2563eb);
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.45);
  }
}
