:root {
  --sea: #0d7377;
  --sea-dark: #095456;
  --sea-light: #14919b;
  --sand: #f7f3eb;
  --foam: #e8f4f4;
  --ink: #1a2e2e;
  --muted: #5a6e6e;
  --accent: #e07a3d;
  --radius: 1rem;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(20, 145, 155, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(224, 122, 61, 0.12), transparent 50%),
    linear-gradient(165deg, var(--foam) 0%, var(--sand) 55%, #dff0ef 100%);
  background-attachment: fixed;
}

h1, h2, .brand {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* ——— Login ——— */
.login-panel {
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: rise-in 0.55s ease-out both;
}

.brand {
  font-size: clamp(2.4rem, 8vw, 3.25rem);
  color: var(--sea-dark);
  line-height: 1.1;
  margin: 0 0 0.5rem;
}

.brand-mark {
  display: inline-block;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 1.25rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #fff8 0%, transparent 45%),
    linear-gradient(145deg, var(--sea-light), var(--sea-dark));
  box-shadow: 0 8px 24px rgba(13, 115, 119, 0.28);
  animation: float-soft 4s ease-in-out infinite;
}

.tagline {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 2rem;
  line-height: 1.45;
}

.login-form {
  text-align: left;
}

.login-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sea-dark);
  margin-bottom: 0.4rem;
}

.login-form .form-control {
  border: 2px solid transparent;
  border-radius: calc(var(--radius) - 0.15rem);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  box-shadow: 0 2px 12px rgba(26, 46, 46, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form .form-control:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 4px rgba(13, 115, 119, 0.15);
  background: #fff;
}

.btn-sea {
  background: var(--sea);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  border-radius: calc(var(--radius) - 0.15rem);
  transition: background 0.2s, transform 0.15s;
}

.btn-sea:hover,
.btn-sea:focus {
  background: var(--sea-dark);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-ghost:hover {
  color: var(--sea-dark);
}

/* ——— Hub ——— */
.hub-shell {
  width: 100%;
  max-width: 720px;
  animation: rise-in 0.5s ease-out both;
}

.hub-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.hub-header .brand {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  margin: 0;
}

.hub-greeting {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hub-greeting strong {
  color: var(--sea-dark);
}

.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 576px) {
  .hub-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.hub-link {
  display: block;
  padding: 1.35rem 1.4rem;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(13, 115, 119, 0.12);
  border-radius: var(--radius);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  animation: rise-in 0.55s ease-out both;
}

.hub-link:nth-child(1) { animation-delay: 0.05s; }
.hub-link:nth-child(2) { animation-delay: 0.1s; }
.hub-link:nth-child(3) { animation-delay: 0.15s; }
.hub-link:nth-child(4) { animation-delay: 0.2s; }

.hub-link:hover {
  background: #fff;
  border-color: var(--sea);
  color: inherit;
  transform: translateY(-2px);
}

.hub-link h2 {
  font-size: 1.2rem;
  margin: 0 0 0.35rem;
  color: var(--sea-dark);
}

.hub-link p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.4;
}

.hub-link .hub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.75rem;
  border-radius: 0.55rem;
  background: var(--foam);
  color: var(--sea);
  font-size: 1.1rem;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float-soft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ——— Calcolatrice ——— */
.calc-shell {
  max-width: 560px;
}

.calc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.calc-preset {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(13, 115, 119, 0.2);
  background: rgba(255, 255, 255, 0.65);
  color: var(--sea-dark);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.calc-preset:hover {
  border-color: var(--sea);
  background: #fff;
}

.calc-preset.is-active {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}

.calc-form {
  margin-bottom: 1.25rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.calc-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sea-dark);
  margin-bottom: 0.35rem;
}

.calc-field input {
  width: 100%;
  border: 2px solid transparent;
  border-radius: calc(var(--radius) - 0.25rem);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.7rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(26, 46, 46, 0.05);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.calc-field input:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 4px rgba(13, 115, 119, 0.12);
  background: #fff;
}

.calc-result {
  padding: 1.35rem 1.4rem;
  background: linear-gradient(145deg, var(--sea), var(--sea-dark));
  color: #fff;
  border-radius: var(--radius);
  text-align: center;
}

.calc-result-label {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.calc-result-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 600;
  line-height: 1.1;
}

.calc-breakdown {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  opacity: 0.88;
  line-height: 1.4;
}

@media (max-width: 400px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

/* ——— Lista spesa ——— */
.page-shell--top {
  align-items: flex-start;
  padding-top: 2.5rem;
  padding-bottom: 3rem;
}

.spesa-shell {
  max-width: 560px;
}

.spesa-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.spesa-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.spesa-status.is-error {
  color: #b42318;
}

.hub-greeting kbd {
  font-family: var(--font-body);
  font-size: 0.85em;
  font-weight: 600;
  padding: 0.1em 0.4em;
  border-radius: 0.3em;
  background: rgba(13, 115, 119, 0.1);
  color: var(--sea-dark);
}

.spesa-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.spesa-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(13, 115, 119, 0.12);
  border-radius: calc(var(--radius) - 0.2rem);
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.spesa-item:focus-within {
  background: #fff;
  border-color: var(--sea);
}

.spesa-item.is-done {
  opacity: 0.55;
}

.spesa-item.is-done .spesa-text {
  text-decoration: line-through;
  color: var(--muted);
}

.spesa-check {
  position: relative;
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  cursor: pointer;
}

.spesa-check input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.spesa-check span {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid var(--sea);
  border-radius: 0.35rem;
  background: #fff;
  transition: background 0.15s, border-color 0.15s;
}

.spesa-check input:checked + span {
  background: var(--sea);
  border-color: var(--sea);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");
  background-size: 0.85rem;
  background-position: center;
  background-repeat: no-repeat;
}

.spesa-text {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  padding: 0.35rem 0;
  outline: none;
}

.spesa-text::placeholder {
  color: #9aa8a8;
}

.spesa-delete {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.4rem;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.spesa-item:hover .spesa-delete,
.spesa-item:focus-within .spesa-delete {
  opacity: 1;
}

.spesa-delete:hover {
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
}

@media (max-width: 575px) {
  .spesa-delete {
    opacity: 0.7;
  }
}

.spesa-add {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  border: 1px dashed rgba(13, 115, 119, 0.35);
  border-radius: calc(var(--radius) - 0.2rem);
  background: rgba(255, 255, 255, 0.45);
  color: var(--sea-dark);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.spesa-add:hover {
  background: #fff;
  border-color: var(--sea);
  border-style: solid;
  color: var(--sea);
}

/* ——— Dividi spese ——— */
.dividi-shell {
  max-width: 640px;
}

.dividi-form {
  margin-bottom: 1.75rem;
}

.dividi-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.dividi-field-note {
  grid-column: 1 / -1;
}

.calc-field select {
  width: 100%;
  border: 2px solid transparent;
  border-radius: calc(var(--radius) - 0.25rem);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.7rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(26, 46, 46, 0.05);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23095456' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
}

.calc-field select:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 4px rgba(13, 115, 119, 0.12);
  background-color: #fff;
}

.dividi-section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--sea-dark);
  margin: 0 0 0.75rem;
}

.dividi-riepilogo {
  margin-bottom: 1.75rem;
}

.dividi-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.85rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.dividi-totals strong {
  color: var(--sea-dark);
}

.dividi-families {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.dividi-family {
  padding: 0.9rem 1rem;
  border-radius: calc(var(--radius) - 0.2rem);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(13, 115, 119, 0.12);
  border-left: 4px solid var(--muted);
}

.dividi-family.is-credit {
  border-left-color: var(--sea);
}

.dividi-family.is-debit {
  border-left-color: var(--accent);
}

.dividi-family.is-even {
  border-left-color: #8a9a9a;
}

.dividi-family h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  color: var(--sea-dark);
}

.dividi-family-paid,
.dividi-family-saldo {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.35;
}

.dividi-family-saldo {
  margin-top: 0.25rem;
  font-weight: 600;
}

.dividi-family.is-credit .dividi-family-saldo {
  color: var(--sea-dark);
}

.dividi-family.is-debit .dividi-family-saldo {
  color: #b45309;
}

.dividi-transfers {
  margin-top: 0.9rem;
  padding: 1rem 1.1rem;
  border-radius: calc(var(--radius) - 0.2rem);
  background: linear-gradient(145deg, var(--sea), var(--sea-dark));
  color: #fff;
}

.dividi-transfers-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.dividi-transfers ul {
  margin: 0;
  padding-left: 1.1rem;
}

.dividi-transfers li {
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.dividi-transfers-ok {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.95;
}

.dividi-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dividi-empty {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.5rem 0;
}

.dividi-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(13, 115, 119, 0.12);
  border-radius: calc(var(--radius) - 0.2rem);
}

.dividi-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.dividi-item-amount {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--sea-dark);
}

.dividi-item-who {
  font-size: 0.92rem;
}

.dividi-item-note {
  font-size: 0.88rem;
  color: var(--muted);
}

.dividi-delete {
  opacity: 0.65;
  margin-top: 0.1rem;
}

.dividi-item:hover .dividi-delete {
  opacity: 1;
}

@media (max-width: 575px) {
  .dividi-form-grid,
  .dividi-families {
    grid-template-columns: 1fr;
  }
}
