:root {
  --bg: #08111f;
  --panel: rgba(15, 27, 47, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.035);
  --border: rgba(173, 195, 227, 0.18);
  --text: #edf4ff;
  --muted: #a9b9d1;
  --accent: #75c7ff;
  --accent-2: #6ee7b7;
  --danger: #ff8f9b;
  --warning: #ffd27d;
  --radius: 16px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgba(83, 153, 255, 0.18), transparent 34rem),
    linear-gradient(155deg, #091321, #07101d 55%, #091525);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }

button, input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: rgba(3, 10, 21, 0.72);
}

button {
  min-height: 40px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 750;
}

button:hover { border-color: rgba(117, 199, 255, 0.68); }
button.primary { border-color: rgba(110, 231, 183, 0.42); background: rgba(110, 231, 183, 0.13); }
button.danger { color: var(--danger); }
button:disabled { cursor: not-allowed; opacity: 0.46; }

input, select, textarea { min-height: 40px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid rgba(117, 199, 255, 0.72); outline-offset: 2px; }

.app { min-height: 100vh; }
.app-shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 54px; }

.hero, .panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(18, 34, 57, 0.94), rgba(10, 22, 39, 0.94));
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.2);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  padding: 26px;
  margin-bottom: 16px;
}

.eyebrow { margin: 0 0 6px; color: var(--accent-2); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2 { margin: 0; }
h1 { font-size: clamp(30px, 5vw, 52px); line-height: 1; }
h2 { font-size: 20px; }
.hero p:not(.eyebrow), .panel-head p { max-width: 760px; margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.hero-actions, .inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-actions { justify-content: flex-end; }

.panel { padding: 18px; margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 14px; }
.inline-form input { min-width: 190px; }
code { color: var(--accent-2); font-family: var(--mono); }

.people-list { display: flex; flex-wrap: wrap; gap: 9px; }
.person-chip { display: flex; align-items: center; gap: 6px; padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-soft); }
.person-chip input { width: 132px; min-height: 34px; padding: 6px 8px; font-weight: 700; }
.person-chip button { min-height: 34px; padding: 5px 9px; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: left; vertical-align: middle; }
th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
thead th { position: sticky; top: 0; z-index: 2; color: #dceaff; background: #12233c; white-space: nowrap; }
tfoot td { color: var(--text); background: rgba(117, 199, 255, 0.07); font-weight: 800; }
.expense-table { min-width: 860px; }
.expense-table .item-input { min-width: 150px; }
.expense-table .amount-input { width: 112px; }
.expense-table .payer-select { min-width: 130px; }
.expense-table .weight-input { width: 72px; text-align: center; }
.expense-table input, .expense-table select { min-height: 36px; padding: 6px 8px; }
.expense-table .remove-expense { min-height: 34px; padding: 5px 9px; }
.responsibility-head { text-align: center; }
.responsibility-head span { display: block; max-width: 100px; overflow: hidden; text-overflow: ellipsis; }

.status-line { min-height: 22px; margin: 10px 2px 0; color: var(--muted); }
.status-line.is-warn { color: var(--warning); }
.balance-check, .count-pill { padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); white-space: nowrap; }
.balance-check.is-ok { color: var(--accent-2); border-color: rgba(110, 231, 183, 0.38); }
.summary-description-row { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.summary-description-row p { flex: 1 1 480px; }
.settlement-field { display: grid; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 750; }
.settlement-field select { min-width: 190px; }
.summary-head-actions { display: flex; align-items: end; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.balance-stack { display: grid; gap: 6px; }
.summary-table { min-width: 920px; }
.summary-table td:nth-child(2), .summary-table td:nth-child(3), .summary-table td:nth-child(4) { font-family: var(--mono); white-space: nowrap; }
.net-positive { color: var(--accent-2); }
.net-negative { color: var(--danger); }
.transfer-list { display: grid; gap: 4px; min-width: 160px; }
.transfer-entry { white-space: nowrap; }
.empty-value { color: var(--muted); }

.payment-diagram { min-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: radial-gradient(circle at center, rgba(117, 199, 255, 0.08), rgba(0, 0, 0, 0.16)); }
.payment-diagram svg { display: block; width: 100%; min-width: 720px; height: 460px; }
.diagram-empty { min-height: 360px; display: grid; place-items: center; padding: 28px; color: var(--muted); text-align: center; }
.diagram-edge { stroke: #75c7ff; stroke-width: 2.3; fill: none; opacity: 0.8; marker-end: url(#paymentArrow); }
.diagram-edge-label { fill: #edf4ff; font: 700 13px var(--mono); paint-order: stroke; stroke: #08111f; stroke-width: 5px; stroke-linejoin: round; }
.diagram-node { fill: #132844; stroke: #6ee7b7; stroke-width: 2; }
.diagram-node-name { fill: #edf4ff; font: 800 14px Inter, sans-serif; text-anchor: middle; }
.diagram-node-net { fill: #a9b9d1; font: 12px var(--mono); text-anchor: middle; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .app-shell { width: min(100% - 20px, 1500px); padding-top: 16px; }
  .hero, .panel-head { align-items: stretch; flex-direction: column; }
  .hero-actions { justify-content: stretch; }
  .hero-actions button { flex: 1 1 140px; }
  .inline-form { width: 100%; }
  .inline-form input { flex: 1 1 160px; min-width: 0; }
  .summary-description-row { align-items: stretch; flex-direction: column; }
  .summary-head-actions { justify-content: flex-start; }
}
