:root {
  --bg: #f5f7f8;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-strong: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #18202a;
  --muted: #687482;
  --accent: #2e8c8c;
  --accent-2: #e15d3e;
  --accent-3: #b98222;
  --border: rgba(24, 32, 42, 0.12);
  --shadow: 0 12px 30px rgba(24, 32, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafb 0%, var(--bg) 100%);
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  opacity: 0.16;
  filter: blur(18px);
  animation: float 14s ease-in-out infinite;
}

.glow-1 {
  top: -100px;
  right: -80px;
  background: radial-gradient(circle, rgba(46, 140, 140, 0.45), transparent 70%);
}

.glow-2 {
  bottom: -140px;
  left: -100px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(24, 32, 42, 0.18), transparent 70%);
  animation-delay: -5s;
}

.glow-3 {
  top: 40%;
  left: 60%;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(225, 93, 62, 0.28), transparent 70%);
  animation-delay: -9s;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 32px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: 2rem;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
}

.login-card .btn {
  width: 100%;
}

.topbar {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  animation: rise 0.7s ease both;
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  margin: 6px 0 4px;
  font-size: 1.45rem;
  line-height: 1.2;
}

.tag {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(46, 140, 140, 0.15);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
  font-size: 0.92rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid rgba(28, 27, 31, 0.08);
}

.stat span {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.stat strong {
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink);
}

.layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.password-card {
  margin-top: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  animation: rise 0.7s ease both;
}

.form-card {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  min-width: 0;
  overflow-y: auto;
}

.list-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 292px);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.status {
  display: none;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.status.visible {
  display: block;
}

.status[data-state="success"] {
  background: rgba(46, 140, 140, 0.15);
  color: var(--accent);
}

.status[data-state="error"] {
  background: rgba(225, 93, 62, 0.14);
  color: #b44831;
}

.status[data-state="info"] {
  background: rgba(185, 130, 34, 0.14);
  color: #9a6b09;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.inline {
  justify-content: flex-end;
  padding-top: 22px;
}

.field label {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.88rem;
}

.field input,
.field select,
.field textarea {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 0.95rem;
  background: var(--surface-strong);
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(46, 140, 140, 0.5);
  box-shadow: 0 0 0 3px rgba(46, 140, 140, 0.16);
  transform: translateY(-1px);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.datetime-picker {
  display: grid;
  gap: 12px;
  position: relative;
}

.datetime-display {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 12px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.datetime-display:focus-visible {
  outline: none;
  border-color: rgba(46, 140, 140, 0.5);
  box-shadow: 0 0 0 3px rgba(46, 140, 140, 0.16);
}

.datetime-main {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(46, 140, 140, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.datetime-panel {
  border: 1px solid rgba(28, 27, 31, 0.12);
  border-radius: 16px;
  background: var(--surface-strong);
  padding: 14px;
  box-shadow: 0 16px 32px rgba(27, 31, 42, 0.12);
  display: grid;
  gap: 14px;
}

.datetime-section {
  display: grid;
  gap: 8px;
}

.panel-label {
  display: block;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.86rem;
}

.date-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.date-controls label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.date-controls label > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.date-controls select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 9px 10px;
  font-size: 0.92rem;
  background: var(--surface-strong);
}

.date-controls select:focus {
  outline: none;
  border-color: rgba(46, 140, 140, 0.5);
  box-shadow: 0 0 0 3px rgba(46, 140, 140, 0.16);
}

.time-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.time-column span {
  display: block;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.time-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.time-item {
  border: 1px solid transparent;
  background: rgba(46, 140, 140, 0.08);
  border-radius: 10px;
  padding: 6px 0;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.time-item:hover {
  border-color: rgba(46, 140, 140, 0.3);
  color: var(--accent);
}

.time-item.active {
  border-color: rgba(46, 140, 140, 0.5);
  background: rgba(46, 140, 140, 0.2);
  color: var(--accent);
}

.time-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.time-option {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 999px;
  padding: 8px 0;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease, color 0.2s ease;
}

.time-option:hover {
  transform: translateY(-1px);
  border-color: rgba(46, 140, 140, 0.35);
}

.time-option.active {
  color: var(--accent);
  border-color: rgba(46, 140, 140, 0.5);
  background: rgba(46, 140, 140, 0.12);
  box-shadow: 0 10px 18px rgba(46, 140, 140, 0.18);
}

.datetime-picker.custom .time-badge {
  color: #b44831;
  background: rgba(225, 93, 62, 0.14);
}

.ms-mobile-select {
  position: fixed;
  transform: none;
}

.ms-mobile-select .ms-gray-layer {
  background: rgba(24, 32, 42, 0.35);
  backdrop-filter: blur(2px);
}

.ms-mobile-select .ms-content {
  top: 50%;
  left: 50%;
  bottom: auto;
  width: min(560px, calc(100% - 32px));
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(24, 32, 42, 0.18);
  transform: translate(-50%, -50%);
}

.ms-mobile-select.ms-show .ms-content {
  bottom: auto;
}

.ms-mobile-select .ms-btn-bar {
  height: 48px;
  line-height: 48px;
  border-bottom: 1px solid rgba(24, 32, 42, 0.1);
}

.ms-mobile-select .ms-cancel,
.ms-mobile-select .ms-ensure {
  height: 48px;
  width: 72px;
  font-weight: 700;
}

.ms-mobile-select .ms-title {
  color: var(--ink);
  font-weight: 700;
}

.ms-mobile-select .ms-wheels,
.ms-mobile-select .ms-wheel,
.ms-mobile-select .ms-shadow-mask {
  height: 220px;
}

.ms-mobile-select .ms-select-line {
  top: 90px;
  border-color: rgba(46, 140, 140, 0.22);
  background: rgba(46, 140, 140, 0.06);
}

.ms-mobile-select .ms-select-container li {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
}

.check.compact {
  height: 40px;
  display: inline-flex;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.check input {
  width: 18px;
  height: 18px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 18px rgba(46, 140, 140, 0.22);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(46, 140, 140, 0.3);
}

.btn.ghost {
  background: rgba(46, 140, 140, 0.12);
  color: var(--accent);
  border: 1px solid rgba(46, 140, 140, 0.22);
}

.btn.ghost:hover {
  background: rgba(46, 140, 140, 0.2);
}

.btn.text {
  background: transparent;
  color: var(--ink);
}

.btn.text:hover {
  color: var(--accent-2);
}

.btn.danger {
  background: rgba(225, 93, 62, 0.12);
  color: #b44831;
  border: 1px solid rgba(225, 93, 62, 0.3);
}

.btn.danger:hover {
  background: rgba(225, 93, 62, 0.2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.filters {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filters .field {
  flex: 1 1 260px;
  min-width: 220px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--muted);
}

.switch input {
  display: none;
}

.switch .slider {
  position: relative;
  width: 46px;
  height: 26px;
  background: rgba(28, 27, 31, 0.15);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch .slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 4px 10px rgba(27, 31, 42, 0.2);
}

.switch input:checked + .slider {
  background: rgba(46, 140, 140, 0.5);
}

.switch input:checked + .slider::after {
  transform: translateX(18px);
}

.switch-text {
  white-space: nowrap;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.view-toggle-btn {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 7px 12px;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.view-toggle-btn.active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(24, 32, 42, 0.08);
}

.list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.list-scroll.card-view {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 10px;
  background: var(--surface-muted);
}

.list-scroll.card-view .card-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.reminder-table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  table-layout: fixed;
}

.reminder-table th:nth-child(1),
.reminder-table td:nth-child(1) {
  width: 18%;
}

.reminder-table th:nth-child(2),
.reminder-table td:nth-child(2) {
  width: 14%;
}

.reminder-table th:nth-child(3),
.reminder-table td:nth-child(3) {
  width: 9%;
}

.reminder-table th:nth-child(4),
.reminder-table td:nth-child(4) {
  width: 14%;
}

.reminder-table th:nth-child(5),
.reminder-table td:nth-child(5) {
  width: 11%;
}

.reminder-table th:nth-child(6),
.reminder-table td:nth-child(6) {
  width: 22%;
}

.reminder-table th:nth-child(7),
.reminder-table td:nth-child(7) {
  width: 12%;
}

.reminder-table th,
.reminder-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(24, 32, 42, 0.08);
  text-align: left;
  vertical-align: middle;
}

.reminder-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f9fa;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.reminder-table tbody tr {
  transition: background 0.16s ease;
}

.reminder-table tbody tr:hover {
  background: rgba(46, 140, 140, 0.06);
}

.reminder-table tbody tr.is-upcoming {
  background: rgba(225, 93, 62, 0.04);
}

.person-cell {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 3px;
}

.person-cell strong,
.table-subline,
.email-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-cell strong {
  display: block;
}

.table-subline {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.email-cell {
  display: block;
  max-width: 100%;
}

.countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(24, 32, 42, 0.06);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.countdown.soon {
  background: rgba(225, 93, 62, 0.13);
  color: #b44831;
}

.table-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

.table-actions .btn {
  padding: 7px 9px;
  font-size: 0.82rem;
}

.birthday-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid rgba(28, 27, 31, 0.08);
  box-shadow: 0 6px 16px rgba(27, 31, 42, 0.05);
  display: grid;
  gap: 10px;
}

.birthday-card.upcoming {
  border-color: rgba(225, 93, 62, 0.35);
  box-shadow: 0 8px 18px rgba(225, 93, 62, 0.12);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

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

.meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
  background: rgba(46, 140, 140, 0.12);
  color: var(--accent);
  white-space: nowrap;
}

.birthday-card.upcoming .chip {
  background: rgba(225, 93, 62, 0.14);
  color: #b44831;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  font-size: 0.88rem;
}

.card-grid > div {
  min-width: 0;
}

.card-grid span:not(.label) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-grid .label,
.card-message .label {
  display: block;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.card-message {
  font-size: 0.9rem;
  color: var(--muted);
}

.card-message p {
  margin: 4px 0 0;
  color: var(--ink);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions .btn {
  padding: 8px 12px;
  font-size: 0.86rem;
}

.empty {
  display: none;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.empty.show {
  display: block;
}

.footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(14px);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .form-card {
    position: static;
    max-height: none;
  }

  .list-card {
    min-height: auto;
  }

  .list-scroll {
    max-height: 62vh;
  }

  .topbar-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .topbar-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app {
    padding: 12px 12px 24px;
  }

  .topbar {
    padding: 14px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1 1 calc(50% - 8px);
    padding-inline: 10px;
  }

  .topbar-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    gap: 12px;
    margin-top: 12px;
  }

  .card {
    padding: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .list-scroll.card-view .card-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    align-items: stretch;
  }

  .filters .field,
  .view-toggle {
    width: 100%;
  }

  .view-toggle-btn {
    flex: 1 1 0;
  }

  .list-scroll {
    min-height: 320px;
    max-height: 58vh;
  }

  .reminder-table {
    min-width: 820px;
  }

  .reminder-table th,
  .reminder-table td {
    padding: 10px;
  }

  .time-columns {
    grid-template-columns: 1fr;
  }

  .ms-mobile-select .ms-content {
    left: 50%;
    width: min(100% - 24px, 420px);
    border-radius: 18px;
    transform: translate(-50%, -50%);
  }

  .ms-mobile-select.ms-show .ms-content {
    bottom: auto;
  }

  .footer {
    flex-direction: column;
    gap: 8px;
  }
}
