/* Componenti del pannello Mèmo. I colori partono dalla palette di Unfold, così funziona anche il tema scuro. */
.memo {
  --m-surface: #fff;
  --m-border: var(--color-base-200);
  --m-muted: var(--color-base-500);
  --m-text: var(--color-base-900);
  --m-soft: var(--color-base-50);
  --m-accent: var(--color-primary-600);
  color: var(--m-text);
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
  font-size: 14px;
}
.dark .memo {
  --m-surface: var(--color-base-900);
  --m-border: var(--color-base-800);
  --m-muted: var(--color-base-400);
  --m-text: var(--color-base-100);
  --m-soft: var(--color-base-800);
  --m-accent: var(--color-primary-400);
}
.memo * { box-sizing: border-box; }
.memo a { color: inherit; }
.memo .memo-link { color: var(--m-accent); font-weight: 500; }
.memo .memo-link:hover { text-decoration: underline; }
.memo-muted { color: var(--m-muted); }
.memo-small { font-size: 12.5px; }
.memo-right { text-align: right; }
.memo-nowrap { white-space: nowrap; }
.memo-mobile-only { display: none; }

.memo-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.memo-head h1, .memo-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; color: var(--m-text); }
.memo-head__title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.memo-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.memo-card { background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.memo-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--m-text); }
.memo-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.memo-card__head h3 { margin: 0; }
.memo-card--flush { padding: 0; overflow: hidden; }
.memo-card--flush > h3, .memo-card--flush > .memo-card__head { padding: 16px 20px 0; }

.memo-grid { display: grid; gap: 20px; }
.memo-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.memo-grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.memo-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.memo-kpi__label { display: flex; align-items: center; gap: 6px; color: var(--m-muted); font-size: 13px; }
.memo-kpi__label .material-symbols-outlined { font-size: 18px; }
.memo-kpi__value { margin-top: 6px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }

/* Badge di stato */
.memo-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.memo-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.memo-badge--success { background: #dcfce7; color: #166534; }
.memo-badge--warning { background: #fef3c7; color: #92400e; }
.memo-badge--danger { background: #fee2e2; color: #991b1b; }
.memo-badge--info { background: #dbeafe; color: #1e40af; }
.memo-badge--neutral { background: var(--color-base-100); color: var(--color-base-700); }
.dark .memo-badge--success { background: #14532d; color: #bbf7d0; }
.dark .memo-badge--warning { background: #78350f; color: #fde68a; }
.dark .memo-badge--danger { background: #7f1d1d; color: #fecaca; }
.dark .memo-badge--info { background: #1e3a8a; color: #bfdbfe; }
.dark .memo-badge--neutral { background: var(--color-base-700); color: var(--color-base-200); }
.memo-chip { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 5px; font-size: 11px; background: var(--color-base-100); color: var(--color-base-600); }
.dark .memo-chip { background: var(--color-base-700); color: var(--color-base-200); }

/* Pulsanti */
.memo-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--m-border); background: var(--m-surface); color: var(--m-text) !important; font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.memo-btn:hover { background: var(--m-soft); }
.memo-btn .material-symbols-outlined { font-size: 18px; }
.memo-btn--primary { background: var(--color-primary-600); border-color: var(--color-primary-600); color: #fff !important; }
.memo-btn--primary:hover { background: var(--color-primary-700); border-color: var(--color-primary-700); }
.memo-btn--danger { color: #b91c1c !important; border-color: #fecaca; }
.memo-btn--danger:hover { background: #fef2f2; }
.dark .memo-btn--danger { color: #fca5a5 !important; border-color: #7f1d1d; }
.dark .memo-btn--danger:hover { background: #450a0a; }
.memo-btn--danger-solid { background: #b91c1c; border-color: #b91c1c; color: #fff !important; }
.memo-btn--danger-solid:hover { background: #991b1b; }
.memo-btn--sm { min-height: 30px; padding: 3px 10px; font-size: 12.5px; }

/* Tabelle */
.memo-table-wrap { overflow-x: auto; }
.memo-table { width: 100%; border-collapse: collapse; }
.memo-table th { padding: 10px 20px; text-align: left; font-size: 12px; font-weight: 500; color: var(--m-muted); border-bottom: 1px solid var(--m-border); white-space: nowrap; }
.memo-table td { padding: 11px 20px; border-bottom: 1px solid var(--m-border); vertical-align: middle; }
.memo-table tr:last-child td { border-bottom: 0; }
.memo-table th.memo-right { text-align: right; }

/* Pagina ordine */
.memo-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--m-border); }
.memo-item:first-of-type { border-top: 0; }
.memo-item__img { width: 46px; height: 46px; flex: none; border-radius: 8px; background: var(--m-soft); object-fit: contain; padding: 3px; }
.memo-item__name { flex: 1; min-width: 0; }
.memo-item__sub { font-size: 12.5px; color: var(--m-muted); }
.memo-sum { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--m-border); }
.memo-sum div { display: flex; justify-content: space-between; gap: 12px; }
.memo-sum__total { font-size: 16px; font-weight: 600; }
.memo-sum__due { color: #b45309; font-weight: 500; }
.dark .memo-sum__due { color: #fbbf24; }

.memo-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--m-border); }
.memo-row:first-of-type { border-top: 0; padding-top: 0; }
.memo-address { line-height: 1.5; }

.memo-timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.memo-timeline li { position: relative; padding: 0 0 14px 20px; }
.memo-timeline li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-base-300); }
.memo-timeline li::after { content: ""; position: absolute; left: 6.5px; top: 16px; bottom: -4px; width: 1px; background: var(--m-border); }
.memo-timeline li:last-child::after { display: none; }
.memo-timeline .is-note::before { background: var(--m-accent); }
.memo-comment textarea { width: 100%; min-height: 62px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--m-border); background: var(--m-surface); color: var(--m-text); font-size: 14px; }

.memo-section-title { margin: 8px 0 -6px; font-size: 15px; font-weight: 600; color: var(--m-text); }

/* Tab dell'elenco ordini */
.memo-tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; }
.memo-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500; white-space: nowrap; color: var(--color-base-600); }
.memo-tabs a:hover { background: var(--color-base-100); }
.memo-tabs a.is-active { background: var(--color-primary-600); color: #fff; }
.memo-tabs small { padding: 0 6px; border-radius: 999px; font-size: 11.5px; background: var(--color-base-100); color: var(--color-base-600); }
.memo-tabs a.is-active small { background: rgba(255, 255, 255, .22); color: #fff; }
.dark .memo-tabs a { color: var(--color-base-300); }
.dark .memo-tabs a:hover { background: var(--color-base-800); }
.dark .memo-tabs small { background: var(--color-base-800); color: var(--color-base-300); }

/* Pagine-azione */
.memo-form { max-width: 620px; }
.memo-form__field { margin-bottom: 16px; }
.memo-form__field > label { display: block; margin-bottom: 5px; font-size: 13.5px; font-weight: 500; color: var(--m-text); }
.memo-form__field input:not([type="checkbox"]), .memo-form__field select { max-width: 100%; }
.memo-form__help { margin-top: 4px; font-size: 12.5px; color: var(--m-muted); }
.memo-form__error { margin-top: 4px; font-size: 13px; color: #b91c1c; }
.dark .memo-form__error { color: #fca5a5; }
.memo-form__errors { margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; background: #fee2e2; color: #991b1b; font-size: 13.5px; }
.memo-form__foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.memo-summary { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--m-border); }
.memo-summary dt { color: var(--m-muted); }
.memo-summary dd { margin: 0; font-weight: 500; }

@media (max-width: 1100px) {
  .memo-grid--main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .memo-item__unit { display: none; }
  .memo-mobile-only { display: inline; }
  .memo-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .memo-kpi__value { font-size: 21px; }
  .memo-card { padding: 14px 16px; }
  .memo-table th, .memo-table td { padding-left: 14px; padding-right: 14px; }
  .memo-card--flush > h3, .memo-card--flush > .memo-card__head { padding: 14px 16px 0; }
}

/* Home: panoramica */
.memo-home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.memo-todo h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--m-text); }
.memo-todo__row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; }
.memo-todo__row:hover { background: var(--m-soft); }
.memo-todo__row > span:nth-child(2) { flex: 1; min-width: 0; }
.memo-todo__row .material-symbols-outlined { font-size: 20px; color: var(--m-muted); }
.memo-count { flex: none; min-width: 28px; padding: 2px 8px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 13px; font-weight: 600; text-align: center; }
.dark .memo-count { background: #14532d; color: #bbf7d0; }
.memo-numbers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.memo-number { display: flex; flex-direction: column; gap: 2px; transition: border-color .15s; }
.memo-number:hover { border-color: var(--color-base-400); }
.memo-number strong { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.memo-number span { color: var(--m-muted); font-size: 13px; }
@media (max-width: 1100px) {
  .memo-home { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .memo-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .memo-number strong { font-size: 19px; }
}
