:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-muted: #eef1fa;
  --text: #171b2e;
  --muted: #656d85;
  --line: #dde1ee;
  --accent: #3d4ed6;
  --accent-dark: #2c3aad;
  --positive: #12805c;
  --negative: #c0392b;
  --danger: #c0392b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

a {
  color: inherit;
}

/* Login */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  display: grid;
  gap: 16px;
  text-align: center;
}

.login-hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}

.brand div {
  display: grid;
  line-height: 1.2;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.login-card .brand {
  justify-content: center;
}

/* Shell */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-weight: 650;
  padding: 0 12px;
}

.nav-button.active,
.nav-button:hover {
  border-color: var(--line);
  background: var(--panel-muted);
}

.nav-button.active {
  color: var(--accent-dark);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sidebar-footer span {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.content {
  padding: 32px 40px;
  max-width: 1200px;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.content-header h2 {
  margin: 2px 0 0;
}

.content-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

/* Summary cards */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 6px;
}

.summary-card span {
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  font-size: 22px;
}

.summary-card.emphasized {
  background: var(--panel-muted);
  border-color: var(--accent);
}

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

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

/* Sections */

.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-header h3 {
  margin: 0;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.section-amount {
  margin-left: auto;
  font-weight: 700;
  font-size: 15px;
}

.section-header .button {
  margin-left: auto;
}

/* Collapsible grouped sections */

.collapsible summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  cursor: pointer;
  list-style: none;
}

.collapsible summary::-webkit-details-marker {
  display: none;
}

.collapsible summary h3 {
  margin: 0;
}

.collapsible summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform 0.15s ease;
}

.collapsible[open] summary::before {
  transform: rotate(90deg);
}

.group-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--panel-muted);
  color: var(--accent-dark);
}

/* Projects */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.project-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  transition: border-color 0.15s ease;
}

.project-card:hover {
  border-color: var(--accent);
}

.project-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.project-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.project-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.project-card dl div {
  display: grid;
  gap: 2px;
}

.project-card dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.project-card dd {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
}

.project-card footer {
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

/* Payback banner */

.payback-banner {
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}

.payback-banner.reached {
  background: rgba(18, 128, 92, 0.1);
  border-color: var(--positive);
}

/* Charts */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.chart-box h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

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

.chart-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 30px 0;
  text-align: center;
}

/* Table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}

.data-table thead th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

.data-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--line);
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.pill.positive {
  background: rgba(18, 128, 92, 0.12);
  color: var(--positive);
}

.pill.negative {
  background: rgba(192, 57, 43, 0.12);
  color: var(--negative);
}

/* Buttons */

.button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.button.danger {
  border-color: #f0b8b2;
  color: var(--danger);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.icon-button:hover {
  background: rgba(192, 57, 43, 0.1);
  color: var(--danger);
}

.danger-zone {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 40, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid var(--line);
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal header h3 {
  margin: 0;
}

.modal-body {
  padding: 22px;
}

.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--panel);
}

/* Forms */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-weight: 700;
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--text);
}

.field textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

/* Misc */

.empty,
.empty-inline {
  color: var(--muted);
  font-size: 14px;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 60;
}

.toast.error {
  background: var(--negative);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
  .content {
    padding: 20px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
}
