/* ---------- Forms ---------- */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-family: var(--font-numbers);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  transition: all var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--gold-dim);
  box-shadow:
    0 0 0 2px var(--gold-glow),
    0 0 12px rgba(201, 168, 76, 0.06);
  background: rgba(201, 168, 76, 0.02);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%237a7a8a' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option,
.form-input option,
select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.7;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.form-row .form-group { margin-bottom: 0; }

/* ---------- Position Form Sections ---------- */

.form-section {
  position: relative;
  margin-bottom: 24px;
  padding: 28px 28px 24px;
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.01) 0%, transparent 40%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: card-enter 0.5s var(--transition-slow) both;
}

.form-section:nth-child(1) { animation-delay: 0.05s; }
.form-section:nth-child(2) { animation-delay: 0.12s; }
.form-section:nth-child(3) { animation-delay: 0.19s; }
.form-section:nth-child(4) { animation-delay: 0.26s; }

.form-section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.form-section-number {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-glow);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 50%;
  font-family: var(--font-numbers);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
}

.form-section-title {
  font-family: var(--font-titles);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

/* ---------- Ticker Autocomplete ---------- */

.ticker-ac-wrap {
  position: relative;
  width: 100%;
}

.ticker-ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.ticker-ac-item {
  display: flex;
  align-items: center;
  gap: 4px 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 0.85rem;
}

.ticker-ac-item:hover,
.ticker-ac-item.active {
  background: var(--bg-hover);
}

/* S627 — chi cede per primo, quando la riga non basta.
 *
 * Il difetto (bug report 72a99115 del Sacerdote): cercando «Tsla» da telefono,
 * il primo risultato — TSLA al NASDAQ, cioè l'unico che stava cercando —
 * mostrava il nome come «T…», mentre le righe sotto scrivevano «TESLA INC»
 * per intero. Al contrario di come sembra, era proprio la targhetta a farlo:
 * `white-space: nowrap` senza `min-width: 0` tiene la larghezza minima
 * automatica del flex item, quindi «NASDAQ · equity» non cedeva un pixel; il
 * nome invece, avendo `overflow: hidden`, quella larghezza minima non ce l'ha
 * e collassava fino a un carattere. Le righe senza borsa avevano spazio solo
 * perché la loro targhetta era corta.
 *
 * La cura NON è far cedere la targhetta: misurato, non serve a niente. Su un
 * nome lungo («TRANSILVANIA BROKER DE ASIGURARE») restringere la targhetta
 * regalava al nome due battute e toglieva la borsa — si perdeva
 * un'informazione intera per non guadagnarne nessuna. Sotto i 220px, per tre
 * cose su una riga lo spazio non c'è: qualcosa DEVE spostarsi.
 *
 * Quindi la targhetta scende su una riga sua (`flex-wrap`) quando non ci sta
 * accanto al nome, e non si tronca mai. Misurato a sei larghezze: il nome è
 * sempre intero dove prima era 0-4 pixel, il caso lungo passa da 3 a 19
 * battute leggibili a 180px, e da 360px in su non cambia niente rispetto a
 * prima — su desktop la riga resta una sola. */
.ticker-ac-symbol {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--gold);
  min-width: 70px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.82rem;
}

.ticker-ac-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-ac-tag {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.ticker-ac-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
}

/* ---------- Sentiment Selector ---------- */

.sentiment-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.sentiment-chip {
  position: relative;
}

.sentiment-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sentiment-chip label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0;
}

.sentiment-chip label:hover {
  border-color: #2a2a3a;
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Color-coded sentiment states */
.sentiment-chip input:checked + label {
  border-color: var(--gold);
  background: var(--gold-glow);
  color: var(--gold);
}

/* Specific sentiment colors when selected */
.sentiment-chip input[value="confident"]:checked + label {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}

.sentiment-chip input[value="fomo"]:checked + label {
  border-color: var(--red);
  background: var(--red-dim);
  color: var(--red);
}

.sentiment-chip input[value="fearful"]:checked + label {
  border-color: var(--amber);
  background: var(--amber-dim);
  color: var(--amber);
}

.sentiment-chip input[value="contrarian"]:checked + label {
  border-color: var(--blue);
  background: var(--blue-dim);
  color: var(--blue);
}

/* ---------- Challenge Question ---------- */

.challenge-box {
  position: relative;
  padding: 24px 28px;
  background:
    linear-gradient(135deg, rgba(201, 168, 76, 0.04) 0%, rgba(201, 168, 76, 0.01) 100%);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: var(--radius);
  border-left: 3px solid var(--gold);
  box-shadow: inset 0 0 20px rgba(201, 168, 76, 0.02);
}

.challenge-box::before {
  content: '\201C';
  position: absolute;
  top: 10px;
  left: 14px;
  font-family: var(--font-titles);
  font-size: 3rem;
  color: rgba(201, 168, 76, 0.12);
  line-height: 1;
}

.challenge-question {
  font-family: var(--font-titles);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.7;
  font-style: italic;
  padding-left: 20px;
}

.challenge-loading {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
}

/* ---------- Tables / Lists ---------- */

.data-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-family: var(--font-numbers);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.data-table .col-num {
  font-family: var(--font-numbers);
  font-size: 0.82rem;
  letter-spacing: -0.02em;
}

/* ---------- List Items ---------- */

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.list-item:hover {
  border-color: #24243a;
  background: var(--bg-card-hover);
  transform: translateX(2px);
}

.list-item-title {
  font-family: var(--font-titles);
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.list-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-numbers);
}

/* ---------- Portfolio Cards ---------- */

.pf-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 18px 22px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
}

.pf-card:hover {
  border-color: var(--gold-dim);
  background: var(--bg-card-hover);
  transform: translateX(2px);
}

.pf-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.pf-card-name {
  font-family: var(--font-titles);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.pf-card-pnl {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.pf-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.pf-card-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.pf-card-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pf-card-stat-val {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.pf-card-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pf-card-types {
  margin-left: auto;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.pf-card-empty {
  font-size: 0.8rem;
  margin-top: 6px;
  font-style: italic;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-family: var(--font-numbers);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-open { background: var(--green-dim); color: var(--green); }
.badge-closed { background: rgba(138, 138, 154, 0.08); color: var(--text-secondary); }
.badge-partial { background: var(--blue-dim); color: var(--blue); }
.badge-long { background: var(--green-dim); color: var(--green); }
.badge-short { background: var(--red-dim); color: var(--red); }
.badge-pending { background: rgba(138, 138, 154, 0.08); color: var(--text-secondary); }
.badge-correct { background: var(--green-dim); color: var(--green); }
.badge-wrong { background: var(--red-dim); color: var(--red); }

/* ---------- States: Loading, Empty, Error ---------- */

.state-loading,
.state-empty,
.state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.state-empty-icon,
.state-error-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.2;
}

.state-empty-icon svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
}

.state-empty-text,
.state-error-text {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 16px;
  max-width: 280px;
  line-height: 1.6;
}

.state-error-text { color: var(--red); }

/* ---------- Stato "primo giorno" (S465) ----------
   Il vuoto di una schermata mai usata non è un errore da segnalare in grigio:
   è il momento in cui si spiega a cosa serve la stanza. Titolo, due righe,
   i passi, l'azione, e la porta verso la guida. */

.state-welcome {
  max-width: 460px;
  margin: 0 auto;
  padding: 46px 24px 40px;
  text-align: center;
}

.state-welcome-title {
  font-family: var(--font-titles);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.state-welcome-body {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 22px;
}

.state-welcome-steps {
  text-align: left;
  display: inline-block;
  margin: 0 0 26px;
  padding-left: 20px;
  counter-reset: welcome;
  list-style: none;
}

.state-welcome-steps li {
  position: relative;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-left: 26px;
  counter-increment: welcome;
}

.state-welcome-steps li::before {
  content: counter(welcome);
  position: absolute;
  left: 0;
  top: 1px;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  border-radius: 50%;
  font-family: var(--font-numbers);
  font-size: 0.62rem;
  line-height: 17px;
  text-align: center;
  color: var(--gold);
}

.state-welcome-steps strong { color: var(--text-primary); font-weight: 500; }

.state-welcome-hint {
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-muted);
  font-style: italic;
  margin: -8px 0 24px;
}

.state-welcome-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.state-welcome-guide {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-numbers);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  opacity: 0.7;
  text-decoration: none;
  transition: opacity var(--transition);
}

.state-welcome-guide:hover { opacity: 1; }
.state-welcome-guide svg { width: 14px; height: 14px; }

/* S603 — solo dove il link segue un'AZIONE (il riquadro dei portafogli, che
   ha «Vai ai portafogli»): senza, i due gesti si toccano e sembrano uno solo.
   Gli altri riquadri hanno il link da solo sotto una riga di testo, e lì la
   spaziatura era già giusta — Sacerdote-verificato a schermo, S603. */
.state-empty .btn + .state-welcome-guide { margin-top: 14px; }

@media (max-width: 600px) {
  .state-welcome { padding: 32px 16px 30px; }
  .state-welcome-title { font-size: 1.45rem; }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255, 255, 255, 0.03) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
}

.skeleton-line:last-child { width: 60%; }

.skeleton-card {
  height: 120px;
  border-radius: var(--radius);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Spinner */
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Modal / Dialog ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.15s ease;
}

.modal {
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.015) 0%, transparent 40%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  min-width: min(400px, 90vw);
  max-width: min(480px, 90vw);
  overflow-wrap: break-word;
  word-break: break-word;
  box-shadow: var(--shadow-lg);
  /* fill-mode: backwards applies keyframe 0% state before the animation's
     actual start, preventing a FOUC flash (visible → invisible → visible)
     when the browser paints the .modal element before the animation kicks in. */
  animation: modal-enter 0.25s var(--transition-slow) backwards;
}

@keyframes modal-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title {
  font-family: var(--font-titles);
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  /* S600 — su un telefono a 412px una modale con tre scelte più «annulla»
   * schiacciava i bottoni fino a spezzarne le etichette. Senza il wrap la fila
   * non va mai a capo: si stringe e basta. Nessuna modale a due bottoni cambia
   * — vanno a capo solo quelle che non ci stanno. */
  flex-wrap: wrap;
}

/* ---------- Toasts ---------- */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: var(--font-numbers);
  animation: toast-enter 0.35s var(--transition-slow);
  max-width: 360px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateX(20px) translateY(-4px); }
  to { opacity: 1; transform: translateX(0) translateY(0); }
}

.toast-success {
  background: rgba(45, 212, 168, 0.12);
  border: 1px solid rgba(45, 212, 168, 0.2);
  color: var(--green);
}

.toast-error {
  background: rgba(224, 92, 92, 0.12);
  border: 1px solid rgba(224, 92, 92, 0.2);
  color: var(--red);
}

/* ---------- Animations ---------- */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.view-enter {
  animation: fade-in 0.25s ease;
}

/* ---------- Utilities ---------- */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Settings (S65, Phase 4.5.5) ---------- */

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
  padding-bottom: 40px;
}

.settings-card {
  animation: card-enter 0.5s var(--transition-slow) both;
}

/* S91 — Settings tab bar (Free / Paid toggle) */

.settings-tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 3px;
}

.settings-tab {
  flex: 1;
  padding: 7px 0;
  font-family: var(--font-numbers);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-tab:hover {
  color: var(--text-secondary);
}

.settings-tab.active {
  color: var(--gold);
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.settings-tab-panel {
  min-height: 0;
}

/* API provider list */

.api-provider-list {
  display: flex;
  flex-direction: column;
}

.api-provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.api-provider-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.api-provider-row:first-child {
  padding-top: 0;
}

.api-provider-info {
  flex: 1;
  min-width: 0;
}

.api-provider-name {
  font-family: var(--font-numbers);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.api-provider-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.api-provider-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.api-provider-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.api-provider-value {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.api-status-badge {
  font-family: var(--font-numbers);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.api-provider-actions {
  display: flex;
  gap: 2px;
}

.api-edit-form {
  width: 100%;
  padding-bottom: 4px;
}

/* S77 — Model selector row within provider row */

.api-model-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.api-model-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 52px;
}

.api-model-selector {
  display: flex;
  gap: 6px;
  flex: 1;
  align-items: center;
}

.api-model-select,
.api-model-input {
  flex: 1;
  font-size: 0.8rem !important;
  padding: 5px 10px !important;
  max-width: 320px;
}

.api-model-select:disabled,
.api-model-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.api-model-save {
  flex-shrink: 0;
}

/* Usage table (S93) */

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.usage-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usage-table th:last-child {
  text-align: right;
}

.usage-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.usage-table td:last-child {
  text-align: right;
  font-family: var(--font-numbers, var(--font-body));
}

.usage-table tr:last-child td {
  border-bottom: none;
}

.usage-table .usage-model-cell {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-numbers, var(--font-body));
}

.usage-table tfoot td {
  font-weight: 600;
  color: var(--gold);
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.usage-empty {
  padding: 16px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Danger zone (reset + purge merged card) */

.settings-card--danger-zone {
  border-color: rgba(224, 92, 92, 0.45);
  padding: 16px 20px;
}

.danger-zone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.danger-zone-text {
  flex: 1;
  min-width: 0;
}

.danger-zone-label {
  font-family: var(--font-numbers);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.danger-zone-desc {
  margin: 0;
  color: var(--text-primary);
  line-height: 1.4;
  font-size: 0.82rem;
}

.danger-zone-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 12px 0;
}

/* ---------- Regolamento ---------- */

.regolamento-section {
  margin-bottom: 18px;
}

.regolamento-list {
  margin: 0;
  padding: 0 0 0 20px;
  list-style: none;
}

.regolamento-list li {
  position: relative;
  padding: 4px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.regolamento-list li::before {
  content: "—";
  position: absolute;
  left: -18px;
  color: var(--gold);
}

.regolamento-list--amber li::before { color: var(--amber); }
.regolamento-list--red li::before { color: var(--red); }

/* ---------- Data calendar (privacy panel) ---------- */

.dcal-months {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.dcal-month {
  flex: 1;
  min-width: 200px;
}
.dcal-month-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-align: center;
}
.dcal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}
.dcal-dow {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}
.dcal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dcal-cell {
  aspect-ratio: 1;
  max-width: 28px;
  border-radius: 3px;
  transition: box-shadow 0.08s ease;
}
.dcal-cell:not(.dcal-blank):hover {
  box-shadow: 0 0 0 2px var(--gold);
  z-index: 2;
}
.dcal-blank {
  background: transparent !important;
  border: none !important;
}
.dcal-nav {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.dcal-nav:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ---------- Suspension banner ---------- */

.suspension-banner {
  background: rgba(224, 92, 92, 0.08);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 12px 18px;
  margin: 0 16px 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.suspension-banner__icon {
  color: var(--red);
  flex-shrink: 0;
  margin-top: 2px;
}

.suspension-banner__text {
  flex: 1;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.suspension-banner__text a {
  color: var(--gold);
}

/* ---------- Project Timeline ---------- */

.project-timeline {
  position: relative;
  padding-left: 28px;
}

.project-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold-dim);
  opacity: 0.5;
}

.tl-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
}

.tl-node {
  position: absolute;
  left: -28px;
  top: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--bg-card);
  flex-shrink: 0;
  cursor: pointer;
  z-index: 1;
  transition: background 0.2s, transform 0.15s;
}

.tl-node:hover {
  transform: scale(1.2);
}

.tl-item.tl-done .tl-node {
  background: var(--gold);
}

.tl-content {
  flex: 1;
  min-width: 0;
}

.tl-label {
  font-size: 0.88rem;
  line-height: 1.3;
}

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

.tl-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-numbers);
  margin-top: 2px;
}

.tl-item.tl-overdue .tl-date {
  color: var(--red);
}

.tl-delete {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  flex-shrink: 0;
  margin-top: 2px;
}

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

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

.tl-today {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  margin: 2px 0;
}

.tl-today::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold-bright);
  transform: translateY(-50%);
  z-index: 1;
  box-shadow: 0 0 6px var(--gold-glow-strong);
}

.tl-today-label {
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-numbers);
}

.tl-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
}

@media (hover: none) {
  .tl-delete {
    opacity: 0.6;
  }
}


/* ═══ Supporto — la card che dice come si chiede aiuto (S550) ═══
   Due strade in ordine di merito, non due bottoni pari: la chat porta il
   filetto oro e il numerale pieno perché è l'unica in cui qualcuno
   risponde; la mail è la porta di servizio, per quando la chat è proprio
   la cosa che non funziona. Stessa grammatica della landing (numerali in
   mono, filetti oro tenui invece dei bordi bianchi da wireframe). */

.settings-support-lead {
  margin: 0 0 14px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.settings-support-ways {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-support-way {
  border: 1px solid var(--border-subtle);
  border-left: 2px solid rgba(201, 168, 76, 0.25);
  border-radius: 3px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.012);
}

.settings-support-way--primary {
  border-left-color: var(--gold);
  background: rgba(201, 168, 76, 0.045);
}

.settings-support-way-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 5px;
}

.settings-support-badge {
  font-family: var(--font-numbers);
  font-size: 0.68rem;
  line-height: 1;
  color: var(--gold);
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 2px;
  padding: 3px 6px;
  flex-shrink: 0;
}

.settings-support-way-title {
  font-family: var(--font-titles);
  font-size: 0.95rem;
  color: var(--text-primary);
}

.settings-support-way-body {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.settings-support-way:last-child .settings-support-way-body {
  margin-bottom: 6px;
}

.settings-support-mail {
  font-family: var(--font-numbers);
  font-size: 0.8rem;
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 168, 76, 0.35);
  padding-bottom: 1px;
}

.settings-support-mail:hover {
  border-bottom-color: var(--gold);
}

/* Le tue segnalazioni — la parte che prima non esisteva in nessun posto */

.settings-support-reports:not(:empty) {
  border-top: 1px solid var(--border-subtle);
  margin-top: 14px;
  padding-top: 12px;
}

.settings-support-reports-head,
.settings-support-empty {
  font-family: var(--font-numbers);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.settings-support-empty {
  text-transform: none;
  letter-spacing: 0;
  font-family: inherit;
  font-size: 0.78rem;
  margin-bottom: 0;
  line-height: 1.5;
}

.settings-support-report {
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}

.settings-support-report:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-support-report-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.settings-support-state {
  font-family: var(--font-numbers);
  font-size: 0.68rem;
  color: var(--amber, #e0a84c);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-support-state--done {
  color: var(--green);
}

.settings-support-date {
  font-family: var(--font-numbers);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.settings-support-what {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Condivisione con link — la modale dell'avviso e quella del link
 * (S580, F158). Sta qui e non in chat.css perché è una modale, e le modali
 * vivono fra i componenti: la stessa forma servirà a chiunque debba avvisare
 * prima di un gesto che manda qualcosa fuori. */

.share-link-warn {
  margin: 10px 0 12px;
  padding-left: 20px;
  color: var(--text-primary);
  font-size: 0.86rem;
  line-height: 1.7;
}

/* S600 — `list-style: none` è globale (base.css), quindi qui una voce non ha
 * niente che la stacchi dalla successiva: con tre voci corte passava, con tre
 * voci lunghe l'elenco si legge come un paragrafo solo. Un filetto oro a
 * sinistra e un po' d'aria — non un pallino, che è la palette consumer già
 * vietata dal design system. */
.share-link-warn > li + li { margin-top: 10px; }

.share-link-warn > li {
  padding-left: 12px;
  border-left: 2px solid rgba(201, 168, 76, 0.35);
}

.share-link-box {
  margin: 14px 0 10px;
  padding: 10px 12px;
  background: var(--bg-elevated, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-numbers, 'JetBrains Mono', monospace);
  font-size: 0.78rem;
  color: var(--gold);
  /* Un indirizzo si spezza dove capita: senza questo, un uuid lungo esce
   * dalla modale su un telefono e il link diventa illeggibile proprio a chi
   * lo deve copiare a mano quando gli appunti non funzionano. */
  word-break: break-all;
  user-select: all;
}

.share-link-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 6px 0 0;
}

/* La riga di un link condiviso, in Impostazioni (S580, F158). */
.share-link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.share-link-row:last-child { border-bottom: none; }

.share-link-row-testo { flex: 1; min-width: 0; }

.share-link-row-titolo {
  font-size: 0.84rem;
  color: var(--text-primary);
  /* Un titolo lungo non deve spingere fuori il bottone che lo spegne. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-link-row-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-numbers, 'JetBrains Mono', monospace);
}

/* S597 — l'elenco delle passkey in Impostazioni → Account.
   Su un telefono le tre parti vanno a capo invece di stringersi: il nome del
   dispositivo è la sola cosa che distingue una riga dall'altra, e una riga che
   dice «Pix…» davanti a un bottone «Rimuovi» è il posto sbagliato dove
   indovinare. */
.passkey-riga {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.passkey-riga:last-child { border-bottom: none; }
.passkey-nome {
  flex: 1 1 auto;
  min-width: 40%;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.passkey-data {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
}
