:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel2: #1e2430;
  --line: #2a3140;
  --text: #e8ecf2;
  --muted: #8b95a8;
  --accent: #3d9cfd;
  --good: #3dd68c;
  --warn: #e6b84d;
  --bad: #ff6b7a;
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; }

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 400px at 20% -10%, rgba(61,156,253,.18), transparent 60%),
    radial-gradient(700px 360px at 90% 10%, rgba(61,214,140,.08), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(400px, 92vw);
  background: linear-gradient(180deg, #1b2130, #141822);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.brand { font-size: 28px; font-weight: 700; letter-spacing: .04em; }
.login-card label { display:block; margin: 14px 0 6px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  background: #0e121a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  background: var(--panel2);
}
.btn.primary { background: linear-gradient(180deg, #4aa6ff, #2f7fd6); color: #fff; width: 100%; margin-top: 16px; }
.btn.good { background: #1f6b4a; }
.btn.warn { background: #6b531f; }
.btn.bad { background: #6b2a33; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

#main-view { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side {
  background: #12161f;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-brand { font-weight: 700; font-size: 18px; padding: 8px 10px 16px; }
.side button.nav {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.side button.nav.active, .side button.nav:hover {
  background: var(--panel2);
  color: var(--text);
}
.side-foot { margin-top: auto; padding: 12px 8px; display: grid; gap: 8px; }
.main { padding: 22px 28px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 650; }
.month-box { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.month-box input { width: auto; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 8px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #2a3140; }
.tag.active { background: rgba(61,214,140,.15); color: var(--good); }
.tag.pending { background: rgba(230,184,77,.15); color: var(--warn); }
.tag.disabled, .tag.dunning { background: rgba(255,107,122,.15); color: var(--bad); }
.tag.user_settled { background: rgba(61,156,253,.15); color: var(--accent); }
.tag.agent_settled { background: rgba(61,214,140,.2); color: var(--good); }

@media (max-width: 960px) {
  #main-view { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .cards { grid-template-columns: 1fr 1fr; }
}
