:root {
  --bg: #fff6f3;
  --ink: #53414d;
  --muted: #8f7f8b;
  --line: rgba(164, 122, 136, 0.14);
  --panel: rgba(255, 251, 250, 0.9);
  --field: rgba(255, 255, 255, 0.96);
  --primary: #f08ba8;
  --primary-soft: #ffe8ef;
  --primary-hover: #ea789a;
  --cyan: #78d3c4;
  --orange: #f7ab72;
  --green: #8acb88;
  --purple: #b592e3;
  --shadow: 0 20px 48px rgba(189, 129, 151, 0.18);
  --soft-shadow: 0 12px 28px rgba(189, 129, 151, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  background: transparent;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body.locked {
  overflow: hidden;
}

body.locked .visual-layer {
  display: none;
}

body.locked .shell,
body.locked .toast {
  filter: blur(22px);
  opacity: 0.18;
  pointer-events: none;
  user-select: none;
}

body.auth-pending .shell,
body.auth-pending .toast {
  visibility: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: -2;
  background:
    url("/assets/harbor-background.jpg") center top / cover no-repeat,
    var(--bg);
  filter: brightness(0.82) saturate(0.9) contrast(0.98);
}

body::after {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(255, 246, 243, 0.82), rgba(255, 241, 244, 0.56) 48%, rgba(255, 249, 244, 0.84)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 236, 241, 0.78));
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
  position: relative;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 216, 227, 0.4), transparent 32%),
    linear-gradient(180deg, rgba(89, 67, 82, 0.64), rgba(89, 67, 82, 0.56)),
    rgba(100, 73, 89, 0.48);
  backdrop-filter: blur(16px);
}

.auth-card {
  width: min(420px, 100%);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  padding: 30px 28px;
  background:
    radial-gradient(circle at top right, rgba(255, 228, 237, 0.9), transparent 28%),
    linear-gradient(180deg, rgba(255, 253, 252, 0.98), rgba(255, 246, 245, 0.94));
  box-shadow: var(--shadow);
}

.auth-card::before,
.auth-card::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.auth-card::before {
  top: -28px;
  right: -12px;
  width: 110px;
  height: 110px;
  background: rgba(255, 217, 229, 0.52);
}

.auth-card::after {
  left: -18px;
  bottom: -22px;
  width: 88px;
  height: 88px;
  background: rgba(120, 211, 196, 0.22);
}

.auth-card h2 {
  position: relative;
  z-index: 1;
  font-size: 31px;
  line-height: 1.18;
  margin-bottom: 10px;
  color: #6d5161;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 232, 239, 0.92);
  color: #d76d8f;
}

.auth-copy {
  position: relative;
  z-index: 1;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

.auth-loading {
  margin-bottom: 18px;
  color: #806879;
  font-size: 14px;
  font-weight: 700;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.auth-error {
  margin-top: 12px;
  color: #cf4f36;
  font-size: 14px;
  font-weight: 700;
}

.visual-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.photo-float,
.motion-ticket {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.2);
}

.photo-float {
  width: 88px;
  height: 88px;
  object-fit: cover;
  opacity: 0.72;
  animation: float-card 11s ease-in-out infinite;
}

.photo-one {
  top: 112px;
  right: max(28px, calc((100vw - 1180px) / 2 - 92px));
  object-position: 62% 52%;
  transform: rotate(4deg);
}

.photo-two {
  display: none;
  top: 54%;
  left: max(18px, calc((100vw - 1180px) / 2 - 76px));
  object-position: 20% 38%;
  animation-delay: -2.2s;
  transform: rotate(-5deg);
}

.photo-three {
  display: none;
  right: max(20px, calc((100vw - 1180px) / 2 - 40px));
  bottom: 108px;
  object-position: 84% 58%;
  animation-delay: -4.4s;
  transform: rotate(-3deg);
}

.motion-ticket {
  display: grid;
  place-items: center;
  height: 34px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
  animation: float-ticket 10s ease-in-out infinite;
}

.ticket-one {
  top: 246px;
  right: max(150px, calc((100vw - 1180px) / 2 + 40px));
}

.ticket-two {
  left: max(38px, calc((100vw - 1180px) / 2 - 30px));
  bottom: 216px;
  color: var(--orange);
  animation-delay: -2.8s;
}

@keyframes float-card {
  0%,
  100% {
    translate: 0 0;
  }

  50% {
    translate: 0 -14px;
  }
}

@keyframes float-ticket {
  0%,
  100% {
    translate: 0 0;
  }

  50% {
    translate: 10px -10px;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 26px;
  padding: 24px 26px;
  background:
    radial-gradient(circle at top right, rgba(255, 222, 232, 0.7), transparent 24%),
    linear-gradient(135deg, rgba(255, 254, 253, 0.96), rgba(255, 244, 246, 0.88)),
    rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: #d76d8f;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  color: #644b59;
}

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

.status-pill {
  min-width: 86px;
  border: 1px solid rgba(240, 139, 168, 0.24);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 240, 245, 0.92);
  color: #d7678b;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 1fr;
  gap: 14px;
}

.tab-section {
  margin-bottom: 16px;
}

.tab-section-head {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.tab-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(240, 139, 168, 0.16);
  border-radius: 999px;
  background: rgba(255, 240, 245, 0.84);
}

.tab-button {
  height: 40px;
  min-width: 92px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: transparent;
  color: #7d6a76;
  font-weight: 800;
  box-shadow: none;
}

.tab-button:hover,
.tab-button.active {
  background: linear-gradient(135deg, var(--primary), #f4a9bf);
  color: #fff;
  box-shadow: 0 8px 18px rgba(240, 139, 168, 0.28);
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  content-visibility: auto;
  contain-intrinsic-size: 320px;
}

.metric {
  min-height: 118px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.metric::after {
  content: "";
  position: absolute;
  right: -26px;
  bottom: -28px;
  width: 86px;
  height: 86px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.22);
  rotate: 15deg;
}

.metric:hover,
.panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.metric strong {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
}

.metric.primary {
  background: linear-gradient(135deg, #f397b2, #f5b8a5);
  color: #fff;
}

.metric.primary span {
  color: rgba(255, 255, 255, 0.72);
}

.metric.peach {
  border-color: rgba(247, 171, 114, 0.2);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 244, 235, 0.92));
}

.metric.mint {
  border-color: rgba(120, 211, 196, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(237, 251, 248, 0.92));
}

.metric.sky {
  border-color: rgba(181, 146, 227, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 239, 255, 0.92));
}

.workspace,
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ledger-workspace {
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  align-items: start;
  margin-bottom: 20px;
}

.form-stage {
  min-width: 0;
}

.ledger-panel {
  min-width: 0;
}

.ledger-panel-head {
  align-items: flex-start;
}

.ledger-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 180px) auto auto;
  align-items: end;
  justify-content: end;
  gap: 10px;
}

.month-filter {
  gap: 6px;
  min-width: 0;
}

.month-filter input {
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.list-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(28, 45, 70, 0.08);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.82);
  color: #314155;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.insight-stack {
  display: grid;
  gap: 16px;
  padding-top: 8px;
}

.insight-intro {
  padding: 0 4px;
}

.insight-intro h2 {
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.15;
  color: #172033;
}

.form-stage .panel,
.ledger-workspace > .panel {
  margin-bottom: 0;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.panel {
  margin-bottom: 16px;
  padding: 22px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(28, 45, 70, 0.08);
}

.panel-head h2 {
  position: relative;
  padding-left: 12px;
}

.panel-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--primary), #f5b8a5);
}

.panel-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  white-space: normal;
}

.month-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.month-controls input {
  width: 170px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.mini-metric {
  min-height: 92px;
  border: 1px solid rgba(240, 139, 168, 0.12);
  border-radius: 20px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 245, 247, 0.92));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mini-metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mini-metric strong {
  font-size: 24px;
  line-height: 1.1;
}

form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

form .panel-head,
form label:last-of-type,
.form-actions {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid rgba(190, 149, 164, 0.18);
  border-radius: 16px;
  padding: 0 12px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(240, 139, 168, 0.14);
}

button {
  height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--primary), #f5b8a5);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(240, 139, 168, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(240, 139, 168, 0.28);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.ghost {
  height: 36px;
  border: 1px solid rgba(240, 139, 168, 0.18);
  background: rgba(255, 250, 251, 0.9);
  color: #816d79;
  box-shadow: none;
}

.ghost:hover,
.ghost.active {
  border-color: rgba(240, 139, 168, 0.34);
  background: var(--primary-soft);
  color: #d7678b;
}

.hidden {
  display: none;
}

.category-list,
.list {
  display: grid;
  gap: 10px;
}

.category-row {
  display: grid;
  grid-template-columns: 76px 1fr 92px;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(240, 139, 168, 0.1);
  overflow: hidden;
}

.bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #f5b8a5);
}

.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.record {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  border: 1px solid rgba(190, 149, 164, 0.12);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.84);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.record:hover {
  border-color: rgba(240, 139, 168, 0.2);
  background: rgba(255, 252, 252, 0.96);
  transform: translateX(2px);
}

.record.archived {
  background: rgba(252, 245, 247, 0.88);
  opacity: 0.86;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--primary-soft);
  color: #d7678b;
  font-size: 12px;
  font-weight: 850;
}

.record .date {
  color: var(--muted);
  font-size: 13px;
}

.record .title {
  font-weight: 850;
  margin-bottom: 4px;
}

.record .sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.amount {
  min-width: 112px;
  text-align: right;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.amount.income {
  color: #5fa974;
}

.amount.expense {
  color: #de7e68;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.small-action {
  height: 32px;
  min-width: 52px;
  padding: 0 10px;
  border: 1px solid rgba(22, 119, 255, 0.12);
  background: rgba(255, 255, 255, 0.84);
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.small-action:hover {
  border-color: rgba(22, 119, 255, 0.32);
  background: var(--primary-soft);
  color: #1668dc;
}

.amount-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.empty {
  border: 1px dashed rgba(22, 119, 255, 0.22);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.66);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #1677ff, #13c2c2);
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1080px) {
  .ledger-workspace {
    grid-template-columns: 1fr;
  }

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

  .ledger-toolbar {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

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

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

  .list-counter {
    justify-content: flex-start;
    width: fit-content;
  }
}

@media (max-width: 900px) {
  .workspace,
  .detail-grid,
  .month-grid {
    grid-template-columns: 1fr;
  }

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

  .photo-float,
  .motion-ticket {
    display: none;
  }

  .panel {
    padding: 18px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .panel-head,
  .tab-section-head,
  .ledger-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .tab-switch {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .ledger-toolbar {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .list-counter {
    width: 100%;
  }

  .toolbar-actions > * {
    flex: 1 1 auto;
  }

  .summary-grid,
  .month-grid {
    grid-template-columns: 1fr;
  }

  body::before {
    background-position: center top;
  }

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

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

  .amount-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .amount {
    text-align: left;
  }

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

  .metric {
    min-height: 104px;
  }
}

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