:root {
  --green: #0fbf6c;
  --green-dark: #0a9c57;
  --green-soft: rgba(15, 191, 108, 0.12);
  --bg: #f3f6f5;
  --card: #ffffff;
  --text: #1c2a24;
  --muted: #7b8894;
  --line: #e9eef0;
  --amber: #f5a524;
  --red: #e5484d;
  --blue: #3d8bff;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(22, 45, 34, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: var(--green-dark);
  text-decoration: none;
}

/* ---------------- 登录页 ---------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 15% 20%, #d9f7e8 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, #dcefff 0%, transparent 45%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 880px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--card);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(16, 48, 32, 0.12);
}

.login-visual {
  padding: 48px 40px;
  color: #eafff5;
  background: linear-gradient(150deg, #0c3a26 0%, #0f7a49 60%, #12b96a 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.login-logo span {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.login-headline {
  font-size: 30px;
  line-height: 1.4;
  font-weight: 700;
  margin: 32px 0 12px;
}

.login-sub {
  color: rgba(234, 255, 245, 0.75);
  line-height: 1.8;
  font-size: 13px;
}

.login-points {
  display: grid;
  gap: 10px;
  margin-top: 28px;
  font-size: 13px;
  color: rgba(234, 255, 245, 0.85);
}

.login-points div::before {
  content: "✓";
  margin-right: 8px;
  color: #5ef2a5;
}

.login-form {
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-form p {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfcfc;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 191, 108, 0.12);
  background: #fff;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  background: #eef2f1;
  color: var(--text);
  transition: transform 0.15s, opacity 0.15s, background 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

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

.btn-primary {
  background: linear-gradient(135deg, #14cb74, #0aa85e);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(15, 191, 108, 0.28);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

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

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

.btn-block {
  width: 100%;
  padding: 13px;
  font-size: 15px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 8px;
}

.login-hint {
  margin-top: 22px;
  padding: 12px 14px;
  background: #f5faf7;
  border: 1px dashed #cfe8dc;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.login-register {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.login-register a {
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: none;
}

.register-card {
  grid-template-columns: 1fr;
  max-width: 560px;
}

.register-card .login-form {
  justify-content: flex-start;
  padding: 36px;
  max-height: 90vh;
  overflow-y: auto;
}

.agreement-box {
  max-height: 190px;
  overflow-y: auto;
  background: #f7f9f8;
  border: 1px solid #e3ebe6;
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.85;
  color: #5a6b62;
  white-space: pre-wrap;
}

.agreement-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #33453c;
  margin: 12px 0 18px;
  line-height: 1.6;
}

.agreement-check input {
  margin-top: 3px;
}

/* ---------------- 后台布局 ---------------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 228px;
  flex: 0 0 228px;
  background: linear-gradient(180deg, #0c3524 0%, #0a2a1c 100%);
  color: #cfe7db;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #29e696, #0cab5f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-text strong {
  font-size: 16px;
  color: #fff;
}

.brand-text span {
  font-size: 11px;
  color: rgba(207, 231, 219, 0.6);
  letter-spacing: 1px;
}

.nav {
  flex: 1;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-group {
  font-size: 11px;
  color: rgba(207, 231, 219, 0.45);
  padding: 14px 10px 6px;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  white-space: nowrap;
  border-radius: 10px;
  color: rgba(235, 250, 243, 0.78);
  font-size: 14px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  position: relative;
  transition: background 0.2s, color 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(46, 224, 140, 0.16);
  color: #fff;
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 2px;
  background: #2ee08c;
}

.nav-icon {
  width: 18px;
  display: inline-flex;
  justify-content: center;
  font-size: 15px;
}

.nav-badge {
  margin-left: auto;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  border-radius: 9px;
  padding: 1px 6px;
  font-weight: 600;
}

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-foot .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #eafff5;
  overflow: hidden;
  white-space: nowrap;
}

.avatar-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(46, 224, 140, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #bfffe0;
  flex: 0 0 28px;
}

.logout {
  border: none;
  background: transparent;
  color: rgba(207, 231, 219, 0.6);
  font-size: 12px;
  padding: 4px;
}

.logout:hover {
  color: #ff9b9b;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 40px;
}

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

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.topbar .sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

/* ---------------- 卡片 / 指标 ---------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card {
  margin-top: 18px;
}

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

.card-head h3 {
  margin: 0;
  font-size: 15px;
}

.card-head .muted {
  font-size: 12px;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

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

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: 0.5px;
}

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

.stat-card.highlight {
  background: linear-gradient(135deg, #0fbf6c, #0a9c57);
  color: #fff;
}

.stat-card.highlight .label,
.stat-card.highlight .foot {
  color: rgba(255, 255, 255, 0.8);
}

.stat-card .stat-icon {
  position: absolute;
  right: 14px;
  top: 14px;
  font-size: 20px;
  opacity: 0.85;
}

.two-col {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

/* 允许网格子项收缩，避免表格最小宽度把页面撑出横向滚动条 */
.two-col > * {
  min-width: 0;
}

.card,
.stat-grid > * {
  min-width: 0;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 6px;
  background: #eef3f1;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #2ee08c, #0fbf6c);
  transition: width 0.4s ease;
}

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

.trend {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 140px;
  padding-top: 8px;
}

.trend-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.trend-bar {
  width: 60%;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2ee08c, #0fbf6c);
}

.trend-item span {
  font-size: 11px;
  color: var(--muted);
}

/* ---------------- 表格 ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar input,
.toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  background: #fbfcfc;
  outline: none;
  font-family: inherit;
}

.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--green);
}

.toolbar .spacer {
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  background: #fafbfb;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fafcfb;
}

td.actions {
  white-space: nowrap;
}

td.actions .btn + .btn {
  margin-left: 6px;
}

.house-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.house-cell img {
  width: 54px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef2f0;
  flex: 0 0 54px;
}

.house-cell .info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.house-cell .info strong {
  font-size: 13px;
  font-weight: 600;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.house-cell .info span {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: #f0f3f2;
  color: var(--muted);
  white-space: nowrap;
}

.badge.on,
.badge.done,
.badge.active,
.badge.paid,
.badge.signed {
  background: var(--green-soft);
  color: var(--green-dark);
}

.badge.off,
.badge.cancelled,
.badge.disabled {
  background: #f4f5f6;
  color: #9aa3ab;
}

.badge.pending,
.badge.unpaid {
  background: rgba(245, 165, 36, 0.14);
  color: #c07a05;
}

.badge.confirmed,
.badge.contacted {
  background: rgba(61, 139, 255, 0.14);
  color: #2a6fd6;
}

.badge.online,
.badge.won,
.badge.settled {
  background: var(--green-soft);
  color: var(--green-dark);
}

.badge.sold,
.badge.partial {
  background: rgba(61, 139, 255, 0.14);
  color: #2a6fd6;
}

.badge.paused,
.badge.expired {
  background: #f4f5f6;
  color: #9aa3ab;
}

.badge.rejected {
  background: #fdecec;
  color: #c0392b;
}

.who-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
}

.who-meta em {
  font-style: normal;
  font-size: 11px;
  color: rgba(207, 231, 219, 0.62);
}

.price {
  color: #c0503a;
  font-weight: 600;
}

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

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

.empty .big {
  font-size: 30px;
  display: block;
  margin-bottom: 8px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------- 弹窗 / 提示 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(12, 26, 20, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 50;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 720px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(10, 30, 20, 0.25);
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--muted);
}

.modal-body {
  padding: 20px 22px;
  max-height: 64vh;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.form-grid .field {
  margin-bottom: 0;
}

.form-grid textarea {
  min-height: 78px;
  resize: vertical;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 20px);
  background: rgba(20, 38, 30, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: rgba(200, 50, 55, 0.95);
}

.loading-block {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

/* ---------------- 响应式 ---------------- */

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

@media (max-width: 860px) {
  .login-card {
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  /* 窄屏保持左侧竖向导航，避免导航文字被挤成竖排 */
  .sidebar {
    width: 196px;
    flex: 0 0 196px;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 16px 10px;
  }

  .brand {
    padding: 0 6px 14px;
  }

  .brand-text span {
    display: none;
  }

  .nav {
    margin-top: 12px;
  }

  .nav-group {
    display: none;
  }

  .nav-item {
    font-size: 13px;
    padding: 9px 10px;
  }

  .main {
    padding: 16px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

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

  .form-grid .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 560px) {
  .sidebar {
    width: 168px;
    flex: 0 0 168px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .brand-text strong {
    font-size: 14px;
  }

  .nav-item {
    font-size: 12px;
    gap: 7px;
    padding: 8px;
  }

  .sidebar-foot .who {
    display: none;
  }

  .main {
    padding: 12px;
  }
}

/* 详情弹窗 */
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line, #e8ecef);
  font-size: 13px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row span {
  color: #8a9199;
  flex-shrink: 0;
}

.detail-row strong {
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.detail-block {
  margin-top: 12px;
}

.detail-block > span {
  display: block;
  margin-bottom: 6px;
  color: #8a9199;
  font-size: 12px;
}

.detail-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.detail-pre {
  white-space: pre-wrap;
}

.detail-img {
  width: 108px;
  height: 108px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 8px 8px 0;
  background: #f3f5f6;
}
