:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --ink: #1f2d27;
  --muted: #6b7a73;
  --line: #dfe8e3;
  --brand: #1f8a5b;
  --brand-dark: #146c46;
  --brand-soft: #e8f5ee;
  --warn: #b7791f;
  --warn-soft: #fff7e6;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --shadow: 0 8px 24px rgba(31, 61, 48, 0.07);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 800;
  font-size: 19px;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.topnav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}
.topnav a {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}
.topnav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.topnav a:hover { text-decoration: none; color: var(--brand-dark); }

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.sidebar,
.sidebar-overlay { display: none; }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.sidebar-close {
  border: 0;
  background: #f1f5f2;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 14px;
}
.sidebar-nav a {
  display: block;
  padding: 13px 12px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}
.sidebar-nav a:hover { text-decoration: none; background: #f5f8f6; }
.sidebar-nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; }
.sidebar-logout { margin-top: auto; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h1 { font-size: 24px; margin: 0 0 2px; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card-sub { color: var(--muted); font-size: 13px; }

.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.stat-value.green { color: var(--brand); }
.stat-value.orange { color: var(--warn); }
.stat-value.blue { color: var(--blue); }

.room-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.room-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.room-title { font-size: 18px; font-weight: 800; }
.room-tenant { color: var(--muted); font-size: 14px; }
.room-money { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.room-money strong { color: var(--ink); font-size: 17px; }
.room-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: var(--brand-soft); color: var(--brand-dark); }
.badge-orange { background: var(--warn-soft); color: var(--warn); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: #f0f3f1; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f5f8f6; color: var(--ink); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0c8c3; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 7px 10px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 18px; font-size: 17px; border-radius: 12px; }

.empty {
  text-align: center;
  padding: 34px 18px;
  color: var(--muted);
}
.empty .big { font-size: 34px; margin-bottom: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 10px 11px;
  font-size: 16px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid #b8dfca;
  border-color: var(--brand);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .readonly {
  background: #f1f5f2;
  color: var(--muted);
  padding: 10px 11px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 16px;
}

.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.summary-box {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.summary-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; }
.summary-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.flash-success { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #bfe5d0; }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f1c7c2; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.list-row:hover { background: #fbfdfc; }
.list-main { min-width: 0; }
.list-title { font-weight: 700; margin-bottom: 2px; }
.list-sub { color: var(--muted); font-size: 13px; }
.list-amount { font-weight: 800; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }

.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.detail-item .k { color: var(--muted); font-size: 12px; }
.detail-item .v { font-size: 15px; font-weight: 600; }

.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-actions .btn { padding: 14px 10px; font-size: 16px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #e8f5ee 0%, #f4f7f5 55%, #eef3ff 100%);
}
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: 0 20px 50px rgba(31, 61, 48, 0.12); }
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.tip { font-size: 13px; color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .topnav { display: none; }
  .topbar-logout { display: none; }
  .menu-btn { display: inline-flex; }
  .brand { font-size: 18px; }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 84vw);
    padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.18);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    z-index: 60;
    overflow-y: auto;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open { overflow: hidden; }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 55;
  }
  body.sidebar-open .sidebar-overlay { opacity: 1; visibility: visible; }

  .container { padding: 14px 10px 40px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 21px; }
  .stat-value { font-size: 22px; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .card { padding: 13px; border-radius: 14px; }
  .list-row { padding: 11px; }
  .hide-mobile { display: none; }
}

@media (min-width: 900px) {
  .container { padding-top: 24px; }
}
