:root {
  --bg: #f6f8ff;
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #172033;
  --muted: #71809a;
  --line: #e8edf8;
  --blue: #6c8cff;
  --green: #38c984;
  --red: #ff6b76;
  --yellow: #ffd166;
  --pink: #ff9ecb;
  --shadow: 0 18px 45px rgba(96, 116, 160, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 214, 102, 0.36), transparent 27%),
    radial-gradient(circle at 88% 12%, rgba(255, 158, 203, 0.32), transparent 25%),
    linear-gradient(135deg, #f8fbff 0%, #eef4ff 52%, #fff7fb 100%);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  text-align: center;
}

.login-mark {
  position: relative;
  width: 112px;
  height: 92px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.brand-badge {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: white;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(145deg, var(--blue), var(--pink));
  box-shadow: 0 15px 30px rgba(108, 140, 255, 0.28);
}

.spark {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.72);
}

.spark-one {
  width: 18px;
  height: 18px;
  top: 8px;
  right: 12px;
}

.spark-two {
  width: 12px;
  height: 12px;
  left: 10px;
  bottom: 12px;
  background: rgba(255, 158, 203, 0.72);
}

.login-card h1 {
  margin: 22px 0 8px;
  font-size: 28px;
}

.login-card label {
  text-align: left;
}

.login-card p,
.login-tip,
.panel small,
.metric-card small,
.eyebrow {
  color: var(--muted);
}

.stack-form,
.record-form {
  display: grid;
  gap: 16px;
}

.stack-form {
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #42506a;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: 0;
  padding: 13px 14px;
  transition: border 0.2s, box-shadow 0.2s, transform 0.2s;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(108, 140, 255, 0.14);
}

.primary-btn,
.ghost-btn,
.nav-item,
.period-btn,
.side-footer button,
.icon-btn {
  border: 0;
  border-radius: 16px;
}

.primary-btn {
  padding: 14px 18px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, #6c8cff, #8f7bff);
  box-shadow: 0 14px 26px rgba(108, 140, 255, 0.24);
}

.ghost-btn {
  padding: 10px 14px;
  color: #50607a;
  background: #f2f5ff;
  font-weight: 800;
}

.login-tip {
  margin-top: 18px;
  font-size: 13px;
}

.form-error {
  padding: 11px 13px;
  border: 1px solid #ffd1d7;
  border-radius: 14px;
  color: #b6404f;
  background: #fff0f3;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid rgba(232, 237, 248, 0.9);
  backdrop-filter: blur(18px);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.side-brand span {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: white;
  font-weight: 900;
  background: linear-gradient(145deg, var(--blue), var(--green));
}

.side-brand strong,
.side-brand small {
  display: block;
}

.side-brand small {
  color: var(--muted);
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.nav-item {
  text-align: left;
  padding: 14px 16px;
  color: #53627a;
  background: transparent;
  font-weight: 900;
}

.nav-item.active {
  color: white;
  background: linear-gradient(135deg, var(--blue), #88a0ff);
  box-shadow: 0 14px 24px rgba(108, 140, 255, 0.2);
}

.side-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: #f5f7ff;
  color: #52627d;
  font-weight: 800;
}

.side-footer button {
  padding: 8px 10px;
  color: #687690;
  background: white;
}

.workspace {
  padding: 26px;
}

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

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: 30px;
}

.period-switch {
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 25px rgba(98, 118, 158, 0.1);
}

.period-btn {
  min-width: 58px;
  padding: 10px 12px;
  color: #52617b;
  background: transparent;
  font-weight: 900;
}

.period-btn.active {
  color: white;
  background: var(--blue);
}

.page-section {
  display: grid;
  gap: 16px;
}

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

.metric-card,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
}

.metric-card:after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border-radius: 999px;
  opacity: 0.18;
}

.metric-card span {
  display: block;
  color: #6c7890;
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin: 16px 0 8px;
  font-size: 28px;
}

.metric-card.income strong {
  color: var(--green);
}

.metric-card.expense strong {
  color: var(--red);
}

.metric-card.balance strong {
  color: var(--blue);
}

.metric-card.income:after {
  background: var(--green);
}

.metric-card.expense:after {
  background: var(--red);
}

.metric-card.balance:after {
  background: var(--blue);
}

.metric-card.records:after {
  background: var(--yellow);
}

.dashboard-grid,
.analytics-grid,
.records-layout,
.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

.wrap-head {
  align-items: flex-start;
  flex-wrap: wrap;
}

.panel h3 {
  margin: 0;
  font-size: 18px;
}

canvas {
  width: 100%;
  height: 320px;
  max-height: 390px;
}

.table-wrap {
  overflow: auto;
}

.table-wrap.tall {
  max-height: 560px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: #7b89a2;
  font-size: 13px;
}

td.amount-income {
  color: var(--green);
  font-weight: 900;
}

td.amount-expense {
  color: var(--red);
  font-weight: 900;
}

.record-form {
  margin-top: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: #f2f5ff;
}

.segmented label {
  display: block;
  padding: 12px;
  border-radius: 14px;
  text-align: center;
  color: #687690;
}

.segmented input {
  display: none;
}

.segmented label.active {
  color: white;
  background: var(--blue);
}

.rank-list,
.user-list {
  display: grid;
  gap: 12px;
}

.rank-item,
.user-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}

.rank-item strong,
.user-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #eef2fb;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--pink));
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  padding: 14px 18px;
  border-radius: 18px;
  color: white;
  background: #172033;
  box-shadow: 0 18px 40px rgba(23, 32, 51, 0.25);
}

.icon-btn {
  padding: 8px 10px;
  color: #a84b58;
  background: #fff0f3;
  font-weight: 900;
}

.danger-btn {
  border: 0;
  border-radius: 16px;
  padding: 10px 14px;
  color: #b6404f;
  background: #fff0f3;
  font-weight: 900;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 430px);
}

.search-row input {
  min-width: 260px;
}

.readonly-panel {
  opacity: 0.72;
}

.readonly-panel button,
.readonly-panel input,
.readonly-panel select,
.readonly-panel textarea {
  cursor: not-allowed;
}

.user-actions {
  flex-wrap: wrap;
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.user-actions button {
  min-height: 40px;
}

.reset-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.active-soft {
  color: white;
  background: var(--blue);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 51, 0.34);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(390px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 60px rgba(23, 32, 51, 0.28);
}

.modal-card h3 {
  margin: 0 0 8px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(4, 1fr);
  }

  .dashboard-grid,
  .analytics-grid,
  .records-layout,
  .account-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

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

  .period-switch,
  .nav-list,
  .search-row {
    width: 100%;
    overflow-x: auto;
  }

  .search-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-row input {
    min-width: 0;
  }

  .nav-list {
    display: flex;
  }

  .nav-item {
    min-width: 82px;
    text-align: center;
  }

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

  .user-actions button {
    width: 100%;
  }

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

  .period-btn {
    min-width: 54px;
  }

  .topbar h2 {
    font-size: 24px;
  }
}
