/* ==========================================================================
   Pokemon Team Builder - foglio di stile principale

   Nessun framework: il layout e costruito su grid e flexbox, i colori su
   variabili CSS. L'interfaccia e pensata per il desktop (griglia a sei
   colonne, pannello laterale sempre visibile) e si adatta a schermi piccoli
   con la stessa struttura, non con una versione ridotta.

   Indice
     1. Token e reset
     2. Elementi di base (pulsanti, campi, interruttori)
     3. Impalcatura e barra superiore
     4. Pannello squadre a scomparsa
     5. Barra dei filtri
     6. Griglia degli slot
     7. Analisi difensiva
     8. Finestre modali
     9. Selettore delle specie
    10. Scheda del membro
    11. Import ed export
    12. Impostazioni
    13. Notifiche
    14. Adattamento agli schermi piccoli
   ========================================================================== */

/* ==========================================================================
   1. Token e reset
   ========================================================================== */

:root {
	/* Superfici, dalla piu profonda alla piu in rilievo */
	--bg-deep:      #0b0e14;
	--bg:           #121722;
	--surface:      #1a2130;
	--surface-2:    #222b3d;
	--surface-3:    #2c3750;

	--border:       #2f3a52;
	--border-soft:  #26304380;

	/* Testo */
	--text:         #e8edf7;
	--text-muted:   #9aa7c0;
	--text-dim:     #6b7891;

	/* Accenti */
	--accent:       #4d8dff;
	--accent-hover: #6ba0ff;
	--accent-soft:  #4d8dff26;
	--danger:       #ff5f6d;
	--danger-soft:  #ff5f6d26;
	--warning:      #ffb547;
	--success:      #46d39a;

	/* Statistiche */
	--stat-hp:  #ff6b6b;
	--stat-atk: #ff9f43;
	--stat-def: #feca57;
	--stat-spa: #54a0ff;
	--stat-spd: #5f27cd;
	--stat-spe: #1dd1a1;

	/* Geometria */
	--radius:    10px;
	--radius-sm: 6px;
	--radius-lg: 16px;

	--shadow:    0 8px 24px rgba(0, 0, 0, .38);
	--shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);

	/* Misure ricorrenti */
	--topbar-h:        60px;
	--drawer-w:        260px;
	--drawer-w-narrow: 56px;

	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

	--ease: cubic-bezier(.4, 0, .2, 1);
}

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

html, body {
	height: 100%;
	margin: 0;
}

body {
	background:
		radial-gradient(1200px 600px at 15% -10%, #1b2438 0%, transparent 60%),
		var(--bg-deep);
	color: var(--text);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
	overflow: hidden;                 /* lo scorrimento vive nei pannelli */
}

body.modal-open { overflow: hidden; }

h1, h2, h3 {
	margin: 0;
	font-weight: 650;
	line-height: 1.2;
}

kbd {
	padding: 2px 6px;
	border: 1px solid var(--border);
	border-bottom-width: 2px;
	border-radius: 4px;
	background: var(--surface-2);
	font-family: var(--mono);
	font-size: 11px;
}

.pixelated { image-rendering: pixelated; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
	border: 2px solid transparent;
	border-radius: 8px;
	background: var(--surface-3);
	background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: #3a4864; }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Schermata iniziale, sostituita da main.js */
.boot {
	display: flex;
	flex-direction: column;
	gap: 16px;
	align-items: center;
	justify-content: center;
	height: 100vh;
	color: var(--text-muted);
}

.boot-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid var(--surface-3);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin .8s linear infinite;
}

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

.fatal {
	max-width: 620px;
	margin: 80px auto;
	padding: 28px;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
}

.fatal h1 { margin-bottom: 10px; font-size: 20px; }
.fatal pre {
	overflow-x: auto;
	padding: 12px;
	border-radius: var(--radius-sm);
	background: var(--bg-deep);
	color: var(--danger);
	font-size: 12px;
}
.fatal-hint { color: var(--text-muted); }

.empty-note,
.panel-note,
.panel-loading {
	margin: 0 0 12px;
	color: var(--text-muted);
	font-size: 12.5px;
}

/* ==========================================================================
   2. Elementi di base
   ========================================================================== */

.icon { display: block; fill: currentColor; }

.btn {
	display: inline-flex;
	gap: 7px;
	align-items: center;
	justify-content: center;
	padding: 8px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-weight: 550;
	white-space: nowrap;
	cursor: pointer;
	transition: background .14s var(--ease), border-color .14s var(--ease),
	            transform .1s var(--ease);
}

.btn:hover:not(:disabled) {
	background: var(--surface-3);
	border-color: #3d4b6b;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #06101f;
}
.btn-primary:hover:not(:disabled) {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
}

.btn-ghost {
	background: transparent;
	border-color: transparent;
	color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
	background: var(--surface-2);
	color: var(--text);
}

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	cursor: pointer;
	transition: background .14s var(--ease), color .14s var(--ease);
}

.icon-btn:hover:not(:disabled) {
	background: var(--surface-3);
	color: var(--text);
}
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); }
.icon-btn-sm { width: 24px; height: 24px; }

.input {
	width: 100%;
	padding: 7px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--text);
	font: inherit;
	transition: border-color .14s var(--ease), background .14s var(--ease);
}

.input:hover { border-color: #3d4b6b; }
.input:focus {
	outline: none;
	border-color: var(--accent);
	background: var(--bg-deep);
}
.input::placeholder { color: var(--text-dim); }

textarea.input { resize: vertical; font-family: var(--mono); font-size: 12.5px; }
select.input { cursor: pointer; }

.input-sm { padding: 5px 8px; font-size: 12.5px; }
.input-xs {
	width: 56px;
	padding: 3px 6px;
	font-size: 12px;
	text-align: center;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
}

.field-label {
	color: var(--text-muted);
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: .3px;
	text-transform: uppercase;
}

.field-hint { color: var(--text-dim); font-size: 11px; }

.inline-check,
.picker-toggle {
	display: inline-flex;
	gap: 7px;
	align-items: center;
	color: var(--text-muted);
	font-size: 12.5px;
	white-space: nowrap;
	cursor: pointer;
}

input[type="checkbox"] {
	width: 15px;
	height: 15px;
	accent-color: var(--accent);
	cursor: pointer;
}

/* Interruttore */
.switch {
	display: inline-flex;
	gap: 9px;
	align-items: center;
	cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
	position: relative;
	flex: none;
	width: 36px;
	height: 20px;
	border-radius: 999px;
	background: var(--surface-3);
	transition: background .16s var(--ease);
}

.switch-thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--text-dim);
	transition: transform .16s var(--ease), background .16s var(--ease);
}

.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb {
	transform: translateX(16px);
	background: #06101f;
}
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: 13px; }

/* Gruppo di pulsanti a segmenti */
.seg {
	display: inline-flex;
	padding: 2px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
}
.seg-wide { display: flex; }

.seg-btn {
	flex: 1;
	padding: 4px 10px;
	border: none;
	border-radius: 4px;
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-size: 12px;
	white-space: nowrap;
	cursor: pointer;
	transition: background .14s var(--ease), color .14s var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--accent); color: #06101f; font-weight: 600; }

/* ==========================================================================
   3. Impalcatura e barra superiore
   ========================================================================== */

.app-shell {
	display: grid;
	grid-template-columns: var(--drawer-w) 1fr;
	height: 100vh;
	transition: grid-template-columns .22s var(--ease);
}

body.drawer-collapsed .app-shell {
	grid-template-columns: var(--drawer-w-narrow) 1fr;
}

.layout-drawer { min-width: 0; }

.layout-main {
	display: grid;
	/* minmax(0, 1fr): senza il minimo a zero i figli della griglia userebbero
	   min-width auto e sfonderebbero la colonna sugli schermi stretti. */
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: var(--topbar-h) auto 1fr auto;
	min-width: 0;
	overflow: hidden;
}

.topbar {
	display: flex;
	gap: 14px;
	align-items: center;
	padding: 0 16px;
	border-bottom: 1px solid var(--border);
	background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}

.topbar-menu { display: none; }

.topbar-ident {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
	margin-right: auto;
}

.app-title {
	overflow: hidden;
	font-size: 17px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.app-status { color: var(--text-dim); font-size: 11.5px; }
.app-status.is-ok { color: var(--text-muted); }
.app-status.is-error { color: var(--danger); }

.topbar-actions {
	display: flex;
	gap: 7px;
	align-items: center;
	min-width: 0;
	/* Quando i pulsanti non ci stanno la striscia scorre, invece di spingere
	   fuori schermo il titolo. */
	overflow-x: auto;
	scrollbar-width: none;
}
.topbar-actions::-webkit-scrollbar { display: none; }
.topbar-actions > * { flex: none; }

.layout-filters {
	min-width: 0;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border-soft);
	background: #0f1420cc;
}

.layout-grid {
	min-width: 0;
	min-height: 0;
	padding: 16px;
	overflow-y: auto;
}

.layout-coverage {
	min-width: 0;
	border-top: 1px solid var(--border);
	background: var(--bg);
}

.topbar { min-width: 0; }

/* ==========================================================================
   4. Pannello squadre a scomparsa
   ========================================================================== */

.drawer {
	display: flex;
	flex-direction: column;
	height: 100vh;
	border-right: 1px solid var(--border);
	background: var(--bg);
	overflow: hidden;
}

.drawer-head {
	display: flex;
	gap: 8px;
	align-items: center;
	flex: none;
	height: var(--topbar-h);
	padding: 0 10px;
	border-bottom: 1px solid var(--border);
}

.drawer-title {
	margin-right: auto;
	font-size: 14px;
	letter-spacing: .2px;
}

.drawer-count {
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text-muted);
	font-size: 11px;
	font-weight: 600;
}

.drawer-list {
	display: flex;
	flex-direction: column;
	gap: 7px;
	flex: 1;
	padding: 10px;
	overflow-y: auto;
}

.drawer-foot {
	flex: none;
	padding: 10px;
	border-top: 1px solid var(--border);
}
.drawer-foot .btn { width: 100%; }

/* Stato ridotto: resta solo la striscia di comando */
.drawer.is-collapsed .drawer-title,
.drawer.is-collapsed .drawer-count,
.drawer.is-collapsed .drawer-list,
.drawer.is-collapsed .drawer-foot { display: none; }

.drawer-scrim { display: none; }

/* Scheda di una squadra */
.team-card {
	padding: 9px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	cursor: pointer;
	transition: border-color .14s var(--ease), background .14s var(--ease),
	            transform .1s var(--ease);
}

.team-card:hover { border-color: #44557a; background: var(--surface-2); }
.team-card.is-active {
	border-color: var(--accent);
	background: linear-gradient(180deg, var(--accent-soft), transparent);
}
.team-card.is-dragging { opacity: .4; }
.team-card.is-drop-target { border-color: var(--accent); border-style: dashed; }

.team-card-head {
	display: flex;
	gap: 8px;
	align-items: baseline;
	margin-bottom: 6px;
}

.team-card-name {
	overflow: hidden;
	flex: 1;
	font-size: 13px;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.team-card-size {
	color: var(--text-dim);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

.team-card-strip {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 2px;
	margin-bottom: 6px;
}

.team-card-sprite {
	width: 100%;
	aspect-ratio: 1;
	border-radius: 4px;
	background: #0d1220;
	object-fit: contain;
	image-rendering: pixelated;
}
.team-card-sprite.is-empty { border: 1px dashed var(--border); background: transparent; }

.team-card-actions {
	display: flex;
	gap: 2px;
	justify-content: flex-end;
	opacity: 0;
	transition: opacity .14s var(--ease);
}

.team-card:hover .team-card-actions,
.team-card:focus-within .team-card-actions { opacity: 1; }

/* ==========================================================================
   5. Barra dei filtri
   ========================================================================== */

.filter-bar {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.filter-search {
	position: relative;
	flex: 1;
	min-width: 190px;
	max-width: 340px;
}

.filter-search-icon,
.picker-search-icon {
	position: absolute;
	top: 50%;
	left: 10px;
	color: var(--text-dim);
	pointer-events: none;
	transform: translateY(-50%);
}

.filter-search-input {
	width: 100%;
	padding: 8px 10px 8px 32px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--text);
	font: inherit;
}
.filter-search-input:focus { outline: none; border-color: var(--accent); }

.filter-menu { position: relative; }

.filter-trigger { position: relative; }
.filter-trigger-label { font-size: 13px; }

.filter-badge {
	display: none;
	min-width: 17px;
	padding: 0 5px;
	border-radius: 999px;
	background: var(--accent);
	color: #06101f;
	font-size: 10.5px;
	font-weight: 700;
	line-height: 17px;
	text-align: center;
}
.filter-badge.is-visible { display: inline-block; }

.filter-panel {
	position: absolute;
	z-index: 40;
	top: calc(100% + 6px);
	left: 0;
	display: none;
	min-width: 250px;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
}
.filter-menu.is-open .filter-panel { display: block; }

.filter-panel-head {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 9px;
	color: var(--text-muted);
	font-size: 11.5px;
	font-weight: 600;
	text-transform: uppercase;
}
.filter-panel-head + .filter-panel-head { margin-top: 14px; }

.filter-panel-foot {
	display: flex;
	gap: 6px;
	justify-content: flex-end;
	margin-top: 10px;
	padding-top: 9px;
	border-top: 1px solid var(--border-soft);
}

.type-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 4px 10px;
}

.type-option,
.filter-option {
	display: flex;
	gap: 8px;
	align-items: center;
	padding: 3px 4px;
	border-radius: 4px;
	cursor: pointer;
	transition: background .12s var(--ease);
}
.type-option:hover,
.filter-option:hover { background: var(--surface-2); }

.filter-list { display: flex; flex-direction: column; gap: 1px; }
.filter-option span { font-size: 13px; }

.range-row {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-top: 8px;
}
.range-sep { color: var(--text-dim); }

.filter-result {
	margin-left: auto;
	color: var(--text-muted);
	font-size: 12.5px;
	white-space: nowrap;
}
.filter-result strong { color: var(--text); }
.filter-result.is-empty strong { color: var(--warning); }

/* ==========================================================================
   6. Griglia degli slot
   ========================================================================== */

.team-grid {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 12px;
	align-items: start;
}

.slot {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: linear-gradient(180deg, var(--surface) 0%, #161c29 100%);
	overflow: hidden;
	transition: border-color .14s var(--ease), transform .12s var(--ease),
	            box-shadow .14s var(--ease);
}

.slot:hover { border-color: #44557a; box-shadow: var(--shadow); }
.slot.is-locked { border-color: var(--warning); }
.slot.is-dragging { opacity: .4; }
.slot.is-drop-target { border-color: var(--accent); border-style: dashed; }
.slot.is-empty { background: none; border-style: dashed; }

.slot-empty {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 240px;
	padding: 20px;
	border: none;
	background: transparent;
	color: var(--text-dim);
	font: inherit;
	cursor: pointer;
	transition: color .14s var(--ease), background .14s var(--ease);
}
.slot-empty:hover { background: var(--surface); color: var(--accent); }
.slot-empty-label { font-size: 12px; }

.slot-toolbar {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	border-bottom: 1px solid var(--border-soft);
	background: #0f1420;
}

.slot-tool {
	width: 100%;
	height: 28px;
	border-radius: 0;
	font-size: 13px;
}
.slot-tool.gender-male { color: #6ba0ff; }
.slot-tool.gender-female { color: #ff86b3; }

.slot-art {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 10px;
	border: none;
	background:
		radial-gradient(circle at 50% 60%, #202a3d 0%, transparent 70%),
		#131926;
	cursor: pointer;
}

.slot-sprite {
	width: 100%;
	max-width: 116px;
	aspect-ratio: 1;
	object-fit: contain;
	image-rendering: pixelated;
	transition: transform .16s var(--ease);
}
.slot-art:hover .slot-sprite { transform: scale(1.07); }

.slot-shiny-mark {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	padding: 3px;
	border-radius: 50%;
	background: #ffd76e;
	color: #3a2a00;
}

.slot-ident {
	padding: 8px 10px 6px;
	border-bottom: 1px solid var(--border-soft);
	text-align: center;
}

.slot-name {
	overflow: hidden;
	font-size: 14.5px;
	font-weight: 650;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.slot-form { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; }

.slot-types {
	display: flex;
	gap: 4px;
	justify-content: center;
	margin-top: 5px;
}

.slot-meta {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
	justify-content: center;
	padding: 7px 8px 0;
}

.meta-chip {
	padding: 2px 7px;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text-muted);
	font-size: 10.5px;
	white-space: nowrap;
}
.meta-chip.is-item { background: var(--accent-soft); color: var(--accent); }

.slot-ability {
	overflow: hidden;
	padding: 5px 10px 0;
	color: var(--text-dim);
	font-size: 11px;
	text-align: center;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.slot-stats { padding: 8px 10px; }

.stat-row {
	display: grid;
	grid-template-columns: 34px 1fr 30px;
	gap: 6px;
	align-items: center;
	margin-bottom: 2px;
}

.stat-label { color: var(--text-dim); font-size: 10px; }

.stat-bar {
	height: 5px;
	border-radius: 3px;
	background: var(--bg-deep);
	overflow: hidden;
}

.stat-fill { display: block; height: 100%; border-radius: 3px; }
.stat-hp  { background: var(--stat-hp); }
.stat-atk { background: var(--stat-atk); }
.stat-def { background: var(--stat-def); }
.stat-spa { background: var(--stat-spa); }
.stat-spd { background: var(--stat-spd); }
.stat-spe { background: var(--stat-spe); }

.stat-value {
	color: var(--text-muted);
	font-size: 10.5px;
	font-variant-numeric: tabular-nums;
	text-align: right;
}

.stat-total {
	display: flex;
	justify-content: space-between;
	margin-top: 6px;
	padding-top: 6px;
	border-top: 1px solid var(--border-soft);
	color: var(--text-dim);
	font-size: 10.5px;
}

.slot-moves {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 3px;
	padding: 0 10px 10px;
}

.move-chip {
	overflow: hidden;
	padding: 4px 6px;
	border: 1px solid var(--border-soft);
	border-radius: 4px;
	background: var(--surface-2);
	color: var(--text-muted);
	font: inherit;
	font-size: 10.5px;
	text-overflow: ellipsis;
	white-space: nowrap;
	cursor: pointer;
	transition: background .12s var(--ease);
}
.move-chip:hover { background: var(--surface-3); color: var(--text); }
.move-chip.is-empty { color: var(--text-dim); border-style: dashed; background: transparent; }

/* ==========================================================================
   7. Analisi difensiva
   ========================================================================== */

.coverage-toggle {
	display: flex;
	gap: 9px;
	align-items: center;
	width: 100%;
	padding: 9px 16px;
	border: none;
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
}
.coverage-toggle:hover { color: var(--text); }

.coverage-summary {
	margin-right: auto;
	color: var(--text-dim);
	font-weight: 400;
}

.coverage-caret { display: flex; transition: transform .18s var(--ease); }
.coverage.is-open .coverage-caret { transform: rotate(90deg); }

.coverage-body { display: none; padding: 0 16px 14px; }
.coverage.is-open .coverage-body { display: block; }

.coverage-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
	gap: 5px;
}

.coverage-cell {
	display: flex;
	gap: 6px;
	align-items: center;
	justify-content: space-between;
	padding: 5px 8px;
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-sm);
	background: var(--surface);
}
.coverage-cell.is-warn { border-color: #6b5320; background: #241c0d; }
.coverage-cell.is-critical { border-color: #7a2a30; background: #2a1216; }

.coverage-nums { font-size: 11px; font-variant-numeric: tabular-nums; }
.coverage-weak { color: var(--danger); font-weight: 700; }
.coverage-safe { color: var(--success); font-weight: 700; }
.coverage-sep { color: var(--text-dim); margin: 0 1px; }

.coverage-legend { margin: 10px 0 0; color: var(--text-dim); font-size: 11px; }

.coverage-gaps {
	display: flex;
	gap: 5px;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid var(--border-soft);
	font-size: 11.5px;
}
.coverage-gaps strong { color: var(--text-muted); font-weight: 600; }

/* ==========================================================================
   8. Finestre modali
   ========================================================================== */

.modal-overlay {
	position: fixed;
	z-index: 100;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(4, 7, 13, .72);
	backdrop-filter: blur(3px);
	animation: fade .16s var(--ease);
}

@keyframes fade { from { opacity: 0; } }

.modal {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-height: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
	box-shadow: var(--shadow-lg);
	animation: rise .18s var(--ease);
}

@keyframes rise {
	from { opacity: 0; transform: translateY(12px) scale(.98); }
}

.modal-sm { max-width: 420px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 880px; }
.modal-xl { max-width: 1040px; }

.modal-head {
	display: flex;
	gap: 12px;
	align-items: center;
	flex: none;
	padding: 14px 16px;
	border-bottom: 1px solid var(--border);
}
.modal-title { flex: 1; font-size: 15.5px; }

.modal-body {
	flex: 1;
	min-height: 0;
	padding: 16px;
	overflow-y: auto;
}

.modal-foot {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: flex-end;
	flex: none;
	padding: 12px 16px;
	border-top: 1px solid var(--border);
}
.modal-foot-hint { margin-right: auto; color: var(--text-dim); font-size: 11.5px; }

/* ==========================================================================
   9. Selettore delle specie
   ========================================================================== */

.picker { display: flex; flex-direction: column; gap: 10px; height: 62vh; }

.picker-bar { position: relative; display: flex; gap: 8px; align-items: center; }
.picker-search { flex: 1; padding-left: 32px; }

.picker-count {
	display: flex;
	gap: 10px;
	align-items: center;
	color: var(--text-muted);
	font-size: 12px;
}
.picker-hint { color: var(--text-dim); font-style: italic; }

.picker-viewport {
	flex: 1;
	min-height: 0;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	overflow-y: auto;
}

.picker-spacer { position: relative; }
.picker-rows { position: absolute; top: 0; right: 0; left: 0; }

.picker-row {
	display: grid;
	grid-template-columns: 46px 54px minmax(120px, 1.4fr) 128px auto 18px;
	gap: 10px;
	align-items: center;
	width: 100%;
	padding: 0 12px;
	border: none;
	border-bottom: 1px solid var(--border-soft);
	background: transparent;
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: background .1s var(--ease);
}
.picker-row:hover { background: var(--surface-2); }

.picker-sprite {
	width: 44px;
	height: 44px;
	object-fit: contain;
	image-rendering: pixelated;
}

.picker-dex {
	color: var(--text-dim);
	font-family: var(--mono);
	font-size: 11px;
}

.picker-ident { display: flex; flex-direction: column; min-width: 0; }
.picker-name {
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.picker-form { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; }

.picker-types { display: flex; gap: 4px; }

.picker-stats { display: flex; gap: 4px; }
.picker-stat {
	min-width: 26px;
	padding: 1px 4px;
	border-radius: 3px;
	background: var(--surface-2);
	color: var(--text-muted);
	font-size: 10.5px;
	font-variant-numeric: tabular-nums;
	text-align: center;
}
.picker-stat.is-total { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.picker-legend { display: flex; color: #ffd76e; }

.picker-blank {
	padding: 36px 16px;
	color: var(--text-dim);
	text-align: center;
}

/* ==========================================================================
   10. Scheda del membro
   ========================================================================== */

.editor { display: flex; flex-direction: column; gap: 14px; }

.editor-head {
	display: flex;
	gap: 16px;
	align-items: center;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--border);
}

.editor-art {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 96px;
	height: 96px;
	border-radius: var(--radius);
	background: radial-gradient(circle at 50% 60%, #202a3d 0%, #131926 70%);
}

.editor-sprite { width: 84px; height: 84px; object-fit: contain; image-rendering: pixelated; }

.editor-ident { flex: 1; min-width: 0; }
.editor-name { font-size: 19px; font-weight: 650; }
.editor-types { display: flex; gap: 5px; margin: 6px 0; }

.editor-facts {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	color: var(--text-dim);
	font-size: 11.5px;
}
.editor-facts .is-legend { color: #ffd76e; }

.editor-tabs {
	display: flex;
	gap: 3px;
	border-bottom: 1px solid var(--border);
}

.editor-tab {
	display: flex;
	gap: 6px;
	align-items: center;
	padding: 8px 14px;
	border: none;
	border-bottom: 2px solid transparent;
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-weight: 550;
	cursor: pointer;
	transition: color .14s var(--ease), border-color .14s var(--ease);
}
.editor-tab:hover { color: var(--text); }
.editor-tab.is-active { border-bottom-color: var(--accent); color: var(--accent); }

.editor-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 12px;
}
.editor-wide { grid-column: 1 / -1; }

.editor-switches {
	display: flex;
	gap: 20px;
	align-items: center;
	flex-wrap: wrap;
	grid-column: 1 / -1;
	padding: 10px 0;
	border-top: 1px solid var(--border-soft);
}

.editor-head-actions { flex: none; }
.editor-foot-left { display: flex; gap: 6px; margin-right: auto; }

.input-with-list { position: relative; }

/* Statistiche */
.stats-panel { display: flex; flex-direction: column; gap: 12px; }

.stats-toolbar {
	display: flex;
	gap: 6px;
	align-items: center;
	flex-wrap: wrap;
}
.stats-toolbar-label {
	margin-right: 4px;
	color: var(--text-muted);
	font-size: 11.5px;
	font-weight: 600;
	text-transform: uppercase;
}

.stat-table {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}

.stat-table-head,
.stat-table-row {
	display: grid;
	grid-template-columns: 1.2fr .6fr .8fr .8fr .8fr;
	gap: 10px;
	align-items: center;
	padding: 7px 12px;
}

.stat-table-head {
	background: var(--surface-2);
	color: var(--text-muted);
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
}

.stat-table-row { border-top: 1px solid var(--border-soft); }
.stat-table-row:nth-child(odd) { background: #ffffff05; }

.stat-name { display: flex; gap: 4px; align-items: center; font-weight: 550; }
.nature-up { color: var(--success); font-style: normal; font-weight: 700; }
.nature-down { color: var(--danger); font-style: normal; font-weight: 700; }

.stat-base,
.stat-total-value { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.stat-total-value { color: var(--text); font-weight: 650; }

.ev-total {
	display: flex;
	gap: 16px;
	padding: 8px 12px;
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	font-size: 12.5px;
}
.ev-total.is-over { border-color: var(--danger); color: var(--danger); }
.ev-left { color: var(--text-muted); }

/* Mosse */
.moves-panel { display: flex; flex-direction: column; gap: 12px; }

/* Due colonne: a quattro affiancate i nomi delle mosse si troncavano. */
.move-slots {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}

.move-slot {
	display: flex;
	gap: 8px;
	align-items: center;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	cursor: pointer;
	transition: border-color .14s var(--ease);
}
.move-slot:hover { border-color: #44557a; }
.move-slot.is-empty { border-style: dashed; background: transparent; }
.move-slot.is-target { border-color: var(--accent); background: var(--accent-soft); }

.move-slot-index {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 19px;
	height: 19px;
	border-radius: 50%;
	background: var(--surface-3);
	color: var(--text-dim);
	font-size: 10.5px;
	font-weight: 700;
}

.move-slot-name {
	overflow: hidden;
	flex: 1;
	font-size: 12.5px;
	font-weight: 550;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.move-slot-empty { flex: 1; color: var(--text-dim); font-size: 12px; }
.move-slot-stat { color: var(--text-dim); font-size: 10.5px; white-space: nowrap; }

.move-cat {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 16px;
	border-radius: 3px;
	font-size: 9.5px;
	font-weight: 700;
}
.move-cat-physical { background: #c92c2c; color: #fff; }
.move-cat-special  { background: #4f5870; color: #fff; }
.move-cat-status   { background: #8a8a8a; color: #1a1a1a; }

.move-search { position: relative; display: flex; gap: 8px; align-items: center; }
.move-search .input { padding-left: 32px; }
.move-search .input-sm { padding-left: 8px; flex: none; width: 140px; }

.move-results {
	max-height: 280px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	overflow-y: auto;
}

.move-row {
	display: grid;
	grid-template-columns: minmax(120px, 1fr) 74px 24px 44px 52px 56px;
	gap: 8px;
	align-items: center;
	width: 100%;
	padding: 6px 12px;
	border: none;
	border-bottom: 1px solid var(--border-soft);
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 12.5px;
	text-align: left;
	cursor: pointer;
}
.move-row:hover { background: var(--surface-2); }

.move-row-name {
	overflow: hidden;
	font-weight: 550;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.move-row-num {
	color: var(--text-muted);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	text-align: right;
}

/* ==========================================================================
   11. Import ed export
   ========================================================================== */

.transfer { display: flex; flex-direction: column; gap: 14px; }
.transfer-body { display: flex; flex-direction: column; gap: 12px; }

.transfer-controls {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 12px;
}

.transfer-options {
	display: flex;
	gap: 14px;
	align-items: center;
	flex-wrap: wrap;
}
.transfer-options:empty { display: none; }

.transfer-text {
	min-height: 160px;
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.55;
	white-space: pre;
}

.transfer-info {
	display: flex;
	gap: 14px;
	flex-wrap: wrap;
	color: var(--text-dim);
	font-size: 11.5px;
}
.transfer-warn { color: var(--warning); }

.transfer-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.transfer-detect {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	font-size: 12px;
}
.detect-chip {
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
}

.drop-zone { position: relative; border-radius: var(--radius-sm); }
.drop-zone.is-hover { outline: 2px dashed var(--accent); outline-offset: 3px; }

.transfer-report:empty { display: none; }

.report-ok,
.report-error {
	display: flex;
	gap: 8px;
	align-items: center;
	padding: 8px 12px;
	border-radius: var(--radius-sm);
	font-size: 12.5px;
}
.report-ok { background: #46d39a1f; color: var(--success); }
.report-error { background: var(--danger-soft); color: var(--danger); }

.report-strip {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 10px;
}

.report-mon {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 84px;
	padding: 6px;
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	text-align: center;
}
.report-mon img { width: 46px; height: 46px; object-fit: contain; image-rendering: pixelated; }
.report-mon span {
	overflow: hidden;
	width: 100%;
	font-size: 10.5px;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.report-mon small { color: var(--text-dim); font-size: 9.5px; }

.report-warnings {
	margin: 10px 0 0;
	padding-left: 18px;
	color: var(--warning);
	font-size: 11.5px;
}
.report-warnings li { margin-bottom: 3px; }

.trainer-form { display: flex; flex-direction: column; gap: 12px; }

/* ==========================================================================
   12. Impostazioni
   ========================================================================== */

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

.settings-heading {
	margin-top: 8px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--border-soft);
	color: var(--text-muted);
	font-size: 11.5px;
	letter-spacing: .5px;
	text-transform: uppercase;
}
.settings-heading:first-child { margin-top: 0; }

.settings-row {
	display: flex;
	gap: 14px;
	align-items: center;
	justify-content: space-between;
	padding: 8px 10px;
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
}
.settings-row.is-clickable { cursor: pointer; }
.settings-row.is-clickable:hover { background: var(--surface-3); }

.settings-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-row-text strong { font-size: 13px; font-weight: 600; }
.settings-row-text small { color: var(--text-dim); font-size: 11.5px; }

.shortcut-list {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 6px 14px;
	margin: 0;
	font-size: 12.5px;
}
.shortcut-list dt { text-align: right; }
.shortcut-list dd { margin: 0; color: var(--text-muted); }

/* ==========================================================================
   13. Notifiche
   ========================================================================== */

.toast-host {
	position: fixed;
	z-index: 200;
	right: 16px;
	bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-width: min(360px, calc(100vw - 32px));
	pointer-events: none;
}

.toast {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-left-width: 3px;
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	box-shadow: var(--shadow);
	opacity: 0;
	pointer-events: auto;
	transform: translateX(16px);
	transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.is-visible { opacity: 1; transform: none; }

.toast-success { border-left-color: var(--success); }
.toast-info    { border-left-color: var(--accent); }
.toast-warning { border-left-color: var(--warning); }
.toast-error   { border-left-color: var(--danger); }

.toast-icon { flex: none; margin-top: 1px; color: var(--text-muted); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error   .toast-icon { color: var(--danger); }

.toast-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.toast-text strong { font-size: 12.5px; font-weight: 600; }
.toast-text small { color: var(--text-muted); font-size: 11.5px; }
.toast-close { flex: none; width: 22px; height: 22px; }

/* ==========================================================================
   14. Adattamento agli schermi piccoli
   ========================================================================== */

/* Portatili: la griglia scende a tre colonne per due file. */
@media (max-width: 1400px) {
	.team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1150px) {
	.topbar-actions .btn span { display: none; }
	.topbar-actions .btn { padding: 8px 10px; }
}

/* Tablet e telefoni: il pannello squadre diventa un cassetto sovrapposto. */
@media (max-width: 900px) {
	.app-shell { grid-template-columns: 1fr; }
	body.drawer-collapsed .app-shell { grid-template-columns: 1fr; }

	.drawer {
		position: fixed;
		z-index: 90;
		top: 0;
		left: 0;
		width: min(300px, 86vw);
		box-shadow: var(--shadow-lg);
		transition: transform .22s var(--ease), visibility 0s;
	}
	/* Fuori schermo va anche nascosto davvero: senza `visibility` resterebbe
	   raggiungibile da tastiera e letto dagli screen reader. */
	.drawer.is-overlay.is-collapsed {
		visibility: hidden;
		transform: translateX(-100%);
		transition: transform .22s var(--ease), visibility 0s .22s;
	}
	.drawer.is-overlay .drawer-title,
	.drawer.is-overlay .drawer-count,
	.drawer.is-overlay .drawer-list,
	.drawer.is-overlay .drawer-foot { display: flex; }
	.drawer.is-overlay .drawer-list { flex-direction: column; }
	.drawer.is-overlay.is-collapsed .drawer-list,
	.drawer.is-overlay.is-collapsed .drawer-foot { display: none; }

	.drawer.is-overlay .drawer-scrim { display: none; }
	body.drawer-open .drawer.is-overlay .drawer-scrim {
		position: fixed;
		z-index: -1;
		inset: 0 0 0 100%;
		display: block;
		width: 100vw;
		background: rgba(4, 7, 13, .6);
	}

	.topbar-menu { display: inline-flex; }
	.drawer-toggle { display: none; }

	.team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
	.layout-grid { padding: 12px; }
	.layout-filters { padding: 10px 12px; }

	.modal-overlay { padding: 0; }
	.modal { max-width: none; height: 100%; max-height: 100%; border-radius: 0; }
	.picker { height: 100%; }

	.picker-row { grid-template-columns: 40px 48px 1fr auto; }
	.picker-stats,
	.picker-legend { display: none; }

	.move-row { grid-template-columns: 1fr 70px 24px 40px; }
	.move-row .move-row-num:nth-last-child(-n+2) { display: none; }
	.move-slots { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
	.team-grid { grid-template-columns: 1fr; }
	.slot { flex-direction: row; flex-wrap: wrap; }
	.slot-toolbar { grid-column: 1 / -1; }
	.slot-art { flex: none; width: 120px; }
	.slot-ident { flex: 1; border-bottom: none; text-align: left; }
	.slot-types { justify-content: flex-start; }
	.slot-meta { justify-content: flex-start; }
	.slot-ability { text-align: left; }
	.slot-stats,
	.slot-moves { flex: 1 0 100%; }

	.topbar { gap: 8px; padding: 0 10px; }
	.app-status { display: none; }
	.filter-result { width: 100%; margin-left: 0; }
	.editor-head { flex-direction: column; text-align: center; }
	.editor-facts { justify-content: center; }
	.transfer-actions .btn { flex: 1; }
	.stat-table-head,
	.stat-table-row { grid-template-columns: 1fr .5fr .7fr .7fr .7fr; gap: 5px; padding: 6px 8px; }
}

/* Chi ha chiesto meno animazioni le ottiene ovunque. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}
