:root {
  --ink: #17211b;
  --muted: #66746d;
  --line: #dfe7e1;
  --paper: #fffdf7;
  --canvas: #f3efe5;
  --brand: #1c5c4f;
  --brand-2: #e6a93d;
  --danger: #ba3b2c;
  --success: #26764d;
  --shadow: 0 24px 70px rgba(32, 41, 35, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(230, 169, 61, 0.25), transparent 26rem),
    radial-gradient(circle at 90% 12%, rgba(28, 92, 79, 0.16), transparent 28rem),
    linear-gradient(135deg, #f8f5ec 0%, #eef3ec 48%, #f8f5ec 100%);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  min-height: 100vh;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: stretch;
}

.login-hero {
  padding: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.login-hero h1 {
  font-size: clamp(36px, 5.6vw, 68px);
  line-height: 1.06;
  margin: 18px 0;
  max-width: 900px;
}

.login-hero p {
  color: var(--muted);
  font-size: 18px;
  max-width: 680px;
  line-height: 1.8;
}

.login-card {
  align-self: center;
  justify-self: center;
  width: min(430px, calc(100vw - 48px));
  background: rgba(255, 253, 247, 0.9);
  border: 1px solid rgba(223, 231, 225, 0.9);
  border-radius: 30px;
  padding: 34px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

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

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.inline-field {
  margin-bottom: 0;
  min-width: 180px;
}

.field label {
  font-size: 14px;
  color: #435047;
}

.input,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffefb;
  min-height: 44px;
  padding: 10px 13px;
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(28, 92, 79, 0.1);
}

.btn {
  border: 0;
  border-radius: 14px;
  min-height: 42px;
  padding: 0 18px;
  background: #e7ebe6;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #23826b);
  box-shadow: 0 12px 26px rgba(28, 92, 79, 0.25);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
}

.btn.small {
  min-height: 34px;
  border-radius: 11px;
  padding: 0 12px;
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: rgba(23, 33, 27, 0.94);
  color: #eff5ef;
  overflow-y: auto;
}

.brand {
  padding: 12px 12px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
  display: block;
  font-size: 24px;
}

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

.nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav button {
  width: 100%;
  text-align: left;
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  padding: 26px;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  padding: 22px 10px 4px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--brand);
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 253, 247, 0.8);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
}

.content-card {
  background: rgba(255, 253, 247, 0.86);
  border: 1px solid rgba(223, 231, 225, 0.86);
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  background: rgba(255, 253, 247, 0.9);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 12px 35px rgba(32, 41, 35, 0.08);
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf0eb;
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}

th {
  color: #425047;
  background: #f5f5ef;
  font-weight: 700;
  position: sticky;
  top: 0;
}

td {
  color: #2d3831;
}

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

.report-sections {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.report-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.52);
  overflow: hidden;
}

.report-card header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.report-card h2 {
  margin: 0;
  font-size: 20px;
}

.report-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
  padding: 18px;
}

.template-card {
  display: grid;
  gap: 16px;
  align-content: space-between;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background:
    linear-gradient(140deg, rgba(255,255,255,0.72), rgba(255,253,247,0.52)),
    radial-gradient(circle at 90% 10%, rgba(230,169,61,0.18), transparent 45%);
}

.template-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

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

.template-meta,
.template-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.template-meta span {
  border-radius: 999px;
  background: rgba(28, 92, 79, 0.09);
  color: var(--brand);
  padding: 6px 10px;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 18, 14, 0.45);
  z-index: 20;
  padding: 20px;
}

.modal {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--paper);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.modal header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal h2 {
  margin: 0;
}

.form-grid {
  padding: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px 18px;
}

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

.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--ink);
  color: #fff;
  padding: 13px 16px;
  border-radius: 14px;
  z-index: 40;
  box-shadow: var(--shadow);
}

.error {
  color: var(--danger);
  margin-top: 12px;
}

.import-error {
  grid-column: 1 / -1;
  border: 1px solid rgba(176, 74, 58, 0.28);
  border-radius: 16px;
  background: rgba(176, 74, 58, 0.08);
  color: var(--danger);
  line-height: 1.7;
  padding: 12px 14px;
  white-space: pre-line;
}

.muted {
  color: var(--muted);
}

.profit {
  color: var(--success);
  font-weight: 700;
}

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

  .login-hero {
    padding: 36px 24px 12px;
  }

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

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

  .main {
    padding: 16px;
  }
}
