:root {
  --page-bg: #005daa;
  --page-bg-deep: #003f79;
  --text: #172033;
  --muted: #64748b;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-muted: #eef3f8;
  --border: #d9e2ec;
  --brand: #005daa;
  --brand-hover: #003f79;
  --brand-soft: #e6f4ff;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.09);
  --button-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
  --ac-start: #fff3cf;
  --ac-end: #ffb454;
  --ac-strong: #d97706;
  --ac-border: #f59e0b;
  --bd-start: #e6f4ff;
  --bd-end: #72b7ff;
  --bd-strong: #2563eb;
  --bd-border: #3b82f6;
}

html.dark {
  --text: #edf4ff;
  --muted: #9cafc6;
  --surface: rgba(15, 27, 46, 0.9);
  --surface-solid: #101c30;
  --surface-muted: #17253c;
  --border: #2a3c57;
  --brand: #60a5fa;
  --brand-hover: #72b7ff;
  --brand-soft: #153864;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  --button-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  --ac-start: #5b3a0a;
  --ac-end: #b86306;
  --ac-strong: #f59e0b;
  --ac-border: #d97706;
  --bd-start: #153864;
  --bd-end: #1d5cae;
  --bd-strong: #60a5fa;
  --bd-border: #3b82f6;
}

* {
  box-sizing: border-box;
}

.min-w-0 {
  min-width: 0;
}

.print-only {
  display: none;
}

html {
  min-width: 320px;
  background: var(--page-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(
    125deg,
    var(--page-bg),
    var(--page-bg-deep)
  );
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.45);
  outline-offset: 3px;
}

.app-shell {
  width: min(100% - 1rem, 1400px);
  margin: 0 auto;
  padding: 0.75rem 0 2rem;
}

.topbar,
.control-panel,
.calendar-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: 1.15rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 0.9rem;
  color: white;
  background: linear-gradient(145deg, #005daa, #003f79);
  box-shadow: 0 12px 24px
    color-mix(in srgb, var(--brand), transparent 75%);
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.site-title {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.05rem, 3.5vw, 1.45rem);
  font-weight: 780;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
}

.control-panel {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: 1.15rem;
}

.month-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.month-title {
  margin: 0;
  font-size: clamp(1.6rem, 6vw, 2.65rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1;
}

.month-subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.nav-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, auto));
  gap: 0.45rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.field {
  display: grid;
  gap: 0.35rem;
  min-width: min(100%, 14rem);
}

.field label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.select {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 2.25rem 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  color: var(--text);
  background-color: var(--surface-solid);
  box-shadow: var(--button-shadow);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.35rem;
  padding: 0.42rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-solid);
  font-size: 0.78rem;
  font-weight: 720;
}

.legend-dot {
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 999px;
}

.legend-dot.ac {
  background: var(--ac-strong);
}

.legend-dot.bd {
  background: var(--bd-strong);
}

.legend-payday {
  display: grid;
  width: 1.15rem;
  height: 1.15rem;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--brand);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.btn {
  display: inline-flex;
  min-width: 2.65rem;
  min-height: 2.65rem;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  padding: 0.58rem 0.78rem;
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  color: var(--text);
  background: var(--surface-solid);
  box-shadow: var(--button-shadow);
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 730;
  line-height: 1;
  text-decoration: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
}

.btn-primary {
  color: white;
  border-color: transparent;
  background: var(--brand);
}

.btn-primary:hover {
  border-color: transparent;
  background: var(--brand-hover);
}

.icon-btn svg {
  width: 1.05rem;
  height: 1.05rem;
}

.button-label {
  display: none;
}

.mobile-month-bar {
  display: none;
}

.mobile-month-title {
  margin: 0;
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 820;
  letter-spacing: -0.025em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-month-button {
  min-width: 2.55rem;
  min-height: 2.55rem;
  padding: 0.5rem;
}

.mobile-today-button {
  min-height: 2.35rem;
  padding: 0.48rem 0.65rem;
  font-size: 0.75rem;
}

.calendar-panel {
  margin-top: 0.75rem;
  padding: 0.65rem;
  overflow: hidden;
  border-radius: 1.15rem;
}

.calendar-stage {
  position: relative;
  overflow: hidden;
  border-radius: 0.8rem;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: height 0.28s ease;
}

.calendar-stage:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.45);
  outline-offset: 4px;
}

.calendar-grid-clone {
  position: absolute !important;
  inset: 0;
  z-index: 2;
  width: 100%;
  pointer-events: none;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.3rem;
  padding: 0.35rem 0 0.55rem;
}

.weekday {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: uppercase;
}

.weekday-long {
  display: none;
}

.calendar-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.3rem;
  will-change: transform, opacity;
}

.card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 5.65rem;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
  padding: 0.38rem;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  color: #122033;
  isolation: isolate;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    box-shadow 0.18s ease;
}

html.dark .card {
  color: #f8fbff;
}

.card::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.28);
  content: "";
  pointer-events: none;
}

.card:hover {
  transform: translateY(-2px);
}

.bg-ac {
  border-color: color-mix(in srgb, var(--ac-border), transparent 52%);
  background: linear-gradient(145deg, var(--ac-start), var(--ac-end));
}

.bg-bd {
  border-color: color-mix(in srgb, var(--bd-border), transparent 52%);
  background: linear-gradient(145deg, var(--bd-start), var(--bd-end));
}

.bg-ac-today {
  color: white !important;
  border-color: #fff1bf;
  background: linear-gradient(145deg, #b45309, var(--ac-strong));
}

.bg-bd-today {
  color: white !important;
  border-color: #dbeafe;
  background: linear-gradient(145deg, #1d4ed8, var(--bd-strong));
}

.today-card {
  box-shadow:
    0 0 0 3px var(--surface-solid),
    0 0 0 6px rgba(245, 158, 11, 0.42),
    0 14px 30px rgba(15, 23, 42, 0.2);
}

.card.outside-month {
  opacity: 0.32;
  filter: saturate(0.55);
}

.card.off-day {
  opacity: 0.24;
  filter: grayscale(0.2);
}

.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.date-number {
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 850;
}

.today-card .date-number {
  color: #111827;
  background: white;
}

.date-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
}

.payday-badge {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  color: white;
  background: var(--brand);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

html.dark .payday-badge {
  color: #003f79;
  border-color: rgba(255, 255, 255, 0.46);
  background: var(--brand);
}

.today-card .payday-badge {
  color: #003f79;
  background: white;
}

.today-label {
  display: none;
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shift-stack {
  display: grid;
  gap: 0.28rem;
  margin-top: auto;
}

.shift-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.28rem 0.2rem;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 0.48rem;
  background: rgba(255, 255, 255, 0.54);
  font-size: 0.66rem;
  font-weight: 750;
  line-height: 1;
}

html.dark .shift-chip {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(2, 8, 23, 0.24);
}

.shift-chip.night {
  color: white;
  border-color: transparent;
  background: rgba(15, 23, 42, 0.58);
}

.shift-label {
  display: none;
  opacity: 0.75;
  font-weight: 650;
}

.empty-shifts {
  min-height: 3.55rem;
}

.mobile-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0.75rem 0 0.1rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
}

.swipe-icon {
  display: inline-flex;
  min-width: 2.1rem;
  justify-content: space-between;
  color: var(--brand);
  font-size: 0.9rem;
  font-weight: 900;
}

@keyframes today-enter {
  0% {
    transform: scale(0.92);
  }
  55% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

.today-bounce {
  animation: today-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 640px) {
  .app-shell {
    width: min(100% - 2rem, 1400px);
    padding-top: 1rem;
  }

  .topbar,
  .control-panel {
    padding: 1.2rem 1.3rem;
  }

  .button-label {
    display: inline;
  }

  .calendar-panel {
    padding: 0.9rem;
  }

  .weekdays,
  .calendar-grid {
    gap: 0.55rem;
  }

  .weekday {
    font-size: 0.7rem;
  }

  .weekday-short {
    display: none;
  }

  .weekday-long {
    display: inline;
  }

  .card {
    min-height: 7.3rem;
    gap: 0.45rem;
    padding: 0.55rem;
    border-radius: 0.85rem;
  }

  .date-number {
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.82rem;
  }

  .today-label {
    display: inline;
  }

  .shift-chip {
    justify-content: flex-start;
    padding: 0.42rem 0.48rem;
    font-size: 0.72rem;
  }

  .shift-label {
    display: inline;
  }

  .mobile-note {
    display: none;
  }
}

@media (min-width: 900px) {
  .control-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .filter-row {
    grid-column: 1 / -1;
  }

  .card {
    min-height: 8.2rem;
    padding: 0.68rem;
  }

  .shift-chip {
    padding: 0.48rem 0.55rem;
    font-size: 0.77rem;
  }
}

@media (max-width: 899px) {
  .month-block {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-row {
    width: 100%;
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-row .btn {
    width: 100%;
    padding-inline: 0.35rem;
  }
}

@media (max-width: 639px) {
  .calendar-panel {
    overflow: visible;
  }

  .mobile-month-bar {
    position: sticky;
    top: 0.35rem;
    z-index: 20;
    display: grid;
    grid-template-columns: 2.55rem minmax(0, 1fr) auto 2.55rem;
    align-items: center;
    gap: 0.55rem;
    margin: -0.1rem 0 0.55rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  html.dark .mobile-month-bar {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
  }

  .month-block,
  .nav-row {
    display: none;
  }

  .filter-row {
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 480px) {
  .topbar {
    align-items: flex-start;
  }

  .brand-mark {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.75rem;
  }

  .eyebrow {
    display: none;
  }

  .top-actions .btn {
    min-width: 2.4rem;
    min-height: 2.4rem;
    padding: 0.45rem;
  }

  .field {
    width: 100%;
  }

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

  .legend {
    width: 100%;
  }

  .legend-item {
    flex: 1 1 auto;
    justify-content: center;
  }
}

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

@media print {
  @page {
    margin: 0.55in;
  }

  .no-print,
  .mobile-month-bar {
    display: none !important;
  }

  body {
    color: black !important;
    background: white !important;
  }

  .app-shell,
  .calendar-panel,
  .calendar-stage {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: white !important;
    box-shadow: none !important;
  }

  .weekdays,
  .mobile-note,
  .calendar-stage {
    display: none !important;
  }

  .print-calendar-header {
    display: block !important;
  }

  .print-month-title {
    margin: 0 0 0.18in;
    color: black;
    font-size: 20px;
    line-height: 1.1;
  }

  .print-calendar-table {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse;
    table-layout: fixed;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-date-column {
    width: 48%;
  }

  .print-calendar-table th,
  .print-calendar-table td {
    padding: 0.04in 0.09in;
    border: 1px solid rgba(0, 0, 0, 0.32);
    font-size: 9.5px;
    line-height: 1.2;
    text-align: left;
  }

  .print-calendar-table th {
    background: rgba(0, 0, 0, 0.08);
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .print-calendar-table thead {
    display: table-header-group;
  }

  .print-calendar-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-calendar-table tbody td:first-child {
    font-weight: 750;
  }

  .print-calendar-table .print-payday-row td {
    background: rgba(0, 93, 170, 0.1);
  }

  .print-payday-label {
    margin-left: 0.08in;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }
}
