/* xpns: mobile-first layout, light and dark themes. */

:root {
  --bg: #f7f7f5;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --card: #ffffff;
  --line: #deded8;
  --accent: #2d5da8;
  --accent-fg: #ffffff;
  --ok: #3b8a4a;
  --warn: #c98a12;
  --over: #c23b30;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171716;
    --fg: #ecece8;
    --muted: #9c9c95;
    --card: #222220;
    --line: #3a3a36;
    --accent: #6b9be0;
    --accent-fg: #0f1a2b;
    --ok: #5fb36e;
    --warn: #e0a83a;
    --over: #e46a5f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

main { max-width: 56rem; margin: 0 auto; padding: 0 1rem 3rem; }
main.narrow { max-width: 24rem; padding-top: 3rem; }

h1 { font-size: 1.4rem; margin: 1.2rem 0 0.6rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 0 0 0.4rem; }
small, .muted { color: var(--muted); font-weight: normal; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); background: var(--card);
}
.top .brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.top nav { display: flex; gap: 1rem; align-items: center; }

form.inline { display: inline; margin: 0; }
form.stack { display: flex; flex-direction: column; gap: 0.8rem; max-width: 28rem; }
form.stack label { display: flex; flex-direction: column; gap: 0.25rem; }
form.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
label.check { flex-direction: row !important; align-items: center; gap: 0.4rem; }

input, select, button {
  font: inherit; padding: 0.5rem 0.6rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  min-width: 0;
}
input.short { width: 8rem; }
input.big { font-size: 1.8rem; padding: 0.6rem; }
button, .button {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
  cursor: pointer; text-decoration: none; display: inline-block; text-align: center;
}
button.big { font-size: 1.2rem; padding: 0.8rem; }
button.link {
  background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline;
}
button.link.danger { color: var(--over); }

.error { color: var(--over); font-weight: 600; }
.notice {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin-top: 1rem;
}

.summary .progress { margin-bottom: 0.4rem; }
.summary > .progress .spent { font-size: 2rem; font-weight: 700; }
.line { padding: 0.4rem 0; border-top: 1px solid var(--line); }
.line .name { display: block; font-weight: 600; }
.progress .figures { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; }
.progress .spent { font-weight: 600; }
.progress .of { color: var(--muted); }
.progress .left { margin-left: auto; }
.progress.warn .left { color: var(--warn); font-weight: 600; }
.progress.over .left { color: var(--over); font-weight: 700; }
progress {
  width: 100%; height: 0.5rem; appearance: none; border: none;
  border-radius: 4px; background: var(--line); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--ok); }
progress::-moz-progress-bar { background: var(--ok); }
.warn progress::-webkit-progress-value { background: var(--warn); }
.warn progress::-moz-progress-bar { background: var(--warn); }
.over progress::-webkit-progress-value { background: var(--over); }
.over progress::-moz-progress-bar { background: var(--over); }

.quick .buttons {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.6rem;
}
.quick .button { padding: 1.1rem 0.5rem; border-radius: 10px; font-weight: 600; font-size: 1.05rem; }
.quick .button.other { background: var(--card); color: var(--accent); }
.quick .button {
  display: flex; align-items: center; gap: 0.5rem; justify-content: flex-start;
  background: var(--card); color: var(--fg); border: 1px solid var(--line); text-align: left;
}
.quick .button .badge { width: 2.2rem; height: 2.2rem; flex: none; }
.quick .button.other { justify-content: center; }

ul.entries { list-style: none; padding: 0; margin: 0; }
ul.entries li { border-top: 1px solid var(--line); }
ul.entries a {
  display: grid; grid-template-columns: 2rem max-content 1fr auto; gap: 0 0.6rem;
  align-items: center; padding: 0.5rem 0; color: inherit; text-decoration: none;
}
ul.entries a > .badge { grid-row: 1 / 3; width: 2rem; height: 2rem; }
ul.entries .date { color: var(--muted); white-space: nowrap; }
ul.entries .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.entries .amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
ul.entries .amount.refund { color: var(--ok); }
ul.entries .meta { grid-column: 2 / 5; color: var(--muted); font-size: 0.85rem; }

ul.menu { list-style: none; padding: 0; }
ul.menu li { border-top: 1px solid var(--line); }
ul.menu a { display: block; padding: 0.8rem 0; }

.item {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.7rem; margin-bottom: 0.6rem;
}
.item.inactive { opacity: 0.6; }
.item .actions { display: flex; gap: 1rem; margin-top: 0.5rem; }
.item form.inline { margin-top: 0.4rem; display: inline-block; }

table.budgets { border-collapse: collapse; width: 100%; }
table.budgets th, table.budgets td { padding: 0.3rem; text-align: left; }
table.budgets input { width: 100%; }

/* Merchant and card badges. */
.badge { display: inline-block; width: 1.4rem; height: 1.4rem; vertical-align: middle; flex: none; }
.badge text { user-select: none; }
.meta .badge { width: 1rem; height: 1rem; }
.with-badge .badge { width: 2rem; height: 2rem; }
input.tiny { width: 4.5rem; }
input[type="color"] { width: 2.6rem; height: 2.3rem; padding: 0.15rem; }
/* Website icons show at favicon size wherever they appear. */
img.badge.icon,
.quick .button img.badge.icon,
ul.entries a > img.badge.icon,
.with-badge img.badge.icon {
  width: 16px; height: 16px; object-fit: contain; justify-self: center;
}
input.site { width: 14rem; }
