/* Sparmål och Lån */

.page-sub { font-size: 13px; color: var(--text-2); }

/* ---------- Nyckeltal överst ---------- */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.hero-stat {
  grid-column: span 3;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.hero-stat.is-wide { grid-column: span 6; }
.hero-stat.is-third { grid-column: span 4; }
.hero-stat .label { font-size: 11px; }
.hero-value { font-size: 28px; font-weight: 400; letter-spacing: -0.02em; white-space: nowrap; }
.hero-note { font-size: 12px; line-height: 1.5; color: var(--text-2); }

.hero-stat.is-dark { background: var(--feature-bg); border-color: var(--feature-border); color: var(--on-feature); }
.hero-stat.is-dark .label, .hero-stat.is-dark .hero-note { color: var(--on-feature-2); }
.hero-stat.is-dark a { color: var(--on-feature); text-decoration: underline; }
.hero-stat.is-dark .hero-value { font-size: 44px; font-weight: 300; letter-spacing: -0.03em; }
.hero-stat.is-dark .hero-value.is-negative { color: var(--on-feature-negative); }

/* ---------- Formulär för nytt/ändra ---------- */
.edit-card {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--r-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.edit-card h2 { font-size: 17px; font-weight: 500; }

.edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.edit-grid .form-row { gap: 6px; }
.edit-grid .label { font-size: 11px; letter-spacing: 0.1em; }
.edit-grid .field { height: 46px; padding: 0 14px; border-radius: var(--r-sm); }
.field.mono { font-family: var(--font-mono); }
.field-hint { font-size: 12px; color: var(--text-2); }
.field-hint.is-error { color: var(--warning); }

/* Datumfält med kalenderknapp (js/datefield.js) */
.date-field { position: relative; display: flex; align-items: center; }
.date-field .field { padding-right: 48px; }
.date-button {
  position: absolute;
  right: 4px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.date-button:hover { background: var(--subtle); color: var(--accent); }
/* Kalenderfältet syns inte men måste finnas i sidan för att kunna öppnas */
.date-picker { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

.edit-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-plain { border-color: transparent; background: transparent; }

/* ---------- Kort ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.item-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.item-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.item-title h2 { font-size: 19px; font-weight: 500; overflow-wrap: anywhere; }
.item-sub { font-family: var(--font-mono); font-size: 13px; color: var(--text-2); }

.item-tools { display: flex; gap: 2px; flex-shrink: 0; }
.tool-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tool-btn:hover { background: var(--subtle); color: var(--text); }
.tool-btn.is-danger:hover { color: var(--warning); }

.badge {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #FFFFFF;
  font-size: 12px;
  white-space: nowrap;
}

.progress { height: 10px; border-radius: var(--r-pill); background: var(--subtle); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--accent); }
.progress span.is-done { background: var(--positive); }

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
}
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact .label { font-size: 11px; letter-spacing: 0.1em; }
.fact-value { font-size: 16px; }
.fact-value.is-big { font-size: 22px; }

.inline-amount { display: flex; align-items: center; gap: 6px; }
.inline-amount .amt-input { width: 110px; }
.inline-amount span { font-size: 13px; color: var(--text-2); }

.amt-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: right;
  transition: border-color .15s, box-shadow .15s;
}
.amt-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.status {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 14px;
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--text-3);
  font-size: 13px;
}
.status.is-good { background: var(--positive-bg); color: var(--positive); }
.status.is-bad { background: var(--warning-bg); color: var(--warning-text); }

.item-foot {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--subtle);
}
.item-foot .field { height: 44px; flex-grow: 1; min-width: 0; border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 14px; }
.item-foot .btn { border-radius: var(--r-sm); }

.tool-btn[aria-expanded="true"] { background: var(--accent-tint); color: var(--accent); }

/* ---------- Historik (js/history.js) ---------- */
.history {
  border-top: 1px solid var(--subtle);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-title { display: flex; justify-content: space-between; align-items: baseline; }
.history-title .label { font-size: 11px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.history-list li {
  display: grid;
  grid-template-columns: 1fr auto 40px;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  border-bottom: 1px solid var(--subtle);
}
.history-list li:last-child { border-bottom: none; }
.history-date { font-size: 14px; color: var(--text-3); }
.history-amount { font-family: var(--font-mono); font-size: 14px; text-align: right; }
.history-amount.is-in { color: var(--positive); }
.history-amount.is-out { color: var(--warning); }
.history-remove { width: 36px; height: 36px; }
.history-empty { font-size: 14px; color: var(--text-2); padding: 6px 0; }

.item-foot .btn { white-space: nowrap; }

/* ---------- Råd på Lån ---------- */
.advice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  line-height: 1.55;
}

@media (max-width: 1320px) {
  .cards { grid-template-columns: 1fr; }
  .edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .hero-stats { grid-template-columns: 1fr; }
  .hero-stat, .hero-stat.is-wide, .hero-stat.is-third { grid-column: auto; }
  .hero-stat.is-dark .hero-value { font-size: 34px; }
  .edit-grid { grid-template-columns: 1fr; }
  .item-card { padding: 18px; }
  .facts { gap: 14px 16px; }
  .item-foot { flex-wrap: wrap; }
}

/* "Insatt/Betalt i september" på varje kort */
.month-note { font-size: 13px; color: var(--text-2); margin-top: -6px; }
.month-note strong { color: var(--text); font-weight: 500; }

/* Sparkonto: kompakt kort. Namn, saldo och Sätt in på en rad när det får plats, annars två rader */
.item-card.is-account.is-wide { grid-column: 1 / -1; }
.account-body { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.account-body .item-head { flex: 1 1 320px; align-items: center; min-width: 0; }
.account-body .item-title { flex: 1 1 auto; min-width: 0; }
.account-body .item-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
.account-body .month-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-body .month-note { margin: 0; }
.account-sum { font-size: 18px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.account-body .item-foot { flex: 1 1 280px; padding-top: 0; border-top: 0; }
.item-card.is-wide .account-body .item-foot { flex: 0 1 420px; }
