:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --ink: #1d2521;
  --muted: #67716c;
  --line: #dfe5dd;
  --green: #1f7a62;
  --green-dark: #155947;
  --teal: #2f8fa3;
  --gold: #c98b23;
  --red: #b54d4d;
  --blue: #3569a8;
  --shadow: 0 20px 50px rgba(26, 43, 36, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(47, 143, 163, 0.1), transparent 280px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 16px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

button:hover {
  border-color: #b7c6bf;
  transform: translateY(-1px);
}

button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

button.primary:hover {
  background: var(--green-dark);
}

button.ghost {
  background: transparent;
}

button.danger {
  color: var(--red);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 32px 28px 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.top-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid rgba(31, 122, 98, 0.25);
  border-radius: 8px;
  background: #eaf5ef;
  color: var(--green-dark);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.login-view {
  display: grid;
  min-height: calc(100vh - 112px);
  place-items: center;
  padding: 24px;
}

.login-view[hidden] {
  display: none;
}

.login-box {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 28px;
}

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

.login-box input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

.login-message {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(380px, 0.86fr) minmax(520px, 1.14fr);
  gap: 22px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 28px 36px;
}

.workspace,
.dashboard {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head.compact {
  align-items: center;
  padding: 14px 16px;
}

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.month-picker {
  display: grid;
  gap: 7px;
  min-width: 150px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.month-picker input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
}

textarea {
  display: block;
  width: calc(100% - 36px);
  min-height: 430px;
  margin: 18px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcf9;
  color: var(--ink);
  line-height: 1.7;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 98, 0.12);
}

.toolbar {
  padding: 0 18px 18px;
}

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

.metric {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.1;
}

.metric.total {
  border-color: rgba(31, 122, 98, 0.3);
  background: #eaf5ef;
}

.alerts {
  display: grid;
  gap: 8px;
}

.alert {
  border: 1px solid #ecd7ab;
  border-radius: 8px;
  background: #fff7e8;
  color: #745018;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.category-bars,
.daily-bars {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 88px minmax(120px, 1fr) 90px;
  align-items: center;
  gap: 12px;
  min-height: 32px;
  font-size: 13px;
}

.bar-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ed;
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--green);
}

.bar-value {
  color: var(--muted);
  text-align: right;
}

.daily-bars {
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  align-items: end;
  min-height: 190px;
}

.daily-column {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 0;
  min-height: 152px;
  align-content: end;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 4px;
  color: inherit;
}

.daily-column:hover {
  border-color: rgba(47, 143, 163, 0.28);
  background: #f1f8f6;
  transform: translateY(-2px);
}

.daily-column.active {
  border-color: var(--green);
  background: #e7f4ee;
  box-shadow: inset 0 0 0 1px rgba(31, 122, 98, 0.08);
}

.daily-column.active .daily-stick {
  background: var(--green-dark);
}

.daily-stick {
  width: 100%;
  min-height: 4px;
  max-width: 34px;
  border-radius: 7px 7px 3px 3px;
  background: var(--teal);
}

.daily-label,
.daily-amount {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.daily-amount {
  color: var(--ink);
  font-weight: 700;
}

.detail-clear[hidden] {
  display: none;
}

.table-wrap {
  overflow: auto;
  max-height: 410px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: 14px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.category-select {
  width: 120px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 9px;
}

.history-list {
  display: grid;
  gap: 8px;
  padding: 14px;
  max-height: 310px;
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  padding: 12px;
  cursor: pointer;
}

.history-item.active {
  border-color: var(--green);
  background: #edf7f1;
}

.history-item strong {
  display: block;
  font-size: 14px;
}

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

.empty {
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

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

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

@media (max-width: 680px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  h1 {
    font-size: 28px;
  }

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

  .bar-row {
    grid-template-columns: 72px minmax(80px, 1fr) 78px;
  }
}
