:root {
  --bg: #0f1115;
  --panel: #171a21;
  --card: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #4f9cf9;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
}
h1 { font-size: 20px; margin: 0; }
.tag {
  font-size: 12px; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle;
}
.health { font-size: 12px; color: var(--muted); }
main { display: grid; grid-template-columns: 280px 1fr; gap: 20px; padding: 20px; max-width: 1100px; margin: 0 auto; }
aside { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: fit-content; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
h4 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); }

.group-list { list-style: none; padding: 0; margin: 0 0 16px; }
.group-list li {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; margin-bottom: 4px;
}
.group-list li:hover { background: var(--card); }
.group-list li.active { background: var(--card); border: 1px solid var(--accent); }
.group-list .meta { font-size: 11px; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

input, select, button {
  font: inherit; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: #11141a; color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
button { background: var(--accent); border: none; color: #0b1118; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.danger:hover { border-color: var(--red); color: var(--red); }

.detail-head { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none; }
.empty { color: var(--muted); display: flex; align-items: center; justify-content: center; min-height: 200px; }

.chips { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: #11141a; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13px; }

.balances, .settlement, .expenses { list-style: none; padding: 0; margin: 0; }
.balances li, .settlement li, .expenses li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.balances li:last-child, .settlement li:last-child, .expenses li:last-child { border-bottom: none; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.settlement li span.arrow { color: var(--muted); }
.expenses .exp-meta { color: var(--muted); font-size: 12px; }
.expenses .del { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.expenses .del:hover { color: var(--red); }
.total { margin-top: 12px; font-size: 13px; color: var(--muted); }

.expense-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.assistant .hint { color: var(--muted); font-size: 12px; margin: -4px 0 10px; }
.assistant input { flex: 1; }
.reply { margin-top: 12px; min-height: 20px; font-size: 14px; }
.reply.ok { color: var(--green); }
.reply.err { color: var(--red); }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .expense-form { grid-template-columns: 1fr 1fr; }
}
