@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
  --primary: #5568FE;
  --primary-light: #EEF0FE;
  --secondary: #FFD95D;
  --accent-bg: #FFF9E6;
  --danger: #DE3B40;
  --gray: #888;
  --input-border: #bbc0c7;
}

body {
  font-family: 'Roboto', sans-serif;
  background: linear-gradient(120deg, #f3f4f9 0%, #eef7fb 100%);
  color: #333;
  margin: 0;
  min-height: 100vh;
}

.container {
  background: #fff;
  box-shadow: 0 8px 32px rgba(80, 90, 120, 0.10);
  border-radius: 16px;
  max-width: 540px;
  margin: 3vh auto 0 auto;
  padding: 32px 22px 30px 22px;
  box-sizing: border-box;
}

header {
  text-align: center;
  margin-bottom: 28px;
}

h1 {
  color: var(--primary);
  font-size: 2.1rem;
  font-weight: 700;
  margin: 0;
  margin-bottom: 0.34em;
  letter-spacing: -1px;
}

.subtitle {
  color: #666;
  margin-top: 0;
  font-size: 1.07rem;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.field {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.label-text {
  font-weight: 500;
  font-size: 1rem;
  margin-bottom: 3px;
}

.input-hint {
  color: var(--gray);
  font-size: 0.93rem;
  margin: 1px 0 0 2px;
  display: block;
  line-height: 1.3;
}

.current-savings-row {
  max-width: calc(100% - 20px);
  margin-left: auto;
  margin-right: auto;
}
.current-savings-row input {
  width: 100%;
}

input {
  border: 1.5px solid var(--input-border);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 1.14rem;
  transition: border-color 0.18s;
  margin-bottom: 2px;
  box-sizing: border-box;
}

input:focus, .purchase input:focus {
  border-color: var(--primary);
  background: #fcfdff;
  /* Outline handled globally below for all focus states */
}

input[type="date"] {
  font-family: inherit;
}

::placeholder {
  color: #b2b6c3;
  opacity: 1;
}

.purchases-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.purchases-header {
  font-size: 1.09rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-purchase-container {
  margin-top: 10px;
  width: 100%;
}

.add-purchase-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  font-size: 1.09rem;
  padding: 11px 0;
  border-radius: 6px;
  margin: 20px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.22s, color 0.22s;
  outline: none;
  width: 100%;
  box-shadow: 0 2px 4px 0 rgba(175,190,255,0.06);
}

.add-purchase-btn:hover, .add-purchase-btn:focus {
  background: var(--primary);
  color: #fff;
}

hr.golden-ratio {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, #eee 8%, var(--primary-light) 50%, #eee 92%);
  width: 75%;
  margin: 22px auto 17px auto;
  border-radius: 1px;
}

#purchases {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.purchase {
  background: var(--accent-bg);
  border: 1.5px solid #f3e4bb;
  border-radius: 9px;
  padding: 16px 10px 14px 10px;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  position: relative;
  transition: box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(255,212,56,0.04);
}

.purchase input.purchaseName,
.purchase input.purchaseValue {
  width: 100%;
  margin-bottom: 0;
}

/* ====== VISIBLE LABEL FOR DATE FIELD ====== */
.purchaseDate-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.purchaseDate-label {
  font-size: .97rem;
  color: #666;
  margin-right: 8px;
  white-space: nowrap;
}

.purchase .purchaseDate {
  flex: 1;
  min-width: 110px;
}
/* =========================================== */

.removePurchase {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: 6px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  outline: none;
  box-shadow: 0 1px 2px rgba(222,59,64,0.05);
}
.removePurchase:hover, .removePurchase:focus {
  background: #b02626;
  color: #fff;
}
.purchase input[type="text"], .purchase input[type="date"] {
  margin-bottom: 0;
}
.purchase input:focus {
  background: #fffbe8;
  border-color: var(--primary);
}
.purchase:focus-within {
  outline: 2px solid #ffe7b2;
}
.purchase.dragging {
  opacity: 0.61;
  border: 2.5px dashed var(--secondary);
  background: #fffce8;
}
.purchase.drag-over {
  border: 2.5px solid var(--primary);
  background: #e7f0ff;
}

#result {
  text-align: center;
  margin-top: 26px;
  font-size: 1.20rem;
  background: none;
  color: var(--primary);
  font-weight: 500;
  padding: 0;
  border-radius: 0;
  min-height: 0;
  box-shadow: none;
}

#result strong {
  color: #20a167;
  font-weight: 700;
  font-size: 1.17em;
}

@media (max-width: 650px) {
  .container {
    max-width: 98vw;
    padding: 10vw 2vw 10vw 2vw;
  }
  h1 { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .purchase {
    padding: 10px 6px;
  }
  .add-purchase-btn {
    width: 100%;
    font-size: 1.02rem;
    padding: 8px 0;
  }
  .purchaseDate-label {
    font-size: .93rem;
    margin-right: 4px;
  }
}

.underline {
  text-decoration: underline dotted;
  cursor: pointer;
}
.dropdown {
  display: inline-block;
  position: relative;
}
.period-label {
  padding: 2px 6px;
}
.period-options {
  position: absolute;
  background: #fff;
  border: 1.5px solid var(--primary);
  border-radius: 4px;
  left: 0;
  top: 100%;
  z-index: 20;
  min-width: 120px;
  box-shadow: 0 4px 15px rgba(70,90,160,0.10);
  margin-top: 2px;
  font-size: 1rem;
}
.period-option {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--primary);
  border-bottom: 1px solid #f3f7fa;
  transition: background 0.14s, color 0.14s;
}
.period-option:last-child { border-bottom: none }
.period-option:hover, .period-option:focus {
  background: var(--primary-light);
  color: #222;
  font-weight: 500;
}

/* Focus outline for accessibility (Consolidated, comes last for specificity) */
input:focus,
button:focus,
.period-option:focus,
.add-purchase-btn:focus,
.removePurchase:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ---- Footer styles ---- */
.site-footer {
  text-align: center;
  color: #666;
  font-size: 0.96em;
  margin-top: 2em;
  padding: 1.5em 0 1em 0;
  border-top: none;
  background: transparent;
  letter-spacing: 0.03em;
}