:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #dde3ee;
  --primary: #146c5f;
  --primary-dark: #0d4d44;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #16743c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
code { background: #eef2f6; padding: 2px 5px; border-radius: 4px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #182432;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
}
.brand { font-size: 19px; font-weight: 700; margin: 4px 8px 22px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a {
  color: #d8e1ec;
  border-radius: 6px;
  padding: 10px 12px;
}
.sidebar a.active, .sidebar a:hover { background: #26384a; color: #fff; }
.userbox {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.16);
}
.userbox span { color: #aebccc; font-size: 12px; }

.main {
  margin-left: 220px;
  padding: 24px;
}
.login-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 14px; }

.login-card, .panel, .stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23,32,51,.05);
}
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card h1 { margin-bottom: 22px; }
.panel { padding: 18px; overflow-x: auto; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  align-items: start;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stats article { padding: 18px; display: grid; gap: 8px; }
.stats span, .muted, small { color: var(--muted); }
.stats strong { font-size: 24px; }

form { margin: 0; }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: #344054; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd7e3;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 82px; resize: vertical; }
textarea[name="payment_schedule"] {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button, .primary {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:hover, .primary:hover { background: var(--primary-dark); color: #fff; }
button.text {
  background: transparent;
  color: var(--primary);
  min-height: 0;
  padding: 0;
  font-weight: 600;
}
button.text:hover { background: transparent; color: var(--primary-dark); }
button.danger { color: var(--danger); }
.small { min-height: 30px; padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.actions, .bill-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-edit {
  display: grid;
  grid-template-columns: 92px 128px 90px 82px minmax(120px, 1fr) auto;
  gap: 7px;
  min-width: 650px;
}
.inline-edit input, .inline-edit select { min-height: 32px; padding: 5px 7px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-paid, .status-active, .status-rented { background: #e7f7ed; color: var(--ok); }
.status-overdue, .status-terminated { background: #ffe8e5; color: var(--danger); }
.status-unpaid, .status-pending { background: #fff4df; color: var(--warn); }
.status-managed, .status-partial { background: #e8f0ff; color: #2456a6; }

.flash {
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #b7e4c7;
  background: #ecfdf3;
  color: #0f5132;
}
.flash.danger {
  border-color: #f3b5ae;
  background: #fff1f0;
  color: var(--danger);
}
.empty { color: var(--muted); text-align: center; padding: 24px; }
.list { display: grid; gap: 10px; }
.notice {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.notice.unread { border-color: #9fd3ca; background: #f3fbf9; }
.notice p { margin: 8px 0; color: #344054; line-height: 1.6; }

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }
  .main { margin-left: 0; padding: 16px; }
  .grid.two, .stats { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
