/* ===== Colors (soft pastel) =====
   Change a color here and it changes everywhere. */
:root {
  color-scheme: light;
  --page: #f8f5fc;        /* very light lilac background */
  --card: #ffffff;
  --input: #fbf9fe;
  --line: #ebe4f4;
  --text: #3b3450;
  --muted: #8d86a0;
  --blue: #cbbaf6;        /* main buttons: pastel lavender */
  --blue-dark: #b9a4f1;   /* buttons when you hover */
  --button-text: #3b2c68;
  --blue-text: #6a52c4;
  --soft-blue: #efe9fd;
  --soft-blue-hover: #e3d9fb;
  --green: #3a9a6a;       /* money in */
  --soft-green: #dff5e9;  /* mint */
  --red: #d1607a;         /* money out */
  --soft-red: #fde4ea;    /* baby pink */
  --peach: #ffeadb;
  --bar: #f4a6b8;         /* spending bars */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--page);
  color: var(--text);
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  text-align: center;
}

/* Summary boxes */
.summary {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.box {
  flex: 1;
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.box p,
.box h2 {
  margin: 4px 0;
}

.box h2 {
  font-size: 1.2rem;
}

.income h2 {
  color: var(--green);
}

.expense h2 {
  color: var(--red);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h3 {
  margin-top: 0;
}

/* Form */
form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

input,
select,
button {
  padding: 10px;
  font-size: 1rem;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  border-radius: 6px;
}

button {
  background: var(--blue);
  color: var(--button-text);
  border: none;
  cursor: pointer;
}

button:hover {
  background: var(--blue-dark);
}

/* Category bars */
.cat-row {
  margin-bottom: 10px;
}

.cat-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.bar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.bar div {
  height: 100%;
  background: var(--red);
}

/* History list */
ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

li small {
  color: var(--muted);
}

.plus {
  color: var(--green);
}

.minus {
  color: var(--red);
}

.delete {
  background: none;
  color: var(--muted);
  padding: 4px 8px;
  margin-left: 8px;
}

.delete:hover {
  background: var(--soft-red);
  color: var(--red);
}

.empty {
  color: var(--muted);
  text-align: center;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.tabs button {
  flex: 1;
  background: var(--card);
  color: var(--text);
}

.tabs button.active {
  background: var(--blue);
  color: var(--button-text);
}

.hidden {
  display: none;
}

/* Payday page */
#pay-amount,
label {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}

label input {
  display: block;
  width: 100%;
  margin-top: 4px;
}

#moved {
  width: 100%;
  margin-top: 10px;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.ok {
  color: var(--green);
}

.warn {
  color: var(--red);
}

.small-btn {
  padding: 4px 10px;
  font-size: 0.85rem;
  margin-left: 4px;
}

.left-over {
  font-weight: bold;
  border-bottom: none;
}

.tabs button:hover {
  background: var(--soft-blue);
}

.tabs button.active:hover {
  background: var(--blue-dark);
}

/* Keep amount and buttons on one line */
li > div:last-child {
  white-space: nowrap;
  margin-left: 8px;
}

/* Pay in 4 page */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  display: inline;
  width: auto;
  margin: 0;
}

li.buy {
  display: block;
}

.buy-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

li.buy > .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  white-space: normal;
}

.chip {
  padding: 6px 10px;
  font-size: 0.85rem;
  background: var(--soft-blue);
  color: var(--blue-text);
}

.chip:hover {
  background: var(--soft-blue-hover);
}

.chip.paid {
  background: var(--soft-green);
  color: var(--green);
  cursor: default;
}

.chip.late {
  background: var(--soft-red);
  color: var(--red);
}

/* Smaller tab text so 5 tabs fit on a phone */
.tabs button {
  padding: 10px 4px;
  font-size: 0.9rem;
}

/* Our own pop-up box */
.dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(59, 52, 80, 0.35);
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.dialog.open {
  display: flex;
}

.dialog-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
}

.dialog-box p {
  margin-top: 0;
}

#dialog-input {
  width: 100%;
  margin-bottom: 12px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

button.secondary {
  background: var(--input);
  color: var(--text);
}

/* Visible outline when using the keyboard */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue-text);
  outline-offset: 2px;
}

/* ===== Pastel touches ===== */
h1 {
  color: var(--blue-text);
}

.card,
.box,
.tabs button {
  box-shadow: 0 2px 8px rgba(106, 82, 196, 0.08);
}

/* Each summary box gets its own pastel color */
.box {
  background: var(--soft-blue);
}

.box.income {
  background: var(--soft-green);
}

.box.expense {
  background: var(--soft-red);
}

/* Spending bars */
.bar div {
  background: var(--bar);
}

/* "Free to spend" line */
.left-over {
  background: var(--peach);
  border-radius: 8px;
  padding: 10px;
}

/* Big "you need" number on the Payday tab */
.next-total {
  background: var(--soft-blue);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  margin-bottom: 12px;
}

.next-total p,
.next-total h2 {
  margin: 4px 0;
}

.next-total h2 {
  color: var(--blue-text);
}

/* Backup & Restore */
.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.row-buttons > * {
  flex: 1;
}

textarea {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
  margin-bottom: 10px;
  resize: vertical;
  font-family: inherit;
}

/* "Restore from file" looks like a button; the real file picker is hidden */
label.file-btn {
  display: block;
  width: auto;
  margin: 0;
  padding: 10px;
  text-align: center;
  border-radius: 6px;
  background: var(--input);
  border: 1px solid var(--line);
  cursor: pointer;
}

label.file-btn:hover {
  background: var(--soft-blue);
}

label.file-btn input {
  display: none;
}
