:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --panel: #ffffff;
  --panel-soft: #f9faf9;
  --ink: #16181d;
  --muted: #717984;
  --line: #e5e8eb;
  --accent: #2477f2;
  --accent-strong: #0f62da;
  --ok: #1c9d61;
  --danger: #dc2d2d;
  --shadow: 0 18px 42px rgba(28, 35, 45, .12);
  --card-shadow: 0 2px 7px rgba(28, 35, 45, .11), 0 1px 0 rgba(28, 35, 45, .04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #e9ecef;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(245, 246, 247, .92)),
    var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.phone-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

.screen {
  min-height: 100vh;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

.home-screen {
  padding-bottom: calc(116px + env(safe-area-inset-bottom));
}

.hidden {
  display: none !important;
}

.home-header,
.editor-header,
.section-title,
.time-card-head,
.segment-topline,
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-header {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0;
}

.add-shift-button {
  width: min(calc(100% - 32px), 428px);
  min-height: 72px;
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 9;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 24px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateX(-50%);
}

.add-shift-button span {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .14);
  position: relative;
}

.add-shift-button span::before,
.add-shift-button span::after,
.header-plus::before,
.header-plus::after {
  content: "";
  width: 18px;
  height: 2px;
  position: absolute;
  inset: 50% auto auto 50%;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.add-shift-button span::after,
.header-plus::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.add-shift-button strong {
  font-size: 19px;
  line-height: 1.1;
}

.list-section {
  margin-top: 22px;
}

.section-title {
  margin-bottom: 12px;
}

.section-title.compact {
  margin-bottom: 8px;
}

.link-button,
.text-button {
  min-height: 40px;
  padding: 8px 4px;
  background: transparent;
  color: var(--accent);
  font-weight: 750;
}

.muted-danger {
  color: var(--danger);
  visibility: hidden;
}

.muted-danger.is-visible {
  visibility: visible;
}

.shift-list {
  max-height: calc(100vh - 235px - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -6px;
  padding: 2px 6px 14px;
  display: grid;
  gap: 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.shift-list::-webkit-scrollbar {
  display: none;
}

.month-group {
  display: grid;
  gap: 8px;
}

.month-toggle {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 2px 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.month-toggle span {
  display: grid;
  gap: 2px;
}

.month-toggle strong {
  font-size: 16px;
}

.month-toggle small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.month-toggle i {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
  position: relative;
  box-shadow: inset 0 0 0 1px var(--line);
}

.month-toggle i::before {
  content: "";
  width: 9px;
  height: 9px;
  position: absolute;
  left: 50%;
  top: 47%;
  border-right: 2px solid #6f7782;
  border-bottom: 2px solid #6f7782;
  transform: translate(-50%, -50%) rotate(45deg);
}

.month-group.is-collapsed .month-toggle i::before {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.month-shifts {
  display: grid;
  gap: 10px;
}

.empty-state,
.shift-card,
.time-card,
.segments-card,
.date-field {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.shift-card {
  width: 100%;
  display: grid;
  gap: 12px;
  padding: 16px;
  color: inherit;
  text-align: left;
  box-shadow: 0 2px 5px rgba(28, 35, 45, .15), 0 1px 0 rgba(28, 35, 45, .05);
}

.shift-card:active,
.primary-button:active {
  transform: scale(.99);
}

.add-shift-button:active {
  transform: translateX(-50%) scale(.99);
}

.shift-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.shift-card-date {
  display: grid;
  gap: 2px;
}

.shift-card-date strong {
  font-size: 17px;
}

.shift-card-time {
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  white-space: nowrap;
}

.shift-card-segments {
  display: grid;
  gap: 7px;
}

.shift-segment-line {
  display: flex;
  gap: 14px;
  align-items: start;
  color: #313741;
  font-size: 15px;
  line-height: 1.25;
}

.shift-segment-line time {
  width: 94px;
  flex: 0 0 94px;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 10px;
  background: #f0f3f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.shift-segment-line > span {
  min-width: 0;
  padding-top: 2px;
}

.activity-kind {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
}

.activity-kind.tone-green {
  color: #168653;
}

.activity-kind.tone-black {
  color: var(--ink);
}

.shift-segment-line small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.editor-screen {
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, #11141a 0, #171b22 94px, rgba(23, 27, 34, .62) 112px, rgba(23, 27, 34, 0) 130px),
    var(--bg);
}

.editor-header {
  min-height: 54px;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: #fff;
}

.editor-header > div {
  min-width: 0;
  text-align: center;
}

.editor-header .muted-danger {
  justify-self: end;
}

.editor-header .eyebrow {
  color: rgba(255, 255, 255, .68);
}

.editor-header .muted-danger {
  color: #ffb6b6;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  position: relative;
}

.icon-button::before,
.icon-button::after,
.segment-remove::before,
.segment-remove::after {
  content: "";
  width: 16px;
  height: 2px;
  position: absolute;
  inset: 50% auto auto 50%;
  border-radius: 2px;
  background: currentColor;
}

.icon-button {
  color: #fff;
}

.segment-remove {
  color: #3c424a;
}

.icon-button::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.icon-button::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

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

.date-field {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 1fr 48px;
  grid-template-rows: auto auto;
  gap: 3px 12px;
  align-items: center;
  padding: 14px 12px 14px 16px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.date-icon {
  width: 48px;
  height: 48px;
  grid-row: 1 / 3;
  grid-column: 2;
  padding: 11px;
  border-radius: 16px;
  background: #eef5ff;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  box-shadow:
    inset 0 0 0 1px rgba(36, 119, 242, .18),
    0 8px 18px rgba(36, 119, 242, .12);
}

.date-field span,
.search-field span,
.comment-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.date-field strong {
  min-width: 0;
  font-size: 20px;
  font-weight: 850;
  line-height: 1.15;
}

.search-field input,
.comment-field textarea {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.time-card,
.segments-card {
  padding: 14px;
}

.time-card-head {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.time-display {
  min-height: 78px;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-soft);
  color: inherit;
  text-align: left;
  box-shadow: var(--card-shadow);
}

.time-display small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.time-display strong {
  font-size: 27px;
  line-height: 1;
}

.timeline {
  display: grid;
  gap: 10px;
}

.segment-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
}

.segment-rail {
  width: 2px;
  min-height: 112px;
  margin: 15px auto 0;
  border-radius: 2px;
  background: #d4d9df;
  position: relative;
}

.segment-rail::before,
.segment-rail::after {
  content: "";
  width: 10px;
  height: 10px;
  position: absolute;
  left: 50%;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  transform: translateX(-50%);
}

.segment-rail::before {
  top: 0;
}

.segment-rail::after {
  bottom: 0;
}

.segment-main {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(229, 232, 235, .86);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.segment-time {
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.segment-remove {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  position: relative;
}

.segment-remove::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.segment-remove::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.work-button,
.activity-choice,
.order-option {
  width: 100%;
  min-height: 56px;
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-align: left;
}

.work-button {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  box-shadow: var(--card-shadow);
}

.work-button span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.work-button span:empty {
  display: none;
}

.work-button strong {
  font-size: 17px;
  font-weight: 900;
}

.work-button small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
}

.work-button small:empty {
  display: none;
}

.work-button.is-empty {
  min-height: 58px;
  place-items: center;
  border: 0;
  background: var(--ink);
  color: #fff;
  text-align: center;
  box-shadow: 0 12px 24px rgba(22, 24, 29, .16);
}

.work-button.is-empty strong {
  color: #fff;
}

.comment-toggle {
  justify-self: start;
  min-height: 36px;
  padding: 4px 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 750;
}

.comment-field {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.comment-field textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.35;
}

.form-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.save-bar {
  width: min(100%, 460px);
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 8;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(245, 246, 247, 0), rgba(245, 246, 247, .96) 24%);
  transform: translateX(-50%);
}

.primary-button {
  width: 100%;
  min-height: 58px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(36, 119, 242, .22);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 31, .32);
}

.sheet-panel {
  width: min(100%, 460px);
  max-height: calc(88vh - env(safe-area-inset-top));
  position: absolute;
  left: 50%;
  bottom: 0;
  display: grid;
  gap: 14px;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--panel);
  box-shadow: 0 -24px 54px rgba(28, 35, 45, .18);
  transform: translateX(-50%);
  animation: sheetIn .18s ease-out;
}

@keyframes sheetIn {
  from {
    transform: translate(-50%, 20px);
    opacity: .6;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  justify-self: center;
  border-radius: 999px;
  background: #d8dde3;
}

.sheet-header h2 {
  font-size: 20px;
}

.time-sheet-panel {
  overflow: hidden;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.time-sheet-panel .sheet-header {
  margin-bottom: 4px;
}

.wheel-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 244px;
  position: relative;
  overflow: hidden;
}

.wheel-picker::before {
  content: "";
  height: 48px;
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 0;
  border-radius: 16px;
  background: #f0f3f6;
  transform: translateY(-50%);
  pointer-events: none;
}

.wheel-picker::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    180deg,
    #fff 0,
    rgba(255, 255, 255, .86) 15%,
    rgba(255, 255, 255, 0) 38%,
    rgba(255, 255, 255, 0) 62%,
    rgba(255, 255, 255, .86) 85%,
    #fff 100%
  );
  pointer-events: none;
}

.wheel-column {
  height: 244px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
  padding: 98px 0;
  z-index: 1;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.wheel-column::-webkit-scrollbar {
  display: none;
}

.wheel-item {
  width: 100%;
  height: 48px;
  display: grid;
  place-items: center;
  scroll-snap-align: center;
  border-radius: 16px;
  border: 0;
  background: transparent;
  color: #8a929c;
  font-size: 25px;
  font-weight: 850;
  appearance: none;
}

.wheel-item.selected {
  color: var(--ink);
  font-size: 30px;
}

.activity-panel {
  max-height: min(86vh, 720px);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
}

.activity-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 16px;
  background: #f0f2f4;
}

.tab {
  min-height: 42px;
  border-radius: 12px;
  background: transparent;
  color: #606873;
  font-size: 13px;
  font-weight: 800;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(25, 31, 40, .08);
}

.order-picker,
.activity-choice-list {
  min-height: 260px;
  max-height: calc(86vh - 190px);
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  margin: 0 -8px;
  padding: 4px 8px 18px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.order-picker::-webkit-scrollbar,
.activity-choice-list::-webkit-scrollbar {
  display: none;
}

.order-picker {
  gap: 12px;
}

.installation-orders,
.installation-other-form {
  display: grid;
  gap: 12px;
}

.other-jump {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
  text-align: center;
  box-shadow: 0 10px 20px rgba(22, 24, 29, .14);
  margin-bottom: 4px;
}

.comment-field.standalone {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: var(--panel-soft);
}

.comment-field.standalone textarea {
  min-height: 116px;
}

.sheet-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
}

.primary-choice {
  min-height: 56px;
  place-items: center;
  border: 0;
  background: var(--ink);
  color: #fff;
  text-align: center;
  box-shadow: 0 12px 24px rgba(22, 24, 29, .16);
}

.primary-choice strong {
  justify-self: center;
}

.date-panel {
  overflow: hidden;
  border-radius: 28px 28px 0 0;
}

.calendar-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.calendar-head strong {
  text-align: center;
  font-size: 18px;
  font-weight: 850;
}

.calendar-nav {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: #eef5ff;
  position: relative;
}

.calendar-nav::before {
  content: "";
  width: 10px;
  height: 10px;
  position: absolute;
  left: 18px;
  top: 17px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
}

.calendar-nav.next::before {
  left: 15px;
  transform: rotate(225deg);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-weekdays span:nth-last-child(-n + 2) {
  color: #d15a5a;
}

.calendar-day,
.calendar-empty {
  aspect-ratio: 1;
  min-width: 0;
}

.calendar-day {
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 15px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 850;
}

.calendar-day.is-weekend {
  background: #fff1f1;
  color: #c94343;
}

.calendar-day.has-shift {
  background: #e8edf3;
  color: #15181d;
  box-shadow: inset 0 0 0 1px rgba(22, 24, 29, .05);
}

.calendar-day.has-shift::after {
  content: "";
  width: 5px;
  height: 5px;
  position: absolute;
  left: 50%;
  bottom: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .62;
  transform: translateX(-50%);
}

.calendar-day.has-shift.is-weekend {
  background: #f3e4e6;
  color: #b5333d;
}

.calendar-day.is-selected {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(36, 119, 242, .26);
}

.calendar-day.is-selected::after {
  background: #fff;
  opacity: .85;
}

.recent-block {
  display: grid;
  gap: 8px;
}

.recent-block:empty {
  display: none;
}

.recent-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.recent-pill {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--accent-strong);
  font-weight: 800;
}

.search-field {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-soft);
  box-shadow: var(--card-shadow);
}

.search-field input {
  min-height: 36px;
  font-size: 17px;
}

.order-list,
.activity-choice-list {
  display: grid;
  gap: 14px;
}

.order-list {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.order-option,
.activity-choice {
  display: grid;
  gap: 3px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
}

.activity-choice.primary-choice {
  min-height: 56px;
  place-items: center;
  border: 0;
  background: var(--accent);
  color: #fff;
  text-align: center;
  box-shadow: 0 12px 24px rgba(36, 119, 242, .24);
}

.activity-choice.primary-choice:disabled {
  cursor: default;
  background: #d8dde3;
  color: #7b8490;
  box-shadow: none;
}

.order-option small,
.activity-choice small {
  color: var(--muted);
  font-size: 13px;
}

.gap-warning {
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff7e8;
  color: #9a5b00;
  font-size: 13px;
  font-weight: 750;
}

@media (min-width: 680px) {
  body {
    padding: 28px 0;
  }

  .phone-shell {
    min-height: calc(100vh - 56px);
    border-radius: 34px;
    box-shadow: var(--shadow);
  }

  .screen {
    min-height: calc(100vh - 56px);
  }
}

@media (max-width: 380px) {
  .screen {
    padding-left: 12px;
    padding-right: 12px;
  }

  .time-display strong {
    font-size: 24px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
