:root {
  color-scheme: light;
  --bg: #eef4f2;
  --surface: #ffffff;
  --surface-soft: #f7fbf9;
  --ink: #10201d;
  --muted: #64736f;
  --line: #dce8e4;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #dff5ef;
  --accent: #2563eb;
  --danger: #dc2626;
  --warning: #b45309;
  --success: #15803d;
  --shadow: 0 18px 50px rgba(20, 48, 43, .11);
  --radius: 8px;
  --sidebar: 280px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 8%, rgba(15, 118, 110, .08), transparent 30%),
    linear-gradient(135deg, #eef4f2 0%, #f8fbfa 55%, #edf5f2 100%);
  color: var(--ink);
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(15, 118, 110, .14), transparent 32%),
    linear-gradient(135deg, #eaf4f1, #f9fbfa);
}

.lock-card {
  width: min(430px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 14px;
}

.lock-card h1, .lock-card p {
  margin: 0;
}

.lock-card p, .lock-card small {
  color: var(--muted);
  line-height: 1.55;
}

.lock-card .brand-mark {
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.lock-card form {
  display: grid;
  gap: 12px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--brand), #0b4f4a);
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(15, 118, 110, .24);
}

.brand strong, .brand span {
  display: block;
}

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

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #43524e;
  padding: 12px;
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
}

.nav-item span {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #edf4f2;
  color: var(--brand);
  font-weight: 800;
}

.nav-item i {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e6f3ef;
  color: var(--brand-dark);
  font-style: normal;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.main {
  min-width: 0;
  padding: 22px clamp(16px, 3vw, 34px) 40px;
}

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

.topbar h1, .section-intro h2, .panel h2, .hero-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}

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

.primary-button, .secondary-button, .small-button, .text-button, .link-button, .icon-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 40px;
}

.primary-button {
  background: var(--brand);
  color: white;
  padding: 0 16px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 118, 110, .2);
}

.secondary-button {
  background: white;
  color: var(--brand-dark);
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 750;
}

.small-button {
  background: #eaf4f1;
  color: var(--brand-dark);
  padding: 0 12px;
  font-weight: 750;
  min-height: 34px;
}

.text-button, .link-button {
  background: transparent;
  color: var(--brand-dark);
  font-weight: 800;
  padding: 0;
  min-height: 30px;
}

.icon-button {
  width: 42px;
  background: white;
  border: 1px solid var(--line);
}

.mobile-menu {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel, .panel, .metric, .section-intro {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(220, 232, 228, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel {
  min-height: 190px;
  padding: clamp(22px, 4vw, 38px);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .92), rgba(17, 94, 89, .84)),
    linear-gradient(45deg, #11433f, #18877d);
  color: white;
}

.hero-panel .eyebrow, .hero-panel p {
  color: rgba(255, 255, 255, .78);
}

.hero-panel h2 {
  max-width: 720px;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.08;
}

.hero-panel p {
  max-width: 650px;
  margin: 12px 0 0;
}

.hero-panel .primary-button {
  background: white;
  color: var(--brand-dark);
  box-shadow: none;
  flex: 0 0 auto;
}

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

.metric {
  padding: 18px;
  text-align: left;
}

.metric span, .metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 30px;
  margin: 8px 0 4px;
  color: var(--ink);
}

.compact {
  margin-top: 0;
}

.filter-card {
  border: 1px solid var(--line);
}

.filter-card.active {
  outline: 2px solid rgba(15, 118, 110, .24);
  background: var(--brand-soft);
}

.dashboard-grid, .money-grid, .self-grid, .sync-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 16px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.wide {
  grid-column: 1 / -1;
}

.panel-heading, .section-intro {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.section-intro {
  padding: 20px;
  margin-bottom: 16px;
}

.section-intro p {
  color: var(--muted);
  margin: 6px 0 0;
}

.stack-list, .record-list, .warning-list {
  display: grid;
  gap: 10px;
}

.record-card, .action-card, .warning-card, .empty-state {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: var(--radius);
  padding: 14px;
}

.record-card {
  display: grid;
  gap: 9px;
}

.record-top, .action-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  border-radius: 999px;
  background: #e6f3ef;
  color: var(--brand-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
}

.badge.money { background: #fff7ed; color: var(--warning); }
.badge.work { background: #eff6ff; color: #1d4ed8; }
.badge.risk { background: #fef2f2; color: var(--danger); }
.badge.done { background: #ecfdf5; color: var(--success); }

.record-card h3, .action-card h3 {
  margin: 0;
  font-size: 17px;
}

.record-card p, .action-card p, .empty-state, .side-note {
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
}

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

.card-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--radius);
  color: var(--brand-dark);
  font-weight: 750;
}

.warning-card {
  border-color: #fed7aa;
  background: #fffaf3;
}

.money-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.flow-strip button {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  text-align: left;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.flow-strip strong {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.flow-strip span {
  color: #314743;
  font-weight: 800;
  line-height: 1.25;
}

.money-strip div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.money-strip span, .money-strip strong {
  display: block;
}

.money-strip span {
  color: var(--muted);
}

.money-strip strong {
  font-size: 22px;
  margin-top: 6px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.inbox-meaning {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.inbox-meaning article, .template-hint {
  border: 1px solid #bfe4dc;
  background: #effaf7;
  border-radius: var(--radius);
  padding: 14px;
}

.inbox-meaning strong, .inbox-meaning span {
  display: block;
}

.inbox-meaning strong {
  margin-bottom: 5px;
}

.inbox-meaning span, .template-hint {
  color: #41615a;
  line-height: 1.55;
}

.template-hint {
  font-weight: 750;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  background: white;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  font-weight: 750;
}

.segmented button.active {
  background: var(--brand);
  color: white;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.review-main h2 {
  font-size: clamp(24px, 4vw, 38px);
  margin-bottom: 16px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-soft);
}

.review-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: #263936;
  font-weight: 750;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  outline-color: rgba(15, 118, 110, .32);
}

textarea {
  resize: vertical;
}

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

.review-side dl {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.review-side dl div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.goal-ring {
  width: 180px;
  height: 180px;
  margin: 14px auto;
  border-radius: 50%;
  background: conic-gradient(var(--brand) var(--goal, 0%), #e8f0ed 0);
  display: grid;
  place-items: center;
}

.goal-ring div {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  align-content: center;
}

.goal-ring strong, .goal-ring span {
  display: block;
}

.goal-ring strong {
  font-size: 32px;
}

.goal-ring span, .goal-meta {
  color: var(--muted);
}

.goal-meta {
  display: flex;
  justify-content: space-between;
}

.sync-meta {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.sync-meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.sync-meta span {
  color: var(--muted);
}

.sync-meta strong {
  text-align: right;
  font-size: 13px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-form textarea {
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

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

.sync-note-list {
  display: grid;
  gap: 12px;
}

.sync-note-list article {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.sync-note-list span {
  color: var(--muted);
  line-height: 1.7;
}

.work-stages {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.work-stages article {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.work-stages span {
  color: var(--brand);
  font-weight: 900;
}

.work-stages strong, .work-stages small {
  display: block;
}

.work-stages small {
  color: var(--muted);
  margin-top: 4px;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(7, 19, 17, .45);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(680px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .25);
  padding: 20px;
}

.small-modal {
  width: min(460px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal form {
  display: grid;
  gap: 13px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #10201d;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  z-index: 100;
  box-shadow: var(--shadow);
}

@media (max-width: 1040px) {
  .metric-grid, .money-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid, .money-grid, .self-grid, .sync-grid, .review-layout {
    grid-template-columns: 1fr;
  }

  .work-stages {
    grid-template-columns: repeat(3, 1fr);
  }

  .flow-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 14px 12px 92px;
  }

  .mobile-menu {
    display: inline-grid;
    place-items: center;
  }

  .topbar {
    align-items: start;
  }

  .top-actions {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 20;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px;
    backdrop-filter: blur(16px);
  }

  .top-actions button {
    flex: 1;
  }

  .hero-panel {
    display: grid;
    min-height: 240px;
    align-items: end;
  }

  .hero-panel h2 {
    font-size: 32px;
  }

  .metric-grid, .money-strip, .form-grid, .rule-grid {
    grid-template-columns: 1fr;
  }

  .inbox-meaning {
    grid-template-columns: 1fr;
  }

  .section-intro, .panel-heading {
    display: grid;
  }

  .work-stages {
    grid-template-columns: 1fr 1fr;
  }

  .flow-strip {
    grid-template-columns: 1fr 1fr;
  }
}
