:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --ink: #12263f;
  --muted: #5d718d;
  --line: #d9e4f2;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --blue-soft: #e3edff;
  --amber: #f0a81e;
  --amber-deep: #c27900;
  --amber-soft: #fff3d6;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --shadow: 0 12px 28px rgba(15, 32, 61, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: #ffffff;
  background-image: linear-gradient(rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.78)), url("./images/beihang.png");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

button {
  font: inherit;
  color: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  max-width: 640px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 14px max(12px, env(safe-area-inset-bottom, 0px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 4px 12px rgba(0, 0, 0, 0.35);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-name {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-sub {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.time-band {
  margin: 10px 0 0;
  padding: 10px 14px 12px;
  text-align: center;
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.date-label {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--muted);
}

.clock {
  margin: 0;
  font-size: clamp(38px, 11vw, 54px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--blue-strong);
  font-variant-numeric: tabular-nums;
}

.day-status {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.balance-band {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface) 100%);
}

.balance-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber-deep) 0%, var(--amber) 100%);
  color: #2a1e04;
}

.balance-icon svg {
  width: 24px;
  height: 24px;
}

.balance-icon-text {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.balance-copy {
  flex: 1;
  min-width: 0;
}

.balance-label {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.balance-note {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.balance-value {
  margin: 0;
  font-size: clamp(24px, 7.5vw, 34px);
  font-weight: 800;
  line-height: 1;
  color: var(--amber-deep);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.tile {
  display: flex;
  flex-direction: column;
  min-height: 132px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}

.stats-tile .tile-icon {
  background: var(--amber-soft);
  color: var(--amber-deep);
}

.tile-icon-text {
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.stats-tile {
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
}

.tile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tile-header h2,
.dialog-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.tile-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.tile-icon--amber {
  background: var(--amber-soft);
  color: var(--amber-deep);
}

.tile-icon svg {
  width: 17px;
  height: 17px;
}

.stats-inner {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f8ff;
  text-align: center;
}

.mini-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.mini-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.mini-dot--amber {
  background: var(--amber);
}

.mini-dot--blue {
  background: var(--blue);
}

.mini-value {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.calendar-tile {
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.calendar-tile:hover {
  border-color: var(--blue);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.32);
}

.calendar-tile:active {
  transform: translateY(1px);
}

.calendar-tile-month {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.calendar-tile-summary {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--blue-strong);
  font-variant-numeric: tabular-nums;
}

.expand-chip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  margin-top: auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 700;
}

.expand-chip svg {
  width: 13px;
  height: 13px;
}

.checkin-band {
  position: relative;
  padding: 12px 0 2px;
  text-align: center;
}

.checkin-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: min(168px, 52vw);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #5ba3ff 0%, var(--blue) 48%, #1c5bb8 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(31, 111, 210, 0.42), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

.checkin-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 40px rgba(31, 111, 210, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.checkin-button:active {
  transform: translateY(1px);
}

.checkin-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.checkin-icon svg {
  width: 29px;
  height: 29px;
}

.checkin-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  padding: 0 10px;
}

.checkin-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.checkin-caption {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}

.checkin-button.is-checked {
  background: radial-gradient(circle at 32% 26%, #2a5fa8 0%, #16406f 55%, #0f3259 100%);
  color: #b9d8ff;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  cursor: default;
}

.checkin-button.is-checked:hover {
  transform: none;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.checkin-button.is-checked .checkin-icon {
  background: rgba(217, 236, 255, 0.22);
  color: #e5f1ff;
}

.checkin-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.cancel-button {
  position: absolute;
  right: 10px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 72px;
  min-height: 64px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  opacity: 0.45;
  cursor: not-allowed;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.cancel-button svg {
  width: 20px;
  height: 20px;
}

.cancel-button:not(:disabled) {
  opacity: 1;
  border-color: rgba(242, 104, 108, 0.55);
  background: linear-gradient(160deg, var(--red-soft) 0%, var(--surface) 100%);
  color: var(--red);
  cursor: pointer;
}

.cancel-button:not(:disabled):active {
  transform: translateY(1px);
}

.burst-flash {
  position: fixed;
  inset: 0;
  z-index: 24;
  pointer-events: none;
  background: radial-gradient(circle at var(--cx) var(--cy), rgba(255, 222, 120, 0.4) 0%, rgba(255, 222, 120, 0.1) 30%, transparent 65%);
  animation: burst-flash 0.6s ease-out forwards;
}

@keyframes burst-flash {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.burst-ring {
  position: fixed;
  z-index: 25;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border: 3px solid rgba(255, 214, 110, 0.95);
  border-radius: 50%;
  pointer-events: none;
  animation: burst-ring 0.7s ease-out forwards;
}

@keyframes burst-ring {
  0% {
    transform: scale(0.25);
    opacity: 1;
  }

  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

.burst-particle {
  position: fixed;
  z-index: 26;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  animation: burst-particle var(--dur, 0.85s) cubic-bezier(0.16, 0.84, 0.44, 1) forwards;
}

@keyframes burst-particle {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot, 0deg)) scale(0.15);
    opacity: 0;
  }
}

.checkin-button.is-punch {
  animation: checkin-punch 0.55s ease;
}

@keyframes checkin-punch {

  0%,
  100% {
    transform: scale(1);
  }

  30% {
    transform: scale(0.93);
  }

  65% {
    transform: scale(1.07);
  }
}

.balance-pop {
  animation: balance-pop 0.5s ease;
}

@keyframes balance-pop {

  0%,
  100% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.12);
  }
}

.checkin-time {
  width: fit-content;
  max-width: 100%;
  margin: 8px auto 0;
  text-align: center;
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.footer {
  margin-top: auto;
  padding: 8px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.settings-dialog,
.calendar-dialog {
  width: calc(100% - 32px);
  max-width: 440px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop,
.calendar-dialog::backdrop {
  background: rgba(2, 7, 18, 0.68);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 18px 6px;
}

.dialog-header h2 {
  font-size: 17px;
}

.dialog-body {
  padding: 0 18px 20px;
}

.dialog-body--calendar {
  padding-top: 6px;
}

.field-label {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.segment-option {
  position: relative;
}

.segment-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.segment-option span {
  display: block;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.segment-option input:checked+span {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-weight: 700;
}

.dialog-actions {
  display: grid;
  gap: 9px;
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.action-button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.action-button svg {
  width: 19px;
  height: 19px;
}

.action-button--danger {
  color: var(--red);
}

.action-button--danger:hover {
  border-color: var(--red);
  background: var(--red-soft);
}

.dialog-note {
  margin: 13px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.month-title {
  min-width: 92px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nav-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.nav-button:hover {
  border-color: var(--blue);
  color: var(--blue-strong);
}

.nav-button svg {
  width: 17px;
  height: 17px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 5px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.day-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  aspect-ratio: 0.9;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
}

.day-cell.is-blank {
  border: 0;
}

.day-cell.is-muted {
  color: #5f7396;
}

.day-cell.is-checked {
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-weight: 700;
}

.day-cell.is-today {
  border-color: var(--amber-deep);
  box-shadow: inset 0 0 0 1px var(--amber-deep);
}

.day-num {
  font-size: 13px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.day-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.day-cell.is-checked .day-dot {
  background: var(--blue);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 13px 0 0;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot--checked {
  background: var(--blue);
}

.legend-dot--today {
  border: 2px solid var(--amber-deep);
  background: var(--amber-soft);
  width: 10px;
  height: 10px;
}

.legend-dot--plain {
  border: 1px solid #3a557f;
  background: transparent;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  max-width: calc(100% - 40px);
  padding: 9px 15px;
  border-radius: 999px;
  background: #12263f;
  color: #ffffff;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 640px) {
  .clock {
    font-size: 58px;
  }

  .checkin-button {
    width: 190px;
  }

  .tile {
    min-height: 142px;
  }

  .calendar-grid {
    gap: 8px;
  }

  .day-cell {
    aspect-ratio: 1;
  }
}

@media (max-height: 620px) and (min-width: 700px) {
  .app-shell {
    justify-content: center;
  }

  .time-band {
    padding: 4px 14px 6px;
  }

  .clock {
    font-size: 40px;
  }

  .tile {
    min-height: 112px;
  }

  .checkin-button {
    width: 148px;
  }

  .checkin-band {
    padding: 8px 0 0;
  }

  .footer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  .checkin-button,
  .calendar-tile,
  .toast {
    transition: none;
  }
}
