:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1c;
  --muted: #666666;
  --border: #d9d9d4;
  --accent: #1f6feb;
  --danger: #c0392b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --surface: #1d1f24;
    --text: #ececec;
    --muted: #a0a0a0;
    --border: #3a3d45;
    --accent: #6ea8ff;
    --danger: #ff6b5b;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0 auto;
  padding: 1rem;
  max-width: 1100px;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 1.1rem;
  margin: 0;
}

.muted {
  color: var(--muted);
}

#notice {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
}

/* --- Rings --------------------------------------------------------------- */

.ring-wrap {
  position: relative;
  margin: 0 auto;
}

.ring-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.ring-grand {
  width: min(70vw, 280px);
}

.ring-card {
  width: min(60vw, 200px);
}

.ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 12;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.ring-centre {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 18%;
}

.ring-value {
  font-weight: 700;
  font-size: clamp(1rem, 4.5vw, 1.6rem);
  overflow-wrap: anywhere;
}

/* --- Grand total ------------------------------------------------------- */

#grand {
  text-align: center;
  padding: 1rem 0 1.5rem;
}

#grand .ring-value {
  font-size: clamp(1.2rem, 6vw, 2.2rem);
}

/* --- Forms ---------------------------------------------------------------- */

#forms {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 1.5rem;
}

form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

fieldset:disabled {
  opacity: 0.55;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

label {
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
  color: inherit;
  min-height: 44px;
}

input,
select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  width: 100%;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
}

.error {
  color: var(--danger);
  min-height: 1.2em;
  font-size: 0.9rem;
}

button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-width: 44px;
}

button:hover {
  filter: brightness(1.08);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-small {
  padding: 0.25rem 0.6rem;
  min-height: 44px;
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* --- Investor cards -------------------------------------------------------- */

#investors {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-head {
  text-align: center;
}

.payments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.payment {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "date amount button"
    "project project button"
    "notes notes button";
  column-gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}

.p-date {
  grid-area: date;
  font-variant-numeric: tabular-nums;
}

.p-amount {
  grid-area: amount;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.p-project {
  grid-area: project;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.p-notes {
  grid-area: notes;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.payment button {
  grid-area: button;
}

.card-name {
  overflow-wrap: anywhere;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 0;
}
