:root {
  --bg: #f6f7f9;
  --paper: #ffffff;
  --text: #171a1f;
  --muted: #68727d;
  --line: #e7ebf0;
  --soft: #f1f4f7;
  --blue: #0a7cff;
  --dark: #101827;
  --green: #138a4d;
  --red: #d70015;
  --orange: #b66a00;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0;
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.shell {
  display: flex;
  flex-direction: column;
  max-width: 520px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.desktop-sidebar {
  display: none;
}

.topbar {
  position: relative;
  top: 0;
  flex: 0 0 auto;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(231, 235, 240, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
}

.brand strong {
  display: block;
  font-size: 18px;
  font-weight: 620;
}

.brand span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

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

.icon-btn,
.primary-btn,
.soft-btn,
.plain-btn {
  border: 0;
  border-radius: 12px;
  min-height: 36px;
  padding: 8px 12px;
}

.icon-btn {
  width: 36px;
  padding: 0;
  background: var(--dark);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.primary-btn {
  background: var(--dark);
  color: #fff;
  font-weight: 580;
}

.soft-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #263241;
}

.plain-btn {
  background: transparent;
  color: #263241;
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 18px 96px;
}

.content::-webkit-scrollbar,
.sheet::-webkit-scrollbar,
.list-scroll::-webkit-scrollbar {
  width: 6px;
}

.content::-webkit-scrollbar-thumb,
.sheet::-webkit-scrollbar-thumb,
.list-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d5dbe3;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 650;
}

.page-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.quick-card,
.panel,
.editor-card,
.auth-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}

.quick-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.quick-card input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: none;
  padding: 0 10px;
  color: var(--text);
  font-size: 16px;
}

.quick-actions {
  display: flex;
  gap: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.home-board {
  display: block;
}

.finance-mini {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 16px;
}

.finance-mini .section-title {
  margin-top: 0;
}

.finance-mini dl {
  margin: 0;
}

.finance-mini div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 13px 0;
}

.finance-mini dt {
  color: var(--muted);
}

.finance-mini dd {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.metric {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 23px;
  font-weight: 650;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 8px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 620;
}

.section-title button {
  border: 0;
  background: transparent;
  color: #334155;
  padding: 6px 0;
}

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

.item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 14px 0;
  text-align: left;
}

.item-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--soft);
  color: #475569;
  font-size: 13px;
  font-weight: 650;
}

.item h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  line-height: 1.35;
}

.item p {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item small {
  display: block;
  margin-top: 6px;
  color: #7b8794;
}

.item-side {
  align-self: center;
  color: #526071;
  font-size: 13px;
  white-space: nowrap;
}

.empty {
  padding: 24px 0;
  color: var(--muted);
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(520px, 100%);
  transform: translateX(-50%);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid rgba(231, 235, 240, 0.9);
  backdrop-filter: blur(18px);
}

.new-menu {
  width: min(460px, calc(100% - 28px));
  border-radius: 24px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
}

.soft-modal {
  place-items: center;
}

.new-options {
  display: grid;
  gap: 10px;
}

.new-options button {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 14px;
  text-align: left;
}

.new-options button:active {
  transform: scale(0.99);
}

.new-options strong,
.new-options span {
  display: block;
}

.new-options strong {
  font-size: 16px;
  font-weight: 620;
}

.new-options span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.nav-item {
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #73808f;
  padding: 7px 4px;
  font-size: 11px;
}

.nav-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
  line-height: 1;
}

.nav-item.active {
  background: #f1f5f9;
  color: #111827;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: #f2f4f7;
  color: #596675;
  padding: 8px 12px;
}

.tabs button.active {
  background: var(--dark);
  color: #fff;
}

.editor-card {
  display: grid;
  gap: 13px;
  padding: 16px;
}

.editor-card input,
.editor-card textarea,
.editor-card select,
.auth-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  padding: 10px 12px;
  outline: none;
}

.editor-card textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.6;
}

.rich-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.rich-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f7f8fa;
  padding: 8px;
}

.rich-toolbar button {
  flex: 0 0 auto;
  min-width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  padding: 7px 10px;
}

.rich-toolbar button:hover,
.rich-toolbar button.active {
  background: #e8edf3;
  color: #111827;
}

.rich-editor {
  min-height: 230px;
  outline: none;
  padding: 16px;
  line-height: 1.75;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #98a2af;
}

.rich-view {
  max-width: 100%;
}

.rich-view ul,
.rich-view ol,
.rich-editor ul,
.rich-editor ol {
  padding-left: 1.4em;
}

.note-image {
  max-width: 100%;
  margin: 12px 0;
}

.note-image img,
.rich-view img,
.rich-editor img {
  display: block;
  max-width: min(100%, 420px);
  max-height: 280px;
  border-radius: 14px;
  object-fit: contain;
}

.note-image figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip {
  display: flex;
  gap: 7px;
  align-items: center;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 7px 9px;
  font-size: 12px;
}

.attachment-chip span,
.muted {
  color: var(--muted);
}

.attachment-chip strong {
  overflow: hidden;
  max-width: 180px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip button {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 0;
}

.detail-files {
  margin-top: 18px;
}

.check-editor {
  display: grid;
  gap: 10px;
}

.check-editor label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.check-editor input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--dark);
}

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

.editor-card > label,
.field-row label,
.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  background: rgba(15, 23, 42, 0.26);
}

.sheet {
  width: min(520px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  background: #fff;
  padding: 18px;
}

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

.sheet-head h2 {
  margin: 0;
  font-size: 22px;
}

.detail-body {
  color: #263241;
  line-height: 1.75;
  white-space: pre-wrap;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
}

.detail-meta span {
  border-radius: 999px;
  background: #f3f5f8;
  padding: 5px 9px;
  font-size: 12px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.check-line input {
  width: 16px;
  height: 16px;
  accent-color: var(--dark);
}

.check-line.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.auth-card {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: #f2f4f7;
}

.auth-tabs button {
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #64748b;
  padding: 9px;
}

.auth-tabs button.active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.account-card {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.account-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.sync-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #f2f4f7;
  color: #667085;
  padding: 6px 10px;
  font-size: 12px;
}

.sync-pill.on {
  background: #edf8f2;
  color: var(--green);
}

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

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

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

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

.warn {
  color: var(--orange);
}

@media (min-width: 720px) {
  .shell {
    max-width: 760px;
    height: 100dvh;
  }

  .content {
    padding: 30px 34px 106px;
  }

  .page-head h1 {
    font-size: 36px;
  }

  .summary-grid {
    gap: 14px;
  }

  .metric {
    min-height: 96px;
    padding: 18px;
  }
}

@media (min-width: 760px) {
  body {
    background: #f3f5f8;
  }

  .shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    max-width: none;
    height: 100dvh;
    margin: 0;
    background: transparent;
    box-shadow: none;
  }

  .desktop-sidebar {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    padding: 28px 20px;
    background: #0b0f16;
    color: #fff;
  }

  .desktop-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 2px 28px;
  }

  .desktop-brand img {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    background: #fff;
  }

  .desktop-brand strong {
    display: block;
    font-size: 22px;
    font-weight: 650;
  }

  .desktop-brand span {
    display: block;
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
  }

  .desktop-nav {
    display: grid;
    align-content: start;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 18px;
  }

  .desktop-nav button {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 58px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    padding: 8px 12px;
    text-align: left;
  }

  .desktop-nav button.active {
    background: #fff;
    color: #111827;
  }

  .desktop-nav span {
    text-align: center;
    font-size: 18px;
  }

  .desktop-nav strong,
  .desktop-nav em {
    display: block;
  }

  .desktop-nav strong {
    font-size: 15px;
    font-style: normal;
    font-weight: 620;
  }

  .desktop-nav em {
    margin-top: 2px;
    color: inherit;
    opacity: 0.7;
    font-size: 12px;
    font-style: normal;
  }

  .desktop-sidebar-foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 18px;
  }

  .desktop-sidebar-foot .soft-btn {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }

  .desktop-sidebar-foot .primary-btn {
    background: #fff;
    color: #111827;
  }

  .topbar,
  .bottom-nav {
    display: none;
  }

  .content {
    min-width: 0;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 42px 44px;
  }

  .page-head h1 {
    font-size: 42px;
  }

  .quick-card {
    max-width: 860px;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    max-width: 860px;
  }

  .home-board {
    display: block;
  }

  .home-side {
    display: grid;
    gap: 18px;
    margin-top: 18px;
  }

  .home-side > section {
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #fff;
    padding: 18px;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.045);
  }

  .home-side .section-title {
    margin-top: 0;
  }

  .home-side .item {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .home-side .item-side {
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
  }

  .list {
    background: #fff;
  }

  .item {
    min-height: 84px;
  }

  .modal {
    place-items: stretch end;
    background: rgba(15, 23, 42, 0.18);
  }

  .sheet {
    width: min(560px, calc(100vw - 248px));
    height: 100vh;
    max-height: 100vh;
    border-left: 1px solid var(--line);
    border-radius: 0;
    box-shadow: -18px 0 44px rgba(15, 23, 42, 0.08);
    padding: 28px;
  }
}

@media (min-width: 1100px) {
  .home-board {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 34px;
    align-items: start;
  }

  .home-side {
    position: sticky;
    top: 32px;
    margin-top: 0;
  }
}

@media (min-width: 1280px) {
  .shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .content {
    padding-left: 64px;
    padding-right: 64px;
  }

  .home-board {
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.55fr);
  }
}
