:root {
  --bg: #f5f1e8;
  --ink: #1d2522;
  --muted: #6e7169;
  --line: #c7c2b4;
  --panel: #fffaf0;
  --panel-strong: #f0e0c2;
  --green: #227861;
  --green-dark: #0f4f42;
  --red: #b94343;
  --blue: #2c6d9d;
  --shadow: 0 18px 50px rgba(45, 35, 20, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(29, 37, 34, 0.045) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(29, 37, 34, 0.04) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 6vw, 42px);
  line-height: 1;
}

h2 {
  font-size: 22px;
}

.status-pill {
  min-width: 112px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fffdf7;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.status-pill.ready {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.auth-panel,
.workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 22px;
}

.panel-head {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.panel-head p {
  color: var(--muted);
}

.auth-form {
  display: flex;
  gap: 10px;
}

.auth-form input {
  flex: 1;
}

.auth-form button,
.month-tools button,
.primary-btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 6px;
  color: #fff;
  background: var(--green-dark);
  font-weight: 800;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 46px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active {
  color: var(--ink);
  background: var(--panel-strong);
}

.tab-panel {
  display: none;
  padding: 14px;
}

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

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

.date-row,
.field-grid {
  display: grid;
  gap: 10px;
}

.date-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(110px, 0.6fr);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fffdf7;
  outline: 0;
}

input {
  height: 46px;
  padding: 0 12px;
}

textarea {
  padding: 11px 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 120, 97, 0.15);
}

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

.computed-strip div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9efd9;
}

.computed-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.computed-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

.computed-strip strong.negative {
  color: var(--red);
}

.computed-strip strong.positive {
  color: var(--green-dark);
}

.primary-btn {
  width: 100%;
}

.month-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.month-tools input {
  max-width: 220px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.ledger-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}

.ledger-table th,
.ledger-table td {
  height: 38px;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.ledger-table th:first-child,
.ledger-table td:first-child {
  text-align: left;
}

.ledger-table th {
  color: var(--ink);
  background: var(--panel-strong);
  font-weight: 900;
}

.ledger-table td.negative {
  color: var(--red);
  font-weight: 800;
}

.ledger-table td.positive {
  color: var(--green-dark);
  font-weight: 800;
}

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

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  overflow: hidden;
}

.record-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: #f9efd9;
}

.record-card h3 {
  margin: 0;
  font-size: 16px;
}

.record-card .profit {
  font-size: 18px;
  font-weight: 900;
}

.record-card .profit.negative {
  color: var(--red);
}

.record-card .profit.positive {
  color: var(--green-dark);
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.record-grid div {
  min-height: 54px;
  padding: 9px;
  background: #fffdf7;
}

.record-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.record-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.record-note {
  padding: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 18px;
  left: 14px;
  z-index: 5;
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 800;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (min-width: 760px) {
  .shell {
    padding-top: 28px;
  }

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

  .record-form {
    max-width: 860px;
  }

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

  .toast {
    left: auto;
  }
}

@media (max-width: 430px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
  }

  .auth-form {
    flex-direction: column;
  }

  .date-row,
  .computed-strip {
    grid-template-columns: 1fr;
  }
}
