:root {
  color-scheme: light;
  --navy-950: #06162f;
  --navy-900: #071d3e;
  --navy-800: #0a2c5f;
  --blue-600: #087be8;
  --blue-500: #10a0ff;
  --cyan-400: #31d9f5;
  --ink: #0b1830;
  --muted: #66748b;
  --line: #dfe6ef;
  --surface: rgba(255, 255, 255, 0.92);
  --danger: #c33434;
  --shadow: 0 24px 70px rgba(6, 22, 47, 0.16);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(49, 217, 245, 0.12), transparent 30rem),
    linear-gradient(145deg, #f7f9fc 0%, #eaf0f7 100%);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.55;
}

.ambient-one {
  width: 28rem;
  height: 28rem;
  right: -10rem;
  top: -8rem;
  background: rgba(16, 160, 255, 0.14);
}

.ambient-two {
  width: 24rem;
  height: 24rem;
  left: -12rem;
  bottom: -8rem;
  background: rgba(49, 217, 245, 0.12);
}

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

.center-view {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 2rem;
}

.center-view > h1 {
  margin: 0.2rem 0 1.5rem;
  font-size: clamp(2.2rem, 7vw, 4rem);
}

.login-card {
  width: min(29rem, calc(100vw - 2rem));
  padding: clamp(1.6rem, 5vw, 2.5rem);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 2rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-row h1 { margin: 0.05rem 0 0; font-size: 1.65rem; }

.brand-mark {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 1.15rem;
  color: white;
  font-weight: 800;
  font-size: 1.45rem;
  background: linear-gradient(145deg, var(--navy-800), var(--blue-600));
  box-shadow: 0 10px 28px rgba(8, 123, 232, 0.25);
}

.eyebrow {
  margin: 0;
  color: var(--blue-600);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.19em;
}

.login-copy { margin: 3rem 0 2rem; }
.login-copy h2 { margin: 0 0 0.4rem; font-size: 2rem; letter-spacing: -0.035em; }
.login-copy p, .page-heading > p:last-child { margin: 0; color: var(--muted); }

form { display: grid; gap: 0.65rem; }
label { margin-top: 0.65rem; font-size: 0.84rem; font-weight: 750; }

input {
  width: 100%;
  height: 3.45rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  color: var(--ink);
  outline: none;
  background: #f9fbfd;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(16, 160, 255, 0.12);
}

.password-field { position: relative; }
.password-field input { padding-right: 4.5rem; }

.text-button {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  translate: 0 -50%;
  border: 0;
  color: var(--blue-600);
  font-size: 0.78rem;
  font-weight: 800;
  background: transparent;
  cursor: pointer;
}

.primary-button, .secondary-button {
  border: 0;
  border-radius: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  min-height: 3.55rem;
  margin-top: 1rem;
  color: white;
  background: linear-gradient(120deg, var(--navy-900), var(--blue-600));
  box-shadow: 0 12px 28px rgba(8, 123, 232, 0.2);
}

.primary-button:disabled { opacity: 0.65; cursor: wait; }

.secondary-button {
  padding: 0.75rem 1rem;
  color: var(--navy-900);
  border: 1px solid var(--line);
  background: white;
}

.form-error {
  margin: 0.55rem 0 0;
  color: var(--danger);
  font-size: 0.84rem;
}

.loader {
  width: 1.8rem;
  height: 1.8rem;
  margin: 0 auto;
  border: 3px solid rgba(8, 123, 232, 0.16);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { rotate: 360deg; } }

.topbar {
  height: 5.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid rgba(6, 22, 47, 0.08);
  background: rgba(247, 249, 252, 0.78);
  backdrop-filter: blur(16px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
}

.mini-mark {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 0.72rem;
  color: white;
  font-weight: 850;
  background: linear-gradient(145deg, var(--navy-800), var(--blue-600));
}

.user-area { display: flex; align-items: center; gap: 1rem; }
.user-copy { display: grid; text-align: right; font-size: 0.82rem; }
.user-copy span { color: var(--muted); font-size: 0.72rem; }

.content {
  width: min(76rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) 0;
}

.page-heading h2 {
  margin: 0.4rem 0 0.65rem;
  font-size: clamp(2.3rem, 6vw, 4.5rem);
  letter-spacing: -0.055em;
}

.page-heading.compact h2 { font-size: clamp(2.2rem, 5vw, 3.6rem); }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1.25rem;
  margin-top: 3rem;
}

.module-card {
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.6rem;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 1.6rem;
  color: white;
  text-decoration: none;
  background:
    radial-gradient(circle at 85% 15%, rgba(49, 217, 245, 0.25), transparent 9rem),
    linear-gradient(140deg, var(--navy-950), var(--navy-800));
  box-shadow: var(--shadow);
  transition: translate 170ms ease, box-shadow 170ms ease;
}

.module-card:hover { translate: 0 -4px; box-shadow: 0 30px 75px rgba(6, 22, 47, 0.22); }
.module-card h3 { margin: 0.5rem 0; font-size: 2rem; }
.module-card p { margin: 0; color: rgba(255,255,255,0.67); }
.module-arrow { align-self: flex-end; font-size: 2.2rem; color: var(--cyan-400); }

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  color: var(--blue-600);
  text-decoration: none;
  font-weight: 750;
}

.roster-placeholder {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.25rem;
  margin-top: 3rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(6, 22, 47, 0.08);
}

.roster-placeholder p { margin: 0.35rem 0 0; color: var(--muted); }
.roster-icon { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.roster-icon span { width: 1.1rem; height: 1.1rem; border-radius: 0.35rem; background: var(--blue-600); }
.roster-icon span:nth-child(2), .roster-icon span:nth-child(3) { background: var(--cyan-400); }

.status-chip {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  color: var(--blue-600);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  background: rgba(16, 160, 255, 0.1);
}

.roster-content {
  width: min(112rem, calc(100% - 2rem));
  padding-top: clamp(1.5rem, 4vw, 3rem);
}

.roster-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.roster-heading .back-link { margin-bottom: 1.25rem; }
.roster-title-line { display: flex; align-items: end; gap: 1rem; }
.roster-title-line h2 { margin: 0.25rem 0 0; font-size: clamp(2.2rem, 5vw, 4.2rem); letter-spacing: -0.055em; }

.live-chip,
.revision-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.48rem 0.72rem;
  border-radius: 999px;
  color: #087b45;
  background: #dff7e9;
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.live-chip { margin-bottom: 0.45rem; }
.live-chip i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: #14a35e; box-shadow: 0 0 0 4px rgba(20,163,94,0.12); }
.revision-chip { color: var(--muted); background: #eef2f7; }

.roster-nav { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; justify-content: flex-end; }
.icon-button {
  width: 2.85rem;
  height: 2.85rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  color: var(--navy-900);
  background: white;
  font-weight: 850;
  cursor: pointer;
}

.roster-state {
  min-height: 24rem;
  display: grid;
  place-content: center;
  gap: 1rem;
  text-align: center;
  color: var(--muted);
}

.roster-state p { margin: 0; }
.error-state strong { color: var(--danger); font-size: 1.1rem; }
.error-state .secondary-button { justify-self: center; margin-top: 0.5rem; }

.week-radar {
  display: grid;
  grid-template-columns: repeat(5, minmax(12rem, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.2rem 0 0.6rem;
  scrollbar-width: thin;
}

.week-card {
  min-width: 12rem;
  display: grid;
  gap: 0.42rem;
  padding: 1rem;
  text-align: left;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255,255,255,0.78);
  cursor: pointer;
  transition: border-color 140ms ease, translate 140ms ease, box-shadow 140ms ease;
}

.week-card:hover { translate: 0 -2px; box-shadow: 0 9px 22px rgba(6,22,47,0.08); }
.week-card.active { border-color: #72c8f7; background: linear-gradient(145deg, #f8fdff, #eaf8ff); box-shadow: inset 0 0 0 1px rgba(16,160,255,0.15); }
.week-label { color: var(--blue-600); font-size: 0.62rem; font-weight: 850; letter-spacing: 0.1em; }
.week-period { font-size: 0.87rem; }
.week-metrics { display: flex; gap: 0.5rem; flex-wrap: wrap; color: #168052; font-size: 0.58rem; font-weight: 800; }
.week-metrics .metric-alert, .week-metrics .metric-danger { color: var(--danger); }
.week-metrics .metric-warning { color: #ae7400; }

.roster-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(8.5rem, 1fr));
  gap: 0.75rem;
  margin: 0.8rem 0 1.2rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.kpi-card {
  min-width: 8.5rem;
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255,255,255,0.9);
}

.kpi-card.good { border-color: #b7e5cb; background: #f2fbf6; }
.kpi-card.bad { border-color: #f3c0c0; background: #fff4f4; }
.kpi-card.warn { border-color: #eed69e; background: #fffaf0; }
.kpi-label { color: var(--muted); font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 1.45rem; }

.timeline-card {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 1.35rem;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 18px 50px rgba(6,22,47,0.08);
}

.timeline-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid var(--line);
}

.timeline-card-head h3 { margin: 0.3rem 0 0; font-size: 1.15rem; }
.timeline-scroll { overflow: auto; max-height: calc(100vh - 19rem); scrollbar-width: thin; }
.timeline-canvas { min-width: calc(10rem + (var(--day-count) * 5.75rem)); }

.timeline-row {
  display: grid;
  grid-template-columns: 10rem repeat(var(--day-count), 5.75rem);
  min-height: 4.75rem;
  border-bottom: 1px solid #e7edf4;
}

.timeline-label {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.65rem 0.8rem;
  border-right: 1px solid var(--line);
  color: var(--ink);
  background: #f5f8fb;
}

.timeline-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.74rem; }
.timeline-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.56rem; font-weight: 700; }
.timeline-day { min-width: 0; padding: 0.32rem; border-right: 1px solid #e7edf4; background: rgba(255,255,255,0.72); }

.header-row {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 5.25rem;
  box-shadow: 0 2px 9px rgba(6,22,47,0.05);
}

.header-row .timeline-label { z-index: 6; color: var(--muted); font-size: 0.6rem; font-weight: 850; letter-spacing: 0.08em; }
.day-header { display: grid; place-items: center; align-content: center; gap: 0.15rem; background: #f8fafc; }
.day-weekday { color: var(--muted); font-size: 0.55rem; font-weight: 800; }
.day-number { font-size: 0.9rem; }
.day-counters { display: flex; gap: 0.15rem; margin-top: 0.2rem; }
.counter { width: 0.9rem; height: 0.9rem; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy-900); font-size: 0.45rem; font-style: normal; font-weight: 850; }
.counter.uncovered { background: #e3a20b; }
.counter.hard { background: #d34b4b; }
.counter.warning { background: #8c70cf; }
.counter:not(.on):not(.sessions) { opacity: 0.2; }

.section-row { min-height: 2.15rem; }
.section-row .timeline-label { color: var(--blue-600); font-size: 0.61rem; font-weight: 850; letter-spacing: 0.1em; background: #eaf2fb; }
.section-row .timeline-day { background: #edf3f9; }
.resource-cell, .crew-cell { display: flex; flex-direction: column; justify-content: center; gap: 0.22rem; }

.session-card,
.duty-badge {
  min-width: 0;
  display: grid;
  justify-items: start;
  padding: 0.35rem 0.4rem;
  border-radius: 0.48rem;
  line-height: 1.05;
}

.session-card { color: white; background: var(--navy-800); border-left: 3px solid #20c87a; }
.session-card.uncovered { border-left-color: #f5ac24; background: #624514; }
.session-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.57rem; }
.session-time, .session-crew { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,0.72); font-size: 0.46rem; }

.duty-badge { color: #11233d; background: #dce7f4; border-left: 3px solid #7ea7cf; }
.duty-badge strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.57rem; }
.duty-badge span { color: inherit; opacity: 0.7; font-size: 0.46rem; }
.duty-badge.off { color: #4e5966; background: #e4e7ea; border-left-color: #a7adb4; }
.duty-badge.available { color: #075b8b; background: #d9f1ff; border-left-color: #26a7eb; }
.duty-badge.standby { color: #552e72; background: #eee1f8; border-left-color: #8751ae; }
.duty-badge.duty { color: white; background: #0b376d; border-left-color: #2ed28a; }
.duty-badge.special { color: white; background: #774172; border-left-color: #e68bd8; }
.duty-badge.session { color: white; background: #0a5ea8; border-left-color: #37d99a; }

@media (max-width: 640px) {
  .user-copy { display: none; }
  .topbar { height: 4.7rem; }
  .content { padding-top: 3.5rem; }
  .roster-placeholder { grid-template-columns: auto 1fr; }
  .status-chip { grid-column: 1 / -1; justify-self: start; }
  .roster-heading { align-items: start; flex-direction: column; gap: 1rem; }
  .roster-nav { justify-content: flex-start; }
  .week-radar { grid-template-columns: repeat(5, 12rem); }
  .roster-kpis { grid-template-columns: repeat(6, 8.5rem); }
  .timeline-scroll { max-height: calc(100vh - 16rem); }
}
