* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #dbeafe 0, transparent 32rem), var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
}

.topbar h1,
.auth-card h1,
.calendar-toolbar h2,
.card h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.muted {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.25rem;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 2rem;
}

.calendar-panel,
.card,
.auth-card,
.entry-dialog,
.share-dialog {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 226, 239, 0.88);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.calendar-panel {
  padding: 1rem;
  overflow: hidden;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0.2rem 1rem;
  text-align: center;
}

.holiday-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.1rem;
  margin: 0 0 0.75rem;
  padding: 0.58rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  color: #344054;
}

.holiday-summary-icon {
  display: grid;
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 9px;
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.78rem;
  font-weight: 900;
  place-items: center;
}

.holiday-summary strong,
.holiday-summary small {
  display: block;
}

.holiday-summary strong {
  font-size: 0.82rem;
  line-height: 1.35;
}

.holiday-summary small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.holiday-summary-content {
  min-width: 0;
}

.holiday-legend {
  display: inline-block;
  width: 0.48rem;
  height: 0.48rem;
  margin: 0 0.2rem 0 0.35rem;
  border-radius: 50%;
  vertical-align: 0.02rem;
}

.holiday-legend:first-child {
  margin-left: 0;
}

.holiday-color {
  background: #dc2626;
}

.workday-color {
  background: #b45309;
}

.holiday-summary.no-holidays .holiday-summary-icon {
  background: #eef2f6;
  color: #667085;
}

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

.weekdays {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.55rem;
  text-align: center;
}

.day-cell {
  position: relative;
  min-width: 0;
  min-height: 112px;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
  .day-cell:hover {
    border-color: #9bb7e9;
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.13);
    transform: translateY(-1px);
  }
}

.day-cell.outside {
  color: #98a2b3;
  background: #f8fafc;
}

.day-cell.today {
  border-color: var(--primary);
}

.day-number {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
}

.holiday-badge {
  position: absolute;
  top: 0.62rem;
  right: 0.62rem;
  z-index: 1;
  max-width: calc(100% - 3.2rem);
  padding: 0.18rem 0.4rem;
  border-radius: 999px;
  overflow: hidden;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statutory-holiday {
  background: #fef2f2;
  color: #dc2626;
}

.adjusted-workday {
  background: #fffbeb;
  color: #b45309;
}

.shift-pill,
.shift-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.shift-pill {
  margin-top: 0.75rem;
  padding: 0.35rem 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shift-chip {
  padding: 0.35rem 0.65rem;
}

.entry-title {
  margin-top: 0.55rem;
  color: #344054;
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.side-panel {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.card {
  padding: 1rem;
}

.shift-list {
  display: grid;
  gap: 0.6rem;
  margin: 0.9rem 0;
}

.shift-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
}

.shift-row > div {
  min-width: 0;
}

.shift-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.25rem;
}

.edit-btn,
.text-btn {
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
}

.edit-btn {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
}

.edit-btn:hover,
.text-btn:hover {
  background: #eff6ff;
}

.shift-form-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.shift-form-heading h4 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-btn {
  flex: 0 0 auto;
  padding: 0.35rem 0.55rem;
}

.text-btn[hidden] {
  display: none;
}

.shift-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.stack-form {
  display: grid;
  gap: 0.85rem;
}

.compact-form {
  margin-top: 0.9rem;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

.field-help {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.35;
}

.shift-choice-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.shift-choice-fieldset legend {
  margin-bottom: 0.45rem;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

.shift-choice-list {
  display: grid;
  gap: 0.5rem;
  max-height: 17rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow-y: auto;
  outline: none;
}

.shift-choice-list:focus,
.shift-choice-list:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.shift-choice-list[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.shift-choice {
  position: relative;
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  min-height: 3.4rem;
  padding: 0.6rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.shift-choice:hover {
  border-color: #bfdbfe;
  background: #f0f7ff;
}

.shift-choice.is-selected {
  border-color: #93c5fd;
  background: #eff6ff;
}

.shift-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.shift-choice-mark {
  display: grid;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #98a2b3;
  border-radius: 5px;
  background: #fff;
  place-items: center;
}

.shift-choice input:checked + .shift-choice-mark {
  border-color: var(--primary);
  background: var(--primary);
}

.shift-choice input:checked + .shift-choice-mark::after {
  width: 0.28rem;
  height: 0.52rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  content: "";
  transform: translateY(-1px) rotate(45deg);
}

.shift-choice input:focus-visible + .shift-choice-mark {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.shift-choice-content {
  display: grid;
  min-width: 0;
  gap: 0.15rem;
}

.shift-choice-name {
  color: var(--shift-color);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.shift-choice-time {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.shift-choice-fieldset > .field-help {
  margin: 0.4rem 0 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  outline: none;
}

select[multiple] {
  min-height: 8.8rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
}

.check-row input {
  width: auto;
}

.primary,
.ghost,
.danger {
  min-height: 2.55rem;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-weight: 800;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
}

.danger {
  background: #fee2e2;
  color: var(--danger);
}

.icon-btn {
  min-width: 2rem;
  min-height: 2rem;
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  font-weight: 900;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(100%, 420px);
  padding: 2rem;
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 900;
}

.alert {
  margin: 1rem 0;
  border-radius: 14px;
  background: #fee2e2;
  color: #991b1b;
  padding: 0.8rem 0.9rem;
  font-weight: 700;
}

.switch-link {
  margin: 1rem 0 0;
  color: var(--muted);
  text-align: center;
}

.entry-dialog {
  width: min(94vw, 520px);
  border: 0;
  padding: 1.2rem;
}

.entry-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.share-dialog {
  width: min(94vw, 760px);
  max-height: min(92dvh, 980px);
  border: 0;
  padding: 0;
  overflow: hidden;
}

.share-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.share-dialog-content {
  display: grid;
  gap: 0.85rem;
  max-height: min(92dvh, 980px);
  padding: 1.1rem;
  overflow-y: auto;
}

.share-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.share-dialog-heading h3 {
  margin: 0;
}

.share-close {
  flex: 0 0 auto;
  color: #667085;
  font-size: 1.25rem;
}

.share-preview-wrap {
  display: grid;
  max-height: 62dvh;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #eaf0f7;
  overflow: auto;
  place-items: start center;
}

.share-preview {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  -webkit-touch-callout: default;
}

.share-help {
  margin: 0;
  text-align: center;
}

.share-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.share-actions .primary[hidden] {
  display: none;
}

.share-actions.single-action {
  grid-template-columns: 1fr;
}

.share-trigger:disabled {
  cursor: wait;
  opacity: 0.65;
}

.entry-shift-summary {
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.entry-shift-summary[hidden] {
  display: none;
}

.entry-shift-name {
  display: inline-block;
  max-width: 100%;
  padding: 0.35rem 0.65rem;
  border-radius: 12px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.entry-shift-time {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.spacer {
  flex: 1;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  max-width: min(90vw, 360px);
  border-radius: 16px;
  background: #111827;
  color: #fff;
  padding: 0.8rem 1rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
  }

  body {
    background: linear-gradient(180deg, #eff6ff 0, var(--bg) 18rem);
  }

  .topbar {
    align-items: center;
    padding: max(0.8rem, env(safe-area-inset-top)) 0.75rem 0.75rem;
  }

  .topbar h1 {
    font-size: 1.4rem;
    line-height: 1.15;
  }

  .eyebrow {
    font-size: 0.76rem;
  }

  .topbar .ghost {
    min-height: 2.5rem;
    padding: 0.5rem 0.85rem;
  }

  .app-shell {
    gap: 0.75rem;
    padding: 0 0.5rem calc(1rem + env(safe-area-inset-bottom));
  }

  .calendar-panel {
    padding: 0.5rem;
    border-radius: 20px;
  }

  .calendar-toolbar {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
    padding: 0.15rem 0 0.65rem;
  }

  .calendar-toolbar > div {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 0.2rem 0.35rem 0.25rem;
  }

  .calendar-toolbar h2 {
    font-size: 1.25rem;
    line-height: 1.2;
  }

  .calendar-toolbar .muted {
    margin-top: 0.2rem;
    font-size: 0.74rem;
    line-height: 1.4;
  }

  .calendar-toolbar .ghost {
    min-width: 0;
    min-height: 2.6rem;
    padding: 0.5rem 0.25rem;
    font-size: 0.82rem;
  }

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

  .holiday-summary {
    min-height: 2.75rem;
    margin-bottom: 0.45rem;
    padding: 0.48rem 0.55rem;
    border-radius: 11px;
  }

  .holiday-summary-icon {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 8px;
    font-size: 0.7rem;
  }

  .holiday-summary strong {
    font-size: 0.72rem;
  }

  .holiday-summary small {
    font-size: 0.62rem;
  }

  .weekdays {
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
    line-height: 1.8;
  }

  .day-cell {
    min-height: clamp(70px, 20vw, 84px);
    padding: 0.35rem 0.18rem;
    border-radius: 11px;
    border-color: #dce4ef;
    touch-action: manipulation;
  }

  .day-cell.today {
    border-width: 2px;
    padding: calc(0.35rem - 1px) calc(0.18rem - 1px);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.06);
  }

  .day-cell.today::after {
    display: none;
  }

  .day-number {
    display: block;
    padding-left: 0.12rem;
    font-size: 0.9rem;
    line-height: 1.2;
  }

  .day-number > span:last-child:not(:first-child) {
    display: none;
  }

  .holiday-badge {
    top: 0.28rem;
    right: 0.2rem;
    max-width: calc(100% - 1.7rem);
    padding: 0.12rem 0.22rem;
    border-radius: 6px;
    font-size: clamp(0.48rem, 2.1vw, 0.56rem);
  }

  .shift-pill {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 0.55rem;
    padding: 0.28rem 0.1rem;
    overflow: hidden;
    font-size: clamp(0.56rem, 2.65vw, 0.68rem);
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .shift-pill.shift-name-long,
  .shift-pill.shift-name-extra-long {
    display: -webkit-box;
    border-radius: 8px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
  }

  .shift-pill.shift-name-long {
    max-height: 2.4em;
    font-size: clamp(0.52rem, 2.35vw, 0.62rem);
    -webkit-line-clamp: 2;
  }

  .shift-pill.shift-name-extra-long {
    max-height: 3.3em;
    font-size: clamp(0.48rem, 2.1vw, 0.56rem);
    -webkit-line-clamp: 3;
  }

  .entry-title {
    display: none;
  }

  .entry-title.custom-entry-title {
    display: -webkit-box;
    margin-top: 0.25rem;
    padding: 0 0.08rem;
    overflow: hidden;
    color: #475467;
    font-size: clamp(0.5rem, 2.2vw, 0.6rem);
    line-height: 1.15;
    text-align: center;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .day-cell.has-custom-title:not(.has-shift) .custom-entry-title {
    margin-top: 0.55rem;
    font-size: clamp(0.54rem, 2.35vw, 0.64rem);
    -webkit-line-clamp: 4;
  }

  .side-panel {
    gap: 0.75rem;
  }

  .card {
    padding: 0.9rem;
    border-radius: 20px;
  }

  .card h3 {
    font-size: 1.05rem;
  }

  .shift-row {
    padding: 0.7rem;
    border-radius: 14px;
  }

  .edit-btn,
  .icon-btn {
    min-height: 2.5rem;
  }

  .shift-form-heading h4 {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .shift-row .shift-chip {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .shift-choice-list {
    max-height: none;
    padding: 0.45rem;
  }

  .shift-choice {
    min-height: 3.75rem;
    padding: 0.7rem 0.6rem;
  }

  .shift-choice-mark {
    width: 1.35rem;
    height: 1.35rem;
  }

  .shift-choice-name {
    font-size: 0.94rem;
  }

  .shift-choice-time {
    font-size: 0.78rem;
  }

  .two-col {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  input,
  select,
  textarea {
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .primary,
  .ghost,
  .danger {
    min-height: 2.75rem;
  }

  .entry-dialog {
    width: calc(100% - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 1rem;
    border-radius: 22px;
  }

  .share-dialog {
    width: calc(100% - 0.75rem);
    max-height: calc(100dvh - 0.75rem);
    border-radius: 20px;
  }

  .share-dialog-content {
    max-height: calc(100dvh - 0.75rem);
    padding: 0.85rem;
  }

  .share-dialog-heading .muted {
    font-size: 0.72rem;
  }

  .share-preview-wrap {
    max-height: 58dvh;
    padding: 0.35rem;
    border-radius: 12px;
  }

  .share-actions .primary,
  .share-actions .ghost {
    min-height: 2.9rem;
  }

  .dialog-actions {
    gap: 0.45rem;
  }

  .dialog-actions button {
    padding-right: 0.85rem;
    padding-left: 0.85rem;
  }

  .toast {
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    left: 0.75rem;
    max-width: none;
    text-align: center;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
  }

  .app-shell {
    padding-right: 0.25rem;
    padding-left: 0.25rem;
  }

  .calendar-panel {
    padding: 0.35rem;
    border-radius: 17px;
  }

  .calendar-toolbar {
    gap: 0.3rem;
  }

  .calendar-toolbar .ghost {
    font-size: 0.76rem;
  }

  .calendar-grid {
    gap: 0.14rem;
  }

  .day-cell {
    min-height: 68px;
    border-radius: 9px;
  }

  .day-number {
    font-size: 0.82rem;
  }

  .shift-pill {
    margin-top: 0.48rem;
    font-size: 0.55rem;
  }

  .shift-pill.shift-name-long {
    font-size: 0.5rem;
  }

  .shift-pill.shift-name-extra-long {
    font-size: 0.46rem;
  }
}
